Repository navigation
Reject an accessorless property or unknown operator kind before writing anything [patch] - #140
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
…ng anything [patch] PropertyTemplate.WriteTo wrote the doc comment, attributes, modifiers and "Type Name" before checking that the property had an accessor or an expression body, so the throw left an unfinished declaration in the buffer; inside a class the scope then closed it as "public int Foo}". OperatorTemplate did the same for an out-of-range Kind. Both now validate first, so a caller that catches the exception can keep using the CodeBlocker. The PropertyTemplate.WriteTo remarks, which still described the old "terminated with a semicolon" behaviour, now describe the throw. Fixes #128 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014h6btvAuM1Ew7cCFSpuFWc
|
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 #128
What changed
PropertyTemplate.WriteTonow checks for "no getter, no setter, no expression body" before it callsbase.WriteTo. Before this change, the doc comment, attributes, modifiers andType Namewere already in the buffer when theInvalidOperationExceptionfired. Inside a class, the scope then closed the unfinished line aspublic int Foo}.<remarks>, which still described the old behaviour where a property with no accessors was "terminated with a semicolon". I also added an<exception>entry for the throw.OperatorTemplate.WriteTonow works out its signature, including the unknown-kind throw, beforeAddTemplatewrites anything. The issue pointed out this case as having the same pattern.AccessorTemplatealready throws for an unknown kind before writing, so it is unchanged.Tests
TemplateTests.ARejectedPropertyWritesNothingandTemplateTests.AnOperatorOfUnknownKindWritesNothing. Each one catches the exception and asserts that theCodeBlockeroutput is unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_014h6btvAuM1Ew7cCFSpuFWc
Generated by Claude Code