-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
dotnet format: IDE0051 format issues with Razor code behind files with SDK 8.0.200 #39817
Comments
We're seeing this "break" a number of our codebases that use code behind files ( - uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.203 Workaround for us has been an root = false
[*.razor.cs]
# These rules appear to be broken for dotnet format after the .NET 8.0.3 upgrade (8.0.203).
# So we're disabling them for now and hopefully they can be re-enabled in time.
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1823.severity = suggestion
dotnet_diagnostic.IDE0044.severity = suggestion
dotnet_diagnostic.IDE0051.severity = suggestion
dotnet_diagnostic.IDE0052.severity = suggestion
dotnet_diagnostic.IDE0060.severity = none This feels like a pretty big regression. 😞 |
I completely agree. This regression is quite concerning as it significantly impacts our workflow. Spending time dealing with these issues is slowing us down considerably and affecting our productivity. Hopefully, this will be resolved quickly so we can get back to a stable and efficient development environment. |
Are there any plans to investigate the issue? It is still untriaged and broken. dotnet format is completely unusable for Blazor right now |
This is a very severe regression. I am very surprised this hasn't even been investigated yet. A formatter breaking code is about as severe as a regression can get. |
Thank you so much for the workaround. Very much appreaciated 🙌 . I just needed to add |
@jaredpar Do you think the culprit is |
Instinct is this is a |
Are there any updates? |
Since dotnet format has moved to the dotnet SDK repository I'll recreate the issue here to hope for more feedback.
Since the .NET SDK update to version
8.0.200
it seems that the format tool doesn't link the Razor pages with their code behind files anymore.We use code behind files
*.razor.cs
for our Razor components. Using the format tool now leads to aIDE0051
unused private member warning. Looks like the Razor code does not exist for the tool.I've created a repository with the sample Blazor WASM application and moved the C# code of
Counter.razor
andWeather.razor
to a code-behind file to demonstrate the issue.E.g. the verify no style changes command brings up
IDE0051
error and says that the Click event handler defined in the code behind file is unused.Running
dotnet format
formats theCounter.razor.cs
file and removes theIncrementCount()
method.The automatically removed method leads to a failed build.
Environment
.NET
dotnet format
> dotnet format --version 8.0.453106+2651752953c0d41c8c7b8d661cf2237151af33d0
The text was updated successfully, but these errors were encountered: