Created
August 15, 2014 23:59
-
-
Save JoshVarty/694447a0b1f6f576adfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmtpyStatementRemoval : CSharpSyntaxRewriter | |
{ | |
public override SyntaxNode VisitEmptyStatement(EmptyStatementSyntax node) | |
{ | |
//Simply remove all Empty Statements | |
return null; | |
} | |
} | |
public static void Main(string[] args) | |
{ | |
//A syntax tree with an unnecessary semicolon on its own line | |
var tree = CSharpSyntaxTree.ParseText(@" | |
public class Sample | |
{ | |
public void Foo() | |
{ | |
Console.WriteLine(); | |
; | |
} | |
}"); | |
var rewriter = new EmtpyStatementRemoval(); | |
var result = rewriter.Visit(tree.GetRoot()); | |
Console.WriteLine(result.ToFullString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment