You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per annotations, it is perfectly valid to call Activator.CreateInstance due to the annotation on the parameter of CreateInstanceOf. Linker doesn't produce any warnings from the code above.
But when executed, the application fails with:
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'type') at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at lib.Test.CreateInstanceOf(String n) in F:\ILLinker\repro\TypeNameRep\lib\Class1.cs:line 16 at lib.Test.TestIt() in F:\ILLinker\repro\TypeNameRep\lib\Class1.cs:line 10 at Program.Main(String[] args) in F:\ILLinker\repro\TypeNameRep\TypeNameRep\Program.cs:line 17
The failure is because Type.GetType returns null. In the trimmed assembly there's actually no type GenOut.
There are two weird things here:
GenOut<>.ctor() should be kept, but for some reason we leave it out
Even if I force include GenOut<> (by having a direct typeref to it), GenIn also needs to be kept, which won't happen either
The text was updated successfully, but these errors were encountered:
Interestingly changing the code to call CreateInstanceOf("lib.GenOut`1") actually works, the GenOut<>.ctor is kept and the app fails because it's invalid to instantiate open generic type.
The below has to be built into a classlib which is then aggressively trimmed:
Per annotations, it is perfectly valid to call
Activator.CreateInstance
due to the annotation on the parameter ofCreateInstanceOf
. Linker doesn't produce any warnings from the code above.But when executed, the application fails with:
The failure is because
Type.GetType
returns null. In the trimmed assembly there's actually no typeGenOut
.There are two weird things here:
GenOut<>.ctor()
should be kept, but for some reason we leave it outGenOut<>
(by having a direct typeref to it),GenIn
also needs to be kept, which won't happen eitherThe text was updated successfully, but these errors were encountered: