Skip to content
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

Roslyn JSON detection marks strings as JSON even if StringSyntaxAttribute says it's not. #74020

Closed
maartenvansambeek opened this issue Jun 16, 2024 · 0 comments · Fixed by #74019
Assignees
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Milestone

Comments

@maartenvansambeek
Copy link

Version Used:
4.10.0

Steps to Reproduce:

  1. Create a program that has a field marked as something that is not json by using a [StringSyntax] attribute,
  2. Look at the highlighted text in the IDE.

Example program:

using System.Diagnostics.CodeAnalysis;

class Program
{
    [StringSyntax("notjson")]
    private string field;
    void Goo()
    {
        // The JSON constant below is highlighted as json:
        this.field = @"[{ 'goo': 0}]";
    }
}

A minimal repro, with source-code provided, is ideal. Using sharplab is preferred for compiler/language issues whenever possible.

Diagnostic Id:

If this is a report about a bug in an analyzer, please include the diagnostic ID and message if possible (e.g. "IDE0030: Use coalesce expression").

Expected Behavior:

The constant string is not highlighted as JSON.

Actual Behavior:

The constant string is highlighted as JSON.

A PR was created for this issue: #74019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants