Repository navigation
Migrate all source files to file-scoped namespaces - #17470
Conversation
Enforce via IDE0161 as an error in .editorconfig. Co-authored-by: Copilot <[email protected]> Copilot-Session: 0d271fdd-ba34-4ec9-ae26-a77283e22196
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Review tier: Lite
Findings: 3
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.Build.Manifest/AssetManifestModel.cs — The doc comment has a duplicated word ("not not"), which reads as a typo and makes the API docs… |
|
src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/_DiagnosticMessage.cs — The constructor doc comment references DiagnosticMessage, but this type is _DiagnosticMessage.… |
|
src/Microsoft.DotNet.XUnitExtensions.Shared/Attributes/LinuxOnlyTheoryAttribute.cs — The XML doc summary says this attribute should be run only on Windows, but the type is… |
What changed in this PR
This pull request migrates the Arcade repo’s C# codebase to file-scoped namespaces and adds enforcement so future changes stay consistent. It also updates code-generation inputs so regenerated sources keep the same namespace style.
Changes:
- Converted the C# sources to file-scoped namespaces (
namespace X;) across the repo. - Enforced the style via
.editorconfig(csharp_style_namespace_declarations = file_scoped+IDE0161as error). - Updated shared/codegen inputs (e.g., Helix/Swagger generator templates and shared items) to preserve file-scoped namespaces in generated output.
| File | Description |
|---|---|
| .editorconfig | Enforces file-scoped namespaces (IDE0161 as error) going forward. |
| src/Microsoft.DotNet.XUnitExtensions.Shared/Microsoft.DotNet.XUnitExtensions.Shared.projitems | Adds the DynamicallyAccessedMembersAttribute polyfill to the shared compile items. |
| src/Microsoft.DotNet.XUnitExtensions.Shared/Attributes/LinuxOnlyTheoryAttribute.cs | File-scoped namespace conversion; contains a doc-comment inconsistency flagged in review. |
| src/Microsoft.DotNet.Build.Manifest/AssetManifestModel.cs | File-scoped namespace conversion; contains a doc-comment typo flagged in review. |
| src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/_DiagnosticMessage.cs | File-scoped namespace conversion; contains a doc-comment reference issue flagged in review. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ed-namespaces # Conflicts: # src/Microsoft.DotNet.Arcade.Sdk/src/CalculateAssemblyAndFileVersions.cs # src/Microsoft.DotNet.Arcade.Sdk/src/CompareVersions.cs # src/Microsoft.DotNet.Arcade.Sdk/src/GroupItemsBy.cs # src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateCurrentVersion.cs # src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateGuidFromName.cs # src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMsiVersion.cs # src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetMinimumNETStandard.cs # src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetPackageDestination.cs # src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetPackageVersion.cs # src/Microsoft.DotNet.Build.Tasks.Packaging/src/SplitDependenciesBySupport.cs # src/Microsoft.DotNet.Build.Tasks.VisualStudio/Vsix/GetPkgDefAssemblyDependencyGuid.cs # src/Microsoft.DotNet.Build.Tasks.Workloads/src/Wix/WixToolTaskBase.cs # src/Microsoft.DotNet.Helix/JobMonitor/Interfaces/IAzureDevOpsService.cs # src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs # src/Microsoft.DotNet.Helix/JobMonitor/MonitorState.cs # src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs # src/Microsoft.DotNet.Helix/JobMonitor/StatusReporter.cs # src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs # src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsServiceTests.cs # src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Fakes/FakeAzureDevOpsService.cs # src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Fakes/FakeHelixService.cs # src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/JobMonitorRunnerTests.cs # src/Microsoft.DotNet.Helix/Sdk/AzureDevOpsTask.cs # src/Microsoft.DotNet.Helix/Sdk/CancelHelixJob.cs # src/Microsoft.DotNet.Helix/Sdk/CheckAzurePipelinesTestResults.cs # src/Microsoft.DotNet.Helix/Sdk/CheckHelixJobStatus.cs # src/Microsoft.DotNet.Helix/Sdk/CreateFailedTestsForFailedWorkItems.cs # src/Microsoft.DotNet.Helix/Sdk/CreateMTPWorkItems.cs # src/Microsoft.DotNet.Helix/Sdk/CreateXUnitWorkItems.cs # src/Microsoft.DotNet.Helix/Sdk/GetHelixWorkItems.cs # src/Microsoft.DotNet.Helix/Sdk/StartAzurePipelinesTestRun.cs # src/Microsoft.DotNet.Helix/Sdk/StopAzurePipelinesTestRun.cs # src/Microsoft.DotNet.Helix/Sdk/WaitForHelixJobCompletion.cs # src/Microsoft.DotNet.XliffTasks/Tasks/GatherXlf.cs
|
Discussed offline with a set of people who contribute to Arcade the most that this change is OK. I will manually backport it into 10 and 11 post-merge. |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The change is a large-scale repo-wide refactor (1000+ files plus style enforcement), so it warrants a final human review despite only minor issues being identified here.
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.SignCheckLibrary/Verification/Jar/JarError.cs — HasErrors() uses LINQ Count() on a List<string>, which enumerates and allocates… |
Issues resolved since last review (3)
| Severity | Finding |
|---|---|
src/Microsoft.DotNet.XUnitExtensions.Shared/Attributes/LinuxOnlyTheoryAttribute.cs — The XML doc summary says this attribute should be run only on Windows, but the type is… View resolved comment |
|
src/Microsoft.DotNet.XUnitConsoleRunner/src/common/AssemblyResolution/_DiagnosticMessage.cs — The constructor doc comment references DiagnosticMessage, but this type is _DiagnosticMessage.… View resolved comment |
|
src/Microsoft.DotNet.Build.Manifest/AssetManifestModel.cs — The doc comment has a duplicated word ("not not"), which reads as a typo and makes the API docs… View resolved comment |

Converts all C# sources to file-scoped namespaces and enforces the style going forward.
.csfiles with a Roslyn-based transform; each file was validated by comparing the before/after token streams, and lines inside multi-line string literals were left un-dedented..editorconfig: addedcsharp_style_namespace_declarations = file_scopedanddotnet_diagnostic.IDE0161.severity = errorto the[*.cs]section..hbtemplates so regenerated Helix client code stays file-scoped.ToolsetInfo.cs.pp, which is generated intoobjand analyzed.#if !NETDynamicallyAccessedMembersAttributepolyfill out ofStaticReflectionConstants.csso the remaining namespace can be file-scoped.HelixJobInfo.cs: the trailingfile classnow lives inside the namespace; removed the redundant self-using.Note: the C# style rules from
# New line preferencesdown toIDE0073currently sit under the[*.{wixproj,wxs,wxi,wxl,thm}]section and are therefore inert. That pre-existing issue is not addressed here, which is why the new rule was placed in[*.cs].Validated with
build.cmd -configuration Release -test: 0 warnings, 0 compile errors.