Skip to content

Commit 07d728b

Browse files
authored
Enable warnings for IDE0062 (#39463)
Contributes to #24055
1 parent d5557cd commit 07d728b

File tree

17 files changed

+26
-25
lines changed

17 files changed

+26
-25
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ dotnet_diagnostic.IDE0055.severity = warning
233233
# IDE0059: Unnecessary assignment to a value
234234
dotnet_diagnostic.IDE0059.severity = warning
235235

236+
# IDE0062: Make local function static
237+
dotnet_diagnostic.IDE0062.severity = warning
238+
236239
# IDE0073: File header
237240
dotnet_diagnostic.IDE0073.severity = warning
238241
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
@@ -285,6 +288,8 @@ dotnet_diagnostic.IDE0044.severity = suggestion
285288
dotnet_diagnostic.IDE0051.severity = suggestion
286289
# IDE0059: Unnecessary assignment to a value
287290
dotnet_diagnostic.IDE0059.severity = suggestion
291+
# IDE0062: Make local function static
292+
dotnet_diagnostic.IDE0062.severity = suggestion
288293

289294
# CA2016: Forward the 'CancellationToken' parameter to methods that take one
290295
dotnet_diagnostic.CA2016.severity = suggestion
@@ -298,6 +303,8 @@ dotnet_diagnostic.CA1822.severity = silent
298303
dotnet_diagnostic.IDE0011.severity = silent
299304
# IDE0055: Fix formatting
300305
dotnet_diagnostic.IDE0055.severity = silent
306+
# IDE0062: Make local function static
307+
dotnet_diagnostic.IDE0062.severity = silent
301308
# IDE0161: Convert to file-scoped namespace
302309
dotnet_diagnostic.IDE0161.severity = silent
303310

src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CAuthenticationBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private static void AddAdditionalMvcApplicationParts(IServiceCollection services
207207
apm.FeatureProviders.Add(new AzureADB2CAccountControllerFeatureProvider());
208208
});
209209

210-
bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal);
210+
static bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal);
211211
}
212212

213213
private static IEnumerable<ApplicationPart> GetAdditionalParts()

src/Hosting/Hosting/src/WebHostBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ public IWebHost Build()
198198
throw;
199199
}
200200

201-
IServiceProvider GetProviderFromFactory(IServiceCollection collection)
201+
static IServiceProvider GetProviderFromFactory(IServiceCollection collection)
202202
{
203203
var provider = collection.BuildServiceProvider();
204204
var factory = provider.GetService<IServiceProviderFactory<IServiceCollection>>();
205205

206-
if (factory != null && !(factory is DefaultServiceProviderFactory))
206+
if (factory != null && factory is not DefaultServiceProviderFactory)
207207
{
208208
using (provider)
209209
{

src/Http/Routing/src/CompositeEndpointDataSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private string DebuggerDisplayString
205205
}
206206
return sb.ToString();
207207

208-
IEnumerable<string> FormatValues(IEnumerable<KeyValuePair<string, object?>> values)
208+
static IEnumerable<string> FormatValues(IEnumerable<KeyValuePair<string, object?>> values)
209209
{
210210
return values.Select(
211211
kvp =>

src/Http/Routing/src/EndpointNameAddressScheme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static Dictionary<string, Endpoint[]> Initialize(IReadOnlyList<Endpoint>
8989

9090
throw new InvalidOperationException(builder.ToString());
9191

92-
string? GetEndpointName(Endpoint endpoint)
92+
static string? GetEndpointName(Endpoint endpoint)
9393
{
9494
if (endpoint.Metadata.GetMetadata<ISuppressLinkGenerationMetadata>()?.SuppressLinkGeneration == true)
9595
{

src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public IReadOnlyList<PolicyNodeEdge> GetEdges(IReadOnlyList<Endpoint> endpoints)
308308

309309
return policyNodeEdges;
310310

311-
(IReadOnlyList<string> httpMethods, bool acceptCorsPreflight) GetHttpMethods(Endpoint e)
311+
static (IReadOnlyList<string> httpMethods, bool acceptCorsPreflight) GetHttpMethods(Endpoint e)
312312
{
313313
var metadata = e.Metadata.GetMetadata<IHttpMethodMetadata>();
314314
return metadata == null ? (Array.Empty<string>(), false) : (metadata.HttpMethods, metadata.AcceptCorsPreflight);

src/Identity/ApiAuthorization.IdentityServer/src/Authentication/AuthenticationBuilderExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static AuthenticationBuilder AddIdentityServerJwt(this AuthenticationBuil
4747

4848
return builder;
4949

50-
IdentityServerJwtBearerOptionsConfiguration JwtBearerOptionsFactory(IServiceProvider sp)
50+
static IdentityServerJwtBearerOptionsConfiguration JwtBearerOptionsFactory(IServiceProvider sp)
5151
{
5252
var schemeName = IdentityServerJwtConstants.IdentityServerJwtBearerScheme;
5353

@@ -58,5 +58,4 @@ IdentityServerJwtBearerOptionsConfiguration JwtBearerOptionsFactory(IServiceProv
5858
return new IdentityServerJwtBearerOptionsConfiguration(schemeName, apiName, localApiDescriptor);
5959
}
6060
}
61-
6261
}

src/Middleware/Rewrite/src/ApacheModRewrite/FileParser.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ public static IList<IRule> Parse(TextReader input)
1313
var lineNum = 0;
1414

1515
// parsers
16-
var testStringParser = new TestStringParser();
17-
var conditionParser = new ConditionPatternParser();
18-
var regexParser = new RuleRegexParser();
1916
var flagsParser = new FlagParser();
20-
var tokenizer = new Tokenizer();
2117

2218
while ((line = input.ReadLine()) != null)
2319
{

src/Middleware/Spa/SpaProxy/src/SpaProxyMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private async Task InvokeCore(HttpContext context)
6868
context.Response.Redirect(_options.Value.ServerUrl);
6969
}
7070

71-
string GenerateSpaLaunchPage(SpaDevelopmentServerOptions options)
71+
static string GenerateSpaLaunchPage(SpaDevelopmentServerOptions options)
7272
{
7373
return $@"
7474
<!DOCTYPE html>

src/Mvc/Mvc.Core/src/ApplicationModels/ApiBehaviorApplicationModelProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static void EnsureActionIsAttributeRouted(ActionModel actionModel)
9797
throw new InvalidOperationException(message);
9898
}
9999

100-
bool IsAttributeRouted(IList<SelectorModel> selectorModel)
100+
static bool IsAttributeRouted(IList<SelectorModel> selectorModel)
101101
{
102102
for (var i = 0; i < selectorModel.Count; i++)
103103
{

0 commit comments

Comments
 (0)