Skip to content

Commit a7de397

Browse files
Add stylecop everywhere.
1 parent 749baae commit a7de397

Some content is hidden

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

63 files changed

+316
-263
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dotnet_diagnostic.SA1413.severity = suggestion # Use trailing comma in multi-lin
4040
dotnet_diagnostic.SA1500.severity = suggestion # Braces for multi-line statements should not share line
4141

4242
# Documentation rules
43-
dotnet_diagnostic.SA1600.severity = suggestion # Elements should be documented
43+
dotnet_diagnostic.SA1600.severity = none # Elements should be documented
4444
dotnet_diagnostic.SA1601.severity = suggestion # Partial elements should be documented
4545
dotnet_diagnostic.SA1602.severity = suggestion # Enumeration items should be documented
4646
dotnet_diagnostic.SA1633.severity = none # File should have header

Demo/Callback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ await @event.Source.UpdateDocAsync(notificationCtx, (doc) =>
8484
}
8585
});
8686
});
87-
87+
8888

8989
return default;
9090
}

Demo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public static void Main(string[] args)
1212

1313
builder.Services.AddControllers();
1414
builder.Services.AddRazorPages();
15-
16-
var yDotNet =
15+
16+
var yDotNet =
1717
builder.Services.AddYDotNet()
1818
.AddCallback<Callback>()
1919
.AddWebSockets();

Tests/YDotNet.Tests.Unit/Protocol/WriteAndRead.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public async Task EncodeAndDecodeBytes(int length)
7474
public async Task DecodeJsSample()
7575
{
7676
// Arrange
77-
var buffer = new byte[]
77+
var buffer = new byte[]
7878
{
7979
1,
8080
252,

YDotNet.Extensions/YDotNet.Extensions.csproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net7.0</TargetFramework>
@@ -10,4 +10,19 @@
1010
<ProjectReference Include="..\YDotNet\YDotNet.csproj" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
19+
<PrivateAssets>all</PrivateAssets>
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
</PackageReference>
22+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
23+
<PrivateAssets>all</PrivateAssets>
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
</PackageReference>
26+
</ItemGroup>
27+
1328
</Project>

YDotNet.Extensions/YDotNetExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public static string ToJson(this Output output, Transaction transaction)
5555
return Encoding.UTF8.GetString(jsonStream.ToArray());
5656
}
5757

58+
#pragma warning disable MA0051 // Method is too long
5859
public static void ToJson(this Output output, Stream stream, Transaction transaction)
60+
#pragma warning restore MA0051 // Method is too long
5961
{
6062
var jsonWriter = new Utf8JsonWriter(stream);
6163

YDotNet.Server.MongoDB/MongoDocumentStorage.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace YDotNet.Server.MongoDB;
77

88
public sealed class MongoDocumentStorage : IDocumentStorage, IHostedService
99
{
10-
private readonly UpdateOptions Upsert = new() { IsUpsert = true };
10+
private readonly UpdateOptions upsert = new() { IsUpsert = true };
1111
private readonly MongoDocumentStorageOptions options;
1212
private readonly IMongoClient mongoClient;
1313
private IMongoCollection<DocumentEntity>? collection;
@@ -34,7 +34,7 @@ await collection.Indexes.CreateOneAsync(
3434
{
3535
ExpireAfter = TimeSpan.Zero
3636
}),
37-
cancellationToken: cancellationToken);
37+
cancellationToken: cancellationToken).ConfigureAwait(false);
3838
}
3939

4040
public Task StopAsync(
@@ -43,33 +43,32 @@ public Task StopAsync(
4343
return Task.CompletedTask;
4444
}
4545

46-
public async ValueTask<byte[]?> GetDocAsync(string name,
47-
CancellationToken ct = default)
46+
public async ValueTask<byte[]?> GetDocAsync(string name, CancellationToken ct = default)
4847
{
4948
if (collection == null)
5049
{
5150
return null;
5251
}
5352

54-
var document = await collection.Find(x => x.Id == name).FirstOrDefaultAsync(ct);
53+
var document = await collection.Find(x => x.Id == name).FirstOrDefaultAsync(ct).ConfigureAwait(false);
5554

5655
return document?.Data;
5756
}
5857

59-
public async ValueTask StoreDocAsync(string name, byte[] doc,
60-
CancellationToken ct = default)
58+
public async ValueTask StoreDocAsync(string name, byte[] doc, CancellationToken ct = default)
6159
{
6260
if (collection == null)
6361
{
6462
return;
6563
}
6664

67-
await collection.UpdateOneAsync(x => x.Id == name,
65+
await collection.UpdateOneAsync(
66+
x => x.Id == name,
6867
Builders<DocumentEntity>.Update
6968
.Set(x => x.Data, doc)
7069
.Set(x => x.Expiration, GetExpiration(name)),
71-
Upsert,
72-
ct);
70+
upsert,
71+
ct).ConfigureAwait(false);
7372
}
7473

7574
private DateTime? GetExpiration(string name)

YDotNet.Server.MongoDB/ServiceExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static YDotnetRegistration AddMongoStorage(this YDotnetRegistration regis
1010
{
1111
registration.Services.Configure(configure ?? (x => { }));
1212
registration.Services.AddSingleton<MongoDocumentStorage>();
13-
13+
1414
registration.Services.AddSingleton<IDocumentStorage>(
1515
c => c.GetRequiredService<MongoDocumentStorage>());
1616

YDotNet.Server.MongoDB/YDotNet.Server.MongoDB.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net7.0</TargetFramework>
@@ -7,7 +7,15 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
1014
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
15+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
16+
<PrivateAssets>all</PrivateAssets>
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
</PackageReference>
1119
</ItemGroup>
1220

1321
<ItemGroup>

YDotNet.Server.Redis/RedisConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace YDotNet.Server.Redis;
77

88
public sealed class RedisConnection : IDisposable
99
{
10-
public Task<IConnectionMultiplexer> Instance { get; }
11-
1210
public RedisConnection(IOptions<RedisOptions> options, ILogger<RedisConnection> logger)
1311
{
1412
Instance = options.Value.ConnectAsync(new LoggerTextWriter(logger));
1513
}
1614

15+
public Task<IConnectionMultiplexer> Instance { get; }
16+
1717
public void Dispose()
1818
{
1919
if (Instance.IsCompletedSuccessfully)

0 commit comments

Comments
 (0)