Fixed immutable from external assemblies

were wrongly interpreted as builders
This commit is contained in:
Carl de Billy 2018-08-21 16:28:23 -04:00
Родитель 1831caf578
Коммит 54894d7663
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -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.");
}