Skip to content

Commit

Permalink
Allow emission of constant-attributed class fields
Browse files Browse the repository at this point in the history
  • Loading branch information
riverar committed Feb 1, 2023
1 parent 1999cb6 commit 055ba0e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ private static bool HasPropertyKeyAttribute(SyntaxList<AttributeListSyntax> attr
return ret;
}

private static bool HasConstantAttribute(SyntaxList<AttributeListSyntax> attributeLists)
{
return attributeLists.Any(list => list.Attributes.Any(attr => attr.Name.ToString() == "Constant"));
}

private static string FixArchSpecificName(string name)
{
if (name.EndsWith("____1") || name.EndsWith("____2"))
Expand Down Expand Up @@ -1265,7 +1270,7 @@ private FieldDefinitionHandle WriteClassFields(ClassDeclarationSyntax node)
{
fieldAttributes = FieldAttributes.Public | FieldAttributes.Static;

if (!HasGuidAttribute(field.AttributeLists) && !HasPropertyKeyAttribute(field.AttributeLists))
if (!HasGuidAttribute(field.AttributeLists) && !HasPropertyKeyAttribute(field.AttributeLists) && !HasConstantAttribute(field.AttributeLists))
{
continue;
}
Expand Down

0 comments on commit 055ba0e

Please sign in to comment.