Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ICSharpCode.ILSpy.AssertionFailedException #2459

Closed
greenozon opened this issue Jul 24, 2021 · 3 comments
Closed

ICSharpCode.ILSpy.AssertionFailedException #2459

greenozon opened this issue Jul 24, 2021 · 3 comments
Labels

Comments

@greenozon
Copy link

greenozon commented Jul 24, 2021

Steps to reproduce

  1. Save Project or navigate to below item
    input same as in ICSharpCode.ILSpy.AssertionFailedException #2458

Error message shown

Error decompiling @060011B9 ----
in assembly "C:\IL_errs\err111.dll"
 ---> ICSharpCode.ILSpy.AssertionFailedException: 
   at ICSharpCode.ILSpy.ILSpyTraceListener.Fail(String message, String detailMessage) in offset 380
   at ICSharpCode.ILSpy.ILSpyTraceListener.Fail(String message) in offset 9
   at System.Diagnostics.TraceInternal.Fail(String message) in offset 55
   at System.Diagnostics.Debug.Assert(Boolean condition) in offset 6
   at ICSharpCode.Decompiler.IL.Conv.CheckInvariant(ILPhase phase) in Conv.cs:line 176
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Leave.CheckInvariant(ILPhase phase) in Leave.cs:line 112
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.Block.CheckInvariant(ILPhase phase) in Block.cs:line 108
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.BlockContainer.CheckInvariant(ILPhase phase) in BlockContainer.cs:line 196
   at ICSharpCode.Decompiler.IL.ILInstruction.CheckInvariant(ILPhase phase) in ILInstruction.cs:line 95
   at ICSharpCode.Decompiler.IL.ILFunction.CheckInvariant(ILPhase phase) in ILFunction.cs:line 255
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1509
-- continuing with outer exception (ICSharpCode.Decompiler.DecompilerException) --
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1545
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in CSharpDecompiler.cs:line 1444
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(IEnumerable`1 definitions) in CSharpDecompiler.cs:line 993
   at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(EntityHandle[] definitions) in CSharpDecompiler.cs:line 950
   at ICSharpCode.ILSpy.CSharpLanguage.DecompileMethod(IMethod method, ITextOutput output, DecompilationOptions options) in offset 246
   at ICSharpCode.ILSpy.TreeNodes.MethodTreeNode.Decompile(Language language, ITextOutput output, DecompilationOptions options) in offset 15
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) in offset 143
   at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass51_0.<DecompileAsync>b__0() in offset 38

Expected result

			get
			{
				return 41816;
			}

Details

  • Product in use: e.g. ILSpy / ICSharpCode.Decompiler nuget package / VS extension
    ILSpy version 7.1.0.6580
    .NET version 4.8.3928.0
@greenozon greenozon added the Bug label Jul 24, 2021
@siegfriedpammer
Copy link
Member

The code produced by ILSpy is the following:

protected override MessageKeys PressureEngineVSPBMultipointCurveMessageKey
{
	get
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		MessageKeys val = (MessageKeys)41816;
		return val;
	}
}

which looks like it's correct, because we do not know whether MessageKeys is an enum or not. It certainly would be correct if MessageKeys is an enum. On my end, I get an assertion failure because our StLoc instruction does not allow unknown types. Would you be able to provide the missing references as well?

@greenozon
Copy link
Author

Are you using release version of ILSpy?

cause on this build I still see the exception

ILSpy version 7.2.0.6660-preview1
.NET version 4.8.3928.0

PS most probably thats an enum, but I dont have ref dll, sorry

@siegfriedpammer
Copy link
Member

Yeah, I can reproduce the exception. Sorry for the miscommunication.

ElektroKill pushed a commit to dnSpyEx/ILSpy that referenced this issue Nov 6, 2021
…oc and StObjToStLoc preserve the result type, if the source variable has an unknown type.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants