Utilizes System.Reflection.Metadata to read type information very fast and without locking assembly files.
Utilizes System.Reflection.Metadata to read type information very fast and without locking assembly files.
Install-Package FasterReflection
// type defined in MyAssembly.dll
public class MyType { }
var builder = new ReflectionMetadataBuilder();
builder.AddAssembly("MyAssembly.dll");
builder.AddReferenceOnlyAssemblyByType<object>(); // adds the corlib
var result = builder.Build();
var myType = result.FindTypesByName("MyType").First();
Console.WriteLine(myType.BaseType.FullName); // 'System.Object'
Console.WriteLine(myType.IsPublic); // 'True'
Console.WriteLine(myType.HasNonDefaultConstructors); // 'False'
Console.WriteLine(myType.GenericArgumentCount); // '0'