From 3f66d9dbd3be53c15c7d678eb26b664afb6a0dbe Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 13 Aug 2026 06:05:03 +0000 Subject: [PATCH] Remove distinction of enum and flags-enum for ShapeTag Unified the ShapeTag prefix generation for regular enums and [Flags] enums under "enum:", removing the "flags:" prefix entirely and deleting the unused HasFlagsAttribute helper method. Updated the tests to match. --- src/ZeroSerializerGenerator.cs | 22 +--------------------- tests/ShapeTagAndHashTests.cs | 2 +- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/ZeroSerializerGenerator.cs b/src/ZeroSerializerGenerator.cs index ba279b0..5cc1985 100644 --- a/src/ZeroSerializerGenerator.cs +++ b/src/ZeroSerializerGenerator.cs @@ -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) { @@ -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; - } } diff --git a/tests/ShapeTagAndHashTests.cs b/tests/ShapeTagAndHashTests.cs index 6209a37..b11478b 100644 --- a/tests/ShapeTagAndHashTests.cs +++ b/tests/ShapeTagAndHashTests.cs @@ -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)); }