rjasica / ToString

Generate ToString method from public properties.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is an add-in for Fody

Icon

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

Introduction to Fody.

Nuget

Nuget package http://nuget.org/packages/ToString.Fody/

To Install from the Nuget Package Manager Console

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.

License:MIT License