.etype is an internal enum to represent what kind of type this TypeRef represents. Is this a class? A value type? A primitive type (If so, which primitive)? An array? etc.
The Cecil type system will try to ensure the .etype is correct but it's possible a few cases are missing. I'll have a look at the repro. Thanks, Jb On Wed, Sep 27, 2017 at 2:26 PM, John Smith <[email protected]> wrote: > So, a simple repro app. Any ideas what's wrong here? > > var resolver = new DefaultAssemblyResolver(); > var asm = resolver.Resolve(new AssemblyNameReference("mscorlib", > new Version(4, 0, 0, 0))); > var newAsm = AssemblyDefinition.CreateAssembly(new > AssemblyNameDefinition("TestAsm", new Version()), "TestAsm", > ModuleKind.Dll); > > var typeRef = asm.MainModule.GetType("System.String"); > var methodRef = typeRef.Methods.First(cur => cur.Name == > "Copy"); > Debug.Assert(methodRef != null); > var paramRef = methodRef.Parameters.First(); > var paramType = paramRef.ParameterType; > > var typeRef2 = new TypeReference("System", "String", > newAsm.MainModule, asm.MainModule); > Debug.Assert(typeRef2.Resolve() != null); // ok > > var methodRef2 = new MethodReference("Copy", typeRef2, > typeRef2); > var paramRef2 = new ParameterDefinition("str", > ParameterAttributes.None, typeRef2); > methodRef2.Parameters.Add(paramRef2); > > Debug.Assert(methodRef2.Resolve() != null); // oops > > > > On Monday, September 25, 2017 at 5:04:12 PM UTC-5, Jb Evain wrote: >> >> Hey John, >> >> It's hard to say. Do you have a way to reproduce this? >> >> Thanks, >> Jb >> >> On Mon, Sep 25, 2017 at 2:58 PM, John Smith <[email protected]> wrote: >> >>> I have a call to the MetadataResolver.Resolve(method) that fails >>> despite the method reference seems to be completely correct; apparently, >>> the reason is in one of parameters. The target MethodDefinition has >>> etype=String and the method reference passed for resolving has etype=None >>> for this parameter. Both parameters refer to the System.String type. I >>> wonder what does this field mean and why it might be different? >>> >>> -- >>> -- >>> -- >>> 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]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- > -- > -- > 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]. > For more options, visit https://groups.google.com/d/optout. > -- -- -- 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]. For more options, visit https://groups.google.com/d/optout.
