-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON source generator fails to compile if context type isn't in a namespace #56920
Comments
dotnet-issue-labeler
bot
added
area-System.Text.Json
untriaged
New issue has not been triaged by the area owner
labels
Aug 5, 2021
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsThis fails to compile: using System;
using System.Text.Json.Serialization;
class Program
{
public static void Main() { }
}
internal class Book
{
public string? Name { get; set; }
}
[JsonSerializable(typeof(Book))]
internal partial class MyJsonContext : JsonSerializerContext { } with the errors:
but wrap both the type to be serialized and the context type in a namespace, and then it compiles fine: using System;
using System.Text.Json.Serialization;
class Program
{
public static void Main() { }
}
namespace Anything
{
internal class Book
{
public string? Name { get; set; }
}
[JsonSerializable(typeof(Book))]
internal partial class MyJsonContext : JsonSerializerContext { }
}
|
ghost
added
the
in-pr
There is an active PR which will close this issue when it is merged
label
Aug 11, 2021
ghost
removed
the
in-pr
There is an active PR which will close this issue when it is merged
label
Aug 11, 2021
ghost
locked as resolved and limited conversation to collaborators
Sep 11, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This fails to compile:
with the errors:
but wrap both the type to be serialized and the context type in a namespace, and then it compiles fine:
The text was updated successfully, but these errors were encountered: