Skip to content

Style and analyzer fixes #33891

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
Jun 28, 2021
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
5 changes: 3 additions & 2 deletions src/Mvc/Mvc.Testing/src/DeferredHostBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
Expand Down
16 changes: 9 additions & 7 deletions src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.Hosting;
Expand All @@ -32,8 +31,8 @@ public class WebApplicationFactory<TEntryPoint> : IDisposable, IAsyncDisposable
private TestServer? _server;
private IHost? _host;
private Action<IWebHostBuilder> _configuration;
private List<HttpClient> _clients = new();
private List<WebApplicationFactory<TEntryPoint>> _derivedFactories = new();
private readonly List<HttpClient> _clients = new();
private readonly List<WebApplicationFactory<TEntryPoint>> _derivedFactories = new();

/// <summary>
/// <para>
Expand Down Expand Up @@ -226,7 +225,7 @@ private void SetContentRoot(IWebHostBuilder builder)
}
}

private string GetContentRootFromFile(string file)
private static string GetContentRootFromFile(string file)
{
var data = JsonSerializer.Deserialize<IDictionary<string, string>>(File.ReadAllBytes(file))!;
var key = typeof(TEntryPoint).Assembly.GetName().FullName;
Expand Down Expand Up @@ -350,7 +349,7 @@ protected virtual IEnumerable<Assembly> GetTestAssemblies()
return Array.Empty<Assembly>();
}

private void EnsureDepsFile()
private static void EnsureDepsFile()
{
if (typeof(TEntryPoint).Assembly.EntryPoint == null)
{
Expand Down Expand Up @@ -413,7 +412,7 @@ private void EnsureDepsFile()
/// <param name="builder">The <see cref="IWebHostBuilder"/> used to
/// create the server.</param>
/// <returns>The <see cref="TestServer"/> with the bootstrapped application.</returns>
protected virtual TestServer CreateServer(IWebHostBuilder builder) => new TestServer(builder);
protected virtual TestServer CreateServer(IWebHostBuilder builder) => new(builder);

/// <summary>
/// Creates the <see cref="IHost"/> with the bootstrapped application in <paramref name="builder"/>.
Expand Down Expand Up @@ -478,7 +477,7 @@ public HttpClient CreateDefaultClient(params DelegatingHandler[] handlers)
}

var serverHandler = _server.CreateHandler();
handlers[handlers.Length - 1].InnerHandler = serverHandler;
handlers[^1].InnerHandler = serverHandler;

client = new HttpClient(handlers[0]);
}
Expand Down Expand Up @@ -524,6 +523,7 @@ public HttpClient CreateDefaultClient(Uri baseAddress, params DelegatingHandler[
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
Expand Down Expand Up @@ -589,6 +589,8 @@ public virtual async ValueTask DisposeAsync()
_disposedAsync = true;

Dispose(disposing: true);

GC.SuppressFinalize(this);
}

private class DelegatedWebApplicationFactory : WebApplicationFactory<TEntryPoint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public async Task AttributeRoutedAction_ParameterTransformer_LinkToConventionalC
}

[Fact]
public async override Task HasEndpointMatch()
public override async Task HasEndpointMatch()
{
// Arrange & Act
var response = await Client.GetAsync("http://localhost/Routing/HasEndpointMatch");
Expand All @@ -219,7 +219,7 @@ public async override Task HasEndpointMatch()
}

[Fact]
public async override Task RouteData_Routers_ConventionalRoute()
public override async Task RouteData_Routers_ConventionalRoute()
{
// Arrange & Act
var response = await Client.GetAsync("http://localhost/RouteData/Conventional");
Expand All @@ -236,7 +236,7 @@ public async override Task RouteData_Routers_ConventionalRoute()
}

[Fact]
public async override Task RouteData_Routers_AttributeRoute()
public override async Task RouteData_Routers_AttributeRoute()
{
// Arrange & Act
var response = await Client.GetAsync("http://localhost/RouteData/Attribute");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.AspNetCore.Mvc.FunctionalTests
{
public class SimpleWithWebApplicationBuilderExceptionTests : IClassFixture<MvcTestFixture<SimpleWebSiteWithWebApplicationBuilderException.FakeStartup>>
{
private MvcTestFixture<SimpleWebSiteWithWebApplicationBuilderException.FakeStartup> _fixture;
private readonly MvcTestFixture<SimpleWebSiteWithWebApplicationBuilderException.FakeStartup> _fixture;

public SimpleWithWebApplicationBuilderExceptionTests(MvcTestFixture<SimpleWebSiteWithWebApplicationBuilderException.FakeStartup> fixture)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

/// <summary>
/// This is a class we use to reference this assembly statically from tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

/// <summary>
/// This is a class we use to reference this assembly statically from tests
Expand Down