icsharpcode / NRefactory

NRefactory - Refactoring Your C# Code
684 stars 262 forks source link

CSharpOutputVisitor methods should be virtual #499

Closed abock closed 9 years ago

abock commented 9 years ago

It would be very useful to have CSharpOutputVisitor methods as virtual. Currently the class implements IAstVisitor without making its implementation virtual, which means it is useless to subclass.

I have enough scenarios where I mostly want the base visitor to generate C# code for me, in accordance with the provided CSharpFormattingOptions but in some cases need to customize visitation when writing code.

For example, I intentionally insert TextNode nodes in an AST for annotation purposes with the intention of causing invalid C#/compilation failure so that generated code forces an audit in some cases.

abock commented 9 years ago

To clarify, this also means making most of the private members (such as StartNode, Semicolon, etc, even the containerStack protected virtual).

mkrueger commented 9 years ago

Fixed - let us know if anything is missing.