* Emit a diagnostic when attributes deriving from JsonConverterAttribute are being used.
* Address feedback.
| __`SYSLIB1220`__ | JsonSourceGenerator encountered a [JsonConverterAttribute] with an invalid type argument. |
| __`SYSLIB1221`__ | JsonSourceGenerator does not support this C# language version. |
| __`SYSLIB1222`__ | Constructor annotated with JsonConstructorAttribute is inaccessible. |
-| __`SYSLIB1223`__ | *`SYSLIB1220`-`SYSLIB229` reserved for System.Text.Json.SourceGeneration.* |
+| __`SYSLIB1223`__ | Attributes deriving from JsonConverterAttribute are not supported by the source generator. |
| __`SYSLIB1224`__ | *`SYSLIB1220`-`SYSLIB229` reserved for System.Text.Json.SourceGeneration.* |
| __`SYSLIB1225`__ | *`SYSLIB1220`-`SYSLIB229` reserved for System.Text.Json.SourceGeneration.* |
| __`SYSLIB1226`__ | *`SYSLIB1220`-`SYSLIB229` reserved for System.Text.Json.SourceGeneration.* |
category: JsonConstants.SystemTextJsonSourceGenerationName,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
+
+ public static DiagnosticDescriptor DerivedJsonConverterAttributesNotSupported { get; } = new DiagnosticDescriptor(
+ id: "SYSLIB1223",
+ title: new LocalizableResourceString(nameof(SR.DerivedJsonConverterAttributesNotSupportedTitle), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
+ messageFormat: new LocalizableResourceString(nameof(SR.DerivedJsonConverterAttributesNotSupportedMessageFormat), SR.ResourceManager, typeof(FxResources.System.Text.Json.SourceGeneration.SR)),
+ category: JsonConstants.SystemTextJsonSourceGenerationName,
+ defaultSeverity: DiagnosticSeverity.Warning,
+ isEnabledByDefault: true);
}
}
}
private TypeRef? GetConverterTypeFromJsonConverterAttribute(INamedTypeSymbol contextType, ISymbol declaringSymbol, AttributeData attributeData)
{
Debug.Assert(_knownSymbols.JsonConverterAttributeType.IsAssignableFrom(attributeData.AttributeClass));
+
+ if (!SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, _knownSymbols.JsonConverterAttributeType))
+ {
+ ReportDiagnostic(DiagnosticDescriptors.DerivedJsonConverterAttributesNotSupported, attributeData.GetDiagnosticLocation(), attributeData.AttributeClass!.ToDisplayString());
+ return null;
+ }
+
+ Debug.Assert(attributeData.ConstructorArguments.Length == 1 && attributeData.ConstructorArguments[0].Value is null or ITypeSymbol);
var converterType = (ITypeSymbol?)attributeData.ConstructorArguments[0].Value;
return GetConverterTypeFromAttribute(contextType, converterType, declaringSymbol, attributeData);
}
<data name="JsonConverterAttributeInvalidTypeMessageFormat" xml:space="preserve">
<value>The 'JsonConverterAttribute' type '{0}' specified on member '{1}' is not a converter type or does not contain an accessible parameterless constructor.</value>
</data>
+ <data name="DerivedJsonConverterAttributesNotSupportedTitle" xml:space="preserve">
+ <value>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</value>
+ </data>
+ <data name="DerivedJsonConverterAttributesNotSupportedMessageFormat" xml:space="preserve">
+ <value>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</value>
+ </data>
<data name="JsonUnsupportedLanguageVersionTitle" xml:space="preserve">
<value>C# language version not supported by the source generator.</value>
</data>
<target state="translated">Typ vlastnosti rozšíření dat není platný</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Existuje několik typů s názvem {0}. Zdroj se vygeneroval pro první zjištěný typ. Tuto kolizi vyřešíte pomocí JsonSerializableAttribute.TypeInfoPropertyName.</target>
<target state="translated">Der Typ der Datenerweiterungseigenschaft ist ungültig.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Es sind mehrere Typen namens "{0}" vorhanden. Die Quelle wurde für den ersten festgestellten Typ generiert. Verwenden Sie "JsonSerializableAttribute.TypeInfoPropertyName", um diesen Konflikt zu beheben.</target>
<target state="translated">Tipo de propiedad de extensión de datos no válido.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Hay varios tipos denominados {0}. El origen se generó para el primero detectado. Use "JsonSerializableAttribute.TypeInfoPropertyName" para resolver esta colisión.</target>
<target state="translated">Type de propriété d’extension de données non valide</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Plusieurs types nommés {0}. La source a été générée pour la première détection détectée. Utilisez « JsonSerializableAttribute.TypeInfoPropertyName » pour résoudre cette collision.</target>
<target state="translated">Il tipo di proprietà dell'estensione dati non è valido.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Sono presenti più tipi denominati {0}. L'origine è stata generata per il primo tipo rilevato. Per risolvere questa collisione, usare 'JsonSerializableAttribute.TypeInfoPropertyName'.</target>
<target state="translated">データ拡張プロパティの型が無効です。</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">{0} と名前が付けられた種類が複数あります。最初に検出されたものに対してソースが生成されました。この問題を解決するには、'JsonSerializableAttribute.TypeInfoPropertyName' を使用します。</target>
<target state="translated">데이터 확장 속성 형식이 잘못되었습니다.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">이름이 {0}인 형식이 여러 개 있습니다. 처음 검색한 원본에 대해 원본이 생성되었습니다. 이 충돌을 해결하려면 'JsonSerializableAttribute.TypeInfoPropertyName'을 사용하세요.</target>
<target state="translated">Nieprawidłowy typ właściwości rozszerzenia danych.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Istnieje wiele typów o nazwie {0}. Wygenerowano źródło dla pierwszego wykrytego elementu. Aby rozwiązać tę kolizję, użyj „JsonSerializableAttribute. TypeInfoPropertyName”.</target>
<body>
<trans-unit id="ContextClassesMustBePartialMessageFormat">
<source>Derived 'JsonSerializerContext' type '{0}' specifies JSON-serializable types. The type and all containing types must be made partial to kick off source generation.</source>
- <target state="translated">O tipo 'JsonSerializerContext' derivado '{0}' especifica tipos serializáveis por JSON. O tipo e todos os tipos de contenção devem ser feitos parcialmente para iniciar a geração de origem.</target>
+ <target state="new">Derived 'JsonSerializerContext' type '{0}' specifies JSON-serializable types. The type and all containing types must be made partial to kick off source generation.</target>
<note />
</trans-unit>
<trans-unit id="ContextClassesMustBePartialTitle">
<source>Derived 'JsonSerializerContext' types and all containing types must be partial.</source>
- <target state="translated">Os tipos derivados de 'JsonSerializerContext' e todos os tipos contidos devem ser parciais.</target>
+ <target state="new">Derived 'JsonSerializerContext' types and all containing types must be partial.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidFormat">
<source>The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary<string, JsonElement>' or 'IDictionary<string, object>', or be 'JsonObject'.</source>
- <target state="translated">A propriedade da extensão de dados '{0}.{1}' é inválida. Deve implementar 'IDictionary<string, JsonElement>' ou 'IDictionary<string, object>', ou ter 'JsonObject'.</target>
+ <target state="new">The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary<string, JsonElement>' or 'IDictionary<string, object>', or be 'JsonObject'.</target>
<note />
</trans-unit>
<trans-unit id="DataExtensionPropertyInvalidTitle">
<source>Data extension property type invalid.</source>
- <target state="translated">Tipo de propriedade de extensão de dados inválido.</target>
+ <target state="new">Data extension property type invalid.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
<note />
</trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
- <target state="translated">Existem vários tipos chamados {0}. A fonte foi gerada para o primeiro detectado. Use 'JsonSerializableAttribute.TypeInfoPropertyName' para resolver esta colisão.</target>
+ <target state="new">There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</target>
<note />
</trans-unit>
<trans-unit id="DuplicateTypeNameTitle">
<source>Duplicate type name.</source>
- <target state="translated">Nome de tipo duplicado.</target>
+ <target state="new">Duplicate type name.</target>
<note />
</trans-unit>
<trans-unit id="FastPathPolymorphismNotSupportedMessageFormat">
<source>Type '{0}' is annotated with 'JsonDerivedTypeAttribute' which is not supported in 'JsonSourceGenerationMode.Serialization'.</source>
- <target state="translated">O tipo '{0}' é anotado com 'JsonDerivedTypeAttribute' que não tem suporte em 'JsonSourceGenerationMode.Serialization'.</target>
+ <target state="new">Type '{0}' is annotated with 'JsonDerivedTypeAttribute' which is not supported in 'JsonSourceGenerationMode.Serialization'.</target>
<note />
</trans-unit>
<trans-unit id="FastPathPolymorphismNotSupportedTitle">
<source>'JsonDerivedTypeAttribute' is not supported in 'JsonSourceGenerationMode.Serialization'.</source>
- <target state="translated">'JsonDerivedTypeAttribute' não tem suporte em 'JsonSourceGenerationMode.Serialization'.</target>
+ <target state="new">'JsonDerivedTypeAttribute' is not supported in 'JsonSourceGenerationMode.Serialization'.</target>
<note />
</trans-unit>
<trans-unit id="InaccessibleJsonIncludePropertiesNotSupportedFormat">
<source>The member '{0}.{1}' has been annotated with the JsonIncludeAttribute but is not visible to the source generator.</source>
- <target state="translated">O membro '{0}.{1}' foi anotado com o JsonIncludeAttribute, mas não é visível para o gerador de origem.</target>
+ <target state="new">The member '{0}.{1}' has been annotated with the JsonIncludeAttribute but is not visible to the source generator.</target>
<note />
</trans-unit>
<trans-unit id="InaccessibleJsonIncludePropertiesNotSupportedTitle">
<source>Inaccessible properties annotated with the JsonIncludeAttribute are not supported in source generation mode.</source>
- <target state="translated">Propriedades inacessíveis anotadas com JsonIncludeAttribute não são suportadas no modo de geração de origem.</target>
+ <target state="new">Inaccessible properties annotated with the JsonIncludeAttribute are not supported in source generation mode.</target>
<note />
</trans-unit>
<trans-unit id="InitOnlyPropertyDeserializationNotSupportedFormat">
<source>The type '{0}' defines init-only properties, deserialization of which is currently not supported in source generation mode.</source>
- <target state="translated">O tipo '{0}' define propriedades apenas de inicialização, a desserialização das quais atualmente não é suportada no modo de geração de origem.</target>
+ <target state="new">The type '{0}' defines init-only properties, deserialization of which is currently not supported in source generation mode.</target>
<note />
</trans-unit>
<trans-unit id="InitOnlyPropertyDeserializationNotSupportedTitle">
<source>Deserialization of init-only properties is currently not supported in source generation mode.</source>
- <target state="translated">A desserialização de propriedades apenas de inicialização não é atualmente suportada no modo de geração de origem.</target>
+ <target state="new">Deserialization of init-only properties is currently not supported in source generation mode.</target>
<note />
</trans-unit>
<trans-unit id="JsonConstructorInaccessibleMessageFormat">
<source>The constructor on type '{0}' has been annotated with JsonConstructorAttribute but is not accessible by the source generator.</source>
- <target state="translated">O construtor do tipo '{0}' foi anotado com JsonConstructorAttribute, mas não pode ser acessado pelo gerador de origem.</target>
+ <target state="new">The constructor on type '{0}' has been annotated with JsonConstructorAttribute but is not accessible by the source generator.</target>
<note />
</trans-unit>
<trans-unit id="JsonConstructorInaccessibleTitle">
<source>Constructor annotated with JsonConstructorAttribute is inaccessible.</source>
- <target state="translated">O construtor anotado com JsonConstructorAttribute está inacessível.</target>
+ <target state="new">Constructor annotated with JsonConstructorAttribute is inaccessible.</target>
<note />
</trans-unit>
<trans-unit id="JsonConverterAttributeInvalidTypeMessageFormat">
<source>The 'JsonConverterAttribute' type '{0}' specified on member '{1}' is not a converter type or does not contain an accessible parameterless constructor.</source>
- <target state="translated">O tipo "JsonConverterAttribute" "{0}" especificado no membro "{1}" não é um tipo de conversor ou não contém um construtor sem parâmetros acessível.</target>
+ <target state="new">The 'JsonConverterAttribute' type '{0}' specified on member '{1}' is not a converter type or does not contain an accessible parameterless constructor.</target>
<note />
</trans-unit>
<trans-unit id="JsonConverterAttributeInvalidTypeTitle">
<source>The 'JsonConverterAttribute.Type' contains an invalid or inaccessible argument.</source>
- <target state="translated">O "JsonConverterAttribute.Type" contém um argumento inválido ou inacessível.</target>
+ <target state="new">The 'JsonConverterAttribute.Type' contains an invalid or inaccessible argument.</target>
<note />
</trans-unit>
<trans-unit id="JsonStringEnumConverterNotSupportedMessageFormat">
<source>The member '{0}' has been annotated with 'JsonStringEnumConverter' which is not supported in native AOT. Consider using the generic 'JsonStringEnumConverter<TEnum>' instead.</source>
- <target state="translated">O membro "{0}" foi anotado com "JsonStringEnumConverter" que não tem suporte na AOT nativa. Considere usar o genérico "JsonStringEnumConverter<TEnum>".</target>
+ <target state="new">The member '{0}' has been annotated with 'JsonStringEnumConverter' which is not supported in native AOT. Consider using the generic 'JsonStringEnumConverter<TEnum>' instead.</target>
<note />
</trans-unit>
<trans-unit id="JsonStringEnumConverterNotSupportedTitle">
<source>The non-generic 'JsonStringEnumConverter' requires dynamic code.</source>
- <target state="translated">O "JsonStringEnumConverter" não genérico requer código dinâmico.</target>
+ <target state="new">The non-generic 'JsonStringEnumConverter' requires dynamic code.</target>
<note />
</trans-unit>
<trans-unit id="JsonUnsupportedLanguageVersionMessageFormat">
<source>The System.Text.Json source generator is not available in C# '{0}'. Please use language version {1} or greater.</source>
- <target state="translated">O gerador de fonte System.Text.Json não está disponível em C# '{0}'. Use a versão do idioma {1} ou superior.</target>
+ <target state="new">The System.Text.Json source generator is not available in C# '{0}'. Please use language version {1} or greater.</target>
<note />
</trans-unit>
<trans-unit id="JsonUnsupportedLanguageVersionTitle">
<source>C# language version not supported by the source generator.</source>
- <target state="translated">Versão da linguagem C# não suportada pelo gerador de origem.</target>
+ <target state="new">C# language version not supported by the source generator.</target>
<note />
</trans-unit>
<trans-unit id="MultipleJsonConstructorAttributeFormat">
<source>Type '{0}' has multiple constructors annotated with 'JsonConstructorAttribute'.</source>
- <target state="translated">O tipo '{0}' tem vários construtores anotados com 'JsonConstructorAttribute'.</target>
+ <target state="new">Type '{0}' has multiple constructors annotated with 'JsonConstructorAttribute'.</target>
<note />
</trans-unit>
<trans-unit id="MultipleJsonConstructorAttributeTitle">
<source>Type has multiple constructors annotated with JsonConstructorAttribute.</source>
- <target state="translated">O tipo tem vários construtores anotados com JsonConstructorAttribute.</target>
+ <target state="new">Type has multiple constructors annotated with JsonConstructorAttribute.</target>
<note />
</trans-unit>
<trans-unit id="MultipleJsonExtensionDataAttributeFormat">
<source>Type '{0}' has multiple members annotated with 'JsonExtensionDataAttribute'.</source>
- <target state="translated">Tipo '{0}' tem vários membros anotados com 'JsonExtensionDataAttribute'.</target>
+ <target state="new">Type '{0}' has multiple members annotated with 'JsonExtensionDataAttribute'.</target>
<note />
</trans-unit>
<trans-unit id="MultipleJsonExtensionDataAttributeTitle">
<source>Type has multiple members annotated with JsonExtensionDataAttribute.</source>
- <target state="translated">Tipo tem vários membros anotados com JsonExtensionDataAttribute.</target>
+ <target state="new">Type has multiple members annotated with JsonExtensionDataAttribute.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedMessageFormat">
<source>Did not generate serialization metadata for type '{0}'.</source>
- <target state="translated">Não gerou metadados de serialização para o tipo '{0}'.</target>
+ <target state="new">Did not generate serialization metadata for type '{0}'.</target>
<note />
</trans-unit>
<trans-unit id="TypeNotSupportedTitle">
<source>Did not generate serialization metadata for type.</source>
- <target state="translated">Não gerou metadados de serialização para o tipo.</target>
+ <target state="new">Did not generate serialization metadata for type.</target>
<note />
</trans-unit>
</body>
<target state="translated">Недопустимый тип свойства расширения данных.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">Существует несколько типов с именем {0}. Исходный код сформирован для первого обнаруженного типа. Используйте JsonSerializableAttribute.TypeInfoPropertyName для устранения этого конфликта.</target>
<target state="translated">Veri uzantısı özellik türü geçersiz.</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">{0} adını taşıyan birden çok tür var. Kaynak, algılanan ilk tür için oluşturuldu. Bu çarpışmayı çözmek için 'JsonSerializableAttribute.TypeInfoPropertyName' özelliğini kullanın.</target>
<target state="translated">数据扩展属性类型无效。</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">有多个名为 {0} 的类型。已为第一个检测到类型的生成源。请使用 'JsonSerializableAttribute.TypeInfoPropertyName' 以解决此冲突。</target>
<target state="translated">資料延伸屬性類型無效。</target>
<note />
</trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedMessageFormat">
+ <source>The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</source>
+ <target state="new">The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.</target>
+ <note />
+ </trans-unit>
+ <trans-unit id="DerivedJsonConverterAttributesNotSupportedTitle">
+ <source>Attributes deriving from JsonConverterAttribute are not supported by the source generator.</source>
+ <target state="new">Attributes deriving from JsonConverterAttribute are not supported by the source generator.</target>
+ <note />
+ </trans-unit>
<trans-unit id="DuplicateTypeNameMessageFormat">
<source>There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.</source>
<target state="translated">有多個名為 {0} 的類型。已為偵測到的第一個項目產生來源。請使用 'JsonSerializableAttribute.TypeInfoPropertyName' 解決此衝突。</target>
<!-- SYSLIB1039: Suppress Polymorphic types not supported warning -->
<!-- SYSLIB1220: Suppress invalid JsonConverterAttribute argument warnings -->
<!-- SYSLIB1222: Suppress inacessible JsonConstructorAttribute annotations -->
- <NoWarn>$(NoWarn);SYSLIB0020;SYSLIB0049;SYSLIB1034;SYSLIB1037;SYSLIB1038;SYSLIB1039;SYSLIB1220;SYSLIB1222</NoWarn>
+ <!-- SYSLIB1223: Suppress derived JsonConverterAttribute warnings -->
+ <NoWarn>$(NoWarn);SYSLIB0020;SYSLIB0049;SYSLIB1034;SYSLIB1037;SYSLIB1038;SYSLIB1039;SYSLIB1220;SYSLIB1222;SYSLIB1223</NoWarn>
<IgnoreForCI Condition="'$(TargetsMobile)' == 'true' or '$(TargetsLinuxBionic)' == 'true' or '$(TargetArchitecture)' == 'ARMv6'">true</IgnoreForCI>
</PropertyGroup>
return CreateCompilation(source);
}
+ public static Compilation CreateCompilationWithDerivedJsonConverterAttributeAnnotations()
+ {
+ string source = """
+ using System.Text.Json.Serialization;
+
+ namespace HelloWorld
+ {
+ [JsonSerializable(typeof(ClassWithConverterDeclaration))]
+ [JsonSerializable(typeof(ClassWithPropertyConverterDeclaration))]
+ internal partial class JsonContext : JsonSerializerContext
+ {
+ }
+
+ [MyJsonConverter]
+ public class ClassWithConverterDeclaration
+ {
+ }
+
+ public partial class ClassWithPropertyConverterDeclaration : JsonSerializerContext
+ {
+ [MyJsonConverter]
+ public int Value { get; set; }
+ }
+
+ public class MyJsonConverterAttribute : JsonConverterAttribute
+ {
+ public override JsonConverter? CreateConverter(Type typeToConvert) => null;
+ }
+ }
+ """;
+
+ return CreateCompilation(source);
+ }
+
public static Compilation CreateContextWithUnboundGenericTypeDeclarations()
{
string source = """
}
[Fact]
+ public void DerivedJsonConverterAttributeTypeWarns()
+ {
+ Compilation compilation = CompilationHelper.CreateCompilationWithDerivedJsonConverterAttributeAnnotations();
+ JsonSourceGeneratorResult result = CompilationHelper.RunJsonSourceGenerator(compilation, disableDiagnosticValidation: true);
+
+ Location typeAttrLocation = compilation.GetSymbolsWithName("ClassWithConverterDeclaration").First().GetAttributes()[0].GetLocation();
+ Location jsonSerializableAttrLocation = compilation.GetSymbolsWithName("JsonContext").First().GetAttributes()[0].GetLocation();
+ Location propAttrLocation = compilation.GetSymbolsWithName("Value").First().GetAttributes()[0].GetLocation();
+
+ var expectedDiagnostics = new DiagnosticData[]
+ {
+ new(DiagnosticSeverity.Warning, typeAttrLocation, "The custom attribute 'HelloWorld.MyJsonConverterAttribute' deriving from JsonConverterAttribute is not supported by the source generator."),
+ new(DiagnosticSeverity.Warning, jsonSerializableAttrLocation, "Did not generate serialization metadata for type 'HelloWorld.ClassWithConverterDeclaration'."),
+ new(DiagnosticSeverity.Warning, propAttrLocation, "The custom attribute 'HelloWorld.MyJsonConverterAttribute' deriving from JsonConverterAttribute is not supported by the source generator."),
+ };
+
+ CompilationHelper.AssertEqualDiagnosticMessages(expectedDiagnostics, result.Diagnostics);
+ }
+
+ [Fact]
public void UnboundGenericTypeDeclarationWarns()
{
Compilation compilation = CompilationHelper.CreateContextWithUnboundGenericTypeDeclarations();