2

With extension I meant a Visual Studio Extension.

I want to know if there's a way to autogenerate a ToString method with an already created extension.

I want to have a class with some properties and use a tool to generate the ToString method using its properties.

class A {
    String propA { get; set; }
    String propB { get; set; }

    // Autogenerated
    override ToString() 
    {
        return "propA = " + propA + ", propB" + propB;
    }
}

If not, I want to know how can I make one. I searched the web but I can't find the correct way to add custom code to a already created class with a extension. Especially the project type I need to create.

Edit: This question Is there a ToString() generator available in Visual Studio 2010? didn't answer what I want; you can't use a snippet to generate code from the properties of the class. You can only add code or replace some created code.

TarHalda
  • 1,050
  • 1
  • 9
  • 27

1 Answers1

0

On vs2015 you can build a CodeFix project. see: Build CodeFix ex. On that project you can easely add your logic for adding ToString as part of vs15 new Analyzers.

Option 2: I'm part of OzCode team and we create a great tool that one of it's features is to create a custom "ToString" method, on the fly (while debugging) I'm adding a linq the the Reveal feature

Eli Dagan
  • 808
  • 8
  • 14