ReverseMutty 1.0.4

Suggested Alternatives

Mutty

Additional Details

Use partial declarations instead

dotnet add package ReverseMutty --version 1.0.4
                    
NuGet\Install-Package ReverseMutty -Version 1.0.4
                    
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="ReverseMutty" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReverseMutty" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="ReverseMutty" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ReverseMutty --version 1.0.4
                    
#r "nuget: ReverseMutty, 1.0.4"
                    
#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.
#:package ReverseMutty@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ReverseMutty&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=ReverseMutty&version=1.0.4
                    
Install as a Cake Tool

Warn: This project is currently for internal use only due to development time limits. Use at your own risk.

ReverseMutty

A simple source generator to create a record class automatically from your written class. Inspired by Mutty.

Usage

Add [GenerateImmutable] attribute on your original class, and then the generator will generate the record class with public properties in your original class.

Add [InImmutable] attribute on the methods of your original class, and then the methods will be copied into the new class.

For example:

[GenerateImmutable]
public class Examples
{
    public string Name { get; init; }
    public int Game { get; set; }

    [InImmutable]
    public bool IsMatch()
    {
        return Game.ToString() == Name;
    }
}

Will generate:

// <auto-generated/>
#nullable enable
namespace ReverseMutty.Sample
{
    public record ImmutableExamples
    {
        public string Name { get; init; }
        public int Game { get; init; }


        // Warn: Copied from Examples, please ensure the compilability (may need to change the accessibility or the original class)
        public bool IsMatch()
    {
        return Game.ToString() == Name;
    }

        public Examples ToMutable()
        {
            return new Examples
            {
                Name = this.Name,
                Game = this.Game,
            };
        }
    }

    public static class ExamplesImmutableExtensions
    {
        public static ImmutableExamples ToImmutable(this Examples source)
        {
            return new ImmutableExamples
            {
                Name = source.Name,
                Game = source.Game,
            };
        }
    }
}

Be cautious that ungeneratable properties used in the copied methods and converters will cause compile errors. In this situation, you have to change your implementations.

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
1.0.4 125 2/17/2026 1.0.4 is deprecated because it has critical bugs.
1.0.3 97 2/17/2026
1.0.2 100 2/17/2026
1.0.1 100 2/16/2026
1.0.0 102 2/15/2026