Skip to content

Commit 8d70305

Browse files
committed
Update SPA templates to use file-scoped namesapces
#33947
1 parent 9d28720 commit 8d70305

File tree

12 files changed

+138
-150
lines changed

12 files changed

+138
-150
lines changed

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Controllers/OidcConfigurationController.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
using Microsoft.AspNetCore.Mvc;
33
using Microsoft.Extensions.Logging;
44

5-
namespace Company.WebApplication1.Controllers
5+
namespace Company.WebApplication1.Controllers;
6+
7+
public class OidcConfigurationController : Controller
68
{
7-
public class OidcConfigurationController : Controller
8-
{
9-
private readonly ILogger<OidcConfigurationController> _logger;
9+
private readonly ILogger<OidcConfigurationController> _logger;
1010

11-
public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger<OidcConfigurationController> logger)
12-
{
13-
ClientRequestParametersProvider = clientRequestParametersProvider;
14-
_logger = logger;
15-
}
11+
public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger<OidcConfigurationController> logger)
12+
{
13+
ClientRequestParametersProvider = clientRequestParametersProvider;
14+
_logger = logger;
15+
}
1616

17-
public IClientRequestParametersProvider ClientRequestParametersProvider { get; }
17+
public IClientRequestParametersProvider ClientRequestParametersProvider { get; }
1818

19-
[HttpGet("_configuration/{clientId}")]
20-
public IActionResult GetClientRequestParameters([FromRoute]string clientId)
21-
{
22-
var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId);
23-
return Ok(parameters);
24-
}
19+
[HttpGet("_configuration/{clientId}")]
20+
public IActionResult GetClientRequestParameters([FromRoute]string clientId)
21+
{
22+
var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId);
23+
return Ok(parameters);
2524
}
2625
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Controllers/WeatherForecastController.cs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88
using Microsoft.AspNetCore.Mvc;
99
using Microsoft.Extensions.Logging;
1010

11-
namespace Company.WebApplication1.Controllers
12-
{
11+
namespace Company.WebApplication1.Controllers;
12+
1313
#if (!NoAuth)
14-
[Authorize]
14+
[Authorize]
1515
#endif
16-
[ApiController]
17-
[Route("[controller]")]
18-
public class WeatherForecastController : ControllerBase
16+
[ApiController]
17+
[Route("[controller]")]
18+
public class WeatherForecastController : ControllerBase
19+
{
20+
private static readonly string[] Summaries = new[]
1921
{
20-
private static readonly string[] Summaries = new[]
21-
{
22-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
23-
};
22+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
23+
};
2424

25-
private readonly ILogger<WeatherForecastController> _logger;
25+
private readonly ILogger<WeatherForecastController> _logger;
2626

27-
public WeatherForecastController(ILogger<WeatherForecastController> logger)
28-
{
29-
_logger = logger;
30-
}
27+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
28+
{
29+
_logger = logger;
30+
}
3131

32-
[HttpGet]
33-
public IEnumerable<WeatherForecast> Get()
32+
[HttpGet]
33+
public IEnumerable<WeatherForecast> Get()
34+
{
35+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
3436
{
35-
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
36-
{
37-
Date = DateTime.Now.AddDays(index),
38-
TemperatureC = Random.Shared.Next(-20, 55),
39-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
40-
})
41-
.ToArray();
42-
}
37+
Date = DateTime.Now.AddDays(index),
38+
TemperatureC = Random.Shared.Next(-20, 55),
39+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
40+
})
41+
.ToArray();
4342
}
4443
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Data/ApplicationDbContext.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
using System.Linq;
99
using System.Threading.Tasks;
1010

11-
namespace Company.WebApplication1.Data
11+
namespace Company.WebApplication1.Data;
12+
13+
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser>
1214
{
13-
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser>
15+
public ApplicationDbContext(
16+
DbContextOptions options,
17+
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
1418
{
15-
public ApplicationDbContext(
16-
DbContextOptions options,
17-
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
18-
{
19-
}
2019
}
2120
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/Angular-CSharp/Models/ApplicationUser.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
using System.Linq;
55
using System.Threading.Tasks;
66

7-
namespace Company.WebApplication1.Models
7+
namespace Company.WebApplication1.Models;
8+
9+
public class ApplicationUser : IdentityUser
810
{
9-
public class ApplicationUser : IdentityUser
10-
{
11-
}
1211
}

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,24 @@
77
using Microsoft.AspNetCore.Mvc.RazorPages;
88
using Microsoft.Extensions.Logging;
99

10-
namespace Company.WebApplication1.Pages
10+
namespace Company.WebApplication1.Pages;
11+
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
public class ErrorModel : PageModel
1114
{
12-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13-
public class ErrorModel : PageModel
14-
{
15-
private readonly ILogger<ErrorModel> _logger;
15+
private readonly ILogger<ErrorModel> _logger;
1616

17-
public ErrorModel(ILogger<ErrorModel> logger)
18-
{
19-
_logger = logger;
20-
}
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
2121

22-
public string? RequestId { get; set; }
22+
public string? RequestId { get; set; }
2323

24-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
24+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
2525

26-
public void OnGet()
27-
{
28-
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
29-
}
26+
public void OnGet()
27+
{
28+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
3029
}
3130
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using System;
22

3-
namespace Company.WebApplication1
3+
namespace Company.WebApplication1;
4+
5+
public class WeatherForecast
46
{
5-
public class WeatherForecast
6-
{
7-
public DateTime Date { get; set; }
7+
public DateTime Date { get; set; }
88

9-
public int TemperatureC { get; set; }
9+
public int TemperatureC { get; set; }
1010

11-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1212

13-
public string? Summary { get; set; }
14-
}
13+
public string? Summary { get; set; }
1514
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Controllers/OidcConfigurationController.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
22
using Microsoft.AspNetCore.Mvc;
33
using Microsoft.Extensions.Logging;
44

5-
namespace Company.WebApplication1.Controllers
5+
namespace Company.WebApplication1.Controllers;
6+
7+
public class OidcConfigurationController : Controller
68
{
7-
public class OidcConfigurationController : Controller
8-
{
9-
private readonly ILogger<OidcConfigurationController> _logger;
9+
private readonly ILogger<OidcConfigurationController> _logger;
1010

11-
public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger<OidcConfigurationController> logger)
12-
{
13-
ClientRequestParametersProvider = clientRequestParametersProvider;
14-
_logger = logger;
15-
}
11+
public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger<OidcConfigurationController> logger)
12+
{
13+
ClientRequestParametersProvider = clientRequestParametersProvider;
14+
_logger = logger;
15+
}
1616

17-
public IClientRequestParametersProvider ClientRequestParametersProvider { get; }
17+
public IClientRequestParametersProvider ClientRequestParametersProvider { get; }
1818

19-
[HttpGet("_configuration/{clientId}")]
20-
public IActionResult GetClientRequestParameters([FromRoute]string clientId)
21-
{
22-
var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId);
23-
return Ok(parameters);
24-
}
19+
[HttpGet("_configuration/{clientId}")]
20+
public IActionResult GetClientRequestParameters([FromRoute]string clientId)
21+
{
22+
var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId);
23+
return Ok(parameters);
2524
}
2625
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Controllers/WeatherForecastController.cs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88
using Microsoft.AspNetCore.Mvc;
99
using Microsoft.Extensions.Logging;
1010

11-
namespace Company.WebApplication1.Controllers
12-
{
11+
namespace Company.WebApplication1.Controllers;
12+
1313
#if (!NoAuth)
14-
[Authorize]
14+
[Authorize]
1515
#endif
16-
[ApiController]
17-
[Route("[controller]")]
18-
public class WeatherForecastController : ControllerBase
16+
[ApiController]
17+
[Route("[controller]")]
18+
public class WeatherForecastController : ControllerBase
19+
{
20+
private static readonly string[] Summaries = new[]
1921
{
20-
private static readonly string[] Summaries = new[]
21-
{
22-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
23-
};
22+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
23+
};
2424

25-
private readonly ILogger<WeatherForecastController> _logger;
25+
private readonly ILogger<WeatherForecastController> _logger;
2626

27-
public WeatherForecastController(ILogger<WeatherForecastController> logger)
28-
{
29-
_logger = logger;
30-
}
27+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
28+
{
29+
_logger = logger;
30+
}
3131

32-
[HttpGet]
33-
public IEnumerable<WeatherForecast> Get()
32+
[HttpGet]
33+
public IEnumerable<WeatherForecast> Get()
34+
{
35+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
3436
{
35-
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
36-
{
37-
Date = DateTime.Now.AddDays(index),
38-
TemperatureC = Random.Shared.Next(-20, 55),
39-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
40-
})
41-
.ToArray();
42-
}
37+
Date = DateTime.Now.AddDays(index),
38+
TemperatureC = Random.Shared.Next(-20, 55),
39+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
40+
})
41+
.ToArray();
4342
}
4443
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Data/ApplicationDbContext.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
using System.Linq;
99
using System.Threading.Tasks;
1010

11-
namespace Company.WebApplication1.Data
11+
namespace Company.WebApplication1.Data;
12+
13+
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser>
1214
{
13-
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser>
15+
public ApplicationDbContext(
16+
DbContextOptions options,
17+
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
1418
{
15-
public ApplicationDbContext(
16-
DbContextOptions options,
17-
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
18-
{
19-
}
2019
}
2120
}

src/ProjectTemplates/Web.Spa.ProjectTemplates/content/React-CSharp/Models/ApplicationUser.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
using System.Linq;
55
using System.Threading.Tasks;
66

7-
namespace Company.WebApplication1.Models
7+
namespace Company.WebApplication1.Models;
8+
9+
public class ApplicationUser : IdentityUser
810
{
9-
public class ApplicationUser : IdentityUser
10-
{
11-
}
1211
}

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,24 @@
77
using Microsoft.AspNetCore.Mvc.RazorPages;
88
using Microsoft.Extensions.Logging;
99

10-
namespace Company.WebApplication1.Pages
10+
namespace Company.WebApplication1.Pages;
11+
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
public class ErrorModel : PageModel
1114
{
12-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13-
public class ErrorModel : PageModel
14-
{
15-
private readonly ILogger<ErrorModel> _logger;
15+
private readonly ILogger<ErrorModel> _logger;
1616

17-
public ErrorModel(ILogger<ErrorModel> logger)
18-
{
19-
_logger = logger;
20-
}
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
2121

22-
public string? RequestId { get; set; }
22+
public string? RequestId { get; set; }
2323

24-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
24+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
2525

26-
public void OnGet()
27-
{
28-
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
29-
}
26+
public void OnGet()
27+
{
28+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
3029
}
3130
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using System;
22

3-
namespace Company.WebApplication1
3+
namespace Company.WebApplication1;
4+
5+
public class WeatherForecast
46
{
5-
public class WeatherForecast
6-
{
7-
public DateTime Date { get; set; }
7+
public DateTime Date { get; set; }
88

9-
public int TemperatureC { get; set; }
9+
public int TemperatureC { get; set; }
1010

11-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1212

13-
public string? Summary { get; set; }
14-
}
13+
public string? Summary { get; set; }
1514
}

0 commit comments

Comments
 (0)