ILSpy bundled with LINQPad cannot decompile .NET 10 assemblies
This may or may not be a problem you'll be able to address but I noticed the ILSpy version bundled with LINQPad is unable to decompile .NET 10 assemblies.
If you try to browse any .NET 10 class, you'll get this error in the output tab (in ILSpy):
System.ArgumentException: Argument must be between 0 and 2. (Parameter 'fieldCount') at System.Version.<TryFormatCore>g__ThrowArgumentException|35_0[TChar](String failureUpperBound) at System.Version.TryFormatCore[TChar](Span`1 destination, Int32 fieldCount, Int32& charsWritten) at System.Version.ToString(Int32 fieldCount) at ICSharpCode.Decompiler.TypeSystem.DecompilerTypeSystem.InitializeAsync(PEFile mainModule, IAssemblyResolver assemblyResolver, TypeSystemOptions typeSystemOptions) in /_/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs:line 309 at ICSharpCode.Decompiler.TypeSystem.DecompilerTypeSystem..ctor(PEFile mainModule, IAssemblyResolver assemblyResolver, TypeSystemOptions typeSystemOptions) in /_/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs:line 227 at ICSharpCode.Decompiler.TypeSystem.DecompilerTypeSystem..ctor(PEFile mainModule, IAssemblyResolver assemblyResolver, DecompilerSettings settings) in /_/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs:line 217 at ICSharpCode.Decompiler.CSharp.CSharpDecompiler..ctor(PEFile module, IAssemblyResolver assemblyResolver, DecompilerSettings settings) in /_/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs:line 256 at ICSharpCode.ILSpy.CSharpLanguage.CreateDecompiler(PEFile module, DecompilationOptions options) at ICSharpCode.ILSpy.CSharpLanguage.DecompileType(ITypeDefinition type, ITextOutput output, DecompilationOptions options) at ICSharpCode.ILSpy.TreeNodes.TypeTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options) at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass53_0.<DecompileAsync>b__0()
Note you'll need to force the version to .NET 10 to see this happen. I made sure to update to the latest version of the preview (.NET 10.0.0-preview.6.25358.103) and it still occurs. Any assemblies that uses previous .NET versions loads fine.
Comments
-
See https://github.com/icsharpcode/ILSpy/issues/3349
This has been fixed in Version 9 but that currently does not work with LinqPad.
My workaround was to fork the repo and create a branch at the last change for Version 8 which is
https://github.com/icsharpcode/ILSpy/commit/95108c967af69642f0f445212f350ec451354b98Then apply the fix which is
https://github.com/icsharpcode/ILSpy/commit/62cdf38e9b96f87add9adb9281fdee439e74b6eeThen rebuild and replace the extracted dlls in %localappdata%\LINQPad\ILSpy8.2. (Note, you have to repeat this step after updating LinqPad.)
I did try to get github to build a version this morning, but failed See https://github.com/sgmoore/ILSpy/tree/TestV8.2
-
I've forked ILSpy 9.1 to make it compatible with LINQPad. This will be in the next LINQPad 9 build.