Skip to content

Commit d8bba72

Browse files
Remove usings from templates implicitly added by the SDK (#34219)
-Depends on dotnet/sdk#18459 flowing to dotnet/aspnetcore repo before we can merge this - There's a couple of places we could remove usings from .razor files but need to verify the global usings flow into Razor compiler (#34217) - Reordered usings in some places to ensure they get emitted in alphabetical order (modulo System.* & Microsoft.* coming before any others)
1 parent 952062e commit d8bba72

File tree

33 files changed

+46
-203
lines changed

33 files changed

+46
-203
lines changed

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Areas/Identity/RevalidatingIdentityAuthenticationStateProvider.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
using System;
21
using System.Security.Claims;
3-
using System.Threading;
4-
using System.Threading.Tasks;
52
using Microsoft.AspNetCore.Components;
63
using Microsoft.AspNetCore.Components.Authorization;
74
using Microsoft.AspNetCore.Components.Server;
85
using Microsoft.AspNetCore.Identity;
9-
using Microsoft.Extensions.DependencyInjection;
10-
using Microsoft.Extensions.Logging;
116
using Microsoft.Extensions.Options;
127

138
namespace BlazorServerWeb_CSharp.Areas.Identity

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Data/ApplicationDbContext.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
1+
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
52
using Microsoft.EntityFrameworkCore;
63

74
namespace BlazorServerWeb_CSharp.Data

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Data/WeatherForecast.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace BlazorServerWeb_CSharp.Data
42
{
53
public class WeatherForecast

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Data/WeatherForecastService.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Linq;
3-
using System.Threading.Tasks;
4-
51
namespace BlazorServerWeb_CSharp.Data
62
{
73
public class WeatherForecastService

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/Error.cshtml.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
1+
using System.Diagnostics;
62
using Microsoft.AspNetCore.Mvc;
73
using Microsoft.AspNetCore.Mvc.RazorPages;
8-
using Microsoft.Extensions.Logging;
94

105
namespace BlazorServerWeb_CSharp.Pages
116
{

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs

-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
#if (OrganizationalAuth || IndividualB2CAuth)
62
using Microsoft.AspNetCore.Authentication;
73
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
@@ -14,23 +10,18 @@
1410
#endif
1511
using Microsoft.AspNetCore.Authorization;
1612
#endif
17-
using Microsoft.AspNetCore.Builder;
1813
using Microsoft.AspNetCore.Components;
1914
#if (IndividualLocalAuth)
2015
using Microsoft.AspNetCore.Components.Authorization;
2116
using Microsoft.AspNetCore.Identity;
2217
using Microsoft.AspNetCore.Identity.UI;
2318
#endif
24-
using Microsoft.AspNetCore.Hosting;
2519
#if (OrganizationalAuth)
2620
using Microsoft.AspNetCore.Mvc.Authorization;
2721
#endif
2822
#if (IndividualLocalAuth)
2923
using Microsoft.EntityFrameworkCore;
3024
#endif
31-
using Microsoft.Extensions.Configuration;
32-
using Microsoft.Extensions.DependencyInjection;
33-
using Microsoft.Extensions.Hosting;
3425
#if (GenerateGraph)
3526
using Graph = Microsoft.Graph;
3627
#endif

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Program.cs

-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Net.Http;
4-
using System.Text;
5-
using System.Threading.Tasks;
61
#if (!NoAuth && Hosted)
72
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
83
#endif
94
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
10-
using Microsoft.Extensions.Configuration;
11-
using Microsoft.Extensions.DependencyInjection;
12-
using Microsoft.Extensions.Logging;
135
#if (Hosted)
146
using ComponentsWebAssembly_CSharp.Client;
157
#else

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/OidcConfigurationController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer;
22
using Microsoft.AspNetCore.Mvc;
3-
using Microsoft.Extensions.Logging;
43

54
namespace ComponentsWebAssembly_CSharp.Server.Controllers
65
{

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
#if (!NoAuth)
1+
#if (!NoAuth)
62
using Microsoft.AspNetCore.Authorization;
73
#endif
84
#if (GenerateApi)
9-
using Microsoft.Extensions.Configuration;
105
using Microsoft.Identity.Web;
116
using System.Net;
12-
using System.Net.Http;
137
#endif
148
#if (GenerateGraph)
159
using Microsoft.Graph;
1610
#endif
1711
using Microsoft.AspNetCore.Mvc;
18-
using Microsoft.Extensions.Logging;
1912
#if (OrganizationalAuth || IndividualB2CAuth)
2013
using Microsoft.Identity.Web.Resource;
2114
#endif

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Data/ApplicationDbContext.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
using ComponentsWebAssembly_CSharp.Server.Models;
2-
using IdentityServer4.EntityFramework.Options;
3-
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer;
1+
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer;
42
using Microsoft.EntityFrameworkCore;
53
using Microsoft.Extensions.Options;
6-
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
9-
using System.Threading.Tasks;
4+
using IdentityServer4.EntityFramework.Options;
5+
using ComponentsWebAssembly_CSharp.Server.Models;
106

117
namespace ComponentsWebAssembly_CSharp.Server.Data
128
{

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Models/ApplicationUser.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using Microsoft.AspNetCore.Identity;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Threading.Tasks;
62

73
namespace ComponentsWebAssembly_CSharp.Server.Models
84
{

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Pages/Error.cshtml.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
1+
using System.Diagnostics;
62
using Microsoft.AspNetCore.Mvc;
73
using Microsoft.AspNetCore.Mvc.RazorPages;
8-
using Microsoft.Extensions.Logging;
94

105
namespace ComponentsWebAssembly_CSharp.Server.Pages
116
{

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Program.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
using System.Linq;
2-
#if (OrganizationalAuth || IndividualB2CAuth || IndividualLocalAuth)
1+
#if (OrganizationalAuth || IndividualB2CAuth || IndividualLocalAuth)
32
using Microsoft.AspNetCore.Authentication;
43
#endif
54
#if (OrganizationalAuth || IndividualB2CAuth)
65
using Microsoft.AspNetCore.Authentication.JwtBearer;
76
#endif
8-
using Microsoft.AspNetCore.Builder;
9-
using Microsoft.AspNetCore.Hosting;
107
using Microsoft.AspNetCore.ResponseCompression;
118
#if (IndividualLocalAuth)
129
using Microsoft.EntityFrameworkCore;
1310
#endif
14-
using Microsoft.Extensions.Configuration;
15-
using Microsoft.Extensions.DependencyInjection;
16-
using Microsoft.Extensions.Hosting;
1711
#if (GenerateGraph)
1812
using Graph = Microsoft.Graph;
1913
#endif

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Shared/WeatherForecast.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace ComponentsWebAssembly_CSharp.Shared
1+
namespace ComponentsWebAssembly_CSharp.Shared
62
{
73
public class WeatherForecast
84
{

src/ProjectTemplates/Web.ProjectTemplates/content/EmptyWeb-CSharp/Program.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using Microsoft.AspNetCore.Builder;
3-
using Microsoft.Extensions.Hosting;
4-
51
var builder = WebApplication.CreateBuilder(args);
62
var app = builder.Build();
73

src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/Program.cs

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore.Builder;
7-
using Microsoft.AspNetCore.Hosting;
8-
using Microsoft.Extensions.DependencyInjection;
9-
using Microsoft.Extensions.Hosting;
101
using GrpcService_CSharp.Services;
112

123
var builder = WebApplication.CreateBuilder(args);

src/ProjectTemplates/Web.ProjectTemplates/content/GrpcService-CSharp/Services/GreeterService.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Grpc.Core;
6-
using Microsoft.Extensions.Logging;
72
using GrpcService_CSharp;
83

94
namespace GrpcService_CSharp.Services

src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/Areas/MyFeature/Pages/Page1.cshtml.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
62
using Microsoft.AspNetCore.Mvc.RazorPages;
73

84
namespace Company.RazorClassLibrary1.MyFeature.Pages

src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/ExampleJsInterop.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using System.Threading.Tasks;
31
using Microsoft.JSInterop;
42

53
namespace Company.RazorClassLibrary1

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Data/ApplicationDbContext.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
1+
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
52
using Microsoft.EntityFrameworkCore;
63

74
namespace Company.WebApplication1.Data

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Error.cshtml.cs

-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
62
using Microsoft.AspNetCore.Mvc;
73
using Microsoft.AspNetCore.Mvc.RazorPages;
8-
using Microsoft.Extensions.Logging;
94

105
namespace Company.WebApplication1.Pages
116
{

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Index.cshtml.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
#if (GenerateApiOrGraph)
6-
using Microsoft.Extensions.Configuration;
7-
using Microsoft.Identity.Web;
1+
#if (GenerateApiOrGraph)
82
using System.Net;
9-
using System.Net.Http;
103
#endif
4+
using Microsoft.AspNetCore.Mvc;
5+
using Microsoft.AspNetCore.Mvc.RazorPages;
116
#if (GenerateGraph)
127
using Microsoft.Graph;
138
#endif
14-
using Microsoft.AspNetCore.Mvc;
15-
using Microsoft.AspNetCore.Mvc.RazorPages;
16-
using Microsoft.Extensions.Logging;
9+
#if (GenerateApiOrGraph)
10+
using Microsoft.Identity.Web;
11+
#endif
1712

1813
namespace Company.WebApplication1.Pages
1914
{

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Privacy.cshtml.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
62
using Microsoft.AspNetCore.Mvc.RazorPages;
7-
using Microsoft.Extensions.Logging;
83

94
namespace Company.WebApplication1.Pages
105
{

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Program.cs

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
#if (OrganizationalAuth || IndividualB2CAuth)
62
using Microsoft.AspNetCore.Authentication;
7-
using Microsoft.Identity.Web;
8-
using Microsoft.Identity.Web.UI;
93
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
104
using Microsoft.AspNetCore.Authorization;
115
#endif
12-
using Microsoft.AspNetCore.Builder;
13-
using Microsoft.AspNetCore.Hosting;
146
#if (IndividualLocalAuth)
157
using Microsoft.AspNetCore.Identity;
168
#endif
@@ -20,10 +12,10 @@
2012
#if (IndividualLocalAuth)
2113
using Microsoft.EntityFrameworkCore;
2214
#endif
23-
using Microsoft.Extensions.Configuration;
24-
using Microsoft.Extensions.DependencyInjection;
25-
using Microsoft.Extensions.Hosting;
26-
using Microsoft.Extensions.Logging;
15+
#if (OrganizationalAuth || IndividualB2CAuth)
16+
using Microsoft.Identity.Web;
17+
using Microsoft.Identity.Web.UI;
18+
#endif
2719
#if (MultiOrgAuth)
2820
using Microsoft.IdentityModel.Tokens;
2921
#endif

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Controllers/HomeController.cs

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
#if (OrganizationalAuth)
7-
using Microsoft.AspNetCore.Authorization;
8-
#endif
1+
using System.Diagnostics;
92
#if (GenerateApiOrGraph)
10-
using Microsoft.Extensions.Configuration;
11-
using Microsoft.Identity.Web;
123
using System.Net;
13-
using System.Net.Http;
144
#endif
5+
#if (OrganizationalAuth)
6+
using Microsoft.AspNetCore.Authorization;
7+
#endif
8+
using Microsoft.AspNetCore.Mvc;
159
#if (GenerateGraph)
1610
using Microsoft.Graph;
1711
#endif
18-
using Microsoft.AspNetCore.Mvc;
19-
using Microsoft.Extensions.Logging;
12+
#if (GenerateApiOrGraph)
13+
using Microsoft.Identity.Web;
14+
#endif
2015
using Company.WebApplication1.Models;
2116

2217
namespace Company.WebApplication1.Controllers

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Data/ApplicationDbContext.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
1+
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
52
using Microsoft.EntityFrameworkCore;
63

74
namespace Company.WebApplication1.Data

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Models/ErrorViewModel.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace Company.WebApplication1.Models
42
{
53
public class ErrorViewModel

0 commit comments

Comments
 (0)