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

Build fails on VS2022 due to IDE0044 and similar errors #687

Closed
LucaBlackDragon opened this issue Aug 23, 2024 · 3 comments
Closed

Build fails on VS2022 due to IDE0044 and similar errors #687

LucaBlackDragon opened this issue Aug 23, 2024 · 3 comments

Comments

@LucaBlackDragon
Copy link

I am trying to make a PR for #584 but the build fails on Visual Studio 2022 (17.11.1).
It looks like it is ignoring the .editorconfig rules, e.g.:

dotnet_diagnostic.IDE0044.severity = suggestion

1>Build FAILED.
1>
1>C:\Users\redacted\Dev\sbom-tool\src\Microsoft.Sbom.Contracts\Contracts\Enums\AlgorithmName.cs(22,34,22,45): error IDE0044: Make field readonly (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0044)
1>C:\Users\redacted\Dev\sbom-tool\src\Microsoft.Sbom.Contracts\Contracts\Enums\AlgorithmName.cs(22,34,22,45): error IDE0044: Make field readonly (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0044)
1> 0 Warning(s)
1> 2 Error(s)

This is the full build output.

I'm on a Windows 11 PC with .NET 8 SDK, everything is updated to the latest available stable release (and I've deactivated the SonarLint extension which caused further errors).

I can work around these issues by adding a suppression file or #pragma comments, but I don't think this would be correct, am I right?

@DaveTryon
Copy link
Contributor

@LucaBlackDragon, I can't repro this. Here are the steps I did:

  • Updated to VS 2022 17.11.1
  • Ran git clean -fdx from the project root
  • Opened the solution in VS
  • Build > Rebuild Solution
  • Exited VS
  • Ran git clean -fdx from the project root
  • Ran dotnet build from the project root

Everything worked as expected. I explicitly changed line 1007 of the .editorconfig file from

dotnet_diagnostic.IDE0044.severity = suggestion

to

dotnet_diagnostic.IDE0044.severity = error

and then I got the failure that you're seeing. The warning behavior seems to be local to your config, although I honestly have no idea what would cause that. Please don't add any pragmas to the code to address this. Making IDE0044 error permanently would touch about 6 files and only take a few minutes to create. If you wanted to open a PR to that effect, that would be a far better option than dropping in pragmas that are not needed on other systems.

I'll ask a couple of my colleagues to try to build with the latest VS release. We'll close it out if we can't repro.

@DaveTryon DaveTryon added the needs triage Default status upon issue submission label Aug 26, 2024
@LucaBlackDragon
Copy link
Author

LucaBlackDragon commented Aug 27, 2024

I'm closing this as the problem looks to be due to Visual Studio issues with editorconfig files in general.

Today I made some more research and I've found a ton of comments and issues like this:

I had a similar issue in my team, my VS highlight errors and add suggestions from .editorconfig rules but my other team members open the same project on their VS versions and their VS doesn't respect/load .editorconfig rules at all.

EDIT: @DaveTryon if you need the issue reopened for some reason let me know! And thanks for your interest in this matter

@LucaBlackDragon
Copy link
Author

LucaBlackDragon commented Aug 27, 2024

SMALL UPDATE:

  • checked out the project on a different PC (Win 11, VS2022, .NET 8 again): same build errors
  • launched a Codespace here on Github (default image) and ran dotnet build: build succeeded

honestly I don't know what to think 🥲

@DaveTryon DaveTryon removed the needs triage Default status upon issue submission label Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants