Remove redundant #nullable disable from 153 files#13157
Conversation
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>
These files are already nullable-clean and don't need the directive.
|
@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>
|
@copilot do |
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>
Done in e5dc39c. MSBuild: Removed Tasks: Removed |
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 looks like the build is failing with |
This file has nullable warnings and cannot have the directive removed. Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
There was a problem hiding this comment.
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 disablefrom 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 |
### 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>
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.
### 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>
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.
Context
Projects have
<Nullable>enable</Nullable>at the project level, but many files retain legacy#nullable disabledirectives. Files that are already nullable-clean don't need the directive.Changes Made
Removed
#nullable disablefrom files verified to build without nullable warnings:Shared folder required full repo builds since files compile into multiple projects.
Files retained the directive when:
Testing
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.