From 1c5c7e2bfa779ba129847cfb694d22dff21cc4f5 Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Mon, 5 Feb 2024 09:30:51 -0800 Subject: [PATCH] Adjust public API based on API review feedback (#71940) Closes #71816. --- .../Portable/Binder/Binder.ValueChecks.cs | 8 +-- .../CSharp/Portable/Binder/Binder_Crefs.cs | 2 +- .../Semantics/Conversions/Conversions.cs | 4 +- .../OverloadResolution/OverloadResolution.cs | 2 +- .../OverloadResolutionResult.cs | 4 +- .../EditAndContinue/CSharpSymbolMatcher.cs | 4 +- .../Lowering/LocalRewriter/LocalRewriter.cs | 4 +- .../LocalRewriter/LocalRewriter_Conversion.cs | 2 +- .../SymbolDisplayVisitor.Members.cs | 2 +- .../Symbols/Attributes/SourceAttributeData.cs | 2 +- .../FunctionPointerParameterSymbol.cs | 4 +- .../Symbols/Metadata/PE/PEParameterSymbol.cs | 4 +- .../Portable/Symbols/ParameterSymbol.cs | 6 +-- .../Symbols/PublicModel/ParameterSymbol.cs | 6 ++- .../RetargetingSymbolTranslator.cs | 8 +-- .../Symbols/SignatureOnlyParameterSymbol.cs | 22 ++++---- .../Symbols/Source/ParameterHelpers.cs | 2 +- .../Source/SourceClonedParameterSymbol.cs | 8 +-- .../Source/SourceComplexParameterSymbol.cs | 4 +- .../Source/SourceMemberContainerSymbol.cs | 16 +++--- .../Source/SourceParameterSymbolBase.cs | 4 +- .../Source/SourceSimpleParameterSymbol.cs | 4 +- .../Symbols/Source/ThisParameterSymbol.cs | 4 +- .../Synthesized/SynthesizedParameterSymbol.cs | 12 ++--- .../Symbols/Wrapped/WrappedParameterSymbol.cs | 8 +-- .../CodeGen/CodeGenOverridingAndHiding.cs | 12 ++--- .../CSharp/Test/Emit/Emit/NoPiaEmbedTypes.cs | 4 +- .../Test/Emit2/Attributes/AttributeTests.cs | 12 ++--- .../AttributeTests_WellKnownAttributes.cs | 4 +- .../Attributes/WellKnownAttributesTestBase.cs | 4 +- .../Emit2/Semantics/ParamsCollectionTests.cs | 12 +++-- .../Test/Semantic/Semantics/LambdaTests.cs | 52 +++++++++---------- .../Symbols/Metadata/MetadataMemberTests.cs | 8 +-- .../Symbols/Metadata/PE/LoadingIndexers.cs | 20 +++---- .../Symbols/Source/CustomModifierCopyTests.cs | 48 ++++++++--------- .../CSharp/Test/Symbol/Symbols/TypeTests.cs | 4 +- .../Core/Portable/PublicAPI.Unshipped.txt | 3 +- .../Core/Portable/Symbols/IParameterSymbol.cs | 9 +++- .../CSharp/FunctionPointerUtilities.cs | 4 +- .../SymbolDisplayVisitor.Members.vb | 2 +- .../Portable/Symbols/ParameterSymbol.vb | 4 +- .../SymbolsTests/ParamsCollectionTests.vb | 47 +++++++++++++++++ .../Symbols/CodeGenerationParameterSymbol.cs | 3 +- 43 files changed, 230 insertions(+), 168 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs index f34362ce82cd8..1275fa01322ef 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs @@ -4794,8 +4794,8 @@ private SignatureOnlyMethodSymbol GetInlineArrayAccessEquivalentSignatureMethod( ImmutableArray.Create(new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(elementAccess.Expression.Type), ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, parameterRefKind )), resultRefKind, @@ -4834,8 +4834,8 @@ private SignatureOnlyMethodSymbol GetInlineArrayConversionEquivalentSignatureMet ImmutableArray.Create(new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(inlineArray.Type), ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, parameterRefKind )), RefKind.None, diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Crefs.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Crefs.cs index 224e0b90898a6..4c0e04302fc1e 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Crefs.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Crefs.cs @@ -942,7 +942,7 @@ private ImmutableArray BindCrefParameters(BaseCrefParameterList Debug.Assert(parameterListSyntax.Parent is object); TypeSymbol type = BindCrefParameterOrReturnType(parameter.Type, (MemberCrefSyntax)parameterListSyntax.Parent, diagnostics); - parameterBuilder.Add(new SignatureOnlyParameterSymbol(TypeWithAnnotations.Create(type), ImmutableArray.Empty, isParamArray: false, isParamCollection: false, refKind: refKind)); + parameterBuilder.Add(new SignatureOnlyParameterSymbol(TypeWithAnnotations.Create(type), ImmutableArray.Empty, isParamsArray: false, isParamsCollection: false, refKind: refKind)); } return parameterBuilder.ToImmutableAndFree(); diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs index a0cd26ff64d66..730f641cb889d 100644 --- a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs @@ -60,7 +60,7 @@ public override Conversion GetMethodGroupDelegateConversion(BoundMethodGroup sou if (methodSymbol.OriginalDefinition is SynthesizedDelegateInvokeMethod invoke) { // If synthesizing a delegate with `params` array, check that `ParamArrayAttribute` is available. - if (invoke.Parameters is [.., { IsParamArray: true }]) + if (invoke.Parameters is [.., { IsParamsArray: true }]) { Binder.AddUseSiteDiagnosticForSynthesizedAttribute( Compilation, @@ -413,7 +413,7 @@ public static void GetDelegateOrFunctionPointerArguments(SyntaxNode syntax, Anal // which will cause some error to be reported. That's sufficient (i.e. no need to specifically report its absence here). parameter = new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Object), customModifiers: parameter.TypeWithAnnotations.CustomModifiers), parameter.RefCustomModifiers, - isParamArray: parameter.IsParamArray, isParamCollection: parameter.IsParamCollection, parameter.RefKind); + isParamsArray: parameter.IsParamsArray, isParamsCollection: parameter.IsParamsCollection, parameter.RefKind); } analyzedArguments.Arguments.Add(new BoundParameter(syntax, parameter) { WasCompilerGenerated = true }); diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs index 5327c521067a1..81b16e78d38d3 100644 --- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs +++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs @@ -1167,7 +1167,7 @@ public static bool IsValidParams(Binder binder, Symbol member) } ParameterSymbol final = member.GetParameters().Last(); - if ((final.IsParamArray && final.Type.IsSZArray()) || (final.IsParamCollection && !final.Type.IsSZArray())) + if ((final.IsParamsArray && final.Type.IsSZArray()) || (final.IsParamsCollection && !final.Type.IsSZArray())) { return TryInferParamsCollectionIterationType(binder, final.OriginalDefinition.Type, out _); } diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs index b8d9fce8e61e6..a5eddaed1fec7 100644 --- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs +++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs @@ -1328,8 +1328,8 @@ private static void ReportBadArgumentError( SignatureOnlyParameterSymbol displayArg = new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(argType), ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, refKind: refArg); SymbolDistinguisher distinguisher = new SymbolDistinguisher(binder.Compilation, displayArg, unwrapIfParamsCollection(badArg, parameter, isLastParameter)); diff --git a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs index b44c688e9e011..b704ada726b26 100644 --- a/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs +++ b/src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpSymbolMatcher.cs @@ -516,8 +516,8 @@ otherType.DelegateInvokeMethod is { } otherInvokeMethod && invokeMethod.Parameters.SequenceEqual(otherInvokeMethod.Parameters, (x, y) => isCorrespondingType(x.TypeWithAnnotations, y.TypeWithAnnotations) && x.ExplicitDefaultConstantValue == y.ExplicitDefaultConstantValue && - x.IsParamArray == y.IsParamArray && - x.IsParamCollection == y.IsParamCollection) && + x.IsParamsArray == y.IsParamsArray && + x.IsParamsCollection == y.IsParamsCollection) && isCorrespondingType(invokeMethod.ReturnTypeWithAnnotations, otherInvokeMethod.ReturnTypeWithAnnotations); } diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs index 72fa6ae9b4f2c..841d1d4873ab0 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs @@ -317,10 +317,10 @@ public override BoundNode VisitLambda(BoundLambda node) if (delegateType?.IsAnonymousType == true && delegateType.ContainingModule == _compilation.SourceModule && delegateType.DelegateInvokeMethod() is MethodSymbol delegateInvoke && - delegateInvoke.Parameters.Any(static (p) => p.IsParamCollection)) + delegateInvoke.Parameters.Any(static (p) => p.IsParamsCollection)) { Location location; - if (node.Symbol.Parameters.LastOrDefault(static (p) => p.IsParamCollection) is { } parameter) + if (node.Symbol.Parameters.LastOrDefault(static (p) => p.IsParamsCollection) is { } parameter) { location = ParameterHelpers.GetParameterLocation(parameter); } diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs index ed2837a660700..b0f418eec38f4 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs @@ -646,7 +646,7 @@ private void EnsureParamCollectionAttributeExists(SyntaxNode node, TypeSymbol de if (delegateType.IsAnonymousType && delegateType.ContainingModule == _compilation.SourceModule && delegateType.DelegateInvokeMethod() is MethodSymbol delegateInvoke && - delegateInvoke.Parameters.Any(static (p) => p.IsParamCollection)) + delegateInvoke.Parameters.Any(static (p) => p.IsParamsCollection)) { _factory.ModuleBuilderOpt.EnsureParamCollectionAttributeExists(_diagnostics, node.Location); } diff --git a/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs b/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs index 39122b1eda16a..6ca4ca10adcc9 100644 --- a/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs +++ b/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.cs @@ -827,7 +827,7 @@ public override void VisitParameter(IParameterSymbol symbol) AddSpace(); } - if (symbol.IsParams || symbol.IsParamCollection) + if (symbol.IsParams) { AddKeyword(SyntaxKind.ParamsKeyword); AddSpace(); diff --git a/src/Compilers/CSharp/Portable/Symbols/Attributes/SourceAttributeData.cs b/src/Compilers/CSharp/Portable/Symbols/Attributes/SourceAttributeData.cs index 74a9f513cf91a..5b138993c7eec 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Attributes/SourceAttributeData.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Attributes/SourceAttributeData.cs @@ -150,7 +150,7 @@ internal CSharpSyntaxNode GetAttributeArgumentSyntax(int parameterIndex) // -1 signifies optional parameter whose default argument is used, or // an empty params array. Debug.Assert(this.AttributeConstructor.Parameters[parameterIndex].IsOptional || - this.AttributeConstructor.Parameters[parameterIndex].IsParamArray); + this.AttributeConstructor.Parameters[parameterIndex].IsParamsArray); return attributeSyntax.Name; } else diff --git a/src/Compilers/CSharp/Portable/Symbols/FunctionPointers/FunctionPointerParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/FunctionPointers/FunctionPointerParameterSymbol.cs index 5d53de6a4b7cf..2f1e0ed39b953 100644 --- a/src/Compilers/CSharp/Portable/Symbols/FunctionPointers/FunctionPointerParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/FunctionPointers/FunctionPointerParameterSymbol.cs @@ -70,8 +70,8 @@ internal int MethodHashCode() public override ImmutableArray Locations => ImmutableArray.Empty; public override ImmutableArray DeclaringSyntaxReferences => ImmutableArray.Empty; public override bool IsDiscard => false; - public override bool IsParamArray => false; - public override bool IsParamCollection => false; + public override bool IsParamsArray => false; + public override bool IsParamsCollection => false; public override bool IsImplicitlyDeclared => true; internal override MarshalPseudoCustomAttributeData? MarshallingInformation => null; internal override bool IsMetadataOptional => false; diff --git a/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs index 55a313483103d..02540a7efea77 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs @@ -989,7 +989,7 @@ internal override UnmanagedType MarshallingType } } - public override bool IsParamArray + public override bool IsParamsArray { get { @@ -997,7 +997,7 @@ public override bool IsParamArray } } - public override bool IsParamCollection + public override bool IsParamsCollection { get { diff --git a/src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs index e0b6cb3a3ba68..e470e8da5e131 100644 --- a/src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/ParameterSymbol.cs @@ -119,16 +119,16 @@ internal bool IsMarshalAsObject /// Note: it is possible for any parameter to have the [ParamArray] attribute (for instance, in IL), /// even if it is not the last parameter. So check for that. /// - public abstract bool IsParamArray { get; } + public abstract bool IsParamsArray { get; } /// /// Returns true if the parameter was declared as a parameter collection. /// Note: it is possible for any parameter to have the [ParamCollection] attribute (for instance, in IL), /// even if it is not the last parameter. So check for that. /// - public abstract bool IsParamCollection { get; } + public abstract bool IsParamsCollection { get; } - internal bool IsParams => IsParamArray || IsParamCollection; + internal bool IsParams => IsParamsArray || IsParamsCollection; /// /// Returns true if the parameter is semantically optional. diff --git a/src/Compilers/CSharp/Portable/Symbols/PublicModel/ParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/PublicModel/ParameterSymbol.cs index c3c74e1da6acb..a4863a8ed2d92 100644 --- a/src/Compilers/CSharp/Portable/Symbols/PublicModel/ParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/PublicModel/ParameterSymbol.cs @@ -62,9 +62,11 @@ IParameterSymbol IParameterSymbol.OriginalDefinition bool IParameterSymbol.IsDiscard => _underlying.IsDiscard; - bool IParameterSymbol.IsParams => _underlying.IsParamArray; + bool IParameterSymbol.IsParams => _underlying.IsParams; - bool IParameterSymbol.IsParamCollection => _underlying.IsParamCollection; + bool IParameterSymbol.IsParamsArray => _underlying.IsParamsArray; + + bool IParameterSymbol.IsParamsCollection => _underlying.IsParamsCollection; bool IParameterSymbol.IsOptional => _underlying.IsOptional; diff --git a/src/Compilers/CSharp/Portable/Symbols/Retargeting/RetargetingSymbolTranslator.cs b/src/Compilers/CSharp/Portable/Symbols/Retargeting/RetargetingSymbolTranslator.cs index 24306845851c9..f6360b609d070 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Retargeting/RetargetingSymbolTranslator.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Retargeting/RetargetingSymbolTranslator.cs @@ -1003,8 +1003,8 @@ IEqualityComparer retargetedMethodComparer static ParameterSymbol (param, translator) => new SignatureOnlyParameterSymbol( translator.Retarget(param.TypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode), translator.RetargetModifiers(param.RefCustomModifiers, modifiersHaveChanged: out _), - isParamArray: param.IsParamArray, - isParamCollection: param.IsParamCollection, + isParamsArray: param.IsParamsArray, + isParamsCollection: param.IsParamsCollection, param.RefKind), translator); @@ -1077,8 +1077,8 @@ private PropertySymbol FindPropertyInRetargetedType(PropertySymbol property, Nam static ParameterSymbol (param, self) => new SignatureOnlyParameterSymbol( self.Retarget(param.TypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode), self.RetargetModifiers(param.RefCustomModifiers, modifiersHaveChanged: out _), - isParamArray: param.IsParamArray, - isParamCollection: param.IsParamCollection, + isParamsArray: param.IsParamsArray, + isParamsCollection: param.IsParamsCollection, param.RefKind), this); diff --git a/src/Compilers/CSharp/Portable/Symbols/SignatureOnlyParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/SignatureOnlyParameterSymbol.cs index 44587c394b5cb..c574c5bc9f945 100644 --- a/src/Compilers/CSharp/Portable/Symbols/SignatureOnlyParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/SignatureOnlyParameterSymbol.cs @@ -16,15 +16,15 @@ internal sealed class SignatureOnlyParameterSymbol : ParameterSymbol { private readonly TypeWithAnnotations _type; private readonly ImmutableArray _refCustomModifiers; - private readonly bool _isParamArray; - private readonly bool _isParamCollection; + private readonly bool _isParamsArray; + private readonly bool _isParamsCollection; private readonly RefKind _refKind; public SignatureOnlyParameterSymbol( TypeWithAnnotations type, ImmutableArray refCustomModifiers, - bool isParamArray, - bool isParamCollection, + bool isParamsArray, + bool isParamsCollection, RefKind refKind) { Debug.Assert((object)type.Type != null); @@ -32,8 +32,8 @@ public SignatureOnlyParameterSymbol( _type = type; _refCustomModifiers = refCustomModifiers; - _isParamArray = isParamArray; - _isParamCollection = isParamCollection; + _isParamsArray = isParamsArray; + _isParamsCollection = isParamsCollection; _refKind = refKind; } @@ -41,9 +41,9 @@ public SignatureOnlyParameterSymbol( public override ImmutableArray RefCustomModifiers { get { return _refCustomModifiers; } } - public override bool IsParamArray { get { return _isParamArray; } } + public override bool IsParamsArray { get { return _isParamsArray; } } - public override bool IsParamCollection { get { return _isParamCollection; } } + public override bool IsParamsCollection { get { return _isParamsCollection; } } public override RefKind RefKind { get { return _refKind; } } @@ -118,8 +118,8 @@ public override bool Equals(Symbol obj, TypeCompareKind compareKind) TypeSymbol.Equals(_type.Type, other._type.Type, compareKind) && _type.CustomModifiers.Equals(other._type.CustomModifiers) && _refCustomModifiers.SequenceEqual(other._refCustomModifiers) && - _isParamArray == other._isParamArray && - _isParamCollection == other._isParamCollection && + _isParamsArray == other._isParamsArray && + _isParamsCollection == other._isParamsCollection && _refKind == other._refKind; } @@ -130,7 +130,7 @@ public override int GetHashCode() Hash.Combine( Hash.CombineValues(_type.CustomModifiers), Hash.Combine( - (_isParamArray || _isParamCollection).GetHashCode(), + (_isParamsArray || _isParamsCollection).GetHashCode(), ((int)_refKind).GetHashCode()))); } } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs b/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs index 26057fc7fcb26..f756990c0da9b 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs @@ -266,7 +266,7 @@ private static void EnsureRefKindAttributesExist(CSharpCompilation compilation, internal static void EnsureParamCollectionAttributeExistsAndModifyCompilation(CSharpCompilation compilation, ImmutableArray parameters, BindingDiagnosticBag diagnostics) { - if (parameters.LastOrDefault(static (p) => p.IsParamCollection) is { } parameter) + if (parameters.LastOrDefault(static (p) => p.IsParamsCollection) is { } parameter) { compilation.EnsureParamCollectionAttributeExistsAndModifyCompilation(diagnostics, GetParameterLocation(parameter)); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs index 461afc5e50b58..3c86d84884589 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceClonedParameterSymbol.cs @@ -44,14 +44,14 @@ public override ImmutableArray DeclaringSyntaxReferences } } - public override bool IsParamArray + public override bool IsParamsArray { - get { return !_suppressOptional && _originalParam.IsParamArray; } + get { return !_suppressOptional && _originalParam.IsParamsArray; } } - public override bool IsParamCollection + public override bool IsParamsCollection { - get { return !_suppressOptional && _originalParam.IsParamCollection; } + get { return !_suppressOptional && _originalParam.IsParamsCollection; } } internal override bool IsMetadataOptional diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs index 4d5b7bb32c715..5ae72bdfd3b27 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs @@ -1499,9 +1499,9 @@ internal sealed override bool IsMetadataOut internal sealed override MarshalPseudoCustomAttributeData MarshallingInformation => GetDecodedWellKnownAttributeData()?.MarshallingInformation; - public sealed override bool IsParamArray => (_parameterSyntaxKind & ParameterSyntaxKind.ParamsParameter) != 0 && this.Type.IsSZArray(); + public sealed override bool IsParamsArray => (_parameterSyntaxKind & ParameterSyntaxKind.ParamsParameter) != 0 && this.Type.IsSZArray(); - public sealed override bool IsParamCollection => (_parameterSyntaxKind & ParameterSyntaxKind.ParamsParameter) != 0 && !this.Type.IsSZArray(); + public sealed override bool IsParamsCollection => (_parameterSyntaxKind & ParameterSyntaxKind.ParamsParameter) != 0 && !this.Type.IsSZArray(); internal override bool IsExtensionMethodThis => (_parameterSyntaxKind & ParameterSyntaxKind.ExtensionThisParameter) != 0; diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs index 854e410536379..51db470bd160b 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs @@ -4142,8 +4142,8 @@ void addDeconstruct(SynthesizedPrimaryConstructor ctor, ImmutableArray p ImmutableArray.Empty, ctor.Parameters.SelectAsArray(param => new SignatureOnlyParameterSymbol(param.TypeWithAnnotations, ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, RefKind.Out )), RefKind.None, @@ -4190,8 +4190,8 @@ void addCopyCtor(bool primaryAndCopyCtorAmbiguity) ImmutableArray.Create(new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(this), ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, RefKind.None )), RefKind.None, @@ -4239,8 +4239,8 @@ MethodSymbol addPrintMembersMethod(IEnumerable userDefinedMembers) ImmutableArray.Create(new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Text_StringBuilder)), ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, RefKind.None)), RefKind.None, isInitOnly: false, @@ -4564,8 +4564,8 @@ MethodSymbol addThisEquals(PropertySymbol? equalityContract) ImmutableArray.Create(new SignatureOnlyParameterSymbol( TypeWithAnnotations.Create(this), ImmutableArray.Empty, - isParamArray: false, - isParamCollection: false, + isParamsArray: false, + isParamsCollection: false, RefKind.None )), RefKind.None, diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbolBase.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbolBase.cs index 1ddce20df058b..a8a1d2f81f362 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbolBase.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbolBase.cs @@ -72,11 +72,11 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r var compilation = this.DeclaringCompilation; - if (this.IsParamArray) + if (this.IsParamsArray) { AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_ParamArrayAttribute__ctor)); } - else if (this.IsParamCollection) + else if (this.IsParamsCollection) { AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeParamCollectionAttribute(this)); } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceSimpleParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceSimpleParameterSymbol.cs index daa81f8f52e42..15ce41d52f059 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceSimpleParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceSimpleParameterSymbol.cs @@ -57,12 +57,12 @@ internal override bool IsMetadataOptional get { return false; } } - public override bool IsParamArray + public override bool IsParamsArray { get { return false; } } - public override bool IsParamCollection + public override bool IsParamsCollection { get { return false; } } diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs index cbfa8d5263e0c..373f6bcaf5436 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/ThisParameterSymbol.cs @@ -80,12 +80,12 @@ internal override bool IsMetadataOptional get { return false; } } - public override bool IsParamArray + public override bool IsParamsArray { get { return false; } } - public override bool IsParamCollection + public override bool IsParamsCollection { get { return false; } } diff --git a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs index f702497e71e61..87045c0165364 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedParameterSymbol.cs @@ -60,12 +60,12 @@ public override int Ordinal get { return _ordinal; } } - public override bool IsParamArray + public override bool IsParamsArray { get { return false; } } - public override bool IsParamCollection + public override bool IsParamsCollection { get { return false; } } @@ -196,11 +196,11 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Diagnostics_CodeAnalysis_UnscopedRefAttribute__ctor)); } - if (this.IsParamArray && this.ContainingSymbol is SynthesizedDelegateInvokeMethod) + if (this.IsParamsArray && this.ContainingSymbol is SynthesizedDelegateInvokeMethod) { AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_ParamArrayAttribute__ctor)); } - else if (this.IsParamCollection && this.ContainingSymbol is SynthesizedDelegateInvokeMethod) + else if (this.IsParamsCollection && this.ContainingSymbol is SynthesizedDelegateInvokeMethod) { AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeParamCollectionAttribute(this)); } @@ -380,9 +380,9 @@ public override ImmutableArray GetAttributes() internal override MarshalPseudoCustomAttributeData? MarshallingInformation => _baseParameterForAttributes?.MarshallingInformation; - public override bool IsParamArray => _isParams && Type.IsSZArray(); + public override bool IsParamsArray => _isParams && Type.IsSZArray(); - public override bool IsParamCollection => _isParams && !Type.IsSZArray(); + public override bool IsParamsCollection => _isParams && !Type.IsSZArray(); internal override bool HasUnscopedRefAttribute => _hasUnscopedRefAttribute; diff --git a/src/Compilers/CSharp/Portable/Symbols/Wrapped/WrappedParameterSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Wrapped/WrappedParameterSymbol.cs index 84c40f5334f63..c15838b1daea2 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Wrapped/WrappedParameterSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Wrapped/WrappedParameterSymbol.cs @@ -86,14 +86,14 @@ public override int Ordinal get { return _underlyingParameter.Ordinal; } } - public override bool IsParamArray + public override bool IsParamsArray { - get { return _underlyingParameter.IsParamArray; } + get { return _underlyingParameter.IsParamsArray; } } - public override bool IsParamCollection + public override bool IsParamsCollection { - get { return _underlyingParameter.IsParamCollection; } + get { return _underlyingParameter.IsParamsCollection; } } internal override bool IsMetadataOptional diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs index 1cb3f427370c6..5b7dedd7554d8 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenOverridingAndHiding.cs @@ -4109,16 +4109,16 @@ static void Main() Assert.Equal(1, fooA.ParameterCount); var parameterA = fooA.Parameters[0]; Assert.True(parameterA.IsParams, "Parameter is not ParameterArray"); - Assert.True(parameterA.IsParamArray, "Parameter is not ParameterArray"); - Assert.False(parameterA.IsParamCollection); + Assert.True(parameterA.IsParamsArray, "Parameter is not ParameterArray"); + Assert.False(parameterA.IsParamsCollection); Assert.False(parameterA.HasExplicitDefaultValue, "ParameterArray param has default value"); Assert.False(parameterA.IsOptional, "ParameterArray param cannot be optional"); Assert.Equal(1, fooB.ParameterCount); var parameterB = fooB.Parameters[0]; Assert.True(parameterB.IsParams, "Parameter is not ParameterArray"); - Assert.True(parameterB.IsParamArray, "Parameter is not ParameterArray"); - Assert.False(parameterB.IsParamCollection); + Assert.True(parameterB.IsParamsArray, "Parameter is not ParameterArray"); + Assert.False(parameterB.IsParamsCollection); Assert.False(parameterB.HasExplicitDefaultValue, "ParameterArray param has default value"); Assert.Equal(ConstantValue.Null, parameterB.ExplicitDefaultConstantValue); Assert.False(parameterB.IsOptional, "ParameterArray param cannot be optional"); @@ -4135,8 +4135,8 @@ static void Main() private static void VerifyParamArrayAttribute(ParameterSymbol parameter, bool expected = true) { Assert.Equal(expected, parameter.IsParams); - Assert.Equal(expected, parameter.IsParamArray); - Assert.False(parameter.IsParamCollection); + Assert.Equal(expected, parameter.IsParamsArray); + Assert.False(parameter.IsParamsCollection); var peParameter = (PEParameterSymbol)parameter; var allAttributes = ((PEModuleSymbol)parameter.ContainingModule).GetCustomAttributesForToken(peParameter.Handle); diff --git a/src/Compilers/CSharp/Test/Emit/Emit/NoPiaEmbedTypes.cs b/src/Compilers/CSharp/Test/Emit/Emit/NoPiaEmbedTypes.cs index 8c9a22057d041..26284c7189771 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/NoPiaEmbedTypes.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/NoPiaEmbedTypes.cs @@ -3321,8 +3321,8 @@ public void M1(params int[] x) var m1 = (PEMethodSymbol)itest30.GetMembers("M1").Single(); Assert.True(m1.Parameters[0].IsParams); - Assert.True(m1.Parameters[0].IsParamArray); - Assert.False(m1.Parameters[0].IsParamCollection); + Assert.True(m1.Parameters[0].IsParamsArray); + Assert.False(m1.Parameters[0].IsParamsCollection); Assert.Equal(0, m1.Parameters[0].GetAttributes().Length); }; diff --git a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests.cs b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests.cs index 94b735670e223..c6679bed1893f 100644 --- a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests.cs @@ -3449,8 +3449,8 @@ public interface IGoo attrs.First().VerifyValue(1, TypedConstantKind.Array, new string[] { "" }); Assert.True(attrs.First().AttributeConstructor.Parameters.Last().IsParams); - Assert.True(attrs.First().AttributeConstructor.Parameters.Last().IsParamArray); - Assert.False(attrs.First().AttributeConstructor.Parameters.Last().IsParamCollection); + Assert.True(attrs.First().AttributeConstructor.Parameters.Last().IsParamsArray); + Assert.False(attrs.First().AttributeConstructor.Parameters.Last().IsParamsCollection); }; Action mdAttributeValidator = (ModuleSymbol m) => @@ -3588,8 +3588,8 @@ public interface IGoo attrs.First().VerifyValue(1, TypedConstantKind.Array, new string[] { "whatever" }); Assert.True(attrs.First().AttributeConstructor.Parameters.Last().IsParams); - Assert.True(attrs.First().AttributeConstructor.Parameters.Last().IsParamArray); - Assert.False(attrs.First().AttributeConstructor.Parameters.Last().IsParamCollection); + Assert.True(attrs.First().AttributeConstructor.Parameters.Last().IsParamsArray); + Assert.False(attrs.First().AttributeConstructor.Parameters.Last().IsParamsCollection); }; Action mdAttributeValidator = (ModuleSymbol m) => @@ -8810,8 +8810,8 @@ static void Main(string[] args) Assert.Equal(0, method.GetAttributes().Length); var yParam = method.Parameters[1]; Assert.True(yParam.IsParams); - Assert.True(yParam.IsParamArray); - Assert.False(yParam.IsParamCollection); + Assert.True(yParam.IsParamsArray); + Assert.False(yParam.IsParamsCollection); Assert.Equal(0, yParam.GetAttributes().Length); } diff --git a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_WellKnownAttributes.cs b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_WellKnownAttributes.cs index 5ed7ad92d3a7c..ca2be38186095 100644 --- a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_WellKnownAttributes.cs +++ b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_WellKnownAttributes.cs @@ -9740,8 +9740,8 @@ public void M([Optional, DefaultParameterValue(null)]params int[] args) var param = method.Parameters.Single(); Assert.True(param.IsParams); - Assert.True(param.IsParamArray); - Assert.False(param.IsParamCollection); + Assert.True(param.IsParamsArray); + Assert.False(param.IsParamsCollection); Assert.False(param.IsOptional); Assert.False(param.HasExplicitDefaultValue); }; diff --git a/src/Compilers/CSharp/Test/Emit2/Attributes/WellKnownAttributesTestBase.cs b/src/Compilers/CSharp/Test/Emit2/Attributes/WellKnownAttributesTestBase.cs index 06157a4446cd1..2dd6a1c26b7bc 100644 --- a/src/Compilers/CSharp/Test/Emit2/Attributes/WellKnownAttributesTestBase.cs +++ b/src/Compilers/CSharp/Test/Emit2/Attributes/WellKnownAttributesTestBase.cs @@ -86,8 +86,8 @@ internal NamespaceSymbol Get_System_NamespaceSymbol(ModuleSymbol m) internal static void VerifyParamArrayAttribute(ParameterSymbol parameter, bool expected = true) { Assert.Equal(expected, parameter.IsParams); - Assert.Equal(expected, parameter.IsParamArray); - Assert.False(parameter.IsParamCollection); + Assert.Equal(expected, parameter.IsParamsArray); + Assert.False(parameter.IsParamsCollection); var peParameter = (PEParameterSymbol)parameter; var allAttributes = ((PEModuleSymbol)parameter.ContainingModule).GetCustomAttributesForToken(peParameter.Handle); diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/ParamsCollectionTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/ParamsCollectionTests.cs index 87775d352c837..1991b8c5e9a83 100644 --- a/src/Compilers/CSharp/Test/Emit2/Semantics/ParamsCollectionTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Semantics/ParamsCollectionTests.cs @@ -43,9 +43,14 @@ private static void VerifyParamsAndAttribute(ParameterSymbol parameter, bool isP private static void VerifyParams(ParameterSymbol parameter, bool isParamArray = false, bool isParamCollection = false) { - Assert.Equal(isParamArray, parameter.IsParamArray); - Assert.Equal(isParamCollection, parameter.IsParamCollection); + Assert.Equal(isParamArray, parameter.IsParamsArray); + Assert.Equal(isParamCollection, parameter.IsParamsCollection); Assert.Equal(isParamArray | isParamCollection, parameter.IsParams); + + IParameterSymbol iParameter = parameter.GetPublicSymbol(); + Assert.Equal(isParamArray, iParameter.IsParamsArray); + Assert.Equal(isParamCollection, iParameter.IsParamsCollection); + Assert.Equal(isParamArray | isParamCollection, iParameter.IsParams); } private static void VerifyParams(IParameterSymbol parameter, bool isParamArray = false, bool isParamCollection = false) @@ -2403,7 +2408,8 @@ void verify(MetadataReference comp1Ref) var parameter = (IParameterSymbol)model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType().First()); AssertEx.Equal("System.Collections.Generic.IEnumerable e1", parameter.ToTestDisplayString()); Assert.False(parameter.IsParams); - Assert.False(parameter.IsParamCollection); + Assert.False(parameter.IsParamsArray); + Assert.False(parameter.IsParamsCollection); CompileAndVerify(comp2, symbolValidator: (m) => diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs index 6e898d45c57bc..f00968d5c9b4d 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/LambdaTests.cs @@ -8353,21 +8353,21 @@ public void ParamsArray_Symbol() Assert.Equal(3, lambdas.Length); // lam1 Assert.True(((SourceParameterSymbol)lambdas[0].Parameters.Single()).IsParams); - Assert.True(((SourceParameterSymbol)lambdas[0].Parameters.Single()).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[0].Parameters.Single()).IsParamCollection); + Assert.True(((SourceParameterSymbol)lambdas[0].Parameters.Single()).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[0].Parameters.Single()).IsParamsCollection); // lam2 Assert.False(((SourceParameterSymbol)lambdas[1].Parameters.Single()).IsParams); - Assert.False(((SourceParameterSymbol)lambdas[1].Parameters.Single()).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[1].Parameters.Single()).IsParamCollection); + Assert.False(((SourceParameterSymbol)lambdas[1].Parameters.Single()).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[1].Parameters.Single()).IsParamsCollection); // lam3 Assert.Equal(2, lambdas[2].ParameterCount); Assert.Equal(2, lambdas[2].Parameters.Length); Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[0]).IsParams); - Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[0]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[0]).IsParamCollection); + Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[0]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[0]).IsParamsCollection); Assert.True(((SourceParameterSymbol)lambdas[2].Parameters[1]).IsParams); - Assert.True(((SourceParameterSymbol)lambdas[2].Parameters[1]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[1]).IsParamCollection); + Assert.True(((SourceParameterSymbol)lambdas[2].Parameters[1]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[2].Parameters[1]).IsParamsCollection); } [Fact] @@ -8388,26 +8388,26 @@ public void ParamsArray_Symbol_MultipleParamsArrays() Assert.Equal(3, lambdas[0].ParameterCount); Assert.Equal(3, lambdas[0].Parameters.Length); Assert.True(((SourceParameterSymbol)lambdas[0].Parameters[0]).IsParams); - Assert.True(((SourceParameterSymbol)lambdas[0].Parameters[0]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[0]).IsParamCollection); + Assert.True(((SourceParameterSymbol)lambdas[0].Parameters[0]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[0]).IsParamsCollection); Assert.True(((SourceParameterSymbol)lambdas[0].Parameters[1]).IsParams); - Assert.True(((SourceParameterSymbol)lambdas[0].Parameters[1]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[1]).IsParamCollection); + Assert.True(((SourceParameterSymbol)lambdas[0].Parameters[1]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[1]).IsParamsCollection); Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[2]).IsParams); - Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[2]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[2]).IsParamCollection); + Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[2]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[0].Parameters[2]).IsParamsCollection); // lam2 Assert.Equal(3, lambdas[1].ParameterCount); Assert.Equal(3, lambdas[1].Parameters.Length); Assert.True(((SourceParameterSymbol)lambdas[1].Parameters[0]).IsParams); - Assert.True(((SourceParameterSymbol)lambdas[1].Parameters[0]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[0]).IsParamCollection); + Assert.True(((SourceParameterSymbol)lambdas[1].Parameters[0]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[0]).IsParamsCollection); Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[1]).IsParams); - Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[1]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[1]).IsParamCollection); + Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[1]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[1]).IsParamsCollection); Assert.True(((SourceParameterSymbol)lambdas[1].Parameters[2]).IsParams); - Assert.True(((SourceParameterSymbol)lambdas[1].Parameters[2]).IsParamArray); - Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[2]).IsParamCollection); + Assert.True(((SourceParameterSymbol)lambdas[1].Parameters[2]).IsParamsArray); + Assert.False(((SourceParameterSymbol)lambdas[1].Parameters[2]).IsParamsCollection); } [Fact] @@ -8430,19 +8430,19 @@ public void ParamsArray_Symbol_ExternalReference() { var lam1 = (NamedTypeSymbol)module.GlobalNamespace.GetMember("<>f__AnonymousDelegate0"); Assert.True(lam1.DelegateParameters().Single().IsParams); - Assert.True(lam1.DelegateParameters().Single().IsParamArray); - Assert.False(lam1.DelegateParameters().Single().IsParamCollection); + Assert.True(lam1.DelegateParameters().Single().IsParamsArray); + Assert.False(lam1.DelegateParameters().Single().IsParamsCollection); AssertEx.Equal("TResult <>f__AnonymousDelegate0.Invoke(params T1[] arg)", lam1.DelegateInvokeMethod.ToTestDisplayString()); var lam3 = (NamedTypeSymbol)module.GlobalNamespace.GetMember("<>f__AnonymousDelegate1"); var lam3Parameters = lam3.DelegateParameters(); Assert.Equal(2, lam3Parameters.Length); Assert.False(lam3Parameters[0].IsParams); - Assert.False(lam3Parameters[0].IsParamArray); - Assert.False(lam3Parameters[0].IsParamCollection); + Assert.False(lam3Parameters[0].IsParamsArray); + Assert.False(lam3Parameters[0].IsParamsCollection); Assert.True(lam3Parameters[1].IsParams); - Assert.True(lam3Parameters[1].IsParamArray); - Assert.False(lam3Parameters[1].IsParamCollection); + Assert.True(lam3Parameters[1].IsParamsArray); + Assert.False(lam3Parameters[1].IsParamsCollection); AssertEx.Equal("TResult <>f__AnonymousDelegate1.Invoke(T1 arg1, params T2[] arg2)", lam3.DelegateInvokeMethod.ToTestDisplayString()); }); } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs index 194b12f80b6b8..b767861116756 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/MetadataMemberTests.cs @@ -274,8 +274,8 @@ public void MetadataParameterSymbol01() Assert.False(p2.IsVirtual); Assert.False(p3.IsOverride); Assert.False(p3.IsParams); - Assert.False(p3.IsParamArray); - Assert.False(p3.IsParamCollection); + Assert.False(p3.IsParamsArray); + Assert.False(p3.IsParamsCollection); Assert.False(p4.IsOptional); Assert.False(p4.HasExplicitDefaultValue); // Not Impl - out of scope @@ -371,8 +371,8 @@ public void MetadataParameterSymbolGen02() Assert.False(p1.IsOverride); Assert.False(p1.IsExtern); Assert.False(p1.IsParams); - Assert.False(p1.IsParamArray); - Assert.False(p1.IsParamCollection); + Assert.False(p1.IsParamsArray); + Assert.False(p1.IsParamsCollection); Assert.False(p2.IsOptional); Assert.False(p2.HasExplicitDefaultValue); // Not Impl - Not in M2 scope diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/LoadingIndexers.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/LoadingIndexers.cs index 008880fe8fedc..4b517c3cf4d35 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/LoadingIndexers.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Metadata/PE/LoadingIndexers.cs @@ -918,22 +918,22 @@ .property instance int32 WriteOnly(int32[]) Assert.True(readWrite.IsIndexer); Assert.False(readWrite.MustCallMethodsDirectly); Assert.True(readWrite.Parameters.Last().IsParams); - Assert.True(readWrite.Parameters.Last().IsParamArray); - Assert.False(readWrite.Parameters.Last().IsParamCollection); + Assert.True(readWrite.Parameters.Last().IsParamsArray); + Assert.False(readWrite.Parameters.Last().IsParamsCollection); var readOnly = @class.GetIndexer("ReadOnly"); Assert.True(readOnly.IsIndexer); Assert.False(readOnly.MustCallMethodsDirectly); Assert.True(readOnly.Parameters.Last().IsParams); - Assert.True(readOnly.Parameters.Last().IsParamArray); - Assert.False(readOnly.Parameters.Last().IsParamCollection); + Assert.True(readOnly.Parameters.Last().IsParamsArray); + Assert.False(readOnly.Parameters.Last().IsParamsCollection); var writeOnly = @class.GetIndexer("WriteOnly"); Assert.True(writeOnly.IsIndexer); Assert.False(writeOnly.MustCallMethodsDirectly); Assert.True(writeOnly.Parameters.Last().IsParams); - Assert.True(writeOnly.Parameters.Last().IsParamArray); - Assert.False(writeOnly.Parameters.Last().IsParamCollection); + Assert.True(writeOnly.Parameters.Last().IsParamsArray); + Assert.False(writeOnly.Parameters.Last().IsParamsCollection); }); } @@ -1008,15 +1008,15 @@ .property instance int32 OnlySetter(int32[]) Assert.True(readWrite.IsIndexer); Assert.True(readWrite.MustCallMethodsDirectly); Assert.False(readWrite.Parameters.Last().IsParams); //favour setter - Assert.False(readWrite.Parameters.Last().IsParamArray); //favour setter - Assert.False(readWrite.Parameters.Last().IsParamCollection); //favour setter + Assert.False(readWrite.Parameters.Last().IsParamsArray); //favour setter + Assert.False(readWrite.Parameters.Last().IsParamsCollection); //favour setter var readOnly = @class.GetIndexer("OnlySetter"); Assert.True(readWrite.IsIndexer); Assert.True(readOnly.MustCallMethodsDirectly); Assert.True(readOnly.Parameters.Last().IsParams); //favour setter - Assert.True(readOnly.Parameters.Last().IsParamArray); //favour setter - Assert.False(readOnly.Parameters.Last().IsParamCollection); //favour setter + Assert.True(readOnly.Parameters.Last().IsParamsArray); //favour setter + Assert.False(readOnly.Parameters.Last().IsParamsCollection); //favour setter }); } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs index 8db76f6e6249d..b1068ddbae44f 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/Source/CustomModifierCopyTests.cs @@ -530,23 +530,23 @@ public override void N(int[] a) { } //(re)lost 'params' var derived2N = derived2Class.GetMember("N"); Assert.True(baseM.Parameters.Single().IsParams, "Base.M.IsParams should be true"); - Assert.True(baseM.Parameters.Single().IsParamArray, "Base.M.IsParams should be true"); - Assert.False(baseM.Parameters.Single().IsParamCollection); + Assert.True(baseM.Parameters.Single().IsParamsArray, "Base.M.IsParams should be true"); + Assert.False(baseM.Parameters.Single().IsParamsCollection); Assert.False(baseN.Parameters.Single().IsParams, "Base.N.IsParams should be false"); - Assert.False(baseN.Parameters.Single().IsParamArray, "Base.N.IsParams should be false"); - Assert.False(baseN.Parameters.Single().IsParamCollection); + Assert.False(baseN.Parameters.Single().IsParamsArray, "Base.N.IsParams should be false"); + Assert.False(baseN.Parameters.Single().IsParamsCollection); Assert.True(derivedM.Parameters.Single().IsParams, "Derived.M.IsParams should be true"); //NB: does not reflect source - Assert.True(derivedM.Parameters.Single().IsParamArray, "Derived.M.IsParams should be true"); //NB: does not reflect source - Assert.False(derivedM.Parameters.Single().IsParamCollection); + Assert.True(derivedM.Parameters.Single().IsParamsArray, "Derived.M.IsParams should be true"); //NB: does not reflect source + Assert.False(derivedM.Parameters.Single().IsParamsCollection); Assert.False(derivedN.Parameters.Single().IsParams, "Derived.N.IsParams should be false"); //NB: does not reflect source - Assert.False(derivedN.Parameters.Single().IsParamArray, "Derived.N.IsParams should be false"); //NB: does not reflect source - Assert.False(derivedN.Parameters.Single().IsParamCollection); + Assert.False(derivedN.Parameters.Single().IsParamsArray, "Derived.N.IsParams should be false"); //NB: does not reflect source + Assert.False(derivedN.Parameters.Single().IsParamsCollection); Assert.True(derived2M.Parameters.Single().IsParams, "Derived2.M.IsParams should be true"); - Assert.True(derived2M.Parameters.Single().IsParamArray, "Derived2.M.IsParams should be true"); - Assert.False(derived2M.Parameters.Single().IsParamCollection); + Assert.True(derived2M.Parameters.Single().IsParamsArray, "Derived2.M.IsParams should be true"); + Assert.False(derived2M.Parameters.Single().IsParamsCollection); Assert.False(derived2N.Parameters.Single().IsParams, "Derived2.N.IsParams should be false"); - Assert.False(derived2N.Parameters.Single().IsParamArray, "Derived2.N.IsParams should be false"); - Assert.False(derived2N.Parameters.Single().IsParamCollection); + Assert.False(derived2N.Parameters.Single().IsParamsArray, "Derived2.N.IsParams should be false"); + Assert.False(derived2N.Parameters.Single().IsParamsCollection); } /// @@ -701,23 +701,23 @@ public override char this[params int[] a] { set { } } //regained 'params' var derived2Indexer2 = (PropertySymbol)derived2Class.GetMembers().Where(IsPropertyWithSingleParameter(SpecialType.System_Int64, isArrayType: true)).Single(); Assert.True(baseIndexer1.Parameters.Single().IsParams, "Base.Indexer1.IsParams should be true"); - Assert.True(baseIndexer1.Parameters.Single().IsParamArray, "Base.Indexer1.IsParams should be true"); - Assert.False(baseIndexer1.Parameters.Single().IsParamCollection); + Assert.True(baseIndexer1.Parameters.Single().IsParamsArray, "Base.Indexer1.IsParams should be true"); + Assert.False(baseIndexer1.Parameters.Single().IsParamsCollection); Assert.False(baseIndexer2.Parameters.Single().IsParams, "Base.Indexer2.IsParams should be false"); - Assert.False(baseIndexer2.Parameters.Single().IsParamArray, "Base.Indexer2.IsParams should be false"); - Assert.False(baseIndexer2.Parameters.Single().IsParamCollection); + Assert.False(baseIndexer2.Parameters.Single().IsParamsArray, "Base.Indexer2.IsParams should be false"); + Assert.False(baseIndexer2.Parameters.Single().IsParamsCollection); Assert.True(derivedIndexer1.Parameters.Single().IsParams, "Derived.Indexer1.IsParams should be true"); //Indexer2B: does not reflect source - Assert.True(derivedIndexer1.Parameters.Single().IsParamArray, "Derived.Indexer1.IsParams should be true"); //Indexer2B: does not reflect source - Assert.False(derivedIndexer1.Parameters.Single().IsParamCollection); + Assert.True(derivedIndexer1.Parameters.Single().IsParamsArray, "Derived.Indexer1.IsParams should be true"); //Indexer2B: does not reflect source + Assert.False(derivedIndexer1.Parameters.Single().IsParamsCollection); Assert.False(derivedIndexer2.Parameters.Single().IsParams, "Derived.Indexer2.IsParams should be false"); //Indexer2B: does not reflect source - Assert.False(derivedIndexer2.Parameters.Single().IsParamArray, "Derived.Indexer2.IsParams should be false"); //Indexer2B: does not reflect source - Assert.False(derivedIndexer2.Parameters.Single().IsParamCollection); + Assert.False(derivedIndexer2.Parameters.Single().IsParamsArray, "Derived.Indexer2.IsParams should be false"); //Indexer2B: does not reflect source + Assert.False(derivedIndexer2.Parameters.Single().IsParamsCollection); Assert.True(derived2Indexer1.Parameters.Single().IsParams, "Derived2.Indexer1.IsParams should be true"); - Assert.True(derived2Indexer1.Parameters.Single().IsParamArray, "Derived2.Indexer1.IsParams should be true"); - Assert.False(derived2Indexer1.Parameters.Single().IsParamCollection); + Assert.True(derived2Indexer1.Parameters.Single().IsParamsArray, "Derived2.Indexer1.IsParams should be true"); + Assert.False(derived2Indexer1.Parameters.Single().IsParamsCollection); Assert.False(derived2Indexer2.Parameters.Single().IsParams, "Derived2.Indexer2.IsParams should be false"); - Assert.False(derived2Indexer2.Parameters.Single().IsParamArray, "Derived2.Indexer2.IsParams should be false"); - Assert.False(derived2Indexer2.Parameters.Single().IsParamCollection); + Assert.False(derived2Indexer2.Parameters.Single().IsParamsArray, "Derived2.Indexer2.IsParams should be false"); + Assert.False(derived2Indexer2.Parameters.Single().IsParamsCollection); } [ConditionalFact(typeof(ClrOnly), typeof(DesktopOnly))] diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs index e6babbe8d510c..5a0a8192fcb81 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/TypeTests.cs @@ -1572,8 +1572,8 @@ public class NullableTest paras = mem.GetParameters(); Assert.True(paras[0].IsOptional); Assert.True(paras[1].IsParams); - Assert.True(paras[1].IsParamArray); - Assert.False(paras[1].IsParamCollection); + Assert.True(paras[1].IsParamsArray); + Assert.False(paras[1].IsParamsCollection); memType = paras[0].Type; Assert.Same(comp.GetSpecialType(SpecialType.System_Double), memType.GetNullableUnderlyingType()); memType = paras[1].Type; diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index 96415ca3edcd2..203f163e6d1d5 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,4 +1,5 @@ -Microsoft.CodeAnalysis.IParameterSymbol.IsParamCollection.get -> bool +Microsoft.CodeAnalysis.IParameterSymbol.IsParamsCollection.get -> bool +Microsoft.CodeAnalysis.IParameterSymbol.IsParamsArray.get -> bool Microsoft.CodeAnalysis.Diagnostics.SuppressionInfo.ProgrammaticSuppressions.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.OperationKind.CollectionExpression = 127 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.Spread = 128 -> Microsoft.CodeAnalysis.OperationKind diff --git a/src/Compilers/Core/Portable/Symbols/IParameterSymbol.cs b/src/Compilers/Core/Portable/Symbols/IParameterSymbol.cs index 539b3a8732df8..46597dae572ca 100644 --- a/src/Compilers/Core/Portable/Symbols/IParameterSymbol.cs +++ b/src/Compilers/Core/Portable/Symbols/IParameterSymbol.cs @@ -28,14 +28,19 @@ public interface IParameterSymbol : ISymbol ScopedKind ScopedKind { get; } /// - /// Returns true if the parameter was declared as a parameter array. + /// Returns true if the parameter was declared as a parameter array or as a parameter collection. /// bool IsParams { get; } + /// + /// Returns true if the parameter was declared as a parameter array. + /// + bool IsParamsArray { get; } + /// /// Returns true if the parameter was declared as a parameter collection. /// - bool IsParamCollection { get; } // PROTOTYPE(ParamsCollections): API changes need to go though review. + bool IsParamsCollection { get; } /// /// Returns true if the parameter is optional. diff --git a/src/Compilers/Test/Utilities/CSharp/FunctionPointerUtilities.cs b/src/Compilers/Test/Utilities/CSharp/FunctionPointerUtilities.cs index bcda6d1631825..50631f1757d1a 100644 --- a/src/Compilers/Test/Utilities/CSharp/FunctionPointerUtilities.cs +++ b/src/Compilers/Test/Utilities/CSharp/FunctionPointerUtilities.cs @@ -111,8 +111,8 @@ static void verifyParameter(ParameterSymbol symbol, MethodSymbol containing) Assert.False(symbol.IsDiscard); Assert.False(symbol.IsParams); - Assert.False(symbol.IsParamArray); - Assert.False(symbol.IsParamCollection); + Assert.False(symbol.IsParamsArray); + Assert.False(symbol.IsParamsCollection); Assert.False(symbol.IsMetadataOptional); Assert.False(symbol.IsIDispatchConstant); Assert.False(symbol.IsIUnknownConstant); diff --git a/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.vb b/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.vb index 5a36184c7f42b..4f872a3a02462 100644 --- a/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.vb +++ b/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Members.vb @@ -531,7 +531,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic AddCustomModifiersIfRequired(symbol.RefCustomModifiers, leadingSpace:=False, trailingSpace:=True) End If - If symbol.IsParams Then + If symbol.IsParamsArray Then AddKeyword(SyntaxKind.ParamArrayKeyword) AddSpace() End If diff --git a/src/Compilers/VisualBasic/Portable/Symbols/ParameterSymbol.vb b/src/Compilers/VisualBasic/Portable/Symbols/ParameterSymbol.vb index 09141ebc466e2..024de02e6c912 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/ParameterSymbol.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/ParameterSymbol.vb @@ -124,9 +124,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols ''' ''' Returns true if this parameter was declared as a ParamArray. ''' - Public MustOverride ReadOnly Property IsParamArray As Boolean Implements IParameterSymbol.IsParams + Public MustOverride ReadOnly Property IsParamArray As Boolean Implements IParameterSymbol.IsParams, IParameterSymbol.IsParamsArray - Private ReadOnly Property IsParamCollection As Boolean Implements IParameterSymbol.IsParamCollection + Private ReadOnly Property IsParamsCollection As Boolean Implements IParameterSymbol.IsParamsCollection Get Return False End Get diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/ParamsCollectionTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/ParamsCollectionTests.vb index 6ab595153fcfa..7aa37dabb2143 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/ParamsCollectionTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/ParamsCollectionTests.vb @@ -96,5 +96,52 @@ End Class AssertEx.Equal("Sub C1.M2(ParamArray a As System.Int32())", comp1.GetMember("C1.M2").ToTestDisplayString()) End Sub + + Public Sub PublicApi_01() + + Dim csSource = +" +public class C1 +{ + public static void M1(params System.Collections.Generic.IEnumerable a) {} + public static void M2(System.Collections.Generic.IEnumerable a) {} + public static void M3(params int[] a) {} +} +" + + Dim csCompilation = CreateCSharpCompilation(csSource, + parseOptions:=CSharp.CSharpParseOptions.Default.WithLanguageVersion(CSharp.LanguageVersion.Preview), + referencedAssemblies:=TargetFrameworkUtil.GetReferences(TargetFramework.Standard)).EmitToImageReference() + + Dim source1 = + + + + + Dim comp1 = CreateCompilation(source1, targetFramework:=TargetFramework.Standard, references:={csCompilation}, options:=TestOptions.DebugDll) + + VerifyParams(comp1.GetMember("C1.M1").GetParameters().Last(), isParamArray:=False) + VerifyParams(comp1.GetMember("C1.M2").GetParameters().Last(), isParamArray:=False) + VerifyParams(comp1.GetMember("C1.M3").GetParameters().Last(), isParamArray:=True) + VerifyParams(comp1.GetMember("C2.M4").GetParameters().Last(), isParamArray:=True) + VerifyParams(comp1.GetMember("C2.M5").GetParameters().Last(), isParamArray:=False) + End Sub + + Private Shared Sub VerifyParams(parameter As ParameterSymbol, isParamArray As Boolean) + Assert.Equal(isParamArray, parameter.IsParamArray) + + Dim iParameter = DirectCast(parameter, IParameterSymbol) + Assert.Equal(isParamArray, iParameter.IsParamsArray) + Assert.False(iParameter.IsParamsCollection) + Assert.Equal(isParamArray, iParameter.IsParams) + End Sub + End Class End Namespace diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/Symbols/CodeGenerationParameterSymbol.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/Symbols/CodeGenerationParameterSymbol.cs index c95286c2cd534..3e9148c16fa4e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/Symbols/CodeGenerationParameterSymbol.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/Symbols/CodeGenerationParameterSymbol.cs @@ -27,7 +27,8 @@ internal class CodeGenerationParameterSymbol( { public RefKind RefKind { get; } = refKind; public bool IsParams { get; } = isParams; - bool IParameterSymbol.IsParamCollection => false; + bool IParameterSymbol.IsParamsArray => IsParams; + bool IParameterSymbol.IsParamsCollection => false; public ITypeSymbol Type { get; } = type; public NullableAnnotation NullableAnnotation => Type.NullableAnnotation; public bool IsOptional { get; } = isOptional;