Skip to content

Enable warnings for IDE0062 #39463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ dotnet_diagnostic.IDE0055.severity = warning
# IDE0059: Unnecessary assignment to a value
dotnet_diagnostic.IDE0059.severity = warning

# IDE0062: Make local function static
dotnet_diagnostic.IDE0062.severity = warning

# IDE0073: File header
dotnet_diagnostic.IDE0073.severity = warning
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.
Expand Down Expand Up @@ -285,6 +288,8 @@ dotnet_diagnostic.IDE0044.severity = suggestion
dotnet_diagnostic.IDE0051.severity = suggestion
# IDE0059: Unnecessary assignment to a value
dotnet_diagnostic.IDE0059.severity = suggestion
# IDE0062: Make local function static
dotnet_diagnostic.IDE0062.severity = suggestion

# CA2016: Forward the 'CancellationToken' parameter to methods that take one
dotnet_diagnostic.CA2016.severity = suggestion
Expand All @@ -298,6 +303,8 @@ dotnet_diagnostic.CA1822.severity = silent
dotnet_diagnostic.IDE0011.severity = silent
# IDE0055: Fix formatting
dotnet_diagnostic.IDE0055.severity = silent
# IDE0062: Make local function static
dotnet_diagnostic.IDE0062.severity = silent
# IDE0161: Convert to file-scoped namespace
dotnet_diagnostic.IDE0161.severity = silent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static void AddAdditionalMvcApplicationParts(IServiceCollection services
apm.FeatureProviders.Add(new AzureADB2CAccountControllerFeatureProvider());
});

bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal);
static bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal);
}

private static IEnumerable<ApplicationPart> GetAdditionalParts()
Expand Down
4 changes: 2 additions & 2 deletions src/Hosting/Hosting/src/WebHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ public IWebHost Build()
throw;
}

IServiceProvider GetProviderFromFactory(IServiceCollection collection)
static IServiceProvider GetProviderFromFactory(IServiceCollection collection)
{
var provider = collection.BuildServiceProvider();
var factory = provider.GetService<IServiceProviderFactory<IServiceCollection>>();

if (factory != null && !(factory is DefaultServiceProviderFactory))
if (factory != null && factory is not DefaultServiceProviderFactory)
{
using (provider)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/src/CompositeEndpointDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private string DebuggerDisplayString
}
return sb.ToString();

IEnumerable<string> FormatValues(IEnumerable<KeyValuePair<string, object?>> values)
static IEnumerable<string> FormatValues(IEnumerable<KeyValuePair<string, object?>> values)
{
return values.Select(
kvp =>
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/src/EndpointNameAddressScheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static Dictionary<string, Endpoint[]> Initialize(IReadOnlyList<Endpoint>

throw new InvalidOperationException(builder.ToString());

string? GetEndpointName(Endpoint endpoint)
static string? GetEndpointName(Endpoint endpoint)
{
if (endpoint.Metadata.GetMetadata<ISuppressLinkGenerationMetadata>()?.SuppressLinkGeneration == true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public IReadOnlyList<PolicyNodeEdge> GetEdges(IReadOnlyList<Endpoint> endpoints)

return policyNodeEdges;

(IReadOnlyList<string> httpMethods, bool acceptCorsPreflight) GetHttpMethods(Endpoint e)
static (IReadOnlyList<string> httpMethods, bool acceptCorsPreflight) GetHttpMethods(Endpoint e)
{
var metadata = e.Metadata.GetMetadata<IHttpMethodMetadata>();
return metadata == null ? (Array.Empty<string>(), false) : (metadata.HttpMethods, metadata.AcceptCorsPreflight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static AuthenticationBuilder AddIdentityServerJwt(this AuthenticationBuil

return builder;

IdentityServerJwtBearerOptionsConfiguration JwtBearerOptionsFactory(IServiceProvider sp)
static IdentityServerJwtBearerOptionsConfiguration JwtBearerOptionsFactory(IServiceProvider sp)
{
var schemeName = IdentityServerJwtConstants.IdentityServerJwtBearerScheme;

Expand All @@ -58,5 +58,4 @@ IdentityServerJwtBearerOptionsConfiguration JwtBearerOptionsFactory(IServiceProv
return new IdentityServerJwtBearerOptionsConfiguration(schemeName, apiName, localApiDescriptor);
}
}

}
4 changes: 0 additions & 4 deletions src/Middleware/Rewrite/src/ApacheModRewrite/FileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ public static IList<IRule> Parse(TextReader input)
var lineNum = 0;

// parsers
var testStringParser = new TestStringParser();
var conditionParser = new ConditionPatternParser();
var regexParser = new RuleRegexParser();
var flagsParser = new FlagParser();
var tokenizer = new Tokenizer();

while ((line = input.ReadLine()) != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/Spa/SpaProxy/src/SpaProxyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private async Task InvokeCore(HttpContext context)
context.Response.Redirect(_options.Value.ServerUrl);
}

string GenerateSpaLaunchPage(SpaDevelopmentServerOptions options)
static string GenerateSpaLaunchPage(SpaDevelopmentServerOptions options)
{
return $@"
<!DOCTYPE html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private static void EnsureActionIsAttributeRouted(ActionModel actionModel)
throw new InvalidOperationException(message);
}

bool IsAttributeRouted(IList<SelectorModel> selectorModel)
static bool IsAttributeRouted(IList<SelectorModel> selectorModel)
{
for (var i = 0; i < selectorModel.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public bool AppliesToEndpoints(IReadOnlyList<Endpoint> endpoints)

return false;

bool HasSignificantActionConstraint(IList<IActionConstraintMetadata> constraints)
static bool HasSignificantActionConstraint(IList<IActionConstraintMetadata> constraints)
{
for (var i = 0; i < constraints.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private IEnumerable<CompiledViewDescriptor> GetViewDescriptors(ApplicationPartMa
}
}

bool IsRazorPage(CompiledViewDescriptor viewDescriptor)
static bool IsRazorPage(CompiledViewDescriptor viewDescriptor)
{
if (viewDescriptor.Item != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private Task InitializeStandardComponentServicesAsync(HttpContext httpContext)

return _initialized;

async Task InitializeCore(HttpContext httpContext)
static async Task InitializeCore(HttpContext httpContext)
{
var navigationManager = (IHostEnvironmentNavigationManager)httpContext.RequestServices.GetRequiredService<NavigationManager>();
navigationManager?.Initialize(GetContextBaseUri(httpContext.Request), GetFullUri(httpContext.Request));
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/shared/KnownHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static string AppendSwitchSection(int length, IList<KnownHeader> values)
firstTermVar = "";
}

string GenerateIfBody(KnownHeader header, string extraIndent = "")
static string GenerateIfBody(KnownHeader header, string extraIndent = "")
{
if (header.Name == HeaderNames.ContentLength)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Servers/Kestrel/stress/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public ClientContext(HttpClient httpClient, int taskNum, int seed)
HttpClient = httpClient;

// deterministic hashing copied from System.Runtime.Hashing
int Combine(int h1, int h2)
static int Combine(int h1, int h2)
{
uint rol5 = ((uint)h1 << 5) | ((uint)h1 >> 27);
return ((int)rol5 + h1) ^ h2;
Expand Down
9 changes: 4 additions & 5 deletions src/Shared/BrowserTesting/src/PageInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,17 @@ private void RecordConsoleMessage(object sender, IConsoleMessage message)

var logMessage = $"[{_page.Url}]{Environment.NewLine} {messageText}{Environment.NewLine} ({location})";

_logger.Log(MapLogLevel(message.Type), logMessage);

BrowserConsoleLogs.Add(new LogEntry(messageText, message.Type));

LogLevel MapLogLevel(string messageType) => messageType switch
var logLevel = message.Type switch
{
"info" => LogLevel.Information,
"verbose" => LogLevel.Debug,
"warning" => LogLevel.Warning,
"error" => LogLevel.Error,
_ => LogLevel.Information
};
_logger.Log(logLevel, logMessage);

BrowserConsoleLogs.Add(new LogEntry(messageText, message.Type));
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion src/SignalR/common/Shared/PipeWriterStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private ValueTask WriteCoreAsync(ReadOnlyMemory<byte> source, CancellationToken

return default;

async ValueTask WriteSlowAsync(ValueTask<FlushResult> flushTask)
static async ValueTask WriteSlowAsync(ValueTask<FlushResult> flushTask)
{
var flushResult = await flushTask;

Expand Down