Re: [mono-cecil] detect delayed/fully signed status
Hi JB, That works, thanks a lot. As usual, perfect support. Enjoy the weekend, Jan Am Freitag, 13. April 2012 16:28:51 UTC+2 schrieb Jb Evain: > Hey, > > A strong name assembly has a public key and the > ModuleAttributes.StrongNameSigned bit set. > A delay signed assembly has also a public key, but the StrongNamedSigned > bit is not set. > > Jb > > On Apr 13, 2012, at 4:04 PM, Jan wrote: > > > Hi JB, > > > > An assembly can be unsigned, signed or delayed signed. Is there a way to > distinguish between signed and delayed signed in Cecil? > > > > Background is, I am loading an assembly, adding code and writing it. If > the assembly was fully signed and I am storing it without using the > StrongNameKeyPair, it will be delayed signed and not usable any more. > > The StrongNameKeyPair cannot be used if the snk file only contains the > public part of the key, it crashes in that case. I have to decide if I need > a StrongNameKeyPair instance or if I can write the assembly without it. > > > > Thanks > > > > Jan > > > > -- > > -- > > mono-cecil > > -- -- mono-cecil
[mono-cecil] detect delayed/fully signed status
Hi JB, An assembly can be unsigned, signed or delayed signed. Is there a way to distinguish between signed and delayed signed in Cecil? Background is, I am loading an assembly, adding code and writing it. If the assembly was fully signed and I am storing it without using the StrongNameKeyPair, it will be delayed signed and not usable any more. The StrongNameKeyPair cannot be used if the snk file only contains the public part of the key, it crashes in that case. I have to decide if I need a StrongNameKeyPair instance or if I can write the assembly without it. Thanks Jan -- -- mono-cecil
[mono-cecil] Re: generic method argument leads to assembly self reference
I am using version: 0.9.4.9 -- -- mono-cecil
[mono-cecil] generic method argument leads to assembly self reference
Hi JB, I want to call a generic method that i have to close with an enum type that is in my assembly, the method is in a referenced assembly. var closed = new GenericInstanceMethod(method); closed.GenericArguments.Add(genericType.Resolve()); This operation adds an assembly self reference to my assembly. Do you have an idea how to fix that? If you need an example project I can do that as well. Jan -- -- mono-cecil
[mono-cecil] variable names are written only sometimes
Hi JB, I have a problem with specified variable names. I am adding a static ctor to an existing class. In this method I am adding variables with explicitly set names. My observations are the following: If I add the method, the variable names are not written to the assembly, but if the method was already there and I am using the c# compiler generated method and only add variables, the names are written to the assembly. Do you have an idea? Jan -- -- mono-cecil
[mono-cecil] Re: out of memory
JB, I am not caching imports so far and I do not have the feeling that I am doing to many imports at all. Cecil is running inside Visual Studio in its own app domain, which is created for each run and the OOM occurs after running this operation several times. The Visual Studio has to be restarted after the error comes once. I have no real idea, esp. because i am throwing away the app domain after each run. Jan On 4 Aug., 12:13, Jb Evain wrote: > Hey Jan, > > On Wed, Aug 4, 2010 at 12:04 PM, Jan wrote: > > I just got an out of memory stack trace from a customer: > > > Error 24 OpenAccess Error: System.OutOfMemoryException: Exception of > > type 'System.OutOfMemoryException' was thrown. > > at System.Reflection.AssemblyName.nToString() > > at > > Mono.Cecil.MetadataImporter.TryGetAssemblyNameReference(AssemblyName > > name, AssemblyNameReference& assembly_reference) > > at Mono.Cecil.MetadataImporter.ImportScope(Assembly assembly) > > at Mono.Cecil.MetadataImporter.ImportType(Type type, > > IGenericContext context, ImportGenericType import_type) > > at Mono.Cecil.ModuleDefinition.Import(Type type) > > > Did you see something like that already? Do you have an idea? > > Either it is a bug in the importer (like looping forever allocating > stuff), or it is «simply» a true OOM, if you're importing over and > over, again an again :) > > Are you caching the results of Import? Cecil 0.9 doesn't right now. > > -- > Jb Evain -- -- mono-cecil
[mono-cecil] out of memory
Hi JB, I just got an out of memory stack trace from a customer: Error 24 OpenAccess Error: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Reflection.AssemblyName.nToString() at Mono.Cecil.MetadataImporter.TryGetAssemblyNameReference(AssemblyName name, AssemblyNameReference& assembly_reference) at Mono.Cecil.MetadataImporter.ImportScope(Assembly assembly) at Mono.Cecil.MetadataImporter.ImportType(Type type, IGenericContext context, ImportGenericType import_type) at Mono.Cecil.ModuleDefinition.Import(Type type) Did you see something like that already? Do you have an idea? Thanks Jan -- -- mono-cecil
[mono-cecil] Re: Stability of Cecil 0.9.x
Hi John, If you want to hear something from the user perspective, Cecil 0.9.3 is used in the Telerik ORM OpenAccess since 2 months now. I have ported our assembly enhancer from using the Emit API to Cecil 0.9.0. It was a bigger project and we had some issues with the first versions of Cecil 0.9, but because JB is very responsive all are fixed now and I did not get a single problem from our customers. From my perspective it is pretty stable. Jan On 28 Jul., 06:03, JohnC wrote: > Thank you Jb for your detailed reply - it really helps and reduces my > worries a lot. > > Thanks > John > > On Jul 27, 12:17 pm, Jb Evain wrote: > > > > > Hey, > > > On Tue, Jul 27, 2010 at 7:09 AM, JohnC wrote: > > > Please do not take this the wrong way, I am sure you have taken your > > > best efforts to write bug-free code and do testing, but the fact > > > remains that the new code base is only 3 month mature. > > > No problem John, it's a totally valid concern. > > > > Can you provide any insight if and why the above may not be true? Am I > > > incorrect in the above analysis? > > > But yes, your analysis is not quite correct and is missing some > > points. The code in github has been pushed recently, but I started > > working on the 0.9 version in late 2007. Thanks to some > > early-adapters, who happen to be big users of Cecil, we've been able > > to exercise the code base when they did the porting effort from 0.6 to > > 0.9. I waited as long as possible to release 0.9, to be sure to have > > something at least as good as 0.6. Of course we had small regressions > > and bugs, but 0.9.3 and the upcoming 0.9.4 are really stable. > > > As a side note, 0.9 is backed by a large test suite, making us > > confident when we land patches. At some point, I was a bit unwilling > > to land big patches in 0.6 as I had no idea what I was breaking or not > > (ô the joy of bearing with youth mistakes). Also note that 0.9 has > > been tested with all the problematics assemblies I've collected with > > 0.6, and works just fine, if not better. > > > 0.9 is now used in a diversity of commercial products and open source > > projects, including compilers, and as of today, we have no known case > > of assemblies that can't be read or written. > > > I, for one, am still in the process of porting large portions of code > > from 0.6 to 0.9, and except for the API breakage detailed in the > > migration page of the wiki, everything is going smoothly. The API > > breakage can indeed be really annoying. But it really does clean a lot > > of dark spots in 0.6, so I'm happy I did it. > > > -- > > Jb Evain - Zitierten Text ausblenden - > > - Zitierten Text anzeigen - -- -- mono-cecil
[mono-cecil] Re: Crash during assembly read
Hi JB > What's happening here is that we have an interface containing non > abstract methods with a zero RVA. I have tested it with the original assembly and tool and it works fine. Thanks, Jan -- -- mono-cecil
[mono-cecil] Crash during assembly read
Hi JB, I got an assembly that crashes Cecil. The problem is that the assembly already shows peverify warnings like this: [MD]: Warning: Class does not implement interface method in this module (class:0 x0214; interface:0x06d0; method:0x00360078). [token: 0x0917] This is more a general question, should it be possible to read and write an assembly that already contains invalid IL? For my customers it looks like my enhancer crashes and it is hard for them to find the real cause. Jan -- -- mono-cecil
[mono-cecil] Re: NRE if the assembly only contains string resources
Hi JB, it works fine, Thanks Jan -- -- mono-cecil
[mono-cecil] NRE if the assembly only contains string resources
Hi, I have an assembly that has no code, no binary resources but only some string resources. Cecil is failing during load in ImageReader here: void ComputeTableInformations () { uint offset = (uint) BaseStream.Position - image.MetadataSection.PointerToRawData; // header int stridx_size = image.StringHeap.IndexSize; int blobidx_size = image.BlobHeap.IndexSize; because the image.BlobHeap is null. Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
Hi JB, This is already a lng thread, I am very happy that you have managed to fix that problem. Thanks man, Jan -- -- mono-cecil
[mono-cecil] Re: Problem with pdb debug information
Hi JB, > I just checked in a fix for that. Works fine. Again, thanks a lot, Jan -- -- mono-cecil
[mono-cecil] Re: Problem with pdb debug information
Hi JB, It's me again ;) If you have a class splitted into two files using 'partial' it is not good to expect that the complete method is in one file. part1: partial class PClass1 { public PClass1() { } } part2: partial class PClass1 { int i = 12; } The 'int i = 12;' is part of the ctor of the class. If you now debug the ctor the complete debug sequence is done in the second file because that was the first URI you have found. Jan -- -- mono-cecil
[mono-cecil] Re: Problem with pdb debug information
Hi JB > With 5abdae03b9d927d6be55 I can break on the last curly brace. Sorry, you are right. Github did not give me the latest version. I got 0.9.2.42 half an hour ago and now I got 0.9.2.44 which is working fine. Thanks a lot for the fix, Jan -- -- mono-cecil
[mono-cecil] Re: Problem with pdb debug information
Hi JB > Can you try with the latest from github? That looks a lot better. F10/F11 are working and there are places to stop. In my example 1static void Main(string[] args) 2{ 3Console.WriteLine("Hello JB"); 4} the lines 2 and 3 are working, only the last step in line 4 is not working. Looks like the last symbol info in a method is not working. When I was debugging I had the feeiling that the line number of the last symbol info is sometimes max int, but this is only a feeling. Jan -- -- mono-cecil
[mono-cecil] Re: Problem with pdb debug information
Hi JB, > In VS2008 ? It is not bound to VS or msbuild, I have compiled and tested everything in vs2008 and it shows the same behavior. Jan -- -- mono-cecil
[mono-cecil] Re: Problem with pdb debug information
Hi JB, > Is this specific to VS2010 ? No, this also happens if my test projects are 2.0. Jan -- -- mono-cecil
[mono-cecil] Problem with pdb debug information
Hi, I am reading and writing a simple console application that has an hello world in the static main. After writing I am not really able to debug this main function. 1. F10 or F11 in VS are not working, the app is exceuted but the debugger did not stop. 2. If I set a breakpoint at the beginning od the function I am able to run to that point. a. If I now try to press F10 it does not stop any more. b. If I try to add more breakpoints to that functions VS says that there is not excecutable code. Is that a known issue? Thanks Jan -- -- mono-cecil
[mono-cecil] Type system
Hi JB, I just saw your TypeSystem class that gives you access to all base types. I had to implement the same for myself to get the mscorlib.dll and import the types from the right runtime version. Isn't it possible to make the implementation public available? Additionally I need the System.dll in a specific version as well. Maybe the TypeSystem class can be enhanceable by me to add an implementation for the System.dll. What do you think? Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
> With your repro, if I add a default constructor to the Class1, the > error shows up regardless of the body being loaded or not. Ups, you are right, Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
On 20 Mai, 20:27, Jb Evain wrote: > On Thu, May 20, 2010 at 8:04 PM, Jan wrote: > > This did not fix my problem. I have just added the default ctor to > > class1 in the classlibrary project and I can see the problem again. > > At least it happens with or without the body being loaded. The body must be loaded, if you comment out line 39 in CecilProblem2Task.cs the error is not showing up //var instructions = method.Body.Instructions; Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
Hi JB > Could you try with the latest from github? This did not fix my problem. I have just added the default ctor to class1 in the classlibrary project and I can see the problem again. Jan -- -- mono-cecil
[mono-cecil] Re: .NET 2.0 and .NET 4.0 mixed referenced
Hi JB, I am locating now the mscorlib reference at the assembly that I am loading and I am getting the types from there. Works pretty good, thanks. Nevertheless I am getting a reference to the mscorlib from the cecil process when I add a field to a class with 'FieldAttributes.NotSerialized', it looks like you are adding the 'System.NonSerializedAttribute' loaded from the wrong mscorlib. Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
Hi JB, I was able to make a small example that shows the problem. It occurs also inside the new msbuild, if I touch an existing instruction. I have sent you the example via mail. Jan -- -- mono-cecil
[mono-cecil] .NET 2.0 and .NET 4.0 mixed referenced
Hi, My tool is running in a .NET4.0 environment but reads and writes a .NET 2.0 assembly. I am adding new classes and methods to the assembly. At one place I am emitting a call to Object.MemberWiseClone(). To get the method I am calling: var method = moduleDefinition.Import(moduleDefinition.ResolveMethod(typeof(object), "MemberwiseClone", null)); The result is an Object.MemberWiseClone() from mscorlib 4.0 and not mscorlib 2.0. If I look at the references of the generated assembly I have an additional reference to mscorlib 4.0. How can i avoid this? Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
On 18 Mai, 18:47, Jan wrote: > There is a new version of diasymreader.dll, only the Visual Studio is > loading version 10. No, also not true, I have replaced the the dll and if VS2010 loads version 8 it is also not working. Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
There is a new version of diasymreader.dll, only the Visual Studio is loading version 10. Maybe they changed the interface that you are using: diasymreader.dllC:\Windows\Microsoft.NET\Framework \v2.0.50727\diasymreader.dllN/A N/A Exports loaded. 63 8.0.50727.4927 (NetFXspW7.050727-4900) 04.06.2009 09:24 0520-0528D000* [5028] venhance.exe: Native diasymreader.dllC:\Windows\Microsoft.NET\Framework \v4.0.30319\diasymreader.dllN/A N/A Exports loaded. 202 10.0.30319.1 built by: RTMRel18.03.2010 14:10570D-5717A000 [5312] devenv.exe: Native Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
On 18 Mai, 18:10, Jb Evain wrote: > Hey, > > On Tue, May 18, 2010 at 6:07 PM, Jan wrote: > > Now I habe a new stack trace, really looks like a security problem: > > >> > >> mscorlib.dll!System.AccessViolationException.AccessViolationException() > >> Line 25 C# > > ntdll.dll!executehandl...@20() + 0x26 bytes > > ntdll.dll!executehand...@20() + 0x24 bytes > > ntdll.dll!_kiuserexceptiondispatc...@8() + 0xf bytes > > [Managed to Native Transition] > > Mono.Cecil.Pdb.dll!Mono.Cecil.Pdb.SymWriter.CloseMethod() Line 103 > > C# > > > Has anybody an idea? > > Well, VS could very well have a lock on the pdb, and maybe you're > writing over it? No, I am writing a new file, no overwrite. My feeling is that the managed to native transition is not allowed. Which assembly are you accessing here? Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
Now I habe a new stack trace, really looks like a security problem: > mscorlib.dll!System.AccessViolationException.AccessViolationException() > Line 25 C# ntdll.dll!executehandl...@20() + 0x26 bytes ntdll.dll!executehand...@20() + 0x24 bytes ntdll.dll!_kiuserexceptiondispatc...@8() + 0xf bytes [Managed to Native Transition] Mono.Cecil.Pdb.dll!Mono.Cecil.Pdb.SymWriter.CloseMethod() Line 103 C# Has anybody an idea? Jan -- -- mono-cecil
[mono-cecil] Re: System.BadImageFormatException thrown form pdb writer
On 18 Mai, 12:35, Jb Evain wrote: > On Mon, May 17, 2010 at 7:17 PM, Jan wrote: > > More info: VS2010 32 bit .net 4.0 vm, if I configure the same for my > > exe it works. Can that be a rights problem? > > It's possible. VS sometimes hold locks on files. But the exception > seems to say that the pdb writer is closing an unopen method, or that > something went from when writing a method information. > > Do you have a small repro? I have no repro because it only happens inside the vm hosted inside vs2010. I was not able to debug the unmanaged code to get more info. The file that I am trying to write is not there. And I was able to write the assembly itself, only problems with the pdb file. In this error case you are also locking the pdb file on the drive. Can I get a try..finally like this: sealed class ModuleWriter { public static void WriteModuleTo (ModuleDefinition module, Stream stream, WriterParameters parameters) { if ((module.Attributes & ModuleAttributes.ILOnly) == 0) throw new ArgumentException (); if (module.HasImage && module.ReadingMode == ReadingMode.Deferred) ImmediateModuleReader.ReadModule (module); module.MetadataSystem.Clear (); var fq_name = stream.GetFullyQualifiedName (); var symbol_writer_provider = parameters.SymbolWriterProvider; if (symbol_writer_provider == null && parameters.WriteSymbols) symbol_writer_provider = SymbolProvider.GetPlatformWriterProvider (); var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider); #if !SILVERLIGHT && !CF if (parameters.StrongNameKeyPair != null && module.assembly != null) { var name = module.assembly.Name; name.PublicKey = parameters.StrongNameKeyPair.PublicKey; name.HasPublicKey = true; module.Attributes |= ModuleAttributes.StrongNameSigned; } #endif var metadata = new MetadataBuilder (module, fq_name, symbol_writer_provider, symbol_writer); try { BuildMetadata(module, metadata); if (module.SymbolReader != null) module.SymbolReader.Dispose(); var writer = ImageWriter.CreateWriter(module, metadata, stream); writer.WriteImage(); #if !SILVERLIGHT && !CF if (parameters.StrongNameKeyPair != null) CryptoService.StrongName(stream, writer, parameters.StrongNameKeyPair); #endif } finally { if (symbol_writer != null) symbol_writer.Dispose(); } } I will try to debug more. Jan -- -- mono-cecil
[mono-cecil] Re: File name and line number
Here is my code to open the assembly: private void LoadAssembly() { var resolver = new DefaultAssemblyResolver(); if (string.IsNullOrEmpty(SourceAssemblyFolder) == false) resolver.AddSearchDirectory(SourceAssemblyFolder); var parameters = new ReaderParameters { SymbolReaderProvider = new PdbReaderProvider(), ReadingMode = ReadingMode.Immediate, AssemblyResolver = resolver, }; try { ModuleDefinition = ModuleDefinition.ReadModule(SourceAssemblyFileName, parameters); pdbFileLoaded = true; } catch (Exception) { // if we cannot read the symbols we should ignore them. parameters.SymbolReaderProvider = null; ModuleDefinition = ModuleDefinition.ReadModule(SourceAssemblyFileName, parameters); } } And here how i get the first available file name for a type: public string FindFileName(TypeDefinition typedef) { if (HasDebugInfo) { foreach (var method in typedef.Methods) { if (method.Body != null && method.Body.Instructions != null) { foreach (var instruction in method.Body.Instructions) { if (instruction.SequencePoint != null && instruction.SequencePoint.Document != null && instruction.SequencePoint.Document.Url != null) return instruction.SequencePoint.Document.Url; } } } } return null; } Jan -- -- mono-cecil
[mono-cecil] Re: Suggestion to implement a TypeReference.Equals()
+1 And the same for FieldReference, I have a lot of comparisons between field access and field defitinion. Maybe there is a common way to implement it. Jan On 17 Mai, 09:07, Timwi wrote: > I have run into a case where I have two separate TypeReference objects > that actually refer to the same constructed type (namely, > List). Would it be advisable to override the .Equals() method > so that they would compare as equal? > > -- > -- > mono-cecil -- -- mono-cecil
[mono-cecil] System.BadImageFormatException thrown form pdb writer
Hi, I am stucked with a weird problem. If I write the assembly with my command line tool everything is fine but if I fire the write operations as part of my visual studio addin I get this exception: ClassLibrary11\obj\Debug\ClassLibrary11.dll(-1, 1): error:OpenAccess Error: System.BadImageFormatException: Index not found. (Exception from HRESULT: 0x80131124) at Mono.Cecil.Pdb.ISymUnmanagedWriter2.CloseMethod() at Mono.Cecil.Pdb.PdbWriter.Write(MethodBody body) in D:\jbevain- cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\symbols\pdb \Mono.Cecil.Pdb\PdbWriter.cs:line 64 at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method) in D:\jbevain-cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b \Mono.Cecil.Cil\CodeWriter.cs:line 126 at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method) in D:\jbevain-cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b \Mono.Cecil.Cil\CodeWriter.cs:line 68 at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method) in D:\jbevain-cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 1446 at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type) in D: \jbevain-cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 1440 at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type) in D: \jbevain-cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 1273 at Mono.Cecil.MetadataBuilder.AddTypeDefs() in D:\jbevain- cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 1246 at Mono.Cecil.MetadataBuilder.BuildTypes() in D:\jbevain- cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 1103 at Mono.Cecil.MetadataBuilder.BuildModule() in D:\jbevain- cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 887 at Mono.Cecil.ModuleWriter.b__0(MetadataBuilder builder, MetadataReader _) in D:\jbevain-cecil-0.9.2-14-gbb02d3b \jbevain-cecil-bb02d3b\Mono.Cecil\AssemblyWriter.cs:line 132 at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read) in D:\jbevain-cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b \Mono.Cecil\ModuleDefinition.cs:line 553 at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) in D:\jbevain-cecil-0.9.2-14-gbb02d3b \jbevain-cecil-bb02d3b\Mono.Cecil\AssemblyWriter.cs:line 131 at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters) in D:\jbevain- cecil-0.9.2-14-gbb02d3b\jbevain-cecil-bb02d3b\Mono.Cecil \AssemblyWriter.cs:line 107 at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters) in D:\jbevain-cecil-0.9.2-14-gbb02d3b \jbevain-cecil-bb02d3b\Mono.Cecil\ModuleDefinition.cs:line 720 at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters) in D:\jbevain-cecil-0.9.2-14-gbb02d3b \jbevain-cecil-bb02d3b\Mono.Cecil\ModuleDefinition.cs:line 709 at Telerik.OpenAccess.Sdk.Enhancer.CecilEnhancer.SaveAssembly() in D:\views\tfs\Main\Source\Product\Telerik.OpenAccess.SDK\Enhancer \CecilEnhancer.cs:line 168 at Telerik.OpenAccess.Sdk.Enhancer.CecilEnhancer.ProcessAssembly() in D:\views\tfs\Main\Source\Product\Telerik.OpenAccess.SDK\Enhancer \CecilEnhancer.cs:line 49 More info: VS2010 32 bit .net 4.0 vm, if I configure the same for my exe it works. Can that be a rights problem? Jan -- -- mono-cecil
[mono-cecil] Re: .NET 2.0 Assemblies gets wrong runtime system
Hi JB, thanks for the fast fix, Jan -- -- mono-cecil
[mono-cecil] .NET 2.0 Assemblies gets wrong runtime system
Hi, If I reference an .NET 2.0 assembly written by Cecil i get the following warning from CSC: C:\Windows\Microsoft.NET\Framework \v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "D:\views\tfs\Main\Source\Examples\ExamplesQSF \FirstStepsClasses\bin\cs\20\FirstStepsClasses.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "2.0.65535.65535" than the version "2.0.0.0" in the current target framework. With reflector I can see two references to mscorlib, one is ok, the other says: // Assembly Reference mscorlib Version: 2.0.65535.65535 Name: mscorlib, Version=2.0.65535.65535, Culture=neutral, PublicKeyToken=b77a5c561934e089 Do you have an idea what happens? Thanks Jan -- -- mono-cecil
[mono-cecil] Re: ModuleDefinition.Import damages method signature
Hi JB, sounds like expected. 8 minutes, you are getting better and better ;) Impressive. Thanks a lot Jan On 10 Mai, 16:23, Jb Evain wrote: > Hey, > > On Mon, May 10, 2010 at 4:15 PM, Jan wrote: > > The problem is that after MethodDefinition.Import() the DateTime& > > parameter is a DateTime* parameter. > > This is fixed in github. Thanks! > > > When should I call MethodDefinition.Import() and when does it not make > > sense? > > It's ModuleDefinition.Import. When inside a module, you want to use a > method, a type, or a field, that is defined outside the module, you > have to create a reference to this type, field or method. That's the > process of importing a reference. Calling import on a type, method or > field defined inside the module just returns the type, method or field > unmodified. > > -- > Jb Evain > > -- > -- > mono-cecil -- -- mono-cecil
[mono-cecil] ModuleDefinition.Import damages method signature
Hi, I have a method reference to a method with a ref parameter DateTime&. I want to emit a call to this method and use MethodDefinition.Import() to be sure that the reference is resolved to the right assembly. The problem is that after MethodDefinition.Import() the DateTime& parameter is a DateTime* parameter. When should I call MethodDefinition.Import() and when does it not make sense? Thanks Jan -- -- mono-cecil
[mono-cecil] Re: Pdb or not?
Hi Jonathan, I just want to avoid configuration problems. If the assembly has a pdb referenced and I cannot find it, I do not want to silently ignore it. If I remember right the pdb file path is part of the assembly. Jan On 3 Mai, 22:24, Jonathan Pryor wrote: > On Mon, 2010-05-03 at 20:12 +0200, Jb Evain wrote: > > On Mon, May 3, 2010 at 7:12 PM, Jan wrote: > > > var parameters = new ReaderParameters > > > { > > > SymbolReaderProvider = new PdbReaderProvider(), > > > ReadingMode = ReadingMode.Immediate, > > > AssemblyResolver = resolver, > > > }; > > > > ModuleDefinition = > > > ModuleDefinition.ReadModule(SourceAssemblyFileName, parameters); > > > > Which leads to an exception if the pdb file is not found. But I need a > > > logic where I can ask the assembly if there is a pdb referenced and if > > > it is available to load it. > > > There's no builtin, you'll have to test whether the pdb file exists or > > not, and then, call ModuleDefinition.LoadSymbols with a ISymbolReader > > provided by a PdbSymbolReaderProvider. > > Even if there was a builtin way to "ask the assembly if there is a pdb > referenced," you'd *still* need to check for the PDB "manually," as the > PDB may have been removed and the assembly won't (and can't) know. > > In short, you need to separately check for the pdb anyway. > > - Jon > > -- > -- > mono-cecil- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - -- -- mono-cecil
[mono-cecil] Re: 0.9.2
Good job, thanks for your weekend work. Jan On 3 Mai, 11:54, Александр Буряк wrote: > Nice job! > > On Mon, May 3, 2010 at 5:00 AM, Jb Evain wrote: > > Hey folks, > > > I tagged 0.9.2 in github. Keep the fantastic bug reports coming! > > > -- > > Jb Evain > > > -- > > -- > > mono-cecil > > -- > -- > mono-cecil -- -- mono-cecil
[mono-cecil] Pdb or not?
Hi, Is there a fast way or even a build in mechanism to detect if a pdb file is referenced from the assembly and if I have to load it or not. At the moment I am using: var parameters = new ReaderParameters { SymbolReaderProvider = new PdbReaderProvider(), ReadingMode = ReadingMode.Immediate, AssemblyResolver = resolver, }; ModuleDefinition = ModuleDefinition.ReadModule(SourceAssemblyFileName, parameters); Which leads to an exception if the pdb file is not found. But I need a logic where I can ask the assembly if there is a pdb referenced and if it is available to load it. Jan -- -- mono-cecil
[mono-cecil] Re: return type of closed generic method
Got it working, here is my code: public static TypeReference GetReturnType(this MethodReference self) { TypeReference returnType = self.ReturnType; if (returnType.IsGenericParameter) { GenericParameter tmp = (GenericParameter)returnType; GenericInstanceType owner = tmp.Owner as GenericInstanceType; if (owner != null) returnType = owner.GenericArguments[tmp.Position]; else returnType = ((GenericInstanceMethod)self).GenericArguments[tmp.Position]; } return returnType; } Jan -- -- mono-cecil
[mono-cecil] Re: return type of closed generic method
Hi JB, How can I get the tye? I have inspected the MethodDefinition in the debugger and cannot see a correlation between !0 and the DateTime. Thanks Jan -- -- mono-cecil
mono-cecil@googlegroups.com
Got it, just forgot the cast: if (paraType.IsByReference) paraType = ((ByReferenceType)paraType).ElementType; // removes ref Thanks Jan -- -- mono-cecil
mono-cecil@googlegroups.com
Hi, I have a int?& TypeReference and need a way to remove the &. I have tried Resolve and GetElementType but both returns a Nullable'1. Thanks Jan -- -- mono-cecil
[mono-cecil] return type of closed generic method
Hi, I habe a MethodReference to DateTime?.get_Value() and I need the return type of this method. With Cecil 0.9 the return type is 'T' and not 'DateTime' method.Fullname returns '!0 System.Nullable`1::get_Value()' Is there a way to get the real return type? Do I have to replace the generic parameter by myself? Jan -- -- mono-cecil
[mono-cecil] Re: [MD]: Error: Signature contains long form
Hi JB, works, Thanks a lot, Jan -- -- mono-cecil
[mono-cecil] Re: [MD]: Error: Signature contains long form
Maybe you are expecting my question :) Any change to get that fixed? Jan -- -- mono-cecil
[mono-cecil] Re: [MD]: Error: Signature contains long form
Hi JB, The start is a call to int.ToString() in my assembly that I want to change. Now I am taking the DeclaringType of this function and use it a ref parameter in a new created function. code is something like MethodReference mr = instruction.Operand TypeReference tr = mr.DeclaringType ParameterDefinition p = new ParameterDefinition(new ReferenceType(tr)); I have tried .Resolve() and module.Import() at various places but without success. It seems that the tr is always refering to the wrong (my) assembly. Jan On 30 Apr., 02:30, Jb Evain wrote: > Hey, > > On Thu, Apr 29, 2010 at 2:46 PM, Jan wrote: > > I am adding a ref param to a new generated function. The ref is > > generated by using 'new ByReferenceType'. > > > Peverify tells me: > > > [MD]: Error: Signature contains long form (such as > > ELEMENT_TYPE_CLASS > ystem.String>). [token:0x06000151] > > > Is there anything I have to call on the ref or on the paramater to > > avoid this peverify error? > > Are you creating yourself a TypeReference to System.String ? > > -- > Jb Evain > > -- > -- > mono-cecil -- -- mono-cecil
[mono-cecil] Re: [MD]: Error: Signature contains long form
Additional information: ildasm reports this for the method generate by emit: Method #4 (0600209e) --- MethodName: OpenAccessEnhancedWrap_System_Int32_testing_dotnet_csharp_model_IntType_ToString_value (0600209E) Flags : [PrivateScope] [Static] [HideBySig] [ReuseSlot] (0090) RVA : 0x000a7cf0 ImplFlags : [IL] [Managed] () CallCnvntn: [DEFAULT] ReturnType: String 2 Arguments Argument #1: Class testing.dotnet.csharp.model.IntType Argument #2: ByRef I4 CustomAttribute #1 (0c003147) --- CustomAttribute Type: 0a02 CustomAttributeName: System.Runtime.CompilerServices.CompilerGeneratedAttribute :: instance void .ctor() Length: 4 Value : 01 00 00 00 >< ctor args: () CustomAttribute #2 (0c003148) --- CustomAttribute Type: 0a01 CustomAttributeName: System.ComponentModel.EditorBrowsableAttribute :: instance void .ctor(value class System.ComponentModel.EditorBrowsableState) Length: 8 Value : 01 00 01 00 00 00 00 00 >< ctor args: ( ) and this for the cecil generated method: Method #4 (0600203b) --- MethodName: OpenAccessEnhancedWrap_System_Int32_testing_dotnet_csharp_model_IntType_ToString_value (0600203B) Flags : [PrivateScope] [Static] [HideBySig] [ReuseSlot] (0090) RVA : 0x00098158 ImplFlags : [IL] [Managed] () CallCnvntn: [DEFAULT] ReturnType: String 2 Arguments Argument #1: Class testing.dotnet.csharp.model.IntType Argument #2: ByRef ValueClass System.Int32 2 Parameters (1) ParamToken : (0800157e) Name : flags: [none] () (2) ParamToken : (0800157f) Name : flags: [none] () CustomAttribute #1 (0c002a16) --- CustomAttribute Type: 0a000113 CustomAttributeName: System.Runtime.CompilerServices.CompilerGeneratedAttribute :: instance void .ctor() Length: 4 Value : 01 00 00 00 >< ctor args: () CustomAttribute #2 (0c002a17) --- CustomAttribute Type: 0a000112 CustomAttributeName: System.ComponentModel.EditorBrowsableAttribute :: instance void .ctor(value class System.ComponentModel.EditorBrowsableState) Length: 8 Value : 01 00 01 00 00 00 00 00 >< ctor args: ( ) Any idea would be helpful. Thanks, Jan -- -- mono-cecil
[mono-cecil] [MD]: Error: Signature contains long form
Hi, I am adding a ref param to a new generated function. The ref is generated by using 'new ByReferenceType'. Peverify tells me: [MD]: Error: Signature contains long form (such as ELEMENT_TYPE_CLASS). [token:0x06000151] Is there anything I have to call on the ref or on the paramater to avoid this peverify error? Thanks Jan -- -- mono-cecil
[mono-cecil] Re: Collection.ToArray()
Hi Jon, yep, I am bound to 2.0. BTW: Linq is nice but if the assembly is huge and I am searching very often for a type by name, building up a dictionary is still a lot faster. Jan -- -- mono-cecil
[mono-cecil] Collection.ToArray()
Hi JB, very often I need a copy of one of your collections, can I get a ToArray() method? namespace Mono.Collections.Generic { public class Collection : IList, IList { internal T [] items; internal int size; int version; public T[] ToArray() { T[] destinationArray = new T[this.size]; Array.Copy(this.items, 0, destinationArray, 0, this.size); return destinationArray; } Thanks Jan -- -- mono-cecil
[mono-cecil] Re: TypeReference.GetElementType and ArrayType.ElementType returns different results
Hi JB, I broke it down and now i have the problem that TypeReference.IsValueType always return false for unresolved types but the Resolve() call damages the closed generic types. Is there a way to implement a TypeReference.IsValueType that returns the right value? Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] TypeReference.GetElementType and ArrayType.ElementType returns different results
Hi Is it expected that TypeReference.GetElementType and ArrayType.ElementType are returning different results. I have an unresolved TypeReference to sbyte?[]. TypeReference.GetElementType returns a Nullable'1, if I cast to ArrayType and call ArrayType.ElementType it returns the right info: sbyte?. It is a little confusion when I have to call Resolve, when I have to cast and when I can use GetElementType directly. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Generic function call problem
28 minutes, I cannot believe it, thanks man. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: cecil and local variables
Hi JB On Apr 26, 3:16 pm, Jb Evain wrote: > body.Optimize () > > And it will turn the ldloc into ldloc.0. > > Optimize is an extension method in Mono.Cecil.Rocks. > I only can see OptimizeMacros in 0.9.1.34. It looks like the one you mean. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] length of jumps
Hi, if i insert code into an existing function, do i have to care about the length of existing branches? For example, if I have a br_s in the code where I insert code between the br_s instruction and the instruction it jumps to. What happens if the br_s is now too short, will it be replaced by a br? Thanks Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Generic function call problem
Hi I have this code which leads to a peverify error after reading writing with Cecil 0.9.1.34 public class DoubeFuncClass { public void Test() { Test(); Test(); } public void Test() { Test(); Test(); } public void Test() { Test(); Test(); } } public class DoubeFuncClass { public void Test() { Test(); Test(); } public void Test() { Test(); Test(); } public void Test() { Test(); Test(); } } Peverify: [MD]: Error: MethodSpec method is not generic. [token:0x2B07] [MD]: Error: MethodSpec method is not generic. [token:0x2B08] [MD]: Error: MethodSpec method is not generic. [token:0x2B09] [MD]: Error: MethodSpec method is not generic. [token:0x2B0A] [MD]: Error: MethodSpec method is not generic. [token:0x2B0B] [MD]: Error: MethodSpec method is not generic. [token:0x2B0C] I know this does not look like a real use case but is a stripped down version of a customer problem. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] cecil and local variables
Hi JB, I am adding a bunch of new functions to existing classes. Because I am porting from System.Emit I can compare both APIs. I am adding local variables to the new function with: VariableDefinition loc0 = new VariableDefinition("loc0", ModuleDefinition.Import(typeof(System.Reflection.FieldInfo[]))); md.Body.Variables.Add(loc0); If I now create a usage of the variable with (OpCodes.Stloc, loc0) I always get a OpCodes.Stloc, with Emit I get a OpCodes.Stloc.0 or a OpCodes.Stloc.1 for the first and second defined variable. With Cecil it looks for me I have to do this by hand, where I have to be sure that the ordering of the variables is stable (OpCodes.Stloc_0). How can I be sure that I am refering to the right slot, or is there a way to do it like with Emit? Thanks Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Wrong type calculation in class attribute
Hi JB, thanks for the fix, works perfectly. Jan On Apr 26, 12:12 pm, Jb Evain wrote: > Hey Jan, > > On Mon, Apr 26, 2010 at 11:53 AM, Jan wrote: > > I am trying to get this reproduced in a smaller example but maybe you > > have an idea. > > It looks like a regression introduced by the TypeParser change to > support generic instances as typeof () in custom attributes. > > But yeah, a repro would be most welcome to fix it today and tag 0.9.2. > > -- > Jb Evain > > -- > -- > mono-cecil > > Subscription > settings:http://groups.google.com/group/mono-cecil/subscribe?hl=en -- -- mono-cecil
[mono-cecil] Wrong type calculation in class attribute
Hi JB, With the newest source you have introduced a problem. This is the generated code from cecil 0.9.1 from last night: .class public auto ansi beforefieldinit OrderDetail extends [mscorlib]System.Object implements [Telerik.OpenAccess]Telerik.OpenAccess.SPI.dataobjects.PersistenceCapable { .custom instance void [ClassLibrary1]ClassLibrary1.Persistent1Attribute::.ctor() = { Identity=type(ClassLibrary27.OrderDetail/ID) } .custom instance void [Telerik.OpenAccess]Telerik.OpenAccess.PersistentAttribute::.ctor() = { Identity=type([mscorlib]OrderDetail/ID) } As you can see the class ClassLibrary27.OrderDetail/ID is an inner class in this class. The problem is that in the second attribute the referenced type is damaged. The code is: [Telerik.OpenAccess.Persistent(Identity = typeof(ID))] [ClassLibrary1.Persistent1(Identity = typeof(ID))] public partial class OrderDetail { public class ID { ... The Telerik.OpenAccess.PersistentAttrubute is coming from an assembly in the Gac, the second attribute is comming from a small example where i have tried to reproduce it, with no luck. This was working with your code from the 16th, but I had empty functions in 64 bit mode and switched today. I am trying to get this reproduced in a smaller example but maybe you have an idea. Thanks Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Call method of generic base class
Hi JB, I have to catch a plane now, will need some time to prepare it. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Call method of generic base class
Hi JB, looks good but I have some problems. 1. I found a way to get the System.Type, that is now working, so i have one implementation. 2. Your code generates the following peverify error: [MD]: Error: Signature has an invalid token (token: 0x020001ff; offset: 0x0002). [token:0x1B01] [MD]: Error: Signature has generic type of arity 0 instantiated at different arity 1 at byte=0x0005. [token:0x1B01] and ildasm says: IL_0009: call instance !0 class [ERROR: INVALID TOKEN 0x020001FF] ::getKey() I had to change your second method to: public static MethodReference MakeGeneric (this MethodReference self, TypeReference declaringType) { var reference = new MethodReference(self.Name,self.ReturnType) { DeclaringType = declaringType, HasThis = self.HasThis, ExplicitThis = self.ExplicitThis, CallingConvention = MethodCallingConvention.Generic, }; foreach (var parameter in self.Parameters) reference.Parameters.Add (new ParameterDefinition (parameter.ParameterType)); foreach (var generic_parameter in self.GenericParameters) reference.GenericParameters.Add(new GenericParameter(generic_parameter)); return reference; } Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Call method of generic base class
Hi JB On 20 Apr., 13:32, Jb Evain wrote: > Hey Jan, > On Tue, Apr 20, 2010 at 9:36 AM, Jan wrote: > > Hi, > > I have two classes and I would like to call a generic method of a > > generic base class in the context of a derived class: > > > class BaseClass > > { > > public T GetKey() > > } > > > class DerivedClass: BassClass > > { > > } > > > Now I want to generate ilProcessor.Create(OpCodes.Call, > > CreateMethodRef(typeof(DerivedClass),"GetKey")); > > Why don't do you something like: > > MethodInfo get_key_info = typeof (DerivedClass).GetMethod ("GetKey"); > MethodRef get_key_ref = module.Import (get_key_info); > > And pass it to the call (you should do a callvirt) ? I only have a TypeReference, not the System.Type. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Call method of generic base class
Hi, I have two classes and I would like to call a generic method of a generic base class in the context of a derived class: class BaseClass { public T GetKey() } class DerivedClass: BassClass { } Now I want to generate ilProcessor.Create(OpCodes.Call, CreateMethodRef(typeof(DerivedClass),"GetKey")); How do I have to implement CreateMethodRef. I can find the GetKey function at the base class but this is the open definition. Thanks Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Cannot write variable of struct type
Hi JB, works. Thanks a lot. Jan -- -- mono-cecil Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en
[mono-cecil] Re: Cannot write variable of struct type
Hi JB, I have added a complete new method to an existing class. VariableDefinition loc0 = new VariableDefinition(ModuleDefinition.Import(typeof(StateManager))); VariableDefinition loc1 = new VariableDefinition(ModuleDefinition.Import(typeof(int))); md.Body.Variables.Add(loc0); md.Body.Variables.Add(loc1); md.Body.InitLocals = true; ILProcessor p = md.Body.GetILProcessor(); p.Append(p.Create(OpCodes.Ldfld, ModuleDefinition.Import(stateManager)); p.Append(p.Create(OpCodes.Stloc_0); ... If I switch off the pdb writer the generated code is correct but i am not able to write the pdb file. Everything is fine for new methods without variables. Jan -- -- mono-cecil
[mono-cecil] Cannot write variable of struct type
Hi I am generating in a new method body a variable of type struct (in the same assembly). Everything looks fine but i am getting this exception: System.ArgumentException: Value does not fall within the expected range. at Mono.Cecil.Pdb.ISymUnmanagedWriter2.DefineLocalVariable2(String name, Int3 2 attributes, SymbolToken sigToken, Int32 addrKind, Int32 addr1, Int32 addr2, In t32 addr3, Int32 startOffset, Int32 endOffset) at Mono.Cecil.Pdb.PdbWriter.CreateLocalVariable(VariableDefinition variable, SymbolToken local_var_token, Int32 start_offset, Int32 end_offset) at Mono.Cecil.Pdb.PdbWriter.DefineVariables(MethodBody body) at Mono.Cecil.Pdb.PdbWriter.Write(MethodBody body) at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method) at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method) at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method) at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type) at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type) at Mono.Cecil.MetadataBuilder.AddTypeDefs() at Mono.Cecil.MetadataBuilder.BuildTypes() at Mono.Cecil.MetadataBuilder.BuildModule() at Mono.Cecil.ModuleWriter.b__0(MetadataBuilder builder, Metad ataReader _) at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBui lder metadata) at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stre am, WriterParameters parameters) at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parame ters) at Telerik.OpenAccess.Sdk.Enhancer.CecilEnhancer.SaveAssembly() in D:\views\t fs\Main\Source\Product\Telerik.OpenAccess.SDK\Enhancer \CecilEnhancer.cs:line 110 at Telerik.OpenAccess.Sdk.Enhancer.CecilEnhancer.ProcessAssembly() in D:\view s\tfs\Main\Source\Product\Telerik.OpenAccess.SDK\Enhancer \CecilEnhancer.cs:line 30 What I see is that the SymbolToken has a value of 0. Any idea? I am using version 0.9 Thanks Jan -- -- mono-cecil
[mono-cecil] Enum.GetUnderlyingType
Hi, I am using version 0.9 I have an enum TypeDefinition and I need the primitive type behind that. Example: public enum e : short {a,b} With reflection I have to call Enum.GetUnderlyingType(typeof(e)) which returns typeof(short). How can i achieve this with Cecil? Thanks Jan -- -- mono-cecil To unsubscribe, reply using "remove me" as the subject.
[mono-cecil] TypeReference compare
Hi, I have a TypeReference and would like to know which type it has bool Compare(TypeReference tr, Type t) { return tr.IsOfType(t) } How can I do that? This has to work for typeof(string), typeof(int?) typeof(Dictionary(T,string)) Thanks Jan -- -- mono-cecil To unsubscribe, reply using "remove me" as the subject.