Fix IDE0370 build errors from .NET 10 SDK analyzer#91
Merged
Conversation
The scheduled CI build failed with 32 IDE0370 (suppression is unnecessary) errors raised by the .NET SDK 10.0.301 analyzers with warnings treated as errors. - SemanticQuantity.cs: remove null-forgiving operators on Create<TResult>(...) calls; Create returns a non-nullable TQuantity so the suppressions were never needed. - SemanticString.cs: replace null-forgiving operators in FromStringInternal with Ensure.NotNull, which is valid in both the nullable-annotated (net5.0+) and oblivious (netstandard2.x) builds where IDE0370 flagged the suppressions. https://claude.ai/code/session_01LBGrmJHgP4RpMC9dQ2Pdox
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
Fixes the CI failure in run 27384038671, where the build failed with 32
IDE0370: Suppression is unnecessaryerrors raised by the .NET SDK 10.0.301 analyzers (with code-analysis warnings treated as errors).All 9 flagged locations were null-forgiving (
!) operators:Semantics.Quantities/Core/SemanticQuantity.cs(7 locations):Create<TResult>(...)returns a non-nullableTQuantity, so the trailing!on theMultiply/Divide/Add/Subtract/Negatereturn statements was never needed. Removed.Semantics.Strings/SemanticString.cs(2 locations inFromStringInternal): IDE0370 fired in thenetstandard2.0/2.1builds where the BCL reference assemblies are nullability-oblivious, but simply deleting the!would break the annotatednet5.0+builds (Activator.CreateInstancereturnsobject?,Type.GetPropertyreturnsPropertyInfo?). Replaced the suppressions withEnsure.NotNull(...)(Polyfill), which is correct in both nullable contexts and fails fast withArgumentNullExceptioninstead of a later NRE.Verification
Built
Semantics.Strings(all 8 TFMs) andSemantics.Quantities(all 5 TFMs) in Release with the .NET 10 SDK: noIDE0370and no new nullable (CS86xx) diagnostics. (Local-onlyIDE0055formatting noise from LF line endings on Linux checkouts is pre-existing and does not occur on the Windows CI runners.)https://claude.ai/code/session_01LBGrmJHgP4RpMC9dQ2Pdox
Generated by Claude Code