[Code generation] How do you add a trailing comma to a generated enum? #73814
-
I'm writing code that generates an enum value. But I can't figure out how to get the enum value to include a trailing comma. Is this supported? if so - how do we do it? I'll give an example - let's say we are trying to generate a C# class called TestEnum. I want:
What I get by default is:
Imagine the code to create the enum class is something like this below where I manually created a member list:
I already tried making it so memberList uses a SeparatedSyntaxList with an explicit list of separators matching the same size of the list. But that doesn't work (presumably because the signature requests for that list to be -1 size of the set). I've also tried searching around for any indications of trailing comma support on the net and haven't found any. So is this something that simply doesn't work / isn't supproted today? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
members is |
Beta Was this translation helpful? Give feedback.
Here's an example of how we do it in roslyn:
roslyn/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/EnumMemberGenerator.cs
Lines 24 to 51 in e0abd64