Decide [ArgumentsSource] element-to-parameter mapping from the declared type - #3265
Merged
Merged
Conversation
…ed type Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
IEnumerable<object[]>->IEnumerable<(int, string)>IEnumerable<object>->IEnumerable<long>Core changes:
mastertwo independent decisions disagreed:SmartParamBuilder.Indexesdecided whether the generated code indexes a row from the source's declared return type, whileCreateForArgumentsdecided what the in-process toolchains pass from the row's runtime shape. Wherever they disagreed the two toolchains took different arguments out of the same row — one shape threwInvalidCastExceptionat run time, another failed silently.objectfor back-compat.ValueTuplecontaining the respective parameter types, each type matching exactly (or convertible to by-ref-like), orobject[]for back-compat.Behavior changes:
masterthe generated code relied on the assignment applying the conversion, where C# applies only an implicit operator, and the in-process emitter looked upop_Implicitalone. Discovery admitted the declaration and the failure landed later as a compiler error orBug: No conversion from X to Y.[Params]/[ParamsSource]values, so explicit operators now work there too.ParamSourceTests's two tests become the single theory over both toolchains its own comment said they should become.value.GetType(), and an operator is declared for exactly one type, so a derived value was refused by the very rule its declaration had passed.mastera null named no type, so it skipped the conversion check and reached a field the generated code cannot declare —CS8345out of process,cannot store as a class fieldin the emitter. It now travels the declaration like any other value:IEnumerable<byte[]?>yielding null feedsReadOnlySpan<byte>the empty span.object. Everywhere else the declared element type was judged already — and a null read from a source that names its type says the value could not be read rather than that it was null, since anIEnumerable<T>whereT : allows ref structcannot box one to be looked at.[Arguments(null)]for anintparameter ran in-process against a silently substituted0and failed out of process withCS0037; for a ref struct parameter it wasCS8345instead. Both now stop at discovery, naming the origin, the parameter and its type.Nullable<T>, so[Arguments(null)]on astringorint?parameter is untouched.stringtoReadOnlySpan<Char>in .Net Framework, like the C# first-class-spans feature.Breaking changes:
IEnumerable<object[]>feeding a single-parameter benchmark is refused (unless the parameter is itselfobject[]or convertible to by-ref-like likeSpan<object>).Other Changes: