You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I appreciate that C# 9 support is still work in progress, but given that function pointers work in other contexts, I figure that this bug report might be helpful.
Steps to reproduce
Decompile the following program
using System;
using System.Runtime.InteropServices;
unsafe
{
EnumWindows(&PrintWindow, IntPtr.Zero);
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
static extern int EnumWindows(delegate*<IntPtr, IntPtr, bool> hWnd, IntPtr lParam);
static bool PrintWindow(IntPtr hWnd, IntPtr lParam) => true;
}
Error message shown
Error decompiling @06000001 <Program>$.<Main>$
in assembly "C:\Users\mail\source\repos\ConsoleApp34\ConsoleApp34\bin\Debug\net5.0\ConsoleApp34.dll"
---> System.NullReferenceException: Object reference not set to an instance of an object.
at ICSharpCode.Decompiler.IL.Transforms.LocalFunctionDecompiler.ReplaceReferencesToDisplayClassThis(ValueCollection localFunctions) in offset 20
at ICSharpCode.Decompiler.IL.Transforms.LocalFunctionDecompiler.Run(ILFunction function, ILTransformContext context) in offset 113
at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 542
-- continuing with outer exception (ICSharpCode.Decompiler.DecompilerException) --
at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 833
at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(IMethod method, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 195
at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.DoDecompile(ITypeDefinition typeDef, DecompileRun decompileRun, ITypeResolveContext decompilationContext) in offset 648
at ICSharpCode.Decompiler.CSharp.CSharpDecompiler.Decompile(IEnumerable`1 definitions) in offset 276
at ICSharpCode.ILSpy.CSharpLanguage.DecompileType(ITypeDefinition type, ITextOutput output, DecompilationOptions options) in offset 37
at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) in offset 124
at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>c__DisplayClass48_0.<DecompileAsync>b__0() in offset 36
Details
Product in use: ILSpy version 6.2.1.6137
The text was updated successfully, but these errors were encountered:
Thanks for reporting this! This is actually not related to function pointers at all, but rather C# 9.0 supports "extern" local functions, the decompiler did not. This should be fixed now.
I appreciate that C# 9 support is still work in progress, but given that function pointers work in other contexts, I figure that this bug report might be helpful.
Steps to reproduce
Error message shown
Details
The text was updated successfully, but these errors were encountered: