Runtime: 'Type' does not contain a definition for 'IsEnum'

Created on 21 Apr 2015  路  3Comments  路  Source: dotnet/runtime

In building a project I'm converting to CoreCLR, I ran across this error:

C:\Users\Benjamin\Projects\MiniProfiler\StackExchange.Profiling\SqlTiming.cs(136,25): error CS1061: 'Type' does not contain a definition for 'IsEnum' and no extension method 'IsEnum' accepting a first argument of type 'Type' could be found (are you missing a using directive or an assembly reference?)

What's odd to me about this is that everything I can find online indicates that Type should be available, and the IsEnum property should be available. Fowler's reverse package search finds Type in the System.Runtime package, and I have System.Runtime 4.0.20-* as a dependency in my project.json in the dnxcore50 framework section.

However, the compiler error happens, and dotPeek also says there is no Type type in the System.Runtime package. What have I missed?

Most helpful comment

@aggieben, you probably want .GetTypeInfo().IsEnum (GetTypeInfo is an extension method from the System.Reflection namespace). A bunch of Type's surface area was moved to TypeInfo, including IsEnum I believe. Regarding dotPeek, I've not tried it, but if I had to guess it's not paying attention to the [assembly: TypeForwardedTo(typeof(Type))] attribute in System.Runtime.dll, which is forwarding to the mscorlib implementation.

All 3 comments

@aggieben, you probably want .GetTypeInfo().IsEnum (GetTypeInfo is an extension method from the System.Reflection namespace). A bunch of Type's surface area was moved to TypeInfo, including IsEnum I believe. Regarding dotPeek, I've not tried it, but if I had to guess it's not paying attention to the [assembly: TypeForwardedTo(typeof(Type))] attribute in System.Runtime.dll, which is forwarding to the mscorlib implementation.

Thanks!

Note that as of 2015-8-4 MSDN lists IsEnum under Type for .Net 4.5/4.6
https://msdn.microsoft.com/en-us/library/System.Type_properties(v=vs.110).aspx

Thanks @stephentoub, that helped!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Timovzl picture Timovzl  路  3Comments

jkotas picture jkotas  路  3Comments

EgorBo picture EgorBo  路  3Comments

bencz picture bencz  路  3Comments

chunseoklee picture chunseoklee  路  3Comments