Skip to content

Latest commit

 

History

History
118 lines (60 loc) · 3.51 KB

README.md

File metadata and controls

118 lines (60 loc) · 3.51 KB

Chat on Gitter NuGet Status

Icon

This is a simple solution built as a starter for writing Fody addins.

Usage

See also Fody usage.

NuGet installation

Install the Immersive.Fody NuGet package and update the Fody NuGet package:

PM> Install-Package Immersive.Fody
PM> Update-Package Fody

The Update-Package Fody is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.

Add to FodyWeavers.xml

Add <Immersive/> to FodyWeavers.xml

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <Immersive/>
</Weavers>

The moving parts

Immersive Project

A project that contains any classes used for compile time metadata. Generally any usage and reference to this is removed at compile time so it is not needed as part of application deployment.

Immersive.Fody Project

The project that does the weaving.

Output of the project

It outputs a file named Immersive.Fody. The '.Fody' suffix is necessary for it to be picked up by Fody.

ModuleWeaver

ModuleWeaver.cs is where the target assembly is modified. Fody will pick up this type during a its processing.

In this case a new type is being injected into the target assembly that looks like this.

public class Hello
{
    public string World()
    {
        return "Hello World";
    }
}

See ModuleWeaver for more details.

Nuget construction

Fody addins are deployed as NuGet packages. The Immersive.Fody builds the package for Immersive as part of a build. The output of this project is placed in SolutionDir/nugets.

This project uses pepita to construct the package but you could also any other mechanism for constructing a NuGet package.

For more information on the NuGet structure of Fody addins see DeployingAddinsAsNugets

AssemblyToProcess Project

A target assembly to process and then validate with unit tests.

Tests Project

This is where you would place your unit tests.

The test assembly contains three parts.

1. WeaverHelper

A helper class that takes the output of AssemblyToProcess and uses ModuleWeaver to process it. It also create a copy of the target assembly suffixed with '2' so a side-by-side comparison of the before and after IL can be done using a decompiler.

2. Verifier

A helper class that runs peverfiy to validate the resultant assembly.

3. Tests

The actual unit tests that use WeaverHelper and Verifier. It has one test to construct and execute the injected class.

No reference to Fody

Note that there is no reference to Fody nor are any Fody files included in the solution. Interaction with Fody is done by convention at compile time.

Icon

Lego designed by Timur Zima from The Noun Project