-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.Feature - ParamsCollectionsFeature Requestapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implemented
Description
Background and Motivation
Related to "Params Collections" feature work.
Proposed API
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Represents a parameter of a method or property.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IParameterSymbol : ISymbol
{
/// <summary>
/// Returns true if the parameter was declared as a parameter array.
/// </summary>
bool IsParams { get; }
+ /// <summary>
+ /// Returns true if the parameter was declared as a parameter collection.
+ /// </summary>
+ bool IsParamCollection { get; }
}
}Alternative Designs
Option 1
We could extend the meaning of IsParams property to return true for non-array param collections instead,
but then VB, for example, will print C# methods like
Public Shared Sub M1(ParamArray a As System.Collections.Generic.IEnumerable(Of Integer))
which is likely to confuse the user. VB is not going to support params collections.
Other consumers can be affected in a similar way.
Option 2
As the top proposal, but with additional new property:
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Represents a parameter of a method or property.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IParameterSymbol : ISymbol
{
/// <summary>
/// Returns true if the parameter was declared as a parameter array.
/// </summary>
bool IsParams { get; }
+ /// <summary>
+ /// Same as IsParams
+ /// </summary>
+ bool IsParamArray { get; }
+ /// <summary>
+ /// Returns true if the parameter was declared as a parameter collection.
+ /// </summary>
+ bool IsParamCollection { get; }
}
}Option 3
Have IsParams return true if if the parameter was declared either as a parameter array,
or a parameter collection. Add new property for parameter aray.
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Represents a parameter of a method or property.
/// </summary>
/// <remarks>
/// This interface is reserved for implementation by its associated APIs. We reserve the right to
/// change it in the future.
/// </remarks>
public interface IParameterSymbol : ISymbol
{
/// <summary>
- /// 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.
/// </summary>
bool IsParams { get; }
+ /// <summary>
+ /// Returns true if the parameter was declared as a parameter array
+ /// </summary>
+ bool IsParamArray { get; }
+ /// <summary>
+ /// Returns true if the parameter was declared as a parameter collection.
+ /// </summary>
+ bool IsParamCollection { get; }
}
}Risks
Metadata
Metadata
Assignees
Labels
Area-CompilersConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.Feature - ParamsCollectionsFeature Requestapi-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implemented