Skip to content

Commit bc2a942

Browse files
Fix CA1854 warnings
Fix CA1854 analyser warnings.
1 parent 9c61f2c commit bc2a942

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/Http/Authentication.Core/src/AuthenticationSchemeProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected AuthenticationSchemeProvider(IOptions<AuthenticationOptions> options,
120120
/// <param name="name">The name of the authenticationScheme.</param>
121121
/// <returns>The scheme or null if not found.</returns>
122122
public virtual Task<AuthenticationScheme?> GetSchemeAsync(string name)
123-
=> Task.FromResult(_schemes.ContainsKey(name) ? _schemes[name] : null);
123+
=> Task.FromResult(_schemes.TryGetValue(name, out var scheme) ? scheme : null);
124124

125125
/// <summary>
126126
/// Returns the schemes in priority order for request handling.
@@ -184,13 +184,13 @@ public virtual void AddScheme(AuthenticationScheme scheme)
184184
/// <param name="name">The name of the authenticationScheme being removed.</param>
185185
public virtual void RemoveScheme(string name)
186186
{
187-
if (!_schemes.TryGetValue(name, out var scheme))
187+
if (!_schemes.TryGetValue(name, out _))
188188
{
189189
return;
190190
}
191191
lock (_lock)
192192
{
193-
if (_schemes.TryGetValue(name, out scheme))
193+
if (_schemes.TryGetValue(name, out var scheme))
194194
{
195195
if (_requestHandlers.Remove(scheme))
196196
{

src/Servers/IIS/IntegrationTesting.IIS/src/IISDeployer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ private void GetLogsFromFile()
158158
{
159159
// Handle cases where debug file is redirected by test
160160
var debugLogLocations = new List<string>();
161-
if (IISDeploymentParameters.HandlerSettings.ContainsKey("debugFile"))
161+
if (IISDeploymentParameters.HandlerSettings.TryGetValue("debugFile", out var debugFile))
162162
{
163-
debugLogLocations.Add(IISDeploymentParameters.HandlerSettings["debugFile"]);
163+
debugLogLocations.Add(debugFile);
164164
}
165165

166-
if (DeploymentParameters.EnvironmentVariables.ContainsKey("ASPNETCORE_MODULE_DEBUG_FILE"))
166+
if (DeploymentParameters.EnvironmentVariables.TryGetValue("ASPNETCORE_MODULE_DEBUG_FILE", out debugFile))
167167
{
168-
debugLogLocations.Add(DeploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"]);
168+
debugLogLocations.Add(debugFile);
169169
}
170170

171171
// default debug file name
@@ -397,7 +397,7 @@ private void Stop()
397397
Logger.LogInformation($"Stopping pool, state: {state}");
398398
}
399399
}
400-
400+
401401
// Make sure all sites are stopped
402402
foreach (var site in serverManager.Sites)
403403
{

src/Tools/Microsoft.dotnet-openapi/src/Commands/BaseCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private async Task EnsurePackagesInProjectAsync(FileInfo projectFile, CodeGenera
195195
foreach (var kvp in attributePackages)
196196
{
197197
var packageId = kvp.Key;
198-
var version = urlPackages != null && urlPackages.ContainsKey(packageId) ? urlPackages[packageId] : kvp.Value;
198+
var version = urlPackages != null && urlPackages.TryGetValue(packageId, out var urlPackageVersion) ? urlPackageVersion : kvp.Value;
199199

200200
await TryAddPackage(packageId, version, projectFile);
201201
}

0 commit comments

Comments
 (0)