-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Area-CompilersFeature - Target-Typed New`new (args)` gets the created type inferred from context`new (args)` gets the created type inferred from contextFeature RequestTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Milestone
Description
- Speclet checked in to
csharplang. (https://github.com/dotnet/csharplang/blob/master/proposals/target-typed-new.md) - Re-confirm with LDM (done 3/25/2020)
Compiler (general test plan for reference):
- LangVersion (
TestInLocal_LangVersion8 - arglist (
ArgList, coversnew(__arglist)and variants) - target-typing a nullable type (
TestNullableType01,TestNullableType02) - as default parameter value (
TestInParameterDefaultValue), in params (ArrayTypeInferredFromParams) - in attribute argument (
InAttributeParameter) - struct with a 1-constructor, but no 0-constructor
- in string interpolation (
InStringInterpolation) - in await (
TestInAwait, no target-type) - with explicit cast (
TestBadTargetType_Cast) - is it possible to have a constant value? (
TestInParameterDefaultValue, not a constant) - returning in lambda (with single or multiple returns,
TestBestType_Lambda), in async lambda (TestInAsyncLambda_01) - with unary operators (
+new(), ...), equality (1 == new()), compound (x += new()), ternary (x ? y : new()and vice-versa) - in
using(InUsing01), innameof()(InNameOf), intypeof()(InTypeOf), insizeof()(InSizeOf), inforeach(InForeach), in deconstruction (TestDeconstruction,var (x, y) = new();), inswitch(InSwitch1), in patterns (InIsOperator), inif(ConditionalOnNew), inwhile(ConditionalOnNew), infixed(InFixed), as an expression-statement (TestInStatement,new();), inlock(InLock) - invoking a dynamic method (
InvocationOnDynamic, no target-type) - as initial value for an auto-property (
TestInClassInitializer) - returning in async method (
ReturningFromAsyncMethod) - returning from IEnumerable-returning method
- yielding from iterator method (
YieldReturn) - assign to
var(TestTargetType_Var), to nullable type (TestNullableType1), - semantic model (
TestAssignmentToClass,TestAssignmentToStruct, TODO currently shows a natural type) - type parameter with and without
new()andstructconstraint (TestTypeParameter,TestTypeParameter_ErrorCases) - IOperation
-
new() { 42 }(TestObjectAndCollectionInitializer) - test with collection initializer (
TestObjectAndCollectionInitializer,new() { 1, 2, 3 }) - in object initializer (
new C() { x = new() }), collection initializer (new C() { new D(1), new D(2), new() }) (TestObjectAndCollectionInitializer) - test with enum type (
TestTargetType_Enum), array type, pointer type (TestTargetType_Pointer, error), test in anonymous type (TestTargetType_AnonymousType, error), tuple (TestTargetType_TupleType, okay) - ref local
- ref return (
RefReturnValue1,RefReturnValue2) - in implicitly-typed array (
ImplicitlyTypedArray, no target-type) - use as L-value (
TestAssignment,new() = 1;) - update the compiler test plan
-[ ] test interaction with any C# 8.0 feature that was merged earlier:??=(TestInNullCoalescingAssignment), async-streams, nullability, Ranges (InRange)
IDE:
- formatting
- no space in
new()(SpacingInTargetTypedNew) - auto-formatting when typing
(string a, string b)[] ab = new (string a, string b)[1];vs.C c = new();
- no space in
- verify that completion isn't annoying
- QuickInfo should show the type on
new - UpgradeProject (typically just works)
- colorization
- SignatureHelp should work (it should help tying object creation arguments)
- Is the type of
new()visible by hovering, when debugging? - GoToDefinition on
new()should go to the proper constructor - test existing fixers
UseImplicitTypeandUseExplicitType(for example,List<string> list = new();should never offer to make the declarationvar) - ExplicitType and target-typed new #42554 (ExplicitType and target-typed new)
- FindAllReferences and target-typed new #42555 (FindAllReferences and target-typed new, PR Bring back naive implementation of FAR for target-typed new #43645)
- Symbol completion and target-typed new #42556 (Symbol completion and target-typed new)
- ChangeSignature and target-typed new #42558 (ChangeSignature and target-typed new)
- AddParameter and target-typed new #42559 (AddParameter and target-typed new)
Open LDM questions:
- Confirm behavior for
new[](Championed: Target-typed implicit array creation expressionnew[]csharplang#2701 (comment))
Initial PR: #25196
Proposal: https://github.com/dotnet/csharplang/blob/master/proposals/target-typed-new.md
Championed issue (with LDM history): dotnet/csharplang#100
Relates to #37821 (spec issues with target-typing)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Target-Typed New`new (args)` gets the created type inferred from context`new (args)` gets the created type inferred from contextFeature RequestTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Type
Projects
Status
Done Umbrellas