.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Linq;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Foo().GetAwaiter().GetResult();
    }

    static async Task Foo()
    {
        await Task.Delay(100);
        A a = new();
    }
}

public class A
{
    public A()
    {
        Console.WriteLine("In this stackTrace we know nothing about 'Main':");
        new StackTrace().GetFrames().ToList()
            .ForEach(x => Console.WriteLine(x.GetMethod()?.Name));
		
		Console.WriteLine(Environment.NewLine);
		Console.WriteLine("Here, in exception stacktrace we will see 'Main':");
        throw new Exception();
    }
}
;