Skip to content

Commit 01daf1e

Browse files
authored
Switch to C# Collection Expressions. (#6845)
1 parent 2f25317 commit 01daf1e

File tree

833 files changed

+4225
-4243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

833 files changed

+4225
-4243
lines changed

src/CookieCrumble/src/CookieCrumble/Formatters/ExecutionResultSnapshotValueFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void WriteResponse(IBufferWriter<byte> snapshot)
105105
"You must first set the initial response before you can apply patches.");
106106
}
107107

108-
using var writer = new Utf8JsonWriter(snapshot, new JsonWriterOptions { Indented = true });
108+
using var writer = new Utf8JsonWriter(snapshot, new JsonWriterOptions { Indented = true, });
109109

110110
_json.Remove("hasNext");
111111

src/CookieCrumble/src/CookieCrumble/Formatters/JsonSnapshotValueFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal sealed class JsonSnapshotValueFormatter : ISnapshotValueFormatter
1717
DateFormatHandling = DateFormatHandling.IsoDateFormat,
1818
Culture = CultureInfo.InvariantCulture,
1919
ContractResolver = ChildFirstContractResolver.Instance,
20-
Converters = new List<JsonConverter> { new StringEnumConverter() },
20+
Converters = new List<JsonConverter> { new StringEnumConverter(), },
2121
};
2222

2323
public bool CanHandle(object? value)

src/CookieCrumble/src/CookieCrumble/Snapshot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class Snapshot
3535
});
3636
private static readonly JsonSnapshotValueFormatter _defaultFormatter = new();
3737

38-
private readonly List<SnapshotSegment> _segments = new();
38+
private readonly List<SnapshotSegment> _segments = [];
3939
private readonly string _fileName;
4040
private string _extension;
4141
private string? _postFix;

src/CookieCrumble/test/CookieCrumble.Tests/SnapshotTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public void SnapshotBuilder()
4848
{
4949
var snapshot = new Snapshot();
5050
snapshot.Add(new MyClass());
51-
snapshot.Add(new MyClass { Foo = "Bar" });
52-
snapshot.Add(new MyClass { Foo = "Baz" });
51+
snapshot.Add(new MyClass { Foo = "Bar", });
52+
snapshot.Add(new MyClass { Foo = "Baz", });
5353
snapshot.Match();
5454
}
5555

@@ -58,8 +58,8 @@ public async Task SnapshotBuilderAsync()
5858
{
5959
var snapshot = new Snapshot();
6060
snapshot.Add(new MyClass());
61-
snapshot.Add(new MyClass { Foo = "Bar" });
62-
snapshot.Add(new MyClass { Foo = "Baz" });
61+
snapshot.Add(new MyClass { Foo = "Bar", });
62+
snapshot.Add(new MyClass { Foo = "Baz", });
6363
await snapshot.MatchAsync();
6464
}
6565

@@ -68,8 +68,8 @@ public void SnapshotBuilder_Segment_Name()
6868
{
6969
var snapshot = new Snapshot();
7070
snapshot.Add(new MyClass());
71-
snapshot.Add(new MyClass { Foo = "Bar" }, "Bar:");
72-
snapshot.Add(new MyClass { Foo = "Baz" });
71+
snapshot.Add(new MyClass { Foo = "Bar", }, "Bar:");
72+
snapshot.Add(new MyClass { Foo = "Baz", });
7373
snapshot.Match();
7474
}
7575

@@ -78,8 +78,8 @@ public void SnapshotBuilder_Segment_Name_All()
7878
{
7979
var snapshot = new Snapshot();
8080
snapshot.Add(new MyClass(), "Segment 1:");
81-
snapshot.Add(new MyClass { Foo = "Bar" }, "Segment 2:");
82-
snapshot.Add(new MyClass { Foo = "Baz" }, "Segment 3:");
81+
snapshot.Add(new MyClass { Foo = "Bar", }, "Segment 2:");
82+
snapshot.Add(new MyClass { Foo = "Baz", }, "Segment 3:");
8383
snapshot.Match();
8484
}
8585

@@ -88,9 +88,9 @@ public void SnapshotBuilder_Segment_Custom_Serializer_For_Segment()
8888
{
8989
var snapshot = new Snapshot();
9090
snapshot.Add(new MyClass());
91-
snapshot.Add(new MyClass { Foo = "Baz" }, "Bar:", new CustomSerializer());
92-
snapshot.Add(new MyClass { Foo = "Baz" });
93-
snapshot.Add(new MyClass { Foo = "Baz" });
91+
snapshot.Add(new MyClass { Foo = "Baz", }, "Bar:", new CustomSerializer());
92+
snapshot.Add(new MyClass { Foo = "Baz", });
93+
snapshot.Add(new MyClass { Foo = "Baz", });
9494
snapshot.Match();
9595
}
9696

@@ -100,15 +100,15 @@ public void SnapshotBuilder_Segment_Custom_Global_Serializer()
100100
Snapshot.RegisterFormatter(new CustomSerializer());
101101

102102
var snapshot = new Snapshot();
103-
snapshot.Add(new MyClass { Foo = "123" });
103+
snapshot.Add(new MyClass { Foo = "123", });
104104
snapshot.Match();
105105
}
106106

107107
[Fact]
108108
public void SnapshotBuilder_GraphQL_Segment()
109109
{
110110
var snapshot = new Snapshot();
111-
snapshot.Add(new MyClass { Foo = "def" });
111+
snapshot.Add(new MyClass { Foo = "def", });
112112
snapshot.Add(Utf8GraphQLParser.Parse("{ abc }"));
113113
snapshot.Match();
114114
}
@@ -121,7 +121,7 @@ public class MyClass
121121
public class CustomSerializer : ISnapshotValueFormatter
122122
{
123123
public bool CanHandle(object? value)
124-
=> value is MyClass { Foo: "123" };
124+
=> value is MyClass { Foo: "123", };
125125

126126
public void Format(IBufferWriter<byte> snapshot, object? value)
127127
{

src/GreenDonut/src/Core/Batch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace GreenDonut;
55

66
internal class Batch<TKey> where TKey : notnull
77
{
8-
private readonly List<TKey> _keys = new();
8+
private readonly List<TKey> _keys = [];
99
private readonly Dictionary<TKey, object> _items = new();
1010

1111
public int Size => _keys.Count;

src/GreenDonut/src/Core/CacheDataLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected CacheDataLoader(DataLoaderOptions? options = null)
1515
: base(
1616
AutoBatchScheduler.Default,
1717
options is null
18-
? new DataLoaderOptions { MaxBatchSize = 1 }
18+
? new DataLoaderOptions { MaxBatchSize = 1, }
1919
: CreateLocalOptions(options))
2020
{ }
2121

src/GreenDonut/src/Core/TaskCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private Entry AddNewEntry(TaskCacheKey key, Task value)
144144
{
145145
lock (_sync)
146146
{
147-
var entry = new Entry { Key = key, Value = value };
147+
var entry = new Entry { Key = key, Value = value, };
148148
AppendEntryUnsafe(entry);
149149
ClearSpaceForNewEntryUnsafe();
150150
return entry;

src/GreenDonut/test/Core.Tests/DataLoaderTests.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ClearAllEntries()
3333
var fetch = CreateFetch<string, string>();
3434
var batchScheduler = new ManualBatchScheduler();
3535
var cache = new TaskCache(10);
36-
var options = new DataLoaderOptions { Cache = cache };
36+
var options = new DataLoaderOptions { Cache = cache, };
3737
var loader = new DataLoader<string, string>(fetch, batchScheduler, options);
3838

3939
loader.Set("Foo", Task.FromResult("Bar"));
@@ -200,7 +200,7 @@ public async Task LoadParamsResult()
200200
.CreateFetch<string, string>("Bar");
201201
var batchScheduler = new ManualBatchScheduler();
202202
var loader = new DataLoader<string, string>(fetch, batchScheduler);
203-
var keys = new[] { "Foo" };
203+
var keys = new[] { "Foo", };
204204

205205
// act
206206
var loadResult = loader.LoadAsync(keys);
@@ -252,7 +252,7 @@ public async Task LoadCollectionResult()
252252
var fetch = CreateFetch<string, string>("Bar");
253253
var batchScheduler = new ManualBatchScheduler();
254254
var loader = new DataLoader<string, string>(fetch, batchScheduler);
255-
var keys = new List<string> { "Foo" };
255+
var keys = new List<string> { "Foo", };
256256

257257
// act
258258
var loadResult = loader.LoadAsync(keys, CancellationToken.None);
@@ -271,7 +271,7 @@ public async Task LoadCollectionResultTwice()
271271
var loader = new DataLoader<string, string>(
272272
fetch,
273273
batchScheduler);
274-
var keys = new List<string> { "Foo" };
274+
var keys = new List<string> { "Foo", };
275275

276276
(await loader.LoadAsync(keys, CancellationToken.None)).MatchSnapshot();
277277

@@ -295,7 +295,7 @@ public async Task LoadCollectionResultNoCache()
295295
{
296296
Caching = false,
297297
});
298-
var keys = new List<string> { "Foo" };
298+
var keys = new List<string> { "Foo", };
299299

300300
// act
301301
var loadResult = loader.LoadAsync(keys, CancellationToken.None);
@@ -337,7 +337,7 @@ ValueTask Fetch(
337337

338338
var batchScheduler = new ManualBatchScheduler();
339339
var loader = new DataLoader<string, string>(Fetch, batchScheduler);
340-
var requestKeys = new[] { "Foo", "Bar", "Baz", "Qux" };
340+
var requestKeys = new[] { "Foo", "Bar", "Baz", "Qux", };
341341

342342
// act
343343
var loadResult = loader.LoadAsync(requestKeys);
@@ -382,7 +382,7 @@ ValueTask Fetch(
382382

383383
var batchScheduler = new ManualBatchScheduler();
384384
var loader = new DataLoader<string, string>(Fetch, batchScheduler);
385-
var requestKeys = new[] { "Foo", "Bar", "Baz", "Qux" };
385+
var requestKeys = new[] { "Foo", "Bar", "Baz", "Qux", };
386386

387387
// act
388388
Task Verify() => loader.LoadAsync(requestKeys);
@@ -406,7 +406,7 @@ public async Task LoadBatchingError()
406406
var expectedException = new Exception("Foo");
407407
var batchScheduler = new ManualBatchScheduler();
408408
var loader = new DataLoader<string, string>(Fetch, batchScheduler);
409-
var requestKeys = new[] { "Foo", "Bar", "Baz", "Qux" };
409+
var requestKeys = new[] { "Foo", "Bar", "Baz", "Qux", };
410410

411411
ValueTask Fetch(
412412
IReadOnlyList<string> keys,
@@ -552,7 +552,7 @@ public void RemoveEntry()
552552
var fetch = CreateFetch<string, string>();
553553
var batchScheduler = new ManualBatchScheduler();
554554
var cache = new TaskCache(10);
555-
var options = new DataLoaderOptions { Cache = cache };
555+
var options = new DataLoaderOptions { Cache = cache, };
556556
var loader = new DataLoader<string, string>(fetch, batchScheduler, options);
557557
var key = "Foo";
558558

@@ -604,7 +604,7 @@ public void SetNewCacheEntry()
604604
var fetch = CreateFetch<string, string>();
605605
var batchScheduler = new ManualBatchScheduler();
606606
var cache = new TaskCache(10);
607-
var options = new DataLoaderOptions { Cache = cache };
607+
var options = new DataLoaderOptions { Cache = cache, };
608608
var loader = new DataLoader<string, string>(fetch, batchScheduler, options);
609609
var key = "Foo";
610610
var value = Task.FromResult("Bar");
@@ -623,7 +623,7 @@ public void SetTwice()
623623
var fetch = CreateFetch<string, string>();
624624
var batchScheduler = new ManualBatchScheduler();
625625
var cache = new TaskCache(10);
626-
var options = new DataLoaderOptions { Cache = cache };
626+
var options = new DataLoaderOptions { Cache = cache, };
627627
var loader = new DataLoader<string, string>(fetch, batchScheduler, options);
628628
var key = "Foo";
629629
var first = Task.FromResult("Bar");
@@ -730,7 +730,7 @@ public async Task IDataLoaderLoadParamsResult()
730730
var fetch = CreateFetch<string, string>("Bar");
731731
var batchScheduler = new ManualBatchScheduler();
732732
IDataLoader loader = new DataLoader<string, string>(fetch, batchScheduler);
733-
var keys = new object[] { "Foo" };
733+
var keys = new object[] { "Foo", };
734734

735735
// act
736736
var loadResult = loader.LoadAsync(keys);
@@ -780,7 +780,7 @@ public async Task IDataLoaderLoadCollectionResult()
780780
var fetch = CreateFetch<string, string>("Bar");
781781
var batchScheduler = new ManualBatchScheduler();
782782
IDataLoader loader = new DataLoader<string, string>(fetch, batchScheduler);
783-
var keys = new List<object> { "Foo" };
783+
var keys = new List<object> { "Foo", };
784784

785785
// act
786786
var loadResult = loader.LoadAsync(keys);
@@ -832,7 +832,7 @@ public void IDataLoaderRemoveEntry()
832832
var fetch = CreateFetch<string, string>();
833833
var batchScheduler = new ManualBatchScheduler();
834834
var cache = new TaskCache(10);
835-
var options = new DataLoaderOptions { Cache = cache };
835+
var options = new DataLoaderOptions { Cache = cache, };
836836
IDataLoader loader = new DataLoader<string, string>(fetch, batchScheduler, options);
837837
object key = "Foo";
838838

@@ -901,7 +901,7 @@ public void IDataLoaderSetNewCacheEntry()
901901
var fetch = CreateFetch<string, string>();
902902
var batchScheduler = new ManualBatchScheduler();
903903
var cache = new TaskCache(10);
904-
var options = new DataLoaderOptions { Cache = cache };
904+
var options = new DataLoaderOptions { Cache = cache, };
905905
IDataLoader loader = new DataLoader<string, string>(fetch, batchScheduler, options);
906906
object key = "Foo";
907907
var value = Task.FromResult<object>("Bar");
@@ -920,7 +920,7 @@ public void IDataLoaderSetTwice()
920920
var fetch = TestHelpers.CreateFetch<string, string>();
921921
var batchScheduler = new ManualBatchScheduler();
922922
var cache = new TaskCache(10);
923-
var options = new DataLoaderOptions { Cache = cache };
923+
var options = new DataLoaderOptions { Cache = cache, };
924924
IDataLoader loader = new DataLoader<string, string>(fetch, batchScheduler, options);
925925
const string key = "Foo";
926926
var first = Task.FromResult((object)"Bar");

src/GreenDonut/test/Core.Tests/ResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public void ExplicitResolve(string value)
243243
public void ExplicitResolveList()
244244
{
245245
// arrange
246-
var value = new[] { "Foo", "Bar", "Baz" };
246+
var value = new[] { "Foo", "Bar", "Baz", };
247247

248248
// act
249249
var result = Result<IReadOnlyCollection<string>>.Resolve(value);

src/GreenDonut/test/Core.Tests/TaskCacheTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public void Size(int cacheSize, int expectedCacheSize)
3737
Assert.Equal(expectedCacheSize, result);
3838
}
3939

40-
[InlineData(new[] { "Foo" }, 1)]
41-
[InlineData(new[] { "Foo", "Bar" }, 2)]
42-
[InlineData(new[] { "Foo", "Bar", "Baz" }, 3)]
40+
[InlineData(new[] { "Foo", }, 1)]
41+
[InlineData(new[] { "Foo", "Bar", }, 2)]
42+
[InlineData(new[] { "Foo", "Bar", "Baz", }, 3)]
4343
[InlineData(new[] { "Foo", "Bar", "Baz", "Qux", "Quux", "Corge",
44-
"Grault", "Graply", "Waldo", "Fred", "Plugh", "xyzzy" }, 10)]
44+
"Grault", "Graply", "Waldo", "Fred", "Plugh", "xyzzy", }, 10)]
4545
[Theory(DisplayName = "Usage: Should return the expected cache usage")]
4646
public void Usage(string[] values, int expectedUsage)
4747
{

0 commit comments

Comments
 (0)