Skip to content

Generate ToString method from public properties.

License

Notifications You must be signed in to change notification settings

sreejithk2000/ToString

 
 

Repository files navigation

This is an add-in for Fody

Icon

Generates ToString method from public properties for class decorated with a [ToString] Attribute.

Introduction to Fody.

The nuget package NuGet Status

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

PM> Install-Package ToString.Fody

Your Code

[ToString]
class TestClass
{
    public int Foo { get; set; }

    public double Bar { get; set; }
    
    [IgnoreDuringToString]
    public string Baz { get; set; }
}

What gets compiled

class TestClass
{
    public int Foo { get; set; }

    public double Bar { get; set; }
    
    public string Baz { get; set; }
    
    public override string ToString()
    {
        return string.Format(
            CultureInfo.InvariantCulture, 
            "{{T: TestClass, Foo: {0}, Bar: {1}}}",
            this.Foo,
            this.Bar);
    }
}

Icon

Icon courtesy of The Noun Project

About

Generate ToString method from public properties.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 92.9%
  • PostScript 7.1%