I have a scenario where I'm processing IL, and if symbols are available I'd like to use them (e.g. to provide file and line number information). However, it would seem that if ReaderParameters.ReadSymbols is true, then the presence of symbol files is _required_
> Error while loading assembly: Assembly.dll ---> > System.IO.FileNotFoundException: Could not find file "Assembly.dll.mdb". > File name: 'Assembly.dll.mdb' > at System.IO.FileStream..ctor (System.String path, FileMode > mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean > anonymous, FileOptions options) > at System.IO.FileStream..ctor (System.String path, FileMode > mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, > Boolean anonymous) > at System.IO.FileStream..ctor (System.String path, FileMode > mode, FileAccess access) > at (wrapper remoting-invoke-with-check) > System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess) > at Mono.CompilerServices.SymbolWriter.MonoSymbolFile..ctor > (System.String filename) > at Mono.CompilerServices.SymbolWriter.MonoSymbolFile..ctor > (System.String filename, Mono.Cecil.ModuleDefinition module) > at > Mono.CompilerServices.SymbolWriter.MonoSymbolFile.ReadSymbolFile > (Mono.Cecil.ModuleDefinition module, System.String filename) > at Mono.Cecil.Mdb.MdbReaderProvider.GetSymbolReader > (Mono.Cecil.ModuleDefinition module, System.String fileName) > at Mono.Cecil.ModuleReader.ReadSymbols > (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) > at Mono.Cecil.ModuleReader.CreateModuleFrom > (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) > at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream > stream, Mono.Cecil.ReaderParameters parameters) > at Mono.Cecil.ModuleDefinition.ReadModule (System.String > fileName, Mono.Cecil.ReaderParameters parameters) > at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String > fileName, Mono.Cecil.ReaderParameters parameters) This seems less than ideal. ;-) I can think of two plausible workarounds: 1. Fix the code that calls AssemblyDefinition.ReadAssembly() to _not_ set ReaderParameters.ReadSymbols to true if the symbols don't exist. I don't like this as it'll require that the caller "know" about every possible symbol file extension so that they can be checked, making it brittle and not future-proof. 2. Fix Cecil so that if the symbol file doesn't exist, symbols won't be read. Patch attached. The one potential problem with this approach is that it's possibly a breaking change, in that it changes the semantics of ISymbolReaderProvider.GetSymbolReader() to potentially return `null` (whereas currently it'll potentially throw a FileNotFoundException). Can you provide any guidance on how we should support "optional" symbol files? Thanks, - Jon -- -- -- 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/groups/opt_out.
optional-symbols.patch
Description: Binary data
