Skip to content

Commit 7326cbc

Browse files
authored
Fix CA1802;CA1805;CA1823;CA1822;CA1845;CA1846;CA1852; (#2138)
* Fix CA1802;CA1805;CA1823; * Fix CA1822;CA1845;CA1846;CA1852;
1 parent c01c309 commit 7326cbc

File tree

58 files changed

+185
-194
lines changed

Some content is hidden

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

58 files changed

+185
-194
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<ThirdPartyAssemblySigningCertName>3PartySHA2</ThirdPartyAssemblySigningCertName>
3030
<PackageSigningCertName>NuGet</PackageSigningCertName>
3131
<!-- Disable the warnings for now, enable batch by batch later-->
32-
<NoWarn>$(NoWarn);CA1802;CA1805;CA1823;CA1822;CA1845;CA1846;CA1852;CA2007;CA2008;CA2012;CA2016;CA1835;CA2208;IDE0161;IDE0130;IDE0290;IDE1006;IDE0090</NoWarn>
32+
<NoWarn>$(NoWarn);CA2007;CA2008;CA2012;CA2016;CA1835;CA2208;IDE0161;IDE0130;IDE0290;IDE1006;IDE0090</NoWarn>
3333
</PropertyGroup>
3434

3535
<ItemGroup>

samples/AspNet.ChatSample/AspNet.ChatSample.CSharpClient/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace AspNet.ChatSample.CSharpClient;
1212

13-
class Program
13+
sealed class Program
1414
{
1515
private static readonly Func<Task> ReconnectDelayTask = () => DelayRandom(200, 1000);
1616
private static readonly SemaphoreSlim ReconnectLock = new SemaphoreSlim(1);

samples/ChatSample/ChatSample.CSharpClient/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
25
using System.IO;
36
using System.Threading;
47
using System.Threading.Tasks;
@@ -8,7 +11,7 @@
811

912
namespace ChatSample.CSharpClient
1013
{
11-
class Program
14+
sealed class Program
1215
{
1316
static async Task Main(string[] args)
1417
{

samples/ChatSample/ChatSample.ManagementPublisher/MessagePublisher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// A simple library file to test cross project reference issue: https://github.com/Azure/azure-signalr/issues/1720
77
namespace ManagementPublisher
88
{
9-
internal class MessagePublisher
9+
internal sealed class MessagePublisher
1010
{
1111
private const string Target = "Target";
1212
private const string HubName = "Chat";

src/Common/TextMessageParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.Azure.SignalR
1010
/// </summary>
1111
internal static class TextMessageParser
1212
{
13-
public static readonly byte RecordSeparator = 0x1e;
13+
public const byte RecordSeparator = 0x1e;
1414

1515
public static bool TryParseMessage(ref ReadOnlySequence<byte> buffer, out ReadOnlySequence<byte> payload)
1616
{

src/Microsoft.Azure.SignalR.Common/Auth/AuthUtility.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ internal static class AuthUtility
1515
{
1616
private const int MaxTokenLength = 4096;
1717

18-
private static readonly SignalRJwtSecurityTokenHandler JwtTokenHandler = new();
19-
2018
public static string GenerateJwtToken(byte[] keyBytes,
2119
string? kid = null,
2220
string? issuer = null,
@@ -29,7 +27,7 @@ public static string GenerateJwtToken(byte[] keyBytes,
2927
{
3028
var subject = claims == null ? null : new ClaimsIdentity(claims);
3129

32-
var token = JwtTokenHandler.CreateJwtSecurityToken(
30+
var token = SignalRJwtSecurityTokenHandler.CreateJwtSecurityToken(
3331
expires: expires,
3432
issuedAt: issuedAt,
3533
issuer: issuer,

src/Microsoft.Azure.SignalR.Common/Auth/MicrosoftEntra/MicrosoftEntraAccessKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal class MicrosoftEntraAccessKey : IAccessKey
4242

4343
private readonly IHttpClientFactory _httpClientFactory;
4444

45-
private volatile bool _isAuthorized = false;
45+
private volatile bool _isAuthorized;
4646

4747
private DateTime _updateAt = DateTime.MinValue;
4848

src/Microsoft.Azure.SignalR.Common/Auth/SignalRJwtSecurityTokenHandler.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ internal class SignalRJwtSecurityTokenHandler
2828
// Simplified from following codes:
2929
// method `CreateJwtSecurityToken` in [JwtSecruityTokenHandler.cs](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/6.22.0/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs#L487)
3030
// method `CreateJwtSecurityTokenPrivate` in [JwtSecurityTokenHandler.cs](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/6.22.0/src/System.IdentityModel.Tokens.Jwt/JwtSecurityTokenHandler.cs#L616)
31-
public string CreateJwtSecurityToken(DateTime? notBefore = null,
32-
DateTime? expires = null,
33-
DateTime? issuedAt = null,
34-
string issuer = null,
35-
string audience = null,
36-
ClaimsIdentity subject = null,
37-
byte[] key = null,
38-
string kid = null,
39-
AccessTokenAlgorithm algorithm = AccessTokenAlgorithm.HS256)
31+
public static string CreateJwtSecurityToken(DateTime? notBefore = null,
32+
DateTime? expires = null,
33+
DateTime? issuedAt = null,
34+
string issuer = null,
35+
string audience = null,
36+
ClaimsIdentity subject = null,
37+
byte[] key = null,
38+
string kid = null,
39+
AccessTokenAlgorithm algorithm = AccessTokenAlgorithm.HS256)
4040
{
4141
if (!expires.HasValue || !issuedAt.HasValue || !notBefore.HasValue)
4242
{

src/Microsoft.Azure.SignalR.Common/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static class Keys
3333

3434
public const string AzureSignalREndpointsKey = $"{AzureSignalRSectionKey}:Endpoints";
3535

36-
public static readonly string ConnectionStringSecondaryKey =
36+
public const string ConnectionStringSecondaryKey =
3737
$"ConnectionStrings:{ConnectionStringDefaultKey}";
3838
}
3939

src/Microsoft.Azure.SignalR.Common/ServiceConnections/ConnectionFactory.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Task DisposeAsync(ConnectionContext connection)
7272
return ((WebSocketConnectionContext)connection).StopAsync();
7373
}
7474

75-
private Uri GetServiceUrl(IServiceEndpointProvider provider, string hubName, string connectionId, string target)
75+
private static Uri GetServiceUrl(IServiceEndpointProvider provider, string hubName, string connectionId, string target)
7676
{
7777
var baseUri = new UriBuilder(provider.GetServerEndpoint(hubName));
7878
var query = "cid=" + connectionId;
@@ -82,7 +82,12 @@ private Uri GetServiceUrl(IServiceEndpointProvider provider, string hubName, str
8282
}
8383
if (baseUri.Query != null && baseUri.Query.Length > 1)
8484
{
85+
#if NET6_0_OR_GREATER
86+
baseUri.Query = string.Concat(baseUri.Query.AsSpan(1), "&", query);
87+
#else
88+
8589
baseUri.Query = baseUri.Query.Substring(1) + "&" + query;
90+
#endif
8691
}
8792
else
8893
{

0 commit comments

Comments
 (0)