-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Championed proposal: dotnet/csharplang#7700
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-13.0/params-collections.md
Feature branch: https://github.com/dotnet/roslyn/tree/features/ParamsCollections
- LangVersion (
LanguageVersion_01_Declaration,LanguageVersion_02_CallSite) - Public API changes are approved
- Open ParamCollectionAttribute API proposal for BCL - [API Proposal]: ParamCollectionAttribute runtime#99285
- Add a test against an official definition of
ParamCollectionAttributeonce we can test against an SDK with it. - Cloned all param array specific IDE unit-tests that I could find (Clone some IDE tests for params collections #72228) opened three issues.
- Test new betterness rules when two candidates applicable in expanded form and same arguments used in params collection:
- (assume
Timplicitly convertible toTBase) -
ReadOnlySpan<T>vsSpan<TBase>(ROS is better) -
Span/ReadOnlySpan<T>vsTBase[](Span/ROS is better) -
Span/ReadOnlySpan<T>vsIEnumerable<TBase>(Span/ROS is better) -
T[]vsIEnumerable<T>(Neither is better) -
ICollection<T>vsIEnumerable<TBase>(ICollection<T>is better if covariant conversion exists toIEnumerable<TBase>, otherwise neither is better) -
ICollection<T>vsIEnumerable<T>(ICollection<T>is better)
- (assume
- Test usage of all "collection type kinds"
-
Span<T> -
ReadOnlySpan<T> - Create method
- Collection initializer.
- Require constructor and Add on the type itself (
ImplementsIEnumerableT_04_MissingConstructor,ImplementsIEnumerableT_07_MissingAdd)
- Require constructor and Add on the type itself (
- List interface
-
- Test usage in attribute (invalid) (
Span_InAttribute,CreateMethod_02_InAttribute) - Test accessibility of constructor+Add (require at least as 'params' method) (
ImplementsIEnumerableT_05_InaccessibleConstructor,ImplementsIEnumerableT_08_InaccessibleAdd) - Test extension Add does not satisfy requirement (
ImplementsIEnumerableT_21_AddIsNotAnExtension) - Test when expected members are Obsolete (incl. collection type itself) (incl. suppression thru obsolete context)
- Test accessibility of Create method (require at least as 'params' method)
- Test
dynamic(error when no static resolution and may be applicable in expanded form) (DynamicInvocation_) - Test lambda parameter with
paramsmodifier (attribute not emitted) (WRN_ParamsArrayInLambdaOnly_01) - Test local function parameter with
paramsmodifier (attribute not emitted) (ParamCollectionInLocalFunctionOnly) - Test better params collection type (
BetterConversionFromExpression_) - Test better element type (
BetterNess_01_ElementType) - Test different sets of arguments as
paramsarguments (ambiguous) (BetterOverload_02_NotSameCollectionElements) - Ref safety (
ParameterRefSafetyScope_) -
paramsis inherited by override but override is not implicitlyscoped(ParameterRefSafetyScope_13_Mismatch) - Cannot use
paramscollection in expression tree (ExpressionTree) - Test cycles through expected members, e.g.
CollectionType(params CollectionType t). (Cycle_). - Collection type has required member (error at
paramsdeclaration site) (CollectionWithRequiredMember_) - Type inference (
GenericInference) (e.g.void M<T>(params IEnumerable<T> e)) - Nullable analysis (
NullableAnalysis_) - Disallowed modifier combinations (
ref/in/out) (scopedis permitted for ref structs) -
paramsdifference between overloads (NoOverloadingOnParams_) - Consuming from metadata, including when metadata has attribute combinations not possible in source (
MetadataImport_) - Evaluation order of invocations
- Well-known members for
usingetc. which have params collections - constructor/Add has optional unsafe parameters (overload resolution not affected)
- NoPIA (ParamArrayAttribute is transferred when embedding a related API, ParamCollectionAttribute is not)
- heads up to F# re: interop
- test that VB can consume params collections APIs in normal form
- add to compiler test plan
Manual IDE Test Pass
-
paramsclassification (shows up as blue) -
paramscompletionvoid M(p$$),void M($$ IEnumerable<int> e) - hovering over a parameter declaration
- hitting enter at reasonable points within the construct indent properly
-
paramsmodifier of params collection parameter is carried through when generating an override or interface implementation, similar to params array - analyzer (nice to have) user has
M(new List<int> { ... })but could doM(...) - fixer (nice to have) from
void M(params int[] i)which forwards toM((IEnumerable<int>)i)then change toM(params IEnumerable<int> i)and potentially removevoid M(params int[] i) - analyzer (nice to have) consider changing from
void M(Span<int> s)tovoid M(params Span<int> s)
Reactions are currently unavailable