You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inline arrays. Likely not impactful enough to warrant special fixes here.
The intent here is to also provide different diagnostic IDs for varying classes of these. For example "for arrays", "for spans", etc. We may want to revise this as appropriate as we continue with this.
Relates to test plan #66418 (collection expressions compiler feature)
The text was updated successfully, but these errors were encountered:
CyrusNajmabadi
changed the title
Analyzer/Fixer to convert existing code to collection expressions.
Tracking issue for analyzers/fixers to convert existing code to collection expressions.
Aug 5, 2023
Cases to support:
This will be a large set of work items. So i'm breaking things into pieces to make it easier to review. The pieces are at least:
int[] x = { 1, 2, 3 }
=>int[] x = [1, 2, 3];
. Initial support for a set of analyzers/fixers to update existing code to use collection expressions. #69118..
. e.g.x.Add(1); x.AddRange(y)
=>[1, ..y]
. Update "use collection initializer" to use a collection-expression if the user prefers that form. #69219Array.Empty<int>()
andImmutableXXX<int>.Empty
. Add analyzer/fixer to update expressions likeArray.Empty<T>()
over to using the[]
collection expression. #69279if (x) y.Add(z)
=>.. x ? [z] : []
. Add support for generating the.. x ? [y] : []
pattern in a collection-expression #69280new List<int>{ 1, 2, 3 }
=>[1, 2, 3]
. Add support for converting existing collection-initializers over to collection expressions. #69321..
. Add support for converting existing collection-initializers over to collection expressions. #69321var x = new string[3]; x[0] = ""; ...
Support converting arrays, whose elements are assigned afterwards, to a collection expression. #69415ImmutableArray.Create(1, 2, 3)
=>[1, 2, 3]
. Add analyzer/fixer to suggest changing code likeImmutableArray.Create(1, 2, 3)
to[1, 2, 3]
#69473ImmutableArray.CreateBuilder(); builder.Add ...
Support Add/AddRange/etc. Add analyzer/fixer to suggest changing code likeImmutableArray.CreateBuilder<int>(); ...
to a collection expression. #69500a.Concat(b).ToImmutableArray()
=>[..a, ..b]
. Add analyzer/fixer to suggest changing code fluent collection building to a collection expression #69580Stretch cases:
The intent here is to also provide different diagnostic IDs for varying classes of these. For example "for arrays", "for spans", etc. We may want to revise this as appropriate as we continue with this.
Relates to test plan #66418 (collection expressions compiler feature)
The text was updated successfully, but these errors were encountered: