Skip to content

Commit 0ed99e5

Browse files
Fix warnings.
1 parent 48b57d2 commit 0ed99e5

File tree

14 files changed

+29
-25
lines changed

14 files changed

+29
-25
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ dotnet_diagnostic.SA1101.severity = none # Prefix local calls with this
3030

3131
# Ordering rules
3232
dotnet_diagnostic.SA1200.severity = suggestion # Using directives should be placed correctly
33+
dotnet_diagnostic.SA1201.severity = none # SA1201: Elements should appear in the correct order
34+
dotnet_diagnostic.SA1202.severity = none # SA1202: Elements should be ordered by access
3335
dotnet_diagnostic.SA1204.severity = suggestion # Static elements should appear before instance elements
3436

3537
# Maintainability rules
@@ -45,3 +47,8 @@ dotnet_diagnostic.SA1601.severity = suggestion # Partial elements should be docu
4547
dotnet_diagnostic.SA1602.severity = suggestion # Enumeration items should be documented
4648
dotnet_diagnostic.SA1633.severity = none # File should have header
4749

50+
# CS1591: Missing XML comment for publicly visible type or member
51+
dotnet_diagnostic.CS1591.severity = none
52+
53+
# MA0055: Do not use finalizer
54+
dotnet_diagnostic.MA0055.severity = none

Tests/YDotNet.Tests.Unit/Maps/GetTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ public void GetNewKeyReturnsNull()
334334
var map = doc.Map("map");
335335
var transaction = doc.WriteTransaction();
336336

337-
foreach (var value in values)
337+
foreach (var (kez, value) in values)
338338
{
339-
map.Insert(transaction, value.Key, value.Value);
339+
map.Insert(transaction, kez, value);
340340
}
341341

342342
return (map, transaction);

YDotNet.Extensions/InputFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static Input FromJson(JsonElement json)
1919

2020
static Input ConvertObject(JsonElement element)
2121
{
22-
return Input.Object(element.EnumerateObject().ToDictionary(x => x.Name, x => ConvertValue(x.Value)));
22+
return Input.Object(element.EnumerateObject().ToDictionary(x => x.Name, x => ConvertValue(x.Value), StringComparer.Ordinal));
2323
}
2424

2525
static Input ConvertArray(JsonElement element)

YDotNet.Server.Redis/Internal/LoggerTextWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Microsoft.Extensions.Logging;
21
using System.Text;
2+
using Microsoft.Extensions.Logging;
33

44
namespace YDotNet.Server.Redis.Internal;
55

YDotNet.Server.Redis/RedisDocumentStorage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ private async Task InitializeAsync(RedisConnection redisConnection)
4343
return item;
4444
}
4545

46-
public async ValueTask StoreDocAsync(string name, byte[] doc,
47-
CancellationToken ct = default)
46+
public async ValueTask StoreDocAsync(string name, byte[] doc, CancellationToken ct = default)
4847
{
4948
if (database == null)
5049
{

YDotNet.Server.WebSockets/YDotNetSocketMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private async Task HandleAwarenessAsync(ClientState state, AwarenessMessage awar
258258
}
259259
}
260260

261-
private async Task SendPendingUpdatesAsync(WebSocketEncoder encoder, ClientState state, CancellationToken ct)
261+
private static async Task SendPendingUpdatesAsync(WebSocketEncoder encoder, ClientState state, CancellationToken ct)
262262
{
263263
while (state.PendingUpdates.TryDequeue(out var pendingDiff))
264264
{

YDotNet.Server/DefaultDocumentManager.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public async ValueTask<byte[]> GetStateVectorAsync(
5555
}).ConfigureAwait(false);
5656
}
5757

58-
public async ValueTask<byte[]> GetUpdateAsync(DocumentContext context, byte[] stateVector,
59-
CancellationToken ct = default)
58+
public async ValueTask<byte[]> GetUpdateAsync(DocumentContext context, byte[] stateVector, CancellationToken ct = default)
6059
{
6160
var container = cache.GetContext(context.DocumentName);
6261

@@ -69,8 +68,7 @@ public async ValueTask<byte[]> GetUpdateAsync(DocumentContext context, byte[] st
6968
}).ConfigureAwait(false);
7069
}
7170

72-
public async ValueTask<UpdateResult> ApplyUpdateAsync(DocumentContext context, byte[] stateDiff,
73-
CancellationToken ct = default)
71+
public async ValueTask<UpdateResult> ApplyUpdateAsync(DocumentContext context, byte[] stateDiff, CancellationToken ct = default)
7472
{
7573
var container = cache.GetContext(context.DocumentName);
7674

@@ -103,8 +101,7 @@ await callback.OnDocumentChangedAsync(new DocumentChangedEvent
103101
return result;
104102
}
105103

106-
public async ValueTask UpdateDocAsync(DocumentContext context, Action<Doc> action,
107-
CancellationToken ct = default)
104+
public async ValueTask UpdateDocAsync(DocumentContext context, Action<Doc> action, CancellationToken ct = default)
108105
{
109106
var container = cache.GetContext(context.DocumentName);
110107

@@ -129,8 +126,7 @@ await callback.OnDocumentChangedAsync(new DocumentChangedEvent
129126
}
130127
}
131128

132-
public async ValueTask PingAsync(DocumentContext context, ulong clock, string? state = null,
133-
CancellationToken ct = default)
129+
public async ValueTask PingAsync(DocumentContext context, ulong clock, string? state = null, CancellationToken ct = default)
134130
{
135131
if (users.AddOrUpdate(context.DocumentName, context.ClientId, clock, state, out var newState))
136132
{

YDotNet.Server/Events.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#pragma warning disable MA0048 // File name must match type name
44
#pragma warning disable SA1402 // File may only contain a single type
5+
#pragma warning disable SA1649 // File name should match first type name
56

67
namespace YDotNet.Server;
78

YDotNet.Server/Internal/ConnectedUsers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ namespace YDotNet.Server.Internal;
44

55
public sealed class ConnectedUsers
66
{
7-
private readonly ConcurrentDictionary<string, Dictionary<ulong, ConnectedUser>> users = new();
7+
private readonly ConcurrentDictionary<string, Dictionary<ulong, ConnectedUser>> users = new(StringComparer.Ordinal);
88

9-
public Func<DateTime> Clock = () => DateTime.UtcNow;
9+
public Func<DateTime> Clock { get; set; } = () => DateTime.UtcNow;
1010

1111
public IReadOnlyDictionary<ulong, ConnectedUser> GetUsers(string documentName)
1212
{

YDotNet.Server/Internal/DelayedWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public DelayedWriter(TimeSpan delay, TimeSpan delayMax, Func<Task> action)
1919
writeTimer = new Timer(_ => Write(), null, Timeout.Infinite, Timeout.Infinite);
2020
}
2121

22-
public Func<DateTime> Clock = () => DateTime.UtcNow;
22+
public Func<DateTime> Clock { get; set; } = () => DateTime.UtcNow;
2323

2424
public async Task FlushAsync()
2525
{

0 commit comments

Comments
 (0)