Absence.Fody 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Absence.Fody --version 2.0.1                
NuGet\Install-Package Absence.Fody -Version 2.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Absence.Fody" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Absence.Fody --version 2.0.1                
#r "nuget: Absence.Fody, 2.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Absence.Fody as a Cake Addin
#addin nuget:?package=Absence.Fody&version=2.0.1

// Install Absence.Fody as a Cake Tool
#tool nuget:?package=Absence.Fody&version=2.0.1                

Absence.Fody

NuGet package License

This is an add-in for Fody which lets you trim unused private/internal types during compile-time.

This project has a dependency to Emik.Morsels, if you are building this project, refer to its README first.



Installation

  • Install the NuGet packages Fody and Absence.Fody. Installing Fody explicitly is needed to enable weaving.

    PM> Install-Package Fody
    PM> Install-Package Absence.Fody
    
  • Add the PrivateAssets="all" metadata attribute to the <PackageReference /> items of Fody and Absence.Fody in your project file, so they won't be listed as dependencies.

  • If you already have a FodyWeavers.xml file in the root directory of your project, add the <Absence /> tag there. This file will be created on the first build if it doesn't exist:

<Weavers>
    <Absence />
</Weavers>

See Fody usage for general guidelines, and Fody Configuration for additional options.

Configuration

You can add an Except attribute with regex strings to exclude namespaces, types, or members, separated by any amount of whitespace:

<Weavers>
    <Absence Except="DoNotTrimMe Do.Not.Trim.Me
                     DoNotTrimGenericsEither`1" />
</Weavers>

Example

What you write:

public class Good1
{
    public class Good2
    {
        public static void Good3<[UsedImplicitly] T>() { }

        [UsedImplicitly]
        static void Good4<T>() { }

        static void Bad1() { }
    }

    [UsedImplicitly]
    class Good5
    {
        public static void Good6() { }

        [UsedImplicitly]
        static void Good7() { }

        static void Bad2() { }
    }

    class Bad3
    {
        public static void Bad4() { }

        [UsedImplicitly]
        static void Bad5() { }

        static void Bad6() { }
    }
}

[UsedImplicitly]
class Good8
{
    public class Good9
    {
        public static void Good10() => Good15<int>();

        [UsedImplicitly]
        static void Good11() { }

        static void Bad7() { }
    }

    [UsedImplicitly]
    class Good12
    {
        public static void Good13() { }

        [UsedImplicitly]
        static void Good14() { }

        static void Bad8() { }
    }

    class Bad9
    {
        public static void Bad10() { }

        [UsedImplicitly]
        static void Bad11() { }

        static void Bad12() { }
    }

    static void Good15<[UsedImplicitly] T>() { }

    static void Bad13<[UsedImplicitly] T>() { }
}

class Bad14
{
    public class Bad15
    {
        public static void Bad16() { }

        [UsedImplicitly]
        static void Bad17() { }

        static void Bad18() { }
    }

    [UsedImplicitly]
    class Bad19
    {
        public static void Bad20() { }

        [UsedImplicitly]
        static void Bad21() { }

        static void Bad22() { }
    }

    class Bad23
    {
        public static void Bad24() { }

        [UsedImplicitly]
        static void Bad25() { }

        static void Bad26() { }
    }
}

What gets compiled:

public class Good1
{
    public class Good2
    {
        public static void Good3<[UsedImplicitly] T>() { }

        [UsedImplicitly]
        static void Good4<T>() { }
    }

    [UsedImplicitly]
    class Good5
    {
        public static void Good6() { }

        [UsedImplicitly]
        static void Good7() { }
    }
}

[UsedImplicitly]
class Good8
{
    public class Good9
    {
        public static void Good10() => Good15<int>();

        [UsedImplicitly]
        static void Good11() { }
    }

    [UsedImplicitly]
    class Good12
    {
        public static void Good13() { }

        [UsedImplicitly]
        static void Good14() { }
    }

    static void Good15<[UsedImplicitly] T>() { }
}

Contribute

Issues and pull requests are welcome to help this repository be the best it can be.

License

This repository falls under the MPL-2 license.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.7 89 10/9/2024
2.0.6 91 10/9/2024
2.0.5 94 10/8/2024
2.0.4 88 10/7/2024
2.0.3 86 10/7/2024
2.0.2 93 10/7/2024
2.0.1 89 10/6/2024
2.0.0 103 10/5/2024
1.0.5 402 1/15/2023
1.0.4 270 1/14/2023
1.0.3.3 284 1/14/2023
1.0.3.2 281 1/14/2023
1.0.3.1 274 1/14/2023
1.0.3 279 1/14/2023
1.0.2 271 1/13/2023
1.0.1 279 1/11/2023
1.0.0 283 1/9/2023