Repository navigation
fix: a generated TryParse ends at its return, with no unreachable tail - #106
Merged
Merged
Conversation
Every generated TryParse(string?, IFormatProvider?, out TSelf) over a wrapped type with a TryParse of its own, or over a string, ended in a declaration of __inner and a try/catch (FormatException) after its return. TryParseTemplate returned from a compile-time if, which ends the run-time body, but the two meta.InsertStatement calls after it are compile-time code and still ran. Nothing reached the tail and it changed no behaviour, but it was in every value object that parses, and in the code the READMEs now show. The AspectTesting spike found it reading its expected output (#93). The three branches are an if-else chain now, so the InsertStatements run only in the last one: the strategies without a TryParse of their own (a type converter, a static Parse, a string constructor), whose body is unchanged. WovenReachabilityTests (conventions) reads the probes' woven files and fails on any statement after a return or a throw of the same block, a local function excepted. Before the fix it found 26, one per value object of the probes that parses; after it, none. A fixture pins what counts. Input class: the parse strategies. The probes hold each of them (string, enum, Uri, the primitives and dates, a span-parsable type, NodaTime through its type converter, a static Parse, a string constructor), and the four final-branch bodies are the same as before. The other template that calls InsertStatement, JsonConverterWriteTemplate, has no early return. Closes #100 Defect-Class: GTS Found-By: SF Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes #100
Problem
Every generated
TryParse(string?, IFormatProvider?, out TSelf)over a wrapped type with aTryParseof its own, or over a string, ended in unreachable code after itsreturn: a declaration of__innerand atry/catch (FormatException).TryParseTemplatereturned from a compile-timeif, which ends the run-time body, but its twometa.InsertStatementcalls are compile-time code and still ran. It did nothing at run time. It was in every value object that parses, though, and it showed up in the woven code a reviewer reads and in the excerpts the READMEs now show (#92). The AspectTesting spike found it (#93).Change
ValueObjectParsableAspect.Templates.cs: the three branches ofTryParseTemplateform an if-else chain, so theInsertStatements run only in the last branch. That branch covers the strategies without aTryParseof their own: a type converter, a staticParse, a string constructor. Their bodies are unchanged.WovenReachabilityTests(conventions): reads the probes' woven files and fails on any statement after areturnor athrowof the same block, a local function excepted.Tests
TryParses are read at all.ProbeInstant,ProbeLocalDate,ProbeSku,ProbeIsbn) are the same as before. The only other template callingInsertStatement,JsonConverterWriteTemplate, has no early return.🤖 Generated with Claude Code