Skip to content

Suppress IDE0031 #13260

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

Merged
merged 2 commits into from
Apr 8, 2025
Merged

Suppress IDE0031 #13260

merged 2 commits into from
Apr 8, 2025

Conversation

NikolaMilosavljevic
Copy link
Member

@NikolaMilosavljevic NikolaMilosavljevic commented Apr 7, 2025

IDE0031 warnings were turned into errors in VMR build, with the latest SDK and compiler - dotnet/sdk#48226

D:\a\_work\1\vmr\src\winforms\src\System.Private.Windows.Core\src\System\Private\Windows\Ole\FormatEnumerator.cs(59,13): error IDE0031: Null check can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031) [D:\a\_work\1\vmr\src\winforms\src\System.Private.Windows.Core\src\System.Private.Windows.Core.csproj::TargetFramework=net8.0]
D:\a\_work\1\vmr\src\winforms\src\System.Private.Windows.Core\src\System\Private\Windows\Ole\FormatEnumerator.cs(77,9): error IDE0031: Null check can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031) [D:\a\_work\1\vmr\src\winforms\src\System.Private.Windows.Core\src\System.Private.Windows.Core.csproj::TargetFramework=net8.0]
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Apr 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.78286%. Comparing base (851d52d) to head (222d030).
Report is 6 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                  @@
##                main      #13260          +/-   ##
====================================================
+ Coverage   39.78342%   61.78286%   +21.99944%     
====================================================
  Files           1018        1552         +534     
  Lines          96407      158947       +62540     
  Branches       13451       14802        +1351     
====================================================
+ Hits           38354       98202       +59848     
- Misses         57654       60029        +2375     
- Partials         399         716         +317     
Flag Coverage Δ
Debug 61.78286% <ø> (+21.99943%) ⬆️
integration 10.71507% <ø> (-0.01221%) ⬇️
production 39.79814% <ø> (+0.01471%) ⬆️
test 95.67018% <ø> (?)
unit 37.24638% <ø> (+0.02294%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Tanya-Solyanik
Copy link
Member

@NikolaMilosavljevic - this analyzer is already enabled as a warning -

dotnet_diagnostic.IDE0031.severity = warning
and warnings are treated as errors.
I suppose Roslyn and analyzers have been updated to preview4 in the unified build and you now support ? in L-values feature?
But then I don't understand why these 2 are the only spots that broke your build? When I bump up SDK to P4, I get 51 errors.
I would prefer disabling this analyzer conditionally on the unified build in the corresponding project files, as I prefer applying the new syntax - pceltFetched?[0] = 0; eventually when we get the P4 SDK to pragmas in the source code.

@Tanya-Solyanik Tanya-Solyanik added the waiting-author-feedback The team requires more information from the author label Apr 8, 2025
@NikolaMilosavljevic
Copy link
Member Author

@NikolaMilosavljevic - this analyzer is already enabled as a warning -

dotnet_diagnostic.IDE0031.severity = warning

and warnings are treated as errors.
I suppose Roslyn and analyzers have been updated to preview4 in the unified build and you now support ? in L-values feature?
But then I don't understand why these 2 are the only spots that broke your build? When I bump up SDK to P4, I get 51 errors.
I would prefer disabling this analyzer conditionally on the unified build in the corresponding project files, as I prefer applying the new syntax - pceltFetched?[0] = 0; eventually when we get the P4 SDK to pragmas in the source code.

Yeah, once I disabled these 3 initial errors, I got 51 more errors, which is odd. I agree that we could probably disable this error per project, based on if we are building in VMR. Eventually new syntax could be applied once this repo moves to P4 SDK/compiler.

I'll update the PR.

…e.csproj

Co-authored-by: Tanya Solyanik <tanyaso@microsoft.com>
Copy link
Member

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ViktorHofer ViktorHofer enabled auto-merge (squash) April 8, 2025 05:11
@ViktorHofer ViktorHofer merged commit 2a19e5d into dotnet:main Apr 8, 2025
8 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0 Preview4 milestone Apr 8, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure waiting-author-feedback The team requires more information from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants