Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

System.IndexOutOfRangeException: Index was outside the bounds of the array. - missing info on assembly being decompiled #3309

Open
greenozon opened this issue Oct 23, 2024 · 2 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@greenozon
Copy link

greenozon commented Oct 23, 2024

Input code

get latest ILSpy debug CI build
d-n-d all files insdie
try to decompile itself "eat-your-own-dogfood"

it was doing something for minute or two (not showing info on what assemlby/type being decompiled)

The quesiton is - why does it not add the info on assembly beding decompiled?
it is not possible to deduce which one got asserted provided that I was saving lots of assemblies at once... :(

Erroneous output

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ICSharpCode.Decompiler.CSharp.Transforms.TransformFieldAndConstructorInitializers.HandleInstanceFieldInitializers(IEnumerable`1 members) in /_/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs:line 206
   at ICSharpCode.Decompiler.CSharp.Transforms.TransformFieldAndConstructorInitializers.VisitTypeDeclaration(TypeDeclaration typeDeclaration) in /_/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs:line 168
   at ICSharpCode.Decompiler.CSharp.Syntax.TypeDeclaration.AcceptVisitor(IAstVisitor visitor) in /_/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/TypeDeclaration.cs:line 137
   at ICSharpCode.Decompiler.CSharp.Syntax.DepthFirstAstVisitor.VisitChildren(AstNode node) in /_/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs:line 43
   at ICSharpCode.Decompiler.CSharp.Syntax.DepthFirstAstVisitor.VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration) in /_/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs:line 142
   at ICSharpCode.Decompiler.CSharp.Syntax.NamespaceDeclaration.AcceptVisitor(IAstVisitor visitor) in /_/ICSharpCode.Decompiler/CSharp/Syntax/GeneralScope/NamespaceDeclaration.cs:line 140
   at ICSharpCode.Decompiler.CSharp.Syntax.DepthFirstAstVisitor.VisitChildren(AstNode node) in /_/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs:line 43
   at ICSharpCode.Decompiler.CSharp.Syntax.DepthFirstAstVisitor.VisitSyntaxTree(SyntaxTree syntaxTree) in /_/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs:line 57
   at ICSharpCode.Decompiler.CSharp.Syntax.SyntaxTree.AcceptVisitor(IAstVisitor visitor) in /_/ICSharpCode.Decompiler/CSharp/Syntax/SyntaxTree.cs:line 128
   at ICSharpCode.Decompiler.CSharp.Transforms.TransformFieldAndConstructorInitializers.Run(AstNode node, TransformContext context) in /_/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs:line 55
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.RunTransforms(AstNode rootNode, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in /_/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs:line 570
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileWholeModuleAsSingleFile(Boolean sortTypes) in /_/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs:line 690
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileWholeModuleAsSingleFile() in /_/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs:line 666
   at ICSharpCode.ILSpy.CSharpLanguage.DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
   at ICSharpCode.ILSpy.TreeNodes.AssemblyTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options)
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput)
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass66_0.<SaveToDiskAsync>b__0()

Expectation: ILSpy clearly shows what assembly fails, what type/token.. etc

image

Details

  • ILSpy version 9.0.0.7823-preview3+21e5d0f0349ff2858d24f768e0f88e40bab48272
    .NET version 8.0.8+08338fcaa5c9b9a8190abb99222fed12aaba956c
@greenozon greenozon added Bug Decompiler The decompiler engine itself labels Oct 23, 2024
@siegfriedpammer
Copy link
Member

I cannot reproduce this... in the stack trace we can see DecompileWholeModuleAsSingleFile, which is only executed, if FullDecompilation is set to true, which is only the case if you select "Save Code" and the "single file (.cs)" option, which is not available, when multiple assemblies are selected.

@greenozon
Copy link
Author

OK, I"ll try to repro again and record more detailed steps

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

2 participants