[antlr-interest] CSharp GeneratedCode attribute

Johannes Luber JALuber at gmx.de
Sat Jun 13 16:07:47 PDT 2009


> Hi,
> 
> For the current project I am working on, we need to use a parser.
> I convinced everybody here that writing your own parser is evil, because
> it
> takes much longer to write than using a tool conceived for this exact
> purpose.
> 
> Now we use C# and have some strict coding conventions, enforced using the
> Microsoft tools (FxCop and StyleCop).
> The problem being the antlr-generated code does not comply with these
> rules.
> 
> But Microsoft thought about the possibility of using generated code with
> these tools, and the [GeneratedCode(name, version)] attribute is here for
> this purpose. Hurray !
> The only problem remaining now is that this attribute cannot be placed
> correctly using the C# 2 template.
> 
> So I added a line in the C# 2 template (dunno if I done it "The Right Way"
> though) :
> 
> ...
> 
> 75  <docComment>
> *76  <if(actions.(actionScope).generatedVersion)>
> 77  [GeneratedCode("antlr", @"<actions.(actionScope).generatedVersion>")]
> 78
> 79  <endif>
> *80  <recognizer>
> ...

Hi!

>From what I can gather it seems to be the right place, though I wonder what other way you tried first. Regarding the CSharp3 target: Unlike CSharp2 it is/on the way to be completely .NET-compliant regarding the coding standards. I can't change it for CSharp2 yet because I have to worry about backwards-compatibility, but I plan parity for 3.2.

So the question remains, if including this attribute there makes sense if FxCop won't find anything. Sam, any comments?

Johannes

> Obviously in bold is what I added.
> >>From what I have seen this can also be added in the C# 3 template.
> 
> BTW, when will there be a release of antlrworks including version 3.1.3 of
> antlr ?
> I have tried it by myself but must have done something wrong as I get
> loads
> of errors when trying to compile.
> 
> Keep up the good work,
> Regards.
> 
> -- 
> - Always keep in mind that you may be wrong -

-- 
GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate und Telefonanschluss
für nur 17,95 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02


More information about the antlr-interest mailing list