Repository navigation
fix: the non-generic CompareTo names a nested generic argument's type - #274
Merged
Merged
Conversation
RangeOrder.TypeName stripped the arity at the backtick of Type.Name, which a type nested in a
generic one does not have (List<int>.Enumerator is named "Enumerator"), so comparing a range with
one threw ArgumentOutOfRangeException ("length ('-1')") instead of the ArgumentException naming
both types. It now strips the suffix only when there is one.
NonGenericComparableContractTests adds a List<int>.Enumerator to the foreign arguments and checks
that the message names it; it fails with ArgumentOutOfRangeException without the guard.
Closes #273
Part of #258
Found-By: CA
Defect-Class: ALG
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 #273
Part of #258 (part 1; part 2, the
YearMonthRangeexclusiveinfinity)load, is with the scheduling session)Problem
RangeOrder.TypeNamestrips the generic arity at the backtick inType.Name. A type nested inside a generic one, such asList<int>.Enumerator, is generic but its own name has no backtick. So((IComparable)range).CompareTo(new List<int>().GetEnumerator())threwArgumentOutOfRangeException: length ('-1') must be a non-negative valueinstead of the intendedArgumentExceptionnaming both types. It still derived fromArgumentException, so the contract held, but the message was useless.Change
TypeNamestrips the suffix only when the name has one. The message now readsObject must be of type Int32Range, not Enumerator<Int32>.The PR hygiene check needs a closing keyword and #258 stays open for part 2, so part 1 became its own issue, #273, under the 10.0.0 epic. No changelog line: the non-generic
CompareTois new in this same 10.0.0.Tests
NonGenericComparableContractTestsadds aList<int>.Enumeratorto the foreign arguments of every discovered union. It also checks that the message names the foreign type.Expected exception of exact type ArgumentException but caught ArgumentOutOfRangeException … length ('-1').🤖 Generated with Claude Code