Skip to content

Remove redundant #nullable disable from 153 files#13157

Merged
YuliiaKovalova merged 8 commits intomainfrom
copilot/remove-redundant-nullable-directives
Feb 3, 2026
Merged

Remove redundant #nullable disable from 153 files#13157
YuliiaKovalova merged 8 commits intomainfrom
copilot/remove-redundant-nullable-directives

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 30, 2026

Context

Projects have <Nullable>enable</Nullable> at the project level, but many files retain legacy #nullable disable directives. Files that are already nullable-clean don't need the directive.

Changes Made

Removed #nullable disable from files verified to build without nullable warnings:

Project Cleaned Remaining
Utilities 5 21
Build 79 284
MSBuild 2 11
Tasks 41 86
Shared 26 75
Total 153 477

Shared folder required full repo builds since files compile into multiple projects.

Files retained the directive when:

  • Nullable warnings present in any TFM (net472, net10.0)
  • Interface files (changing nullability affects implementors)
  • Exception classes (signatures affect other code)
  • Public API methods called from non-nullable contexts

Testing

  • Each project built individually with 0 warnings
  • Full repo build: 0 warnings, 0 errors
  • Fixed double blank lines left by directive removal

Notes

None


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

These files are already nullable-clean and don't need the directive:
- src/Utilities/ApiContract.cs
- src/Utilities/AssemblyFolders/AssemblyFoldersExInfo.cs
- src/Utilities/AssemblyFolders/AssemblyFoldersFromConfigInfo.cs
- src/Utilities/SDKType.cs
- src/Utilities/TrackedDependencies/CanonicalTrackedFilesHelper.cs

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove redundant #nullable disable directives from codebase Remove redundant #nullable disable from 5 Utilities files Jan 30, 2026
Copilot AI requested a review from rainersigwald January 30, 2026 16:01
These files are already nullable-clean and don't need the directive.
@rainersigwald
Copy link
Copy Markdown
Member

@copilot I pushed a change that does the same for Framework--now do the Build assembly/folder.

These files are already nullable-clean and don't need the directive.
Files are spread across various subsystems including:
- BackEnd/Components (logging, caching, SDK resolution, scheduler)
- Collections (HashHelpers, CopyOnReadEnumerable)
- Construction/Solution
- Definition (metadata, settings, toolsets)
- Evaluation/Conditionals (expression nodes)
- FileSystem, Globbing, Graph, Instance
- Logging (BinaryLogger enums, ConsoleConfiguration)
- ObjectModelRemoting (all link classes)

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot I pushed a change that does the same for Framework--now do the Build assembly/folder.

Done in 77db019. Removed #nullable disable from 79 files in the Build assembly that are nullable-clean. The remaining 284 files have nullable warnings and must keep the directive for now.

Copilot AI changed the title Remove redundant #nullable disable from 5 Utilities files Remove redundant #nullable disable from Utilities and Build files Jan 30, 2026
@rainersigwald
Copy link
Copy Markdown
Member

@copilot do MSBuild and then Tasks.

MSBuild project (3 files):
- DistributedLoggerRecord.cs
- NodeEndpointOutOfProcTaskHost.cs
- ProjectSchemaValidationHandler.cs

Tasks project (41 files):
- AppConfig: AppConfigException.cs, RuntimeSection.cs
- AssemblyDependency: 13 files (enums, exceptions, helpers)
- BootstrapperUtil: 6 files
- DataDriven: DataDrivenToolTask.cs
- FileIO: HashEncoding.cs
- ManifestUtil: 10 files (constants, formatters, utilities)
- ResourceHandling: 6 files
- RoslynCodeTaskFactory: RoslynCodeTaskFactoryCodeType.cs

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot do MSBuild and then Tasks.

Done in e5dc39c.

MSBuild: Removed #nullable disable from 3 files (DistributedLoggerRecord, NodeEndpointOutOfProcTaskHost, ProjectSchemaValidationHandler). 10 of 13 files still need the directive.

Tasks: Removed #nullable disable from 41 files across AppConfig, AssemblyDependency, BootstrapperUtil, DataDriven, FileIO, ManifestUtil, ResourceHandling, and RoslynCodeTaskFactory. 86 of 127 files still need the directive.

Copilot AI changed the title Remove redundant #nullable disable from Utilities and Build files Remove redundant #nullable disable from Utilities, Build, MSBuild, and Tasks files Jan 30, 2026
Files cleaned:
- AssemblyFolders: AssemblyFoldersFromConfig.cs
- FileSystem: 6 files (CachingFileSystemWrapper, FileSystems, ManagedFileSystem, etc.)
- LanguageParser: 4 files (tokenChar, tokenCharReader, CSharptokenCharReader, VisualBasictokenCharReader)
- Other: BufferedReadStream, Constants, ExtensionFoldersRegistryKey, FileDelegates, FileUtilitiesRegex, MetadataConversionUtilities, NodeBuildComplete, NodeEngineShutdownReason, ProcessExtensions, QuotingUtilities, TaskHostTaskCancelled, VisualStudioConstants, XMakeElements, XamlUtilities

75 of 101 files still need the directive (compiled into multiple projects with different nullable contexts).

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copilot AI changed the title Remove redundant #nullable disable from Utilities, Build, MSBuild, and Tasks files Remove redundant #nullable disable from 154 files Jan 30, 2026
@rainersigwald
Copy link
Copy Markdown
Member

@copilot looks like the build is failing with

src\MSBuild\ProjectSchemaValidationHandler.cs(226,92): error CS8600: (NETCORE_ENGINEERING_TELEMETRY=Build) Converting null literal or possible null value to non-nullable type.

This file has nullable warnings and cannot have the directive removed.

Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot looks like the build is failing with

...

Fixed in 0daa673. Restored #nullable disable to ProjectSchemaValidationHandler.cs - this file has a nullable warning at line 226 where FormatResourceStringStripCodeAndKeyword returns a nullable string.

Copilot AI changed the title Remove redundant #nullable disable from 154 files Remove redundant #nullable disable from 153 files Jan 30, 2026
@rainersigwald rainersigwald marked this pull request as ready for review February 2, 2026 15:14
Copilot AI review requested due to automatic review settings February 2, 2026 15:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes redundant #nullable disable directives from 153 files across the MSBuild codebase. These files are already nullable-clean and don't require the directive since their projects have <Nullable>enable</Nullable> at the project level.

Changes:

  • Removed #nullable disable from 153 files (Utilities: 5, Build: 79, MSBuild: 2, Tasks: 41, Shared: 26)
  • Fixed double blank lines left by directive removal to maintain consistent formatting

Reviewed changes

Copilot reviewed 174 out of 174 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Utilities/*.cs (5 files) Removed nullable disable from TrackedDependencies, AssemblyFolders, and SDKType files
src/Tasks/**/*.cs (41 files) Removed nullable disable from ResourceHandling, ManifestUtil, BootstrapperUtil, AssemblyDependency, AppConfig, DataDriven, and FileIO files
src/Shared/**/*.cs (26 files) Removed nullable disable from FileSystem, LanguageParser, and utility files
src/MSBuild/*.cs (2 files) Removed nullable disable from NodeEndpointOutOfProcTaskHost and DistributedLoggerRecord
src/Framework/**/*.cs (26 files) Removed nullable disable from XamlTypes, Sdk, Profiler, and attribute files
src/Build/**/*.cs (53 files) Removed nullable disable from ObjectModelRemoting, Logging, Instance, Graph, Globbing, FileSystem, Evaluation, Definition, Construction, Collections, and BackEnd files

@YuliiaKovalova YuliiaKovalova merged commit 0172c58 into main Feb 3, 2026
15 checks passed
@YuliiaKovalova YuliiaKovalova deleted the copilot/remove-redundant-nullable-directives branch February 3, 2026 09:39
Copilot AI added a commit that referenced this pull request Feb 3, 2026
### Context

Projects have `<Nullable>enable</Nullable>` at the project level, but
many files retain legacy `#nullable disable` directives. Files that are
already nullable-clean don't need the directive.

### Changes Made

Removed `#nullable disable` from files verified to build without
nullable warnings:

| Project | Cleaned | Remaining |
|---------|---------|-----------|
| Utilities | 5 | 21 |
| Build | 79 | 284 |
| MSBuild | 2 | 11 |
| Tasks | 41 | 86 |
| Shared | 26 | 75 |
| **Total** | **153** | **477** |

**Shared folder** required full repo builds since files compile into
multiple projects.

Files retained the directive when:
- Nullable warnings present in any TFM (net472, net10.0)
- Interface files (changing nullability affects implementors)
- Exception classes (signatures affect other code)
- Public API methods called from non-nullable contexts

### Testing

- Each project built individually with 0 warnings
- Full repo build: 0 warnings, 0 errors
- Fixed double blank lines left by directive removal

### Notes

None

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
rainersigwald added a commit that referenced this pull request Feb 4, 2026
The doc comment explicitly mentions returning null and the SDK can do
so, which caused a break in dotnet/dotnet#4579:


src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\WorkloadSdkResolver.cs(35,36):
error CS8764: Nullability of return type doesn't match overridden member
(possibly because of nullability attributes).

Follow up to #13157 / 0172c58.
JanProvaznik pushed a commit to JanProvaznik/msbuild that referenced this pull request Feb 25, 2026
### Context

Projects have `<Nullable>enable</Nullable>` at the project level, but
many files retain legacy `#nullable disable` directives. Files that are
already nullable-clean don't need the directive.

### Changes Made

Removed `#nullable disable` from files verified to build without
nullable warnings:

| Project | Cleaned | Remaining |
|---------|---------|-----------|
| Utilities | 5 | 21 |
| Build | 79 | 284 |
| MSBuild | 2 | 11 |
| Tasks | 41 | 86 |
| Shared | 26 | 75 |
| **Total** | **153** | **477** |

**Shared folder** required full repo builds since files compile into
multiple projects.

Files retained the directive when:
- Nullable warnings present in any TFM (net472, net10.0)
- Interface files (changing nullability affects implementors)
- Exception classes (signatures affect other code)
- Public API methods called from non-nullable contexts

### Testing

- Each project built individually with 0 warnings
- Full repo build: 0 warnings, 0 errors
- Fixed double blank lines left by directive removal

### Notes

None

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Co-authored-by: Rainer Sigwald <raines@microsoft.com>
JanProvaznik pushed a commit to JanProvaznik/msbuild that referenced this pull request Feb 25, 2026
The doc comment explicitly mentions returning null and the SDK can do
so, which caused a break in dotnet/dotnet#4579:


src\sdk\src\Resolvers\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\WorkloadSdkResolver.cs(35,36):
error CS8764: Nullability of return type doesn't match overridden member
(possibly because of nullability attributes).

Follow up to dotnet#13157 / 0172c58.
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

Successfully merging this pull request may close these issues.

4 participants