Repository navigation
[patch] Accept only one declared SectionType name in a section header - #411
Merged
Merged
Conversation
Section.TryParse read the header with Enum.TryParse, which also takes integers
("[42]" became an undefined SectionType), comma-separated lists ("[Verse, Chorus]"
OR'd into Chorus) and padded names ("[ Verse ]"). None of those are written by
ToString, so the header now has to be the exact, letters-only name of one
declared member. Matching stays case-sensitive.
Fixes #318
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A5MkmzQ4qxxRmHStdQ8oJA
|
This was referenced Oct 9, 2026
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 #318
What changed
Section.TryParseread the[Type]header withEnum.TryParse<SectionType>. That call also accepts input thatSection.ToStringnever writes:[42]gave an undefinedSectionType, and[-1]did the same[Verse, Chorus]OR'd the values together intoChorus[ Verse ]The header now has to be the exact, letters-only name of one declared member, checked with
Enum.IsDefined. Matching stays case-sensitive as before.Arrangement.Parsegoes through the same path, so it picks up the fix too.Tests
TryParseRejectsHeaderThatIsNotOneSectionTypeName: rejects[Verse, Chorus],[42],[-1],[ Verse ]and[verse]. Before the fix, the first four failed (the lowercase case was already rejected).TryParseAcceptsEverySectionTypeName: everySectionTypemember still round-trips throughToString/Parse.Semantics.Testsuite on net10.0: 1486 passed, 8 skipped, 0 failed.Semantics.Musicbuilds for every target framework, netstandard2.0 included.🤖 Generated with Claude Code
https://claude.ai/code/session_01A5MkmzQ4qxxRmHStdQ8oJA
Generated by Claude Code