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

Suppress RZ10012 #6967

Open
lonix1 opened this issue Oct 7, 2022 · 11 comments
Open

Suppress RZ10012 #6967

lonix1 opened this issue Oct 7, 2022 · 11 comments
Labels
area-compiler Umbrella for all compiler issues enhancement Small improvement request vs vscode
Milestone

Comments

@lonix1
Copy link

lonix1 commented Oct 7, 2022

In my blazor project, I get hundreds of RZ10012 warnings:

Found markup element with unexpected name 'Foo'. If this is intended to be a component, add a @using directive for its namespace.(RZ10012)

This seems to be a bug, going back for years. It's been reported dozens of times on SO and in various GitHub repos. There are no fixes or workarounds that work consistently.

It's impossible to be productive when the entire editor shows squigglies. Since the app itself works, I want to suppress that analyser rule.

So I added this to an .editorconfig in the project's root:

[*.razor]
dotnet_diagnostic.RZ10012.severity = none

That doesn't help. I also tried a .globalconfig file.

How can I suppress it?

(I'm using .net6 and vscode)

@ghost ghost added the untriaged label Oct 7, 2022
@DustinCampbell DustinCampbell added this to the 17.5 P1 milestone Oct 13, 2022
@ghost ghost removed the untriaged label Oct 13, 2022
@DustinCampbell DustinCampbell modified the milestones: 17.5 P1, 17.5 P2 Nov 2, 2022
@DustinCampbell
Copy link
Member

@allisonchou: Let's test this with the latest VS Code bits to see if it still repros there.

@MihaMarkic
Copy link

It happened to me in Visual Studio 17.4 just today (not VS Code).
In my case closing VS, deleting obj and bin directories and opening VS again, worked.

@lonix1
Copy link
Author

lonix1 commented Nov 11, 2022

For me, the rm -rf ./bin ./obj trick works sometimes, but even so, only for a few builds after which the problem returns. And I need to close and open vscode too.

@phil-allen-msft phil-allen-msft modified the milestones: 17.5 P2, 17.5 P3 Dec 22, 2022
@phil-allen-msft phil-allen-msft modified the milestones: 17.5 P3, 17.6 P1 Jan 10, 2023
@vgb1993
Copy link

vgb1993 commented Jan 13, 2023

It happens to me too, it is NOT USABLE AT ALL.

This is a very much urgent issue in my opinion. I simply can not keep coding like this.

Check this screen recording, it starts to blink on and off.

screencast-nimbus-capture-2023.01.13-18_56_58.webm

@allisonchou allisonchou added the vs label Jan 24, 2023
@allisonchou
Copy link
Contributor

@phil-allen-msft I'm moving this back to triage since users are reporting this repros in both VS and VS Code. The last comment I believe is another instance of the colorization issues we've been seeing recently.

@allisonchou allisonchou removed their assignment Jan 24, 2023
@phil-allen-msft phil-allen-msft added the area-compiler Umbrella for all compiler issues label Jan 31, 2023
@phil-allen-msft phil-allen-msft modified the milestones: 17.6 P1, 17.6 P2 Feb 14, 2023
@ghost ghost removed the untriaged label Feb 14, 2023
@chsienki chsienki modified the milestones: 17.6 P2, 17.7 Planning Apr 26, 2023
@chsienki
Copy link
Contributor

@phil-allen-msft what was the rationale behind making this a compiler issue? Is there some more info somewhere about what’s causing it?

@chsienki
Copy link
Contributor

Oh, I see this is about the suppression itself not working. Ok makes sense that that would be us.

@MrDoe
Copy link

MrDoe commented Feb 26, 2024

I still have the same issue on .NET 8 using C# and Blazor. Suppressing the RZ10012 warning still doesn't work via .editorconfig or the tag in the .csproj file.

@earloc
Copy link
Contributor

earloc commented Oct 30, 2024

Stumbled upon this as well while tackling some other issue over at #6641 (comment)

(Note that I did the override in .editorconfig on global (all files), as well as on *.cs and *.razor files (and combinations).

[*]
indent_style = space
dotnet_diagnostic.CS8618.severity = error

[*.razor]
dotnet_diagnostic.CS8618.severity = error

[*.cs]
dotnet_diagnostic.CS8618.severity = error

Override works for *.cs

public class Class1
{
    public string Foo { get; set; }
}

✔️ VS:
Image

✔️ VSCode:
Image

But not for *.razor, at least in VSCode...

✔️ VS:
Image

❌ VSCode (still):
Image

So generally speaking, *.razor-files do not respect severity overrides from an .editorconfig-file (even regardless, if the .editorconfig specifies root = true.

edits: more details

@davidwengier
Copy link
Member

I think that .editorconfig not working when tweaking CS* diagnostics, when they're defined for *.cs files, for code in *.razor files is a Roslyn issue, but I could be wrong.

@earloc
Copy link
Contributor

earloc commented Nov 2, 2024

putting the override in a .globalconfig indeed let's VSCode honor the modified severity. I guess this is due to the fact that .editorconfig-settings only applies to non-generated code beneath the current project-path (and C# wihtihn *.razor is treated as generated code? since ) , whereas .globalconfig applies to all artifacts (let it be generated or non-generated content).

This might be due to the original confusion about .editorconfig vs .globalconfig and somehow is treated differntly accross VS and VSCode. But at least there would be a workaround to adress OPs problem (at least on .net 8).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-compiler Umbrella for all compiler issues enhancement Small improvement request vs vscode
Projects
None yet
Development

No branches or pull requests

10 participants