ODataConnectedService icon indicating copy to clipboard operation
ODataConnectedService copied to clipboard

Generated code for Enums should have GeneratedCodeAttribute set

Open dxrdxr opened this issue 3 years ago • 3 comments

The Connected Service code generator does not place a [GeneratedCode] attribute on each enum.

Generate code from a model that has an enum.

<EnumType Name="MemberRole">
    <Member Name="Participant" Value="0"/>
    <Member Name="Leader" Value="1"/>
    <Member Name="Assistant" Value="2"/>
</EnumType>

Run code generation and get:

    [global::Microsoft.OData.Client.OriginalNameAttribute("MemberRole")]
    public enum MemberRole
    {
        [global::Microsoft.OData.Client.OriginalNameAttribute("Participant")]
        Participant = 0,
        [global::Microsoft.OData.Client.OriginalNameAttribute("Leader")]
        Leader = 1,
        [global::Microsoft.OData.Client.OriginalNameAttribute("Assistant")]
        Assistant = 2
    }

Should be:

    [global::Microsoft.OData.Client.OriginalNameAttribute("MemberRole")]
    public enum MemberRole
    {
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]   
        [global::Microsoft.OData.Client.OriginalNameAttribute("Participant")]
        Participant = 0,
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
        [global::Microsoft.OData.Client.OriginalNameAttribute("Leader")]
        Leader = 1,
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "#VersionNumber#")]
        [global::Microsoft.OData.Client.OriginalNameAttribute("Assistant")]
        Assistant = 2
    }

dxrdxr avatar Jun 12 '21 13:06 dxrdxr

Thank you @dxrdxr for reporting this issue. We welcome a contribution to resolve it if you're in a position to

gathogojr avatar Jun 15 '21 16:06 gathogojr

I'm pretty sure that #VersionNumber# needs to be replaced with the actual ODataConnectedService version.

coldacid avatar Oct 19 '21 14:10 coldacid

Also, shouldn't GeneratedCodeAttribute be on the enum itself as well, not just its members?

coldacid avatar Mar 23 '22 13:03 coldacid