dotnet/runtime
在 GitHub 查看Issue diagnostic warnings when custom JsonSerializerContext types don't indicate serializable types
Open
#58,698 创建于 2021年9月5日
area-System.Text.Jsonenhancementhelp wantedsource-generator
仓库指标
- Star
- (17,886 star)
- PR 合并指标
- (平均合并 12天 11小时) (30 天内合并 661 个 PR)
描述
When my custom serialiazer context class has zero JsonSerializable attributes, I get an error message which does not help me understand what the problem is.
I simply get the dreaded:
CS0534 'MyJsonSerializerContext' does not implement inherited abstract member 'JsonSerializerContext.GetTypeInfo(Type)'
I do not get any additional information to help me realize that I forgot to add JsonSerializable attributes to my custom class. It would be extremely helpful to get an error message similar to Your custom serializer context class must have at least one JsonSerializable attribute.
Repro:
public static class Program
{
public static void Main()
{
Console.WriteLine("Hello World!");
}
}
// Notice there are no JsonSerializable attributes here.
internal partial class MyJsonSerializerContext : JsonSerializerContext
{
}
As an aside: Is there a way to get more detailed information when something goes wrong with the code generator? Does it generate a log somewhere?