Skip to content

ghuntley/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.

Nuget package

There is a nuget package available here http://nuget.org/packages/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

Sponsor this project

 

Packages

No packages published

Languages

  • C# 88.8%
  • PowerShell 11.2%