Fix method class over-indentation under file-scoped namespaces#737
Merged
tannergooding merged 1 commit intoJul 13, 2026
Merged
Conversation
Under file-scoped namespaces the base indentation was only reset to empty for the first output builder (the one emitting the namespace declaration). Every subsequent top-level member -- including the method class, which is always emitted last -- kept the default one-level indent and was written as if nested inside a namespace block. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Under file-scoped namespaces the base indentation was only reset to empty for the first output builder (the one emitting the namespace declaration). Every subsequent top-level member kept the default one-level indent and was written as if it were nested inside a
namespace { ... }block. Because the method class is always emitted after the other top-level members, its body was the most visible case, but any struct/enum emitted after the first was affected too.The fix derives the base indent from
Config.GenerateFileScopedNamespacesup front instead of resetting it only inside the (first-builder-only)emitNamespaceDeclarationbranch inCloseOutputBuilder->ForCSharp.Added the regression test
FileScopedNamespaceTest.MembersAfterFirstAreNotOverIndentedcovering a struct + enum + free function. No existing golden exercised file-scoped namespaces with more than one top-level output builder, so there is no golden churn.Full
ClangSharp.PInvokeGenerator.UnitTestssuite passes (Failed: 0, Passed: 3725).