Migrate all source files to file-scoped namespaces - #17470
Open
ViktorHofer wants to merge 1 commit into
Open
Conversation
Enforce via IDE0161 as an error in .editorconfig. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d271fdd-ba34-4ec9-ae26-a77283e22196
Contributor
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.
Comment on lines
+11
to
+13
| /// <summary> | ||
| /// The asset manifest is not not represented as XML | ||
| /// </summary> |
Comment on lines
+10
to
+13
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="DiagnosticMessage"/> class. | ||
| /// </summary> | ||
| /// <param name="message">The message to send</param> |
Comment on lines
+11
to
+13
| /// <summary> | ||
| /// This test should be run only on Windows. | ||
| /// </summary> |
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.

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.