antlr4 icon indicating copy to clipboard operation
antlr4 copied to clipboard

Mark all generated C# classes with [GeneratedCode] attribute

Open martinskuta opened this issue 9 months ago • 1 comments

Hi,

we use ANTLR to generate a C# parser for our grammar and we run for each build static code analysis and for obvious reasons we exclude generated code, including the generated ANTLR classes. For ANTLR generated code we have to manually exclude the generated namespace from the inspection, because not all of the generated classes are marked with [GeneratedCode] attribute, none of the public nested classes are, only the top level parent ones for Parser/Visitor are marked as generated.

We are using NDepend and JetBrains InspectCode to analyse the code. With the changes to the CSharp target template I propose in this PR no further work has to be done to exclude ANTLR generated code from the inspection as both tools understand that attribute, as do probably any other C# static analysis tools.

martinskuta avatar May 22 '24 15:05 martinskuta