ODataConnectedService icon indicating copy to clipboard operation
ODataConnectedService copied to clipboard

Generated Code should be marked with the GeneratedCodeAttribute

Open j2jensen opened this issue 8 years ago • 1 comments

ODataT4CodeGenerator.ttinclude puts GeneratedCodeAttributes on specific members, like the container constructor, but that attribute should really just go on all generated types. This will allow Code Analysis tools to ignore this generated code properly.

Assemblies affected

Microsoft.Data.Web.Design.T4

Reproduce steps

Use the code generator to produce client code for an OData service.

Expected result

All types defined in the generated .cs or .vb file should have a GeneratedCodeAttribute on them.

Actual result

Container constructors, Entity Set Properties, and some methods have the GeneratedCodeAttribute on them, but no generated types do.

Additional details

If you enable Code Analysis using Microsoft's All Rules settings, then the spelling check will complain about the use of the word "composable" in the parameter name "isComposable" on types extending DataServiceQuerySingle<>. This could be fixed by adding the GeneratedCodeAttribute to that specific constructor, but since literally all of this code is generated, it doesn't make much sense to just mark that one member as Generated Code.

It's unclear to me why someone decided to mark specific properties and methods as Generated Code, but never bothered to just mark all the generated types as generated. Focusing on the types and removing the attribute from other members will likely end up producing less code because there are typically more properties than there are types.

j2jensen avatar Jun 24 '16 18:06 j2jensen

@j2jensen, Thanks for reporting this issue to us. We will take a look at it and fix it.

LaylaLiu avatar Jul 19 '16 05:07 LaylaLiu