-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
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 Requestapi-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementation
Milestone
Description
Background and Motivation
C# is adding the with(...) element to a collection expression, like so: List<int> list = [with(capacity: 16), 0]; This information needs to be exposed through the IOperation tree.
Proposed API
namespace Microsoft.CodeAnalysis.Operations
{
public interface ICollectionExpressionOperation : IOperation
{
+ /**
+ <summary>
+ Arguments passed to to <see cref="ConstructMethod"/>, if present. Arguments are in evaluation order. This can
+ be an empty array. Will never be <c>default</c>. If the arguments successfully bound, these will all be
+ <see cref="IArgumentOperation"/>; otherwise, they can be any operation.
+ </summary>
+ <remarks>
+ If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays.
+ Default values are supplied for optional arguments missing in source.
+ </remarks>
+ */
+ ImmutableArray<IOperation> ConstructArguments { get; }
}
+ /**
+ <summary>
+ Represents the elements of a collection expression as they are passed to some construction method
+ specified by a <c>[CollectionBuilder]</c> attribute. This is distinct from <see cref="ICollectionExpressionOperation.Elements"/>
+ which contains the elements as they appear in source. This will appear in <see cref="ICollectionExpressionOperation.ConstructArguments"/>
+ when the construction method is a collection builder method, representing the final <c>ReadOnlySpan</c> passed to that
+ construction method containing the fully evaluated elements of the collection expression.
+ </summary>
+ */
+ public interface ICollectionExpressionElementsPlaceholderOperation : IOperation
+ {
+ }
}- Spans/Arrays. As 'with' is an error you get an empty array.
- normal 'new' types. You get the arguments passed to the constructor on the type being 'new'ed up.
- CollectionBuilder. You get the first first N-1 args passed to the Construct method
- IList/ICollection. Only legal constructors that can be accessed are List() and List(int capacity). So the args would map to the parameters on htat.
- IReadOnlyList/IReadOnlyCollection/IENumerable. The only legal with has no arguments. Anything else is error. So you get an empt list.
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 Requestapi-needs-workAPI needs work before it is approved, it is NOT ready for implementationAPI needs work before it is approved, it is NOT ready for implementation