Skip to content

Commit e6bcf6d

Browse files
Fix additional style/analyzer violations across core library and unit tests
Style rules applied (dotnet format style): - IDE0044: Make field readonly - IDE0063: Use simple using statement (pattern) - IDE0049: Use language keywords (String->string, Int32->int, etc.) - IDE0003: Remove 'this.' qualification - IDE2000: Remove extra blank lines - IDE0059: Remove unnecessary value assignments - IDE0028/IDE0017: Use collection and object initializers - IDE0300/IDE0301: Use collection expressions - IDE0066: Use switch expressions - IDE0074: Use compound assignments (x += y) - IDE0071: Simplify string interpolation - IDE0034: Simplify default expression - IDE0031: Use null propagation - IDE0270: Simplify null checks - IDE0075: Simplify conditional expressions - IDE0251/IDE0250: Make members/structs readonly - IDE0016: Use throw expressions Analyzer rules applied (dotnet format analyzers): - CA1860: Avoid Enumerable.Any() extension method - CA1861: Use static readonly fields over constant array arguments .editorconfig suppressions added (multi-target false positives): - CA1866: char overloads require .NET 5+ (not available in net462/netstandard2.0) - CA1510: ThrowIfNull requires .NET 6+ - IDE0057: Range operator requires System.Index (.NET 5+) - IDE0019: Pattern matching causes duplicate variable issues in #if blocks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2556724 commit e6bcf6d

103 files changed

Lines changed: 457 additions & 556 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,18 @@ dotnet_diagnostic.CA1838.severity = none
863863
# Not applicable: char overloads require .NET 5+; not available in net462/netstandard2.0 targets
864864
dotnet_diagnostic.CA1866.severity = none
865865

866+
# Use ArgumentNullException.ThrowIfNull
867+
# Not applicable: ThrowIfNull requires .NET 6+; not available in net462/netstandard2.0 targets
868+
dotnet_diagnostic.CA1510.severity = none
869+
870+
# Use range subscript operator (x[^1]) and index-from-end operator
871+
# Not applicable: System.Index/System.Range require .NET 5+; polyfill not present in this project
872+
dotnet_diagnostic.IDE0057.severity = none
873+
874+
# Use pattern matching (value is Type x)
875+
# Disabled: introduces duplicate variable declarations in #if multi-target preprocessor blocks
876+
dotnet_diagnostic.IDE0019.severity = none
877+
866878
# Dispose objects before losing scope
867879
dotnet_diagnostic.CA2000.severity = none
868880

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenByAuthorizationCodeParameterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected override void Validate()
6767

6868
if (Parameters.SendX5C == null)
6969
{
70-
Parameters.SendX5C = this.ServiceBundle.Config.SendX5C;
70+
Parameters.SendX5C = ServiceBundle.Config.SendX5C;
7171
}
7272
}
7373

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenByRefreshTokenParameterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected override void Validate()
5252
base.Validate();
5353
if (Parameters.SendX5C == null)
5454
{
55-
Parameters.SendX5C = this.ServiceBundle.Config.SendX5C;
55+
Parameters.SendX5C = ServiceBundle.Config.SendX5C;
5656
}
5757
}
5858

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenByUsernamePasswordParameterBuilder.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ public AcquireTokenByUsernamePasswordParameterBuilder WithProofOfPossession(stri
9696
throw new ArgumentNullException(nameof(nonce));
9797
}
9898

99-
PoPAuthenticationConfiguration popConfig = new(requestUri);
100-
101-
popConfig.Nonce = nonce;
102-
popConfig.HttpMethod = httpMethod;
99+
PoPAuthenticationConfiguration popConfig = new(requestUri)
100+
{
101+
Nonce = nonce,
102+
HttpMethod = httpMethod
103+
};
103104

104105
CommonParameters.PopAuthenticationConfiguration = popConfig;
105106
CommonParameters.AuthenticationOperation = new PopBrokerAuthenticationOperation();

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenForClientParameterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected override void Validate()
219219

220220
if (Parameters.SendX5C == null)
221221
{
222-
Parameters.SendX5C = this.ServiceBundle.Config.SendX5C;
222+
Parameters.SendX5C = ServiceBundle.Config.SendX5C;
223223
}
224224
}
225225

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenForManagedIdentityParameterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private static void ApplyMtlsPopAndAttestation(
111111
if (acquireTokenCommonParameters.IsMtlsPopRequested)
112112
{
113113
acquireTokenCommonParameters.CacheKeyComponents ??=
114-
new SortedList<string, Func<CancellationToken, Task<string>>>();
114+
[];
115115

116116
acquireTokenCommonParameters.CacheKeyComponents[MiAttCacheKeyComponent] =
117117
_ => acquireTokenCommonParameters.AttestationTokenProvider != null ? s_att1 : s_att0;

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenOnBehalfOfParameterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ protected override void Validate()
174174
base.Validate();
175175
if (Parameters.SendX5C == null)
176176
{
177-
Parameters.SendX5C = this.ServiceBundle.Config?.SendX5C ?? false;
177+
Parameters.SendX5C = ServiceBundle.Config?.SendX5C ?? false;
178178
}
179179
}
180180
/// <inheritdoc/>

src/client/Microsoft.Identity.Client/ApiConfig/AcquireTokenSilentParameterBuilder.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected override void Validate()
100100
base.Validate();
101101
if (Parameters.SendX5C == null)
102102
{
103-
Parameters.SendX5C = this.ServiceBundle.Config.SendX5C;
103+
Parameters.SendX5C = ServiceBundle.Config.SendX5C;
104104
}
105105

106106
// During AT Silent with no scopes, Unlike AAD, B2C will not issue an access token if no scopes are requested
@@ -228,9 +228,11 @@ public AcquireTokenSilentParameterBuilder WithProofOfPossession(string nonce, Ht
228228
}
229229
}
230230

231-
PoPAuthenticationConfiguration popConfig = new(requestUri ?? throw new ArgumentNullException(nameof(requestUri)));
232-
popConfig.HttpMethod = httpMethod ?? throw new ArgumentNullException(nameof(httpMethod));
233-
popConfig.Nonce = nonce;
231+
PoPAuthenticationConfiguration popConfig = new(requestUri ?? throw new ArgumentNullException(nameof(requestUri)))
232+
{
233+
HttpMethod = httpMethod ?? throw new ArgumentNullException(nameof(httpMethod)),
234+
Nonce = nonce
235+
};
234236

235237
IAuthenticationOperation authenticationScheme;
236238

src/client/Microsoft.Identity.Client/ApiConfig/BaseAbstractAcquireTokenParameterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public T WithExtraQueryParameters(IDictionary<string, (string Value, bool Includ
122122

123123
if (kvp.Value.IncludeInCacheKey)
124124
{
125-
CommonParameters.CacheKeyComponents = CommonParameters.CacheKeyComponents ?? new SortedList<string, Func<CancellationToken, Task<string>>>();
125+
CommonParameters.CacheKeyComponents = CommonParameters.CacheKeyComponents ?? [];
126126

127127
// Capture the value in a local to avoid closure issues
128128
string valueToCache = kvp.Value.Value;

src/client/Microsoft.Identity.Client/ApiConfig/BrokerOptions.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public enum OperatingSystems
4848
/// </summary>
4949
internal static BrokerOptions CreateFromWindowsOptions(WindowsBrokerOptions winOptions)
5050
{
51-
BrokerOptions ret = new(OperatingSystems.Windows);
52-
ret.Title = winOptions.HeaderText;
53-
ret.MsaPassthrough = winOptions.MsaPassthrough;
54-
ret.ListOperatingSystemAccounts = winOptions.ListWindowsWorkAndSchoolAccounts;
51+
BrokerOptions ret = new(OperatingSystems.Windows)
52+
{
53+
Title = winOptions.HeaderText,
54+
MsaPassthrough = winOptions.MsaPassthrough,
55+
ListOperatingSystemAccounts = winOptions.ListWindowsWorkAndSchoolAccounts
56+
};
5557

5658
return ret;
5759
}

0 commit comments

Comments
 (0)