Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions src/ZeroSerializerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ private static void CreateShapeTag(ITypeSymbol typeSymbol, StringBuilder shapeTa

if (typeSymbol.TypeKind == TypeKind.Enum && typeSymbol is INamedTypeSymbol enumType)
{
string prefix = HasFlagsAttribute(enumType) ? "flags:" : "enum:";
string prefix = "enum:";
string underlyingName = GetPrimitiveKeyword(enumType.EnumUnderlyingType);
if (underlyingName.Length == 0)
{
Expand Down Expand Up @@ -1727,24 +1727,4 @@ private static string GetPrimitiveKeyword(ITypeSymbol? typeSymbol)
};
}

private static bool HasFlagsAttribute(INamedTypeSymbol enumType)
{
foreach (AttributeData attr in enumType.GetAttributes())
{
if (attr.AttributeClass is INamedTypeSymbol
{
Name: "FlagsAttribute", ContainingNamespace: INamespaceSymbol
{
Name: "System", ContainingNamespace: INamespaceSymbol
{
IsGlobalNamespace: true
}
}
})
{
return true;
}
}
return false;
}
}
2 changes: 1 addition & 1 deletion tests/ShapeTagAndHashTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void EnumClassViewTest()
[Fact]
public void SchemaSignatureTestsModelViewTest()
{
string schemaSignatureExpected = "v1/{blittable{int,enum:short},{int,enum:byte},blittable{int,enum:short}[],{},blittable{},{enum:byte,enum:short}?,enum:byte[],flags:ulong[],int?,bool?}";
string schemaSignatureExpected = "v1/{blittable{int,enum:short},{int,enum:byte},blittable{int,enum:short}[],{},blittable{},{enum:byte,enum:short}?,enum:byte[],enum:ulong[],int?,bool?}";
Assert.Equal(SchemaSignatureTestsModelView.ShapeTag, schemaSignatureExpected);
Assert.Equal(SchemaSignatureTestsModelView.ShapeHash, XXHash32.HashToUInt32(schemaSignatureExpected));
}
Expand Down
Loading