diff --git a/docs/project/list-of-diagnostics.md b/docs/project/list-of-diagnostics.md
index 2375aa96652c85..b4122074d369cd 100644
--- a/docs/project/list-of-diagnostics.md
+++ b/docs/project/list-of-diagnostics.md
@@ -257,7 +257,7 @@ The diagnostic id values reserved for .NET Libraries analyzer warnings are `SYSL
| __`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.* |
diff --git a/src/libraries/System.Text.Json/gen/JsonSourceGenerator.DiagnosticDescriptors.cs b/src/libraries/System.Text.Json/gen/JsonSourceGenerator.DiagnosticDescriptors.cs
index 95e6f1e5502e97..000acd0eb68daf 100644
--- a/src/libraries/System.Text.Json/gen/JsonSourceGenerator.DiagnosticDescriptors.cs
+++ b/src/libraries/System.Text.Json/gen/JsonSourceGenerator.DiagnosticDescriptors.cs
@@ -106,6 +106,14 @@ internal static class DiagnosticDescriptors
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);
}
}
}
diff --git a/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs b/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs
index 2499321c538c07..24ac7ccbe79650 100644
--- a/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs
+++ b/src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs
@@ -1454,6 +1454,14 @@ bool MatchesConstructorParameter(ParameterGenerationSpec paramSpec)
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);
}
diff --git a/src/libraries/System.Text.Json/gen/Resources/Strings.resx b/src/libraries/System.Text.Json/gen/Resources/Strings.resx
index baa0c88a79043e..3495443f4af52c 100644
--- a/src/libraries/System.Text.Json/gen/Resources/Strings.resx
+++ b/src/libraries/System.Text.Json/gen/Resources/Strings.resx
@@ -183,6 +183,12 @@
The 'JsonConverterAttribute' type '{0}' specified on member '{1}' is not a converter type or does not contain an accessible parameterless constructor.
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
C# language version not supported by the source generator.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.cs.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.cs.xlf
index bdd3c826078a79..1f31e7a1f0570e 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.cs.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.cs.xlf
@@ -22,6 +22,16 @@
Typ vlastnosti rozšíření dat není platný
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.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.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.de.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.de.xlf
index e055679c10affb..71d1d1bfe880c5 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.de.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.de.xlf
@@ -22,6 +22,16 @@
Der Typ der Datenerweiterungseigenschaft ist ungültig.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.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.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.es.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.es.xlf
index ce257cbb1c7135..75e55202abe537 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.es.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.es.xlf
@@ -22,6 +22,16 @@
Tipo de propiedad de extensión de datos no válido.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.Hay varios tipos denominados {0}. El origen se generó para el primero detectado. Use "JsonSerializableAttribute.TypeInfoPropertyName" para resolver esta colisión.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.fr.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.fr.xlf
index 14537fd03fb0b8..03be4b8b1c6514 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.fr.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.fr.xlf
@@ -22,6 +22,16 @@
Type de propriété d’extension de données non valide
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.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.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.it.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.it.xlf
index 374d71010a2362..b3b1d84e66aa08 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.it.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.it.xlf
@@ -22,6 +22,16 @@
Il tipo di proprietà dell'estensione dati non è valido.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.Sono presenti più tipi denominati {0}. L'origine è stata generata per il primo tipo rilevato. Per risolvere questa collisione, usare 'JsonSerializableAttribute.TypeInfoPropertyName'.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ja.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ja.xlf
index fc01911e03f10c..b50a94bb5dfaa6 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ja.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ja.xlf
@@ -22,6 +22,16 @@
データ拡張プロパティの型が無効です。
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.{0} と名前が付けられた種類が複数あります。最初に検出されたものに対してソースが生成されました。この問題を解決するには、'JsonSerializableAttribute.TypeInfoPropertyName' を使用します。
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ko.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ko.xlf
index 6ccf47433580c6..5f90e2a1553a2c 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ko.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ko.xlf
@@ -22,6 +22,16 @@
데이터 확장 속성 형식이 잘못되었습니다.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.이름이 {0}인 형식이 여러 개 있습니다. 처음 검색한 원본에 대해 원본이 생성되었습니다. 이 충돌을 해결하려면 'JsonSerializableAttribute.TypeInfoPropertyName'을 사용하세요.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pl.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pl.xlf
index 7e051e09a305db..70b4639398e005 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pl.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pl.xlf
@@ -22,6 +22,16 @@
Nieprawidłowy typ właściwości rozszerzenia danych.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.Istnieje wiele typów o nazwie {0}. Wygenerowano źródło dla pierwszego wykrytego elementu. Aby rozwiązać tę kolizję, użyj „JsonSerializableAttribute. TypeInfoPropertyName”.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pt-BR.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pt-BR.xlf
index 1b2fe43b42993f..fc9c847636f6ea 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pt-BR.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.pt-BR.xlf
@@ -4,132 +4,142 @@
Derived 'JsonSerializerContext' type '{0}' specifies JSON-serializable types. The type and all containing types must be made partial to kick off source generation.
- 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.
+ Derived 'JsonSerializerContext' type '{0}' specifies JSON-serializable types. The type and all containing types must be made partial to kick off source generation.Derived 'JsonSerializerContext' types and all containing types must be partial.
- Os tipos derivados de 'JsonSerializerContext' e todos os tipos contidos devem ser parciais.
+ Derived 'JsonSerializerContext' types and all containing types must be partial.The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary<string, JsonElement>' or 'IDictionary<string, object>', or be 'JsonObject'.
- A propriedade da extensão de dados '{0}.{1}' é inválida. Deve implementar 'IDictionary<string, JsonElement>' ou 'IDictionary<string, object>', ou ter 'JsonObject'.
+ The data extension property '{0}.{1}' is invalid. It must implement 'IDictionary<string, JsonElement>' or 'IDictionary<string, object>', or be 'JsonObject'.Data extension property type invalid.
- Tipo de propriedade de extensão de dados inválido.
+ Data extension property type invalid.
+
+
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.
- Existem vários tipos chamados {0}. A fonte foi gerada para o primeiro detectado. Use 'JsonSerializableAttribute.TypeInfoPropertyName' para resolver esta colisão.
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.Duplicate type name.
- Nome de tipo duplicado.
+ Duplicate type name.Type '{0}' is annotated with 'JsonDerivedTypeAttribute' which is not supported in 'JsonSourceGenerationMode.Serialization'.
- O tipo '{0}' é anotado com 'JsonDerivedTypeAttribute' que não tem suporte em 'JsonSourceGenerationMode.Serialization'.
+ Type '{0}' is annotated with 'JsonDerivedTypeAttribute' which is not supported in 'JsonSourceGenerationMode.Serialization'.'JsonDerivedTypeAttribute' is not supported in 'JsonSourceGenerationMode.Serialization'.
- 'JsonDerivedTypeAttribute' não tem suporte em 'JsonSourceGenerationMode.Serialization'.
+ 'JsonDerivedTypeAttribute' is not supported in 'JsonSourceGenerationMode.Serialization'.The member '{0}.{1}' has been annotated with the JsonIncludeAttribute but is not visible to the source generator.
- O membro '{0}.{1}' foi anotado com o JsonIncludeAttribute, mas não é visível para o gerador de origem.
+ The member '{0}.{1}' has been annotated with the JsonIncludeAttribute but is not visible to the source generator.Inaccessible properties annotated with the JsonIncludeAttribute are not supported in source generation mode.
- Propriedades inacessíveis anotadas com JsonIncludeAttribute não são suportadas no modo de geração de origem.
+ Inaccessible properties annotated with the JsonIncludeAttribute are not supported in source generation mode.The type '{0}' defines init-only properties, deserialization of which is currently not supported in source generation mode.
- 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.
+ The type '{0}' defines init-only properties, deserialization of which is currently not supported in source generation mode.Deserialization of init-only properties is currently not supported in source generation mode.
- A desserialização de propriedades apenas de inicialização não é atualmente suportada no modo de geração de origem.
+ Deserialization of init-only properties is currently not supported in source generation mode.The constructor on type '{0}' has been annotated with JsonConstructorAttribute but is not accessible by the source generator.
- O construtor do tipo '{0}' foi anotado com JsonConstructorAttribute, mas não pode ser acessado pelo gerador de origem.
+ The constructor on type '{0}' has been annotated with JsonConstructorAttribute but is not accessible by the source generator.Constructor annotated with JsonConstructorAttribute is inaccessible.
- O construtor anotado com JsonConstructorAttribute está inacessível.
+ Constructor annotated with JsonConstructorAttribute is inaccessible.The 'JsonConverterAttribute' type '{0}' specified on member '{1}' is not a converter type or does not contain an accessible parameterless constructor.
- 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.
+ The 'JsonConverterAttribute' type '{0}' specified on member '{1}' is not a converter type or does not contain an accessible parameterless constructor.The 'JsonConverterAttribute.Type' contains an invalid or inaccessible argument.
- O "JsonConverterAttribute.Type" contém um argumento inválido ou inacessível.
+ The 'JsonConverterAttribute.Type' contains an invalid or inaccessible argument.The member '{0}' has been annotated with 'JsonStringEnumConverter' which is not supported in native AOT. Consider using the generic 'JsonStringEnumConverter<TEnum>' instead.
- O membro "{0}" foi anotado com "JsonStringEnumConverter" que não tem suporte na AOT nativa. Considere usar o genérico "JsonStringEnumConverter<TEnum>".
+ The member '{0}' has been annotated with 'JsonStringEnumConverter' which is not supported in native AOT. Consider using the generic 'JsonStringEnumConverter<TEnum>' instead.The non-generic 'JsonStringEnumConverter' requires dynamic code.
- O "JsonStringEnumConverter" não genérico requer código dinâmico.
+ The non-generic 'JsonStringEnumConverter' requires dynamic code.The System.Text.Json source generator is not available in C# '{0}'. Please use language version {1} or greater.
- O gerador de fonte System.Text.Json não está disponível em C# '{0}'. Use a versão do idioma {1} ou superior.
+ The System.Text.Json source generator is not available in C# '{0}'. Please use language version {1} or greater.C# language version not supported by the source generator.
- Versão da linguagem C# não suportada pelo gerador de origem.
+ C# language version not supported by the source generator.Type '{0}' has multiple constructors annotated with 'JsonConstructorAttribute'.
- O tipo '{0}' tem vários construtores anotados com 'JsonConstructorAttribute'.
+ Type '{0}' has multiple constructors annotated with 'JsonConstructorAttribute'.Type has multiple constructors annotated with JsonConstructorAttribute.
- O tipo tem vários construtores anotados com JsonConstructorAttribute.
+ Type has multiple constructors annotated with JsonConstructorAttribute.Type '{0}' has multiple members annotated with 'JsonExtensionDataAttribute'.
- Tipo '{0}' tem vários membros anotados com 'JsonExtensionDataAttribute'.
+ Type '{0}' has multiple members annotated with 'JsonExtensionDataAttribute'.Type has multiple members annotated with JsonExtensionDataAttribute.
- Tipo tem vários membros anotados com JsonExtensionDataAttribute.
+ Type has multiple members annotated with JsonExtensionDataAttribute.Did not generate serialization metadata for type '{0}'.
- Não gerou metadados de serialização para o tipo '{0}'.
+ Did not generate serialization metadata for type '{0}'.Did not generate serialization metadata for type.
- Não gerou metadados de serialização para o tipo.
+ Did not generate serialization metadata for type.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ru.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ru.xlf
index 0e3e3f34b2c876..87a7936e556c07 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ru.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.ru.xlf
@@ -22,6 +22,16 @@
Недопустимый тип свойства расширения данных.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.Существует несколько типов с именем {0}. Исходный код сформирован для первого обнаруженного типа. Используйте JsonSerializableAttribute.TypeInfoPropertyName для устранения этого конфликта.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.tr.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.tr.xlf
index 2e8e0df34594f1..9f414699c1789e 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.tr.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.tr.xlf
@@ -22,6 +22,16 @@
Veri uzantısı özellik türü geçersiz.
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.{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.
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hans.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hans.xlf
index d0732a7bf21303..5a656d9ff13520 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hans.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hans.xlf
@@ -22,6 +22,16 @@
数据扩展属性类型无效。
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.有多个名为 {0} 的类型。已为第一个检测到类型的生成源。请使用 'JsonSerializableAttribute.TypeInfoPropertyName' 以解决此冲突。
diff --git a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hant.xlf b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hant.xlf
index 9ecddba3e923d3..fa1cefb3b2c4c1 100644
--- a/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hant.xlf
+++ b/src/libraries/System.Text.Json/gen/Resources/xlf/Strings.zh-Hant.xlf
@@ -22,6 +22,16 @@
資料延伸屬性類型無效。
+
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+ The custom attribute '{0}' deriving from JsonConverterAttribute is not supported by the source generator.
+
+
+
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+ Attributes deriving from JsonConverterAttribute are not supported by the source generator.
+
+ There are multiple types named {0}. Source was generated for the first one detected. Use 'JsonSerializableAttribute.TypeInfoPropertyName' to resolve this collision.有多個名為 {0} 的類型。已為偵測到的第一個項目產生來源。請使用 'JsonSerializableAttribute.TypeInfoPropertyName' 解決此衝突。
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets
index 96c0a34cc88518..b350fc936c7983 100644
--- a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/System.Text.Json.SourceGeneration.Tests.targets
@@ -13,7 +13,8 @@
- $(NoWarn);SYSLIB0020;SYSLIB0049;SYSLIB1034;SYSLIB1037;SYSLIB1038;SYSLIB1039;SYSLIB1220;SYSLIB1222
+
+ $(NoWarn);SYSLIB0020;SYSLIB0049;SYSLIB1034;SYSLIB1037;SYSLIB1038;SYSLIB1039;SYSLIB1220;SYSLIB1222;SYSLIB1223true
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/CompilationHelper.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/CompilationHelper.cs
index 4fdb962289337e..09daf5795dab24 100644
--- a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/CompilationHelper.cs
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/CompilationHelper.cs
@@ -697,6 +697,40 @@ public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptio
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 = """
diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/JsonSourceGeneratorDiagnosticsTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/JsonSourceGeneratorDiagnosticsTests.cs
index 92b7c0381924b5..4155df9e3e263e 100644
--- a/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/JsonSourceGeneratorDiagnosticsTests.cs
+++ b/src/libraries/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/JsonSourceGeneratorDiagnosticsTests.cs
@@ -345,6 +345,26 @@ public void InvalidJsonConverterAttributeTypeWarns()
CompilationHelper.AssertEqualDiagnosticMessages(expectedDiagnostics, result.Diagnostics);
}
+ [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()
{