Hello, I'm using the NuGet package of Mono.Cecil [0], it looks like version 0.9.5, on Windows 7 .NET 4.5 and VS 2013 and I experience the same behavior on mono 3.10 on slackware.
I'm trying to determine if the return type of a method is 'void'. My problem is that I get a different value for IsValueType property of a TypeReference obtained from a MethodDefinition and an imported type and as a result the following comparison is false: methodDefinition.ReturnType == methodDefinition.Module.Import(typeof(void)) If I compile a file with this code: using System; namespace Sample { public class Class1 { public void Method1() { } } } and then read it using this code: AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly("Sample.dll"); TypeDefinition typeDefinition = assembly.MainModule.GetTypes().First(_ => _.Name == "Class1"); MethodDefinition methodDefinition = typeDefinition.Methods.First(_ => _.Name == "Method1"); bool equalVoidTypes = methodDefinition.ReturnType == methodDefinition.Module.Import(typeof(void)); bool returnTypeIsValueType = methodDefinition.ReturnType.IsValueType; bool importedVoidTypeIsValueType = methodDefinition.Module.Import(typeof(void)).IsValueType; The value of returnTypeIsValueType is false and the value of importedVoidTypeIsValueType is true and I suspect this is the reason the equal operation fails and equalVoidTypes is false. My question is what is the correct way to use types to test a method for a void return type other than testing the name to be "System.Void"? Am I doing something wrong? Is there another way this sort of thing should be done? [0] https://www.nuget.org/packages/Mono.Cecil/
_______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list