Not 100% sure, I could be wrong. . I suggest that I review.
Version 2 compiled into a func delegate like this new Func<string, Type>(Type.GetType)
Version 3 is compiled into a compiler-generated method in the same class, something like this
[CompilerGenerated] private static Type <Main>b__0(string s) { Type type; type = Type.GetType(s); Label_0009: return type; }
and to func new Func<string, Type>(Program.<Main>b__0)
So, when executing your Version2 enumerator, it's just func that will be called by my WhereSelectArrayIterator<TSource, TResult> private class lives in System.Core.dll
Where version3 version lives in your build .
We get to the point. If Type.GetType is called with partial names (without a full name), it does not know which assembly is of type, it receives an assembly call and assumes that it lives there.
Therefore, Version3 lives in your assembly. Type.GetType out your assembly type and scans that the assembly fully returns the correct type.
But this does not apply to version 2. You do not actually call Type.GetType there. It is called WhereSelectArrayIterator... class , which is located in System.Core.dll . Thus, it is assumed that your type lives in System.Core.dll and Type.GetType cannot recognize your type.
Edit: The following snippet proves that the statements were correct
We fake the class in our assembly and call it System.Linq.Expressions.Expression to see the behavior.
namespace GetTypeTest { public class FindMe { } class Program { static void Main(string[] args) { var assemblyName = Assembly.GetExecutingAssembly().FullName; var className = "System.Linq.Expressions.Expression";
Outputs
System.Linq.Expressions.Expression [your assembly] System.Linq.Expressions.Expression [System.Core assembly] since WhereSelectArrayIterator.. belongs to System.Core assembly System.Linq.Expressions.Expression [your assembly] since compiler generated method belongs to your assembly System.Linq.Expressions.Expression [mscorlib assembly]
Hope this helps