Fix CS8632 warnings in Service.Tests#3610
Open
aaronburtle wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Service.Tests project’s nullable configuration to eliminate CS8632 warnings caused by nullable annotation syntax (string?) being used while the project was in <Nullable>disable</Nullable> mode. This aligns the project with the repo’s warning-as-error posture without turning on broad nullable flow-analysis diagnostics across legacy test code.
Changes:
- Switch
src/Service.Tests/Azure.DataApiBuilder.Service.Tests.csprojfrom<Nullable>disable</Nullable>to<Nullable>annotations</Nullable>. - Add an explanatory comment documenting why
annotationswas chosen and referencing issue #3543.
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.
Why make this change?
Closes #3543
What is this change?
Changed one line in
src/Service.Tests/Azure.DataApiBuilder.Service.Tests.csproj:and we include a comment explaining the choice and linking back to issue #3543.
Why this particular approach?
Azure.DataApiBuilder.Service.Tests.csprojdeclared<Nullable>disable</Nullable>, but ~25 files in the project override it with a per-file#nullable enabledirective. The issue arises when files usedstring?syntax without the per-file override, producing CS8632 noise in build logs and a latent risk of hard build breaks ifTreatWarningsAsErrors=Trueever propagated into the project.Options considered
?from every offending file?s were added deliberately by file authors who used#nullable enable). Doesn't actually fix the underlying mismatch, a new file added tomorrow could re-introduce the warning.<Nullable>enable</Nullable>to match the rest of the repo (Directory.Build.propssetsenable)disable. BecauseDirectory.Build.propssetsTreatWarningsAsErrors=True, every one of those becomes a build break. The scope to clean up is enormous and out of scope for this cleanup issue.<Nullable>annotations</Nullable>?syntax in the annotations context everywhere (no more CS8632), without enabling flow-analysis warnings on the unaudited bulk of the test code. The 25 files that already have#nullable enablekeep their stronger setting.Why
annotationsis the right C# language mode hereThe C# nullable-context feature has two independent dimensions: the annotations context (do
?and!mean anything?) and the warnings context (do flow-analysis diagnostics fire?). The four<Nullable>MSBuild values map to combinations of those two:disable?triggers CS8632warnings?triggers CS8632annotations?is legal everywhereenableannotationsis the only mode that fixes the reported problem (CS8632) without creating a much larger one (flow-analysis warnings turned into errors across legacy code).Per-file
#nullable enabledirectives are unchangedThe 25 files that declare
#nullable enable(e.g.AuthorizationResolverUnitTests.cs,DabCacheServiceIntegrationTests.cs, theMcp/andEmbedding*test files, etc.) have been audited for full nullable correctness and keep their stronger setting. Leaving them alone:How was this tested?
Service.Testswith the change:0 Warning(s), 0 Error(s).private static string? __nullableRegressionProbe = null;toRequestParserUnitTests.cs— one of the files called out in the issue, which has no#nullable enabledirective. Rebuilt:?in files without the per-file directive.0 Warning(s), 0 Error(s).