Skip to content

Commit

Permalink
Switch to C# Collection Expressions. (#6845)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Jan 26, 2024
1 parent 62d14d2 commit 7e0afad
Show file tree
Hide file tree
Showing 948 changed files with 5,342 additions and 9,991 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void WriteResponse(IBufferWriter<byte> snapshot)
"You must first set the initial response before you can apply patches.");
}

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

_json.Remove("hasNext");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class JsonSnapshotValueFormatter : ISnapshotValueFormatter
DateFormatHandling = DateFormatHandling.IsoDateFormat,
Culture = CultureInfo.InvariantCulture,
ContractResolver = ChildFirstContractResolver.Instance,
Converters = new List<JsonConverter> { new StringEnumConverter() }
Converters = new List<JsonConverter> { new StringEnumConverter(), },
};

public bool CanHandle(object? value)
Expand Down
2 changes: 1 addition & 1 deletion src/CookieCrumble/src/CookieCrumble/Snapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Snapshot
});
private static readonly JsonSnapshotValueFormatter _defaultFormatter = new();

private readonly List<SnapshotSegment> _segments = new();
private readonly List<SnapshotSegment> _segments = [];
private readonly string _fileName;
private string _extension;
private string? _postFix;
Expand Down
18 changes: 9 additions & 9 deletions src/CookieCrumble/src/CookieCrumble/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
},
"BananaCakePop.Middleware": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "vksP+PnWLFnsNe3PrD9MufF3zb9y6OcHEmEFjLG87sYaVowzBhos7r+beF0OJleidTeAsinNop9Lt/yMGqKkCA==",
"resolved": "13.0.0",
"contentHash": "6Zj/vfmnCXLjBG7WNdtOgZZ5ZDR3Sy1FQSshZUonIYs3OdzozmsFmqPXMd9XJ0QE9aAildgVGq/lDLpLrMI4Yw==",
"dependencies": {
"Yarp.ReverseProxy": "2.0.1"
}
Expand Down Expand Up @@ -1130,7 +1130,7 @@
"hotchocolate.aspnetcore": {
"type": "Project",
"dependencies": {
"BananaCakePop.Middleware": "[10.0.7, )",
"BananaCakePop.Middleware": "[13.0.0, )",
"HotChocolate": "[0.0.0, )",
"HotChocolate.Subscriptions.InMemory": "[0.0.0, )",
"HotChocolate.Transport.Sockets": "[0.0.0, )",
Expand Down Expand Up @@ -1342,8 +1342,8 @@
},
"BananaCakePop.Middleware": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "vksP+PnWLFnsNe3PrD9MufF3zb9y6OcHEmEFjLG87sYaVowzBhos7r+beF0OJleidTeAsinNop9Lt/yMGqKkCA==",
"resolved": "13.0.0",
"contentHash": "6Zj/vfmnCXLjBG7WNdtOgZZ5ZDR3Sy1FQSshZUonIYs3OdzozmsFmqPXMd9XJ0QE9aAildgVGq/lDLpLrMI4Yw==",
"dependencies": {
"Yarp.ReverseProxy": "2.0.1"
}
Expand Down Expand Up @@ -2437,7 +2437,7 @@
"hotchocolate.aspnetcore": {
"type": "Project",
"dependencies": {
"BananaCakePop.Middleware": "[10.0.7, )",
"BananaCakePop.Middleware": "[13.0.0, )",
"HotChocolate": "[0.0.0, )",
"HotChocolate.Subscriptions.InMemory": "[0.0.0, )",
"HotChocolate.Transport.Sockets": "[0.0.0, )",
Expand Down Expand Up @@ -2689,8 +2689,8 @@
},
"BananaCakePop.Middleware": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "vksP+PnWLFnsNe3PrD9MufF3zb9y6OcHEmEFjLG87sYaVowzBhos7r+beF0OJleidTeAsinNop9Lt/yMGqKkCA==",
"resolved": "13.0.0",
"contentHash": "6Zj/vfmnCXLjBG7WNdtOgZZ5ZDR3Sy1FQSshZUonIYs3OdzozmsFmqPXMd9XJ0QE9aAildgVGq/lDLpLrMI4Yw==",
"dependencies": {
"Yarp.ReverseProxy": "2.0.1"
}
Expand Down Expand Up @@ -3851,7 +3851,7 @@
"hotchocolate.aspnetcore": {
"type": "Project",
"dependencies": {
"BananaCakePop.Middleware": "[10.0.7, )",
"BananaCakePop.Middleware": "[13.0.0, )",
"HotChocolate": "[0.0.0, )",
"HotChocolate.Subscriptions.InMemory": "[0.0.0, )",
"HotChocolate.Transport.Sockets": "[0.0.0, )",
Expand Down
28 changes: 14 additions & 14 deletions src/CookieCrumble/test/CookieCrumble.Tests/SnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public void SnapshotBuilder()
{
var snapshot = new Snapshot();
snapshot.Add(new MyClass());
snapshot.Add(new MyClass { Foo = "Bar" });
snapshot.Add(new MyClass { Foo = "Baz" });
snapshot.Add(new MyClass { Foo = "Bar", });
snapshot.Add(new MyClass { Foo = "Baz", });
snapshot.Match();
}

Expand All @@ -58,8 +58,8 @@ public async Task SnapshotBuilderAsync()
{
var snapshot = new Snapshot();
snapshot.Add(new MyClass());
snapshot.Add(new MyClass { Foo = "Bar" });
snapshot.Add(new MyClass { Foo = "Baz" });
snapshot.Add(new MyClass { Foo = "Bar", });
snapshot.Add(new MyClass { Foo = "Baz", });
await snapshot.MatchAsync();
}

Expand All @@ -68,8 +68,8 @@ public void SnapshotBuilder_Segment_Name()
{
var snapshot = new Snapshot();
snapshot.Add(new MyClass());
snapshot.Add(new MyClass { Foo = "Bar" }, "Bar:");
snapshot.Add(new MyClass { Foo = "Baz" });
snapshot.Add(new MyClass { Foo = "Bar", }, "Bar:");
snapshot.Add(new MyClass { Foo = "Baz", });
snapshot.Match();
}

Expand All @@ -78,8 +78,8 @@ public void SnapshotBuilder_Segment_Name_All()
{
var snapshot = new Snapshot();
snapshot.Add(new MyClass(), "Segment 1:");
snapshot.Add(new MyClass { Foo = "Bar" }, "Segment 2:");
snapshot.Add(new MyClass { Foo = "Baz" }, "Segment 3:");
snapshot.Add(new MyClass { Foo = "Bar", }, "Segment 2:");
snapshot.Add(new MyClass { Foo = "Baz", }, "Segment 3:");
snapshot.Match();
}

Expand All @@ -88,9 +88,9 @@ public void SnapshotBuilder_Segment_Custom_Serializer_For_Segment()
{
var snapshot = new Snapshot();
snapshot.Add(new MyClass());
snapshot.Add(new MyClass { Foo = "Baz" }, "Bar:", new CustomSerializer());
snapshot.Add(new MyClass { Foo = "Baz" });
snapshot.Add(new MyClass { Foo = "Baz" });
snapshot.Add(new MyClass { Foo = "Baz", }, "Bar:", new CustomSerializer());
snapshot.Add(new MyClass { Foo = "Baz", });
snapshot.Add(new MyClass { Foo = "Baz", });
snapshot.Match();
}

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

var snapshot = new Snapshot();
snapshot.Add(new MyClass { Foo = "123" });
snapshot.Add(new MyClass { Foo = "123", });
snapshot.Match();
}

[Fact]
public void SnapshotBuilder_GraphQL_Segment()
{
var snapshot = new Snapshot();
snapshot.Add(new MyClass { Foo = "def" });
snapshot.Add(new MyClass { Foo = "def", });
snapshot.Add(Utf8GraphQLParser.Parse("{ abc }"));
snapshot.Match();
}
Expand All @@ -121,7 +121,7 @@ public class MyClass
public class CustomSerializer : ISnapshotValueFormatter
{
public bool CanHandle(object? value)
=> value is MyClass { Foo: "123" };
=> value is MyClass { Foo: "123", };

public void Format(IBufferWriter<byte> snapshot, object? value)
{
Expand Down
18 changes: 9 additions & 9 deletions src/CookieCrumble/test/CookieCrumble.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
},
"BananaCakePop.Middleware": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "vksP+PnWLFnsNe3PrD9MufF3zb9y6OcHEmEFjLG87sYaVowzBhos7r+beF0OJleidTeAsinNop9Lt/yMGqKkCA==",
"resolved": "13.0.0",
"contentHash": "6Zj/vfmnCXLjBG7WNdtOgZZ5ZDR3Sy1FQSshZUonIYs3OdzozmsFmqPXMd9XJ0QE9aAildgVGq/lDLpLrMI4Yw==",
"dependencies": {
"Yarp.ReverseProxy": "2.0.1"
}
Expand Down Expand Up @@ -1194,7 +1194,7 @@
"hotchocolate.aspnetcore": {
"type": "Project",
"dependencies": {
"BananaCakePop.Middleware": "[10.0.7, )",
"BananaCakePop.Middleware": "[13.0.0, )",
"HotChocolate": "[0.0.0, )",
"HotChocolate.Subscriptions.InMemory": "[0.0.0, )",
"HotChocolate.Transport.Sockets": "[0.0.0, )",
Expand Down Expand Up @@ -1406,8 +1406,8 @@
},
"BananaCakePop.Middleware": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "vksP+PnWLFnsNe3PrD9MufF3zb9y6OcHEmEFjLG87sYaVowzBhos7r+beF0OJleidTeAsinNop9Lt/yMGqKkCA==",
"resolved": "13.0.0",
"contentHash": "6Zj/vfmnCXLjBG7WNdtOgZZ5ZDR3Sy1FQSshZUonIYs3OdzozmsFmqPXMd9XJ0QE9aAildgVGq/lDLpLrMI4Yw==",
"dependencies": {
"Yarp.ReverseProxy": "2.0.1"
}
Expand Down Expand Up @@ -2566,7 +2566,7 @@
"hotchocolate.aspnetcore": {
"type": "Project",
"dependencies": {
"BananaCakePop.Middleware": "[10.0.7, )",
"BananaCakePop.Middleware": "[13.0.0, )",
"HotChocolate": "[0.0.0, )",
"HotChocolate.Subscriptions.InMemory": "[0.0.0, )",
"HotChocolate.Transport.Sockets": "[0.0.0, )",
Expand Down Expand Up @@ -2818,8 +2818,8 @@
},
"BananaCakePop.Middleware": {
"type": "Transitive",
"resolved": "10.0.7",
"contentHash": "vksP+PnWLFnsNe3PrD9MufF3zb9y6OcHEmEFjLG87sYaVowzBhos7r+beF0OJleidTeAsinNop9Lt/yMGqKkCA==",
"resolved": "13.0.0",
"contentHash": "6Zj/vfmnCXLjBG7WNdtOgZZ5ZDR3Sy1FQSshZUonIYs3OdzozmsFmqPXMd9XJ0QE9aAildgVGq/lDLpLrMI4Yw==",
"dependencies": {
"Yarp.ReverseProxy": "2.0.1"
}
Expand Down Expand Up @@ -4045,7 +4045,7 @@
"hotchocolate.aspnetcore": {
"type": "Project",
"dependencies": {
"BananaCakePop.Middleware": "[10.0.7, )",
"BananaCakePop.Middleware": "[13.0.0, )",
"HotChocolate": "[0.0.0, )",
"HotChocolate.Subscriptions.InMemory": "[0.0.0, )",
"HotChocolate.Transport.Sockets": "[0.0.0, )",
Expand Down
2 changes: 1 addition & 1 deletion src/GreenDonut/src/Core/Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace GreenDonut;

internal class Batch<TKey> where TKey : notnull
{
private readonly List<TKey> _keys = new();
private readonly List<TKey> _keys = [];
private readonly Dictionary<TKey, object> _items = new();

public int Size => _keys.Count;
Expand Down
2 changes: 1 addition & 1 deletion src/GreenDonut/src/Core/CacheDataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected CacheDataLoader(DataLoaderOptions? options = null)
: base(
AutoBatchScheduler.Default,
options is null
? new DataLoaderOptions { MaxBatchSize = 1 }
? new DataLoaderOptions { MaxBatchSize = 1, }
: CreateLocalOptions(options))
{ }

Expand Down
2 changes: 1 addition & 1 deletion src/GreenDonut/src/Core/TaskCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private Entry AddNewEntry(TaskCacheKey key, Task value)
{
lock (_sync)
{
var entry = new Entry { Key = key, Value = value };
var entry = new Entry { Key = key, Value = value, };
AppendEntryUnsafe(entry);
ClearSpaceForNewEntryUnsafe();
return entry;
Expand Down
Loading

0 comments on commit 7e0afad

Please sign in to comment.