Skip to content

Commit

Permalink
Avoid emitting enum members with emtpy names by throwing an exeption.…
Browse files Browse the repository at this point in the history
… Fix the json that caused the empty enum member.

Fixes #360
  • Loading branch information
Steve Otteson committed Mar 16, 2021
1 parent c3b4b04 commit 94522b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion generation/scraper/manualEnums.json
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@
},
{
"name": "ASN_SEQUENCE",
"value": "(ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10);"
"value": "(ASN_UNIVERSAL | ASN_CONSTRUCTOR | 0x10)"
},
{
"name": "ASN_IPADDRESS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,15 @@ private void WriteEnumMembers(EnumDeclarationSyntax node)

EncodeTypeSymbol(type, signatureEncoder);

var memberName = member.Identifier.Text;
if (string.IsNullOrEmpty(memberName))
{
throw new InvalidOperationException($"Enum {node.Identifier.Text} has a member with no name.");
}

var fieldDefinitionHandle = metadataBuilder.AddFieldDefinition(
enumFieldAttributes,
metadataBuilder.GetOrAddString(member.Identifier.Text),
metadataBuilder.GetOrAddString(memberName),
metadataBuilder.GetOrAddBlob(fieldSignature));

if (symbol.HasConstantValue)
Expand Down

0 comments on commit 94522b0

Please sign in to comment.