Enforce #nullable enable in source packages - #85067
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Roslyn’s source-package build and packaging settings so that nullable annotations in packaged source files are always in an explicit #nullable context (per-file), preventing downstream consumers from hitting missing-nullable-context diagnostics.
Changes:
- Skip importing
PackageProject.props/targetsforIsSourcePackageprojects undersrc/NuGetso those source-package projects can build under normal SDK compilation behavior. - Add
#nullable enabledirectives to the BuildClient source-packaged files that use nullable annotations. - Set
<Nullable>disable</Nullable>forIsSourcePackageprojects to require per-file#nullabledirectives in the packaged sources.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/NuGet/Directory.Build.targets | Avoids importing PackageProject.targets for IsSourcePackage projects under src/NuGet. |
| src/NuGet/Directory.Build.props | Avoids importing PackageProject.props for IsSourcePackage projects under src/NuGet. |
| src/Compilers/Shared/StandardBuildEnvironment.cs | Adds #nullable enable at file scope so nullable annotations are in an explicit nullable context. |
| src/Compilers/Shared/IBuildEnvironment.cs | Adds #nullable enable at file scope so nullable annotations are in an explicit nullable context. |
| eng/targets/Imports.targets | Sets <Nullable>disable</Nullable> for IsSourcePackage projects to enforce per-file #nullable enabling. |
333fred
reviewed
Aug 27, 2026
333fred
approved these changes
Aug 27, 2026
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.
Fixes build failures in dotnet/dotnet#8731
And ensures they don't happen in the future.
Microsoft Reviewers: Open in CodeFlow