question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Types generated from .razor files are reported as missing

See original GitHub issue

Hello and thank you for an amazing tool! We’re trying to enforce code conventions during commit hooks and dotnet-format helps perfectly.

We’ve got troubles using new rules from Roslynator v3.1.0 introduced a new rule RCS0053 enforcing consistent indentation for lists which is the only rule I found doing so far.

By running dotnet format -wsa warn the following errors appears:

  Unable to fix RCS0053. Code fix FixFormattingOfListCodeFixProvider didn't return a Fix All action.
  Unable to fix SA1306. Code fix RenameToLowerCaseCodeFixProvider didn't return a Fix All action.

Rules are working perfectly in VSCode / Intellij Rider, except of running via dotnet format. We could live with that by manually going though the code invoking the refactoring snippets, but I see that dotnet format -wsa warn --check bypass checks if there is no fix available assuming the code is fine.

Is there any options to return non-zero code if dotnet-format unable see error but unable to fix so that lint-staged would fail?

Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JoeRobichcommented, Feb 23, 2021

@gavar In your case we have performed the restore prior to running dotnet-format. I see that the App class is generated from the App.razor file. It is likely that we are not invoking the proper MSBuild task when loading the workspace to add this class to our compilation. I am going to update this issue title to track this bug.

1reaction
JoeRobichcommented, Feb 23, 2021

@gavar Thanks for the excellent repro repo! =)

I found the answer reading this blog post . The file globbing library that dotnet-format uses has problems with fully rooted paths. Passing the --relative flag to lint-staged in order to generate relative file paths resolves your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing @using on razor view
the main problem is when i try to launch mi webapp, i get this error Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper ' does not ......
Read more >
Introducing the new Razor editor in Visual Studio 2022
The new model opens the doors to add new code fixes and refactorings more easily. The most used refactoring, Add missing usings is...
Read more >
Tutorial: Get started with Razor Pages in ASP.NET Core
This is the first tutorial of a series that teaches the basics of building an ASP.NET Core Razor Pages web app.
Read more >
Razor Pages for ASP.NET Core - Full Course (.NET 6)
Learn the basics of Razor Pages for ASP. ... (0:17:18) Hot Reload ⌨️ (0:21:42) Razor Pages Introduction ⌨️ (0:22:43) Project File ...
Read more >
Dates And Times in a Razor Pages Form
When working with dates and times in a Razor Pages form, you need to render a suitable control based in the task requirement....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found