Backseating-Committee-2k/Backlang

Do you want to work on this issue?
You can request for a bounty in order to promote it!
add module initializer #219
furesoft posted onGitHub
implement module initializers by annotating like in c#
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
internal static void M1()
{
System.Console.WriteLine("init1");
}
[ModuleInitializer]
internal static void M2()
{
System.Console.WriteLine("init2");
}
static void Main() {
System.Console.WriteLine("main");
}
}
the compiler will collect all annotated method and call them in
internal class <Module>
{
static <Module>()
{
C.M1();
C.M2();
}
}
this should be only allowed in applications not in libraries, see https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2255