Skip to content

Adds a module initializer to an assembly.

License

Notifications You must be signed in to change notification settings

ke209/ModuleInit

 
 

Repository files navigation

This is an add-in for Fody

Icon

Adds a module initializer to an assembly.

Introduction to Fody

The nuget package NuGet Status

https://nuget.org/packages/ModuleInit.Fody/

PM> Install-Package ModuleInit.Fody

What it does

Based on Einar Egilsson's suggestion using cecil to create module initializers [http://tech.einaregilsson.com/2009/12/16/module-initializers-in-csharp/]

Finds a class, in the target assembly, named 'ModuleInitializer' with the following form.

public static class ModuleInitializer
{
    public static void Initialize()
    {
        //Init code
    }
}

Injects the following code into the module initializer of the target assembly. This code will be called when the assembly is loaded into memory

static <Module>()
{
    ModuleInitializer.Initialize();
}

Icon

Icon courtesy of The Noun Project

About

Adds a module initializer to an assembly.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 72.5%
  • PostScript 27.5%