-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Decompiling a Program with an async Main method generates an extra method (named u003cMainu003e in example below) that calls the other Main.
Input Program.cs:
namespace Sample3
{
internal class Program
{
async static Task Main(string[] args)
{
Console.WriteLine("Hello, World!");
await sleep();
}
async static Task sleep()
{
await Task.Delay(1000);
}
}
}
Output Program.cs:
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Sample3
{
[Nullable(0)]
[NullableContext(1)]
internal class Program
{
public Program()
{
}
[DebuggerStepThrough]
// <Main>
private static void u003cMainu003e(string[] args)
{
Program.Main(args).GetAwaiter().GetResult();
}
private static async Task Main(string[] args)
{
Console.WriteLine("Hello, World!");
await Program.sleep();
}
private static async Task sleep()
{
await Task.Delay(0x3e8);
}
}
}
csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
Metadata
Metadata
Assignees
Labels
No labels