Reflecting on .NET Core

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

If you have started migration of old .NET to .NET Core, you have probably figured out that working with methods and properties, which reflect type information is slightly changed.

Following are some examples of this:

type.GetTypeInfo().IsEnum

type.GetTypeInfo().GetConstructor(

type.GetTypeInfo().GetCustomAttribute

object value = type.CreateInstance(this.hasDefaultCtor);
 
object value = Activator.CreateInstance(this.type);

That means that instead of writing myInst.GetType().IsEnum(), you will have to write now myInst.GetType.GetTypeInfo().IsEnum.

This does not look as a breaking change, but it can be very painful. Good news is that reflection will become the same as the .NET Framework. That means no need for GetTypeInfo(), good old .GetType() will BE back.

https://github.com/dotnet/corefx/issues/10085#issuecomment-232977943


Posted Jul 15 2016, 06:19 PM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.