Executing the following code, all the Resolve() methods works properly but
the last one; any idea why it fails?
var resolver = new DefaultAssemblyResolver();
>
> var asm = resolver.Resolve(new
> AssemblyNameReference("ClassLibrary1", new Version()));
> var module = asm.MainModule;
> var sysAsm = module.AssemblyReferences.First(cur => cur.Name
> == "netstandard");
>
> // way 1
> var ctorSource =
> typeof(SerializableAttribute).GetConstructor(Type.EmptyTypes);
> var ctorRef1 = module.ImportReference(ctorSource);
> var ctorDef1 = ctorRef1.Resolve();
> if (ctorDef1 == null)
> throw new ApplicationException(); // doesn't throw
>
> // way 2
> var returnType = new TypeReference("System", "Void", module,
> sysAsm);
> var returnTypeDef = returnType.Resolve();
> if (returnTypeDef == null)
> throw new ApplicationException();
>
> var attribType = new TypeReference("System",
> "SerializableAttribute", module, sysAsm);
> var attribTypeDef = attribType.Resolve();
> if (attribTypeDef == null)
> throw new ApplicationException();
>
> var ctorRef2 = new MethodReference(".ctor", returnType,
> attribType)
> {
> HasThis = true,
> };
> ctorRef2 = module.ImportReference(ctorRef2);
> var ctorDef2 = ctorRef2.Resolve();
> if (ctorDef2 == null)
> throw new ApplicationException(); // throws
>
>
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mono-cecil/14b921f6-26de-456c-a9e9-b088f7ee12ae%40googlegroups.com.