runtime: System.Text.JSon Source Generator Diagnostic in the error list doesnt link me to docs or navigate me to the file where the issue is

Description

I am using the System.Text.JSon Source Generator and am getting the following warning in my error list:

image

This analyzer doesn’t follow the analyzer guidelines for it doesnt navigate me to the file where the issue is or link me to docs to understand the issue better. Also should the severity be a warning or a suggestion? Anything that will be a warning or error should go through an analyzer review but let me know your thoughts. @jeffhandley @layomia

Reproduction Steps

I am on Version 17.0.0 Preview 5.0 [31807.358.d17.0]

I am using the following code:

using System.Text.Json;
using System.Text.Json.Serialization;

namespace SolarSystem;

internal record Astronomer(string FirstName, string LastName, string? MiddleName = null);

[JsonSerializable(typeof(Astronomer))]
internal partial class AstronomerJsonContext : JsonSerializerContext
{
}

class Program
{
    static void Main(string[] args)
    {
        var astronomer = new Astronomer(FirstName: "Jane", LastName: "Doe");

        string json = JsonSerializer.Serialize(astronomer, AstronomerJsonContext.Default.Astronomer);
    }
}

And I get the following warning in my error list but clicking on the warning doesnt navigate me to where the warning is coming from. Also the analyzer ID link doenst link me to docs.

image

Expected behavior

I am using the following code:

using System.Text.Json;
using System.Text.Json.Serialization;

namespace SolarSystem;

internal record Astronomer(string FirstName, string LastName, string? MiddleName = null);

[JsonSerializable(typeof(Astronomer))]
internal partial class AstronomerJsonContext : JsonSerializerContext
{
}

class Program
{
    static void Main(string[] args)
    {
        var astronomer = new Astronomer(FirstName: "Jane", LastName: "Doe");

        string json = JsonSerializer.Serialize(astronomer, AstronomerJsonContext.Default.Astronomer);
    }
}

And I get the following warning in my error list but clicking on the warning doesnt navigate me to where the warning is coming from. Also the analyzer ID link doenst link me to docs.

image

I would expect clicking on the warning in the error list will navigate me to where the warning is and the clicking on the ID link will take me to docs to understand what the warning is.

Actual behavior

I am using the following code:

using System.Text.Json;
using System.Text.Json.Serialization;

namespace SolarSystem;

internal record Astronomer(string FirstName, string LastName, string? MiddleName = null);

[JsonSerializable(typeof(Astronomer))]
internal partial class AstronomerJsonContext : JsonSerializerContext
{
}

class Program
{
    static void Main(string[] args)
    {
        var astronomer = new Astronomer(FirstName: "Jane", LastName: "Doe");

        string json = JsonSerializer.Serialize(astronomer, AstronomerJsonContext.Default.Astronomer);
    }
}

And I get the following warning in my error list but clicking on the warning doesnt navigate me to where the warning is coming from. Also the analyzer ID link doenst link me to docs.

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (11 by maintainers)

Most upvoted comments

Additional customer feedback copying here:

Compiler errors reported from generated code without being linked back to user markup / code that caused them.

@terrajobst received customer feedback on this as well. Copying here:

When there’s an error in the generated code make the error go to the generated source code so the user can try to figure out what went wrong. Most of the time I do that and I can understand why there’s an issue (followed by a github report).

@zejji there’s #58770. I would recommend upvoting the issue and sharing any feedback there.