Repository navigation
Skip blank entries in WriteUsings instead of writing using ; [patch] - #191
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
WriteUsings wrote every entry verbatim, so an empty or whitespace entry produced `using ;` (CS1001). A generator that builds optional usings as `condition ? "Ns" : ""` hit this directly, as did SourceFileTemplate.Usings, which goes through the same path. Null, empty and whitespace entries are now skipped, and a list made only of them writes nothing, not even the trailing blank line. Fixes #189 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5wqHMdBMn6Wino1eH
|
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.



Fixes #189
What changed
WriteUsingswrote every entry verbatim, soWriteUsings("System", "", "System.Linq")producedusing ;, which fails with CS1001.SourceFileTemplate.Usingstakes the same path. Null, empty and whitespace entries are now skipped, the same way #166 handles blankPragmaScopewarnings. A list made only of blank entries writes nothing, not even the trailing blank line.Not included
The issue also suggested refusing an entry that contains a line break. I left that out.
AddSourceFilewrites the documentation, comments and namespace before the usings, so throwing insideWriteUsingswould leave partial output, which is whatSourceFileTemplate's up-front validation exists to prevent. Doing it properly means adding a pre-write usings check toAddSourceFile, which can be its own change.Tests
BlankUsingEntriesAreSkipped:"System", "", " ", null, "System.Linq"writes exactly the two real usings plus the blank line.OnlyBlankUsingEntriesWriteNothingIncludingTheBlankLine: covers both overloads.ASourceFileSkipsBlankUsings: covers theSourceFileTemplate.Usingspath.All three fail without the fix and pass with it. The full suite passes (332 tests).
Generated by Claude Code