-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Input code
Add-Type -TypeDefinition @"
public static class HelloWorld
{
public static void Main() => "Hello World!".Say();
static void Say(this string msg) => System.Console.WriteLine("Hello, World!");
}
"@ -OutputAssembly "HelloWorld.dll"#r "nuget: ICSharpCode.Decompiler, 9.0.0.7833-preview3"
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.CSharp;
DecompilerSettings s = new(){ ExtensionMethods = false };
var dll = "HelloWorld.dll";
return new CSharpDecompiler(dll, s).DecompileWholeModuleAsString();Erroneous output
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
public static class HelloWorld
{
public static void Main()
{
"Hello World!".Say();
}
private static void Say(this string msg)
{
Console.WriteLine("Hello, World!");
}
}Correct output
#3356
this above commit solved it.
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: Extension]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
[Extension]
public static class HelloWorld
{
public static void Main()
{
Say("Hello World!");
}
[Extension]
private static void Say(string msg)
{
Console.WriteLine("Hello, World!");
}
}