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
if(origField.FieldType.ContainsGenericParameters){varorigDeclType=origField.DeclaringType;varasm=module.Context.AssemblyResolver.Resolve(origDeclType.Module.Assembly.GetName(),module);if(asmisnull||asm.FullName!=origDeclType.Assembly.FullName)thrownewException("Couldn't resolve the correct assembly");varmod=asm.FindModule(origDeclType.Module.ScopeName)asModuleDefMD;if(modisnull)thrownewException("Couldn't resolve the correct module");varfieldDef=mod.ResolveField((uint)(origField.MetadataToken&0x00FFFFFF));if(fieldDefisnull)thrownewException("Couldn't resolve the correct field");varfieldSig=newFieldSig(Import(fieldDef.FieldSig.GetFieldType()));fieldRef=module.UpdateRowId(newMemberRefUser(module,fieldInfo.Name,fieldSig,parent));}
Sometimes it is difficult to resolve assembly and importer will throw if AssemblyResolver is null.
e.g. Target assembly is memory loaded.
I don't know why generic field should be treated differently. I find it is changed in a old commit 4ebebc1
I've tested many cases of generic field and the old code (same behavior as importing generic method) can return the same result.
I don't remember why. Have you tried opening many other .NET files and checking if the original code produces the same result as code that doesn't try to resolve the assembly?
If you can't find any problems, you can send a PR with a fix!
dnlib/src/DotNet/Importer.cs
Line 595 in 1386325
Sometimes it is difficult to resolve assembly and importer will throw if AssemblyResolver is null.
e.g. Target assembly is memory loaded.
I don't know why generic field should be treated differently. I find it is changed in a old commit 4ebebc1
I've tested many cases of generic field and the old code (same behavior as importing generic method) can return the same result.
Test code:
The text was updated successfully, but these errors were encountered: