diff --git a/src/Uno.CodeGen/ImmutableGenerator.cs b/src/Uno.CodeGen/ImmutableGenerator.cs index 730b19d..4a5c8a5 100644 --- a/src/Uno.CodeGen/ImmutableGenerator.cs +++ b/src/Uno.CodeGen/ImmutableGenerator.cs @@ -47,6 +47,7 @@ namespace Uno private INamedTypeSymbol _immutableAttributeSymbol; private INamedTypeSymbol _generatedImmutableAttributeSymbol; private INamedTypeSymbol _immutableBuilderAttributeSymbol; + private INamedTypeSymbol _immutableBuilderInterfaceSymbol; private INamedTypeSymbol _immutableAttributeCopyIgnoreAttributeSymbol; private INamedTypeSymbol _immutableGenerationOptionsAttributeSymbol; private INamedTypeSymbol _immutableTreatAsImmutableAttributeSymbol; @@ -71,6 +72,7 @@ namespace Uno _immutableAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.ImmutableAttribute"); _generatedImmutableAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.GeneratedImmutableAttribute"); _immutableBuilderAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.ImmutableBuilderAttribute"); + _immutableBuilderInterfaceSymbol = context.Compilation.GetTypeByMetadataName("Uno.IImmutableBuilder`1"); _immutableAttributeCopyIgnoreAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.ImmutableAttributeCopyIgnoreAttribute"); _immutableGenerationOptionsAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.ImmutableGenerationOptionsAttribute"); _immutableTreatAsImmutableAttributeSymbol = context.Compilation.GetTypeByMetadataName("Uno.TreatAsImmutableAttribute"); @@ -861,7 +863,7 @@ $@"public sealed class {symbolName}BuilderJsonConverterTo{symbolName}{genericArg return; // ok } - if (type.FindAttribute(_immutableBuilderAttributeSymbol) != null) + if (type.DerivesFromType(_immutableBuilderInterfaceSymbol)) { Error(builder, $"{typeSource} ({typeName}) is a builder. It cannot be used in an immutable entity."); }