Description
It happen when the developer call DynamicILInfo.GetTokenFor(RuntimeFieldHandle field)
rather than DynamicILInfo.GetTokenFor(RuntimeFieldHandle field, RuntimeTypeHandle contextType)
to build DynamicMethod, .NET doesn't crash without declaring type, it can work fine also.
Especially, .NET2.0 doesn't support a public overload with RuntimeTypeHandle parameter, that's why so many protectors don't pass in this parameter.
As the reason is clear, such name/comment could be updated if necessary.
dnlib/src/DotNet/Emit/DynamicMethodBodyReader.cs
Lines 16 to 28 in 0b2dc95
dnlib/src/DotNet/Emit/DynamicMethodBodyReader.cs
Lines 458 to 462 in 0b2dc95
dnlib/src/DotNet/Emit/DynamicMethodBodyReader.cs
Lines 458 to 462 in 0b2dc95