-
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
System.Text.Json Source Generator with TreatWarningsAsErrors Fails #64499
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsDescriptionWhen project is set to treat warnings as errors and XML documentation generation is enabled the build using System.Text.Json source generator fails. Reproduction Stepscsproj
and when I add a public class derived from JsonSerializerContext the build fails using System.Text.Json;
using System.Text.Json.Serialization;
namespace ConsoleApp7;
/// <summary>
/// </summary>
public class Program
{
static void Main(string[] args)
{
// Display the number of command line arguments.
Console.WriteLine(args.Length);
Person? person = new() { FirstName = "Jane", LastName = "Doe" };
byte[] utf8Json = JsonSerializer.SerializeToUtf8Bytes(person, MyJsonContext2.Default.Person);
person = JsonSerializer.Deserialize(utf8Json, MyJsonContext2.Default.Person);
}
}
/// <summary>
/// </summary>
public class Person
{
/// <summary>
/// </summary>
public string? FirstName { get; set; }
/// <summary>
/// </summary>
public string? LastName { get; set; }
}
/// <summary>
///
/// </summary>
[JsonSerializable(typeof(Person))]
public partial class MyJsonContext2 : JsonSerializerContext
{
} Expected behaviorThe build should pass, one idea is to add Actual behaviorThe build failes Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Dupe of #61379. |
Description
When project is set to treat warnings as errors and XML documentation generation is enabled the build using System.Text.Json source generator fails.
Reproduction Steps
csproj
and when I add a public class derived from JsonSerializerContext the build fails
Expected behavior
The build should pass, one idea is to add
#pragma warning disable 1591
and possibly// <auto-generated />
to generated filesActual behavior
The build failes
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: