From 3b20b8614618e21c736fa2210c11d1bb6d56c773 Mon Sep 17 00:00:00 2001 From: Collin Barrett Date: Sat, 1 Jun 2024 14:21:52 -0500 Subject: [PATCH] =?UTF-8?q?refactor(svcs):=20=E2=99=BB=EF=B8=8F?= =?UTF-8?q?=F0=9F=8E=A8=20Rider=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FilterLists.ApiService.csproj | 16 +++---- services/FilterLists.ApiService/Program.cs | 16 +++---- .../FilterLists.AppHost.csproj | 30 ++++++------- services/FilterLists.AppHost/Program.cs | 8 ++-- .../FilterLists.ServiceDefaults/Extensions.cs | 4 +- .../FilterLists.ServiceDefaults.csproj | 32 +++++++------- .../FilterLists.Tests.csproj | 42 +++++++++---------- services/FilterLists.Tests/WebTests.cs | 5 ++- services/FilterLists.Web/Components/App.razor | 22 +++++----- .../Components/Layout/MainLayout.razor | 4 +- .../Components/Layout/MainLayout.razor.css | 36 ++++++++-------- .../Components/Layout/NavMenu.razor | 4 +- .../Components/Layout/NavMenu.razor.css | 34 +++++++-------- .../Components/Pages/Counter.razor | 5 ++- .../Components/Pages/Error.razor | 6 +-- .../Components/Pages/Home.razor | 2 +- .../Components/Pages/Weather.razor | 39 +++++++++-------- .../FilterLists.Web/Components/Routes.razor | 9 ++-- .../FilterLists.Web/Components/_Imports.razor | 2 +- .../FilterLists.Web/FilterLists.Web.csproj | 16 +++---- services/FilterLists.Web/Program.cs | 14 +++---- services/FilterLists.Web/WeatherApiClient.cs | 13 +++--- services/FilterLists.Web/wwwroot/app.css | 6 +-- 23 files changed, 187 insertions(+), 178 deletions(-) diff --git a/services/FilterLists.ApiService/FilterLists.ApiService.csproj b/services/FilterLists.ApiService/FilterLists.ApiService.csproj index 223cc6ed5..62b2b4f44 100644 --- a/services/FilterLists.ApiService/FilterLists.ApiService.csproj +++ b/services/FilterLists.ApiService/FilterLists.ApiService.csproj @@ -1,13 +1,13 @@ - - net8.0 - enable - enable - + + net8.0 + enable + enable + - - - + + + diff --git a/services/FilterLists.ApiService/Program.cs b/services/FilterLists.ApiService/Program.cs index a93ae7419..d945d7e8b 100644 --- a/services/FilterLists.ApiService/Program.cs +++ b/services/FilterLists.ApiService/Program.cs @@ -19,12 +19,12 @@ app.MapGet("/weatherforecast", () => { var forecast = Enumerable.Range(1, 5).Select(index => - new WeatherForecast - ( - DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - Random.Shared.Next(-20, 55), - summaries[Random.Shared.Next(summaries.Length)] - )) + new WeatherForecast + ( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + summaries[Random.Shared.Next(summaries.Length)] + )) .ToArray(); return forecast; }); @@ -33,7 +33,7 @@ app.Run(); -record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) +internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) { public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); -} +} \ No newline at end of file diff --git a/services/FilterLists.AppHost/FilterLists.AppHost.csproj b/services/FilterLists.AppHost/FilterLists.AppHost.csproj index 023b24012..6ff0db685 100644 --- a/services/FilterLists.AppHost/FilterLists.AppHost.csproj +++ b/services/FilterLists.AppHost/FilterLists.AppHost.csproj @@ -1,21 +1,21 @@ - - Exe - net8.0 - enable - enable - true - c7967ef0-ced7-4e18-8282-7302b3c0002b - + + Exe + net8.0 + enable + enable + true + c7967ef0-ced7-4e18-8282-7302b3c0002b + - - - - + + + + - - - + + + diff --git a/services/FilterLists.AppHost/Program.cs b/services/FilterLists.AppHost/Program.cs index 8e6060630..88f517898 100644 --- a/services/FilterLists.AppHost/Program.cs +++ b/services/FilterLists.AppHost/Program.cs @@ -1,9 +1,11 @@ +using Projects; + var builder = DistributedApplication.CreateBuilder(args); -var apiService = builder.AddProject("apiservice"); +var apiService = builder.AddProject("apiservice"); -builder.AddProject("webfrontend") +builder.AddProject("webfrontend") .WithExternalHttpEndpoints() .WithReference(apiService); -builder.Build().Run(); +builder.Build().Run(); \ No newline at end of file diff --git a/services/FilterLists.ServiceDefaults/Extensions.cs b/services/FilterLists.ServiceDefaults/Extensions.cs index ce94dc2c4..09cd4e7d1 100644 --- a/services/FilterLists.ServiceDefaults/Extensions.cs +++ b/services/FilterLists.ServiceDefaults/Extensions.cs @@ -7,6 +7,8 @@ using OpenTelemetry.Metrics; using OpenTelemetry.Trace; +// ReSharper disable All + namespace Microsoft.Extensions.Hosting; // Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry. @@ -108,4 +110,4 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app) return app; } -} +} \ No newline at end of file diff --git a/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj b/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj index 589e39190..0bdf40255 100644 --- a/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj +++ b/services/FilterLists.ServiceDefaults/FilterLists.ServiceDefaults.csproj @@ -1,22 +1,22 @@ - - net8.0 - enable - enable - true - + + net8.0 + enable + enable + true + - - + + - - - - - - - - + + + + + + + + diff --git a/services/FilterLists.Tests/FilterLists.Tests.csproj b/services/FilterLists.Tests/FilterLists.Tests.csproj index 0d62b5534..838b1c87f 100644 --- a/services/FilterLists.Tests/FilterLists.Tests.csproj +++ b/services/FilterLists.Tests/FilterLists.Tests.csproj @@ -1,28 +1,28 @@ - - net8.0 - enable - enable - false - true - + + net8.0 + enable + enable + false + true + - - - - - - - + + + + + + + - - - + + + - - - - + + + + diff --git a/services/FilterLists.Tests/WebTests.cs b/services/FilterLists.Tests/WebTests.cs index d29011311..af53754d9 100644 --- a/services/FilterLists.Tests/WebTests.cs +++ b/services/FilterLists.Tests/WebTests.cs @@ -1,4 +1,5 @@ using System.Net; +using Projects; namespace FilterLists.Tests; @@ -8,7 +9,7 @@ public class WebTests public async Task GetWebResourceRootReturnsOkStatusCode() { // Arrange - var appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + var appHost = await DistributedApplicationTestingBuilder.CreateAsync(); await using var app = await appHost.BuildAsync(); await app.StartAsync(); @@ -19,4 +20,4 @@ public async Task GetWebResourceRootReturnsOkStatusCode() // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); } -} +} \ No newline at end of file diff --git a/services/FilterLists.Web/Components/App.razor b/services/FilterLists.Web/Components/App.razor index c4b91cb20..1cf14661c 100644 --- a/services/FilterLists.Web/Components/App.razor +++ b/services/FilterLists.Web/Components/App.razor @@ -2,19 +2,19 @@ - - - - - - - - + + + + + + + + - - + + - + \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Layout/MainLayout.razor b/services/FilterLists.Web/Components/Layout/MainLayout.razor index 5a24bb137..df0c2d656 100644 --- a/services/FilterLists.Web/Components/Layout/MainLayout.razor +++ b/services/FilterLists.Web/Components/Layout/MainLayout.razor @@ -2,7 +2,7 @@
@@ -20,4 +20,4 @@ An unhandled error has occurred. Reload 🗙 -
+ \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Layout/MainLayout.razor.css b/services/FilterLists.Web/Components/Layout/MainLayout.razor.css index 038baf178..d49e4b7e3 100644 --- a/services/FilterLists.Web/Components/Layout/MainLayout.razor.css +++ b/services/FilterLists.Web/Components/Layout/MainLayout.razor.css @@ -21,20 +21,20 @@ main { align-items: center; } - .top-row ::deep a, .top-row ::deep .btn-link { - white-space: nowrap; - margin-left: 1.5rem; - text-decoration: none; - } +.top-row ::deep a, .top-row ::deep .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + text-decoration: none; +} - .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { - text-decoration: underline; - } +.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { + text-decoration: underline; +} - .top-row ::deep a:first-child { - overflow: hidden; - text-overflow: ellipsis; - } +.top-row ::deep a:first-child { + overflow: hidden; + text-overflow: ellipsis; +} @media (max-width: 640.98px) { .top-row { @@ -88,9 +88,9 @@ main { z-index: 1000; } - #blazor-error-ui .dismiss { - cursor: pointer; - position: absolute; - right: 0.75rem; - top: 0.5rem; - } +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; +} diff --git a/services/FilterLists.Web/Components/Layout/NavMenu.razor b/services/FilterLists.Web/Components/Layout/NavMenu.razor index b19ef87cc..1f19b940a 100644 --- a/services/FilterLists.Web/Components/Layout/NavMenu.razor +++ b/services/FilterLists.Web/Components/Layout/NavMenu.razor @@ -4,7 +4,7 @@ - + - + \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Layout/NavMenu.razor.css b/services/FilterLists.Web/Components/Layout/NavMenu.razor.css index 95fcc36e0..a3263072d 100644 --- a/services/FilterLists.Web/Components/Layout/NavMenu.razor.css +++ b/services/FilterLists.Web/Components/Layout/NavMenu.razor.css @@ -17,7 +17,7 @@ .top-row { height: 3.5rem; - background-color: rgba(0,0,0,0.4); + background-color: rgba(0, 0, 0, 0.4); } .navbar-brand { @@ -51,30 +51,30 @@ padding-bottom: 0.5rem; } - .nav-item:first-of-type { - padding-top: 1rem; - } +.nav-item:first-of-type { + padding-top: 1rem; +} - .nav-item:last-of-type { - padding-bottom: 1rem; - } +.nav-item:last-of-type { + padding-bottom: 1rem; +} - .nav-item ::deep a { - color: #d7d7d7; - border-radius: 4px; - height: 3rem; - display: flex; - align-items: center; - line-height: 3rem; - } +.nav-item ::deep a { + color: #d7d7d7; + border-radius: 4px; + height: 3rem; + display: flex; + align-items: center; + line-height: 3rem; +} .nav-item ::deep a.active { - background-color: rgba(255,255,255,0.37); + background-color: rgba(255, 255, 255, 0.37); color: white; } .nav-item ::deep a:hover { - background-color: rgba(255,255,255,0.1); + background-color: rgba(255, 255, 255, 0.1); color: white; } diff --git a/services/FilterLists.Web/Components/Pages/Counter.razor b/services/FilterLists.Web/Components/Pages/Counter.razor index 1a4f8e755..4f4fa2fbb 100644 --- a/services/FilterLists.Web/Components/Pages/Counter.razor +++ b/services/FilterLists.Web/Components/Pages/Counter.razor @@ -10,10 +10,11 @@ @code { - private int currentCount = 0; + private int currentCount; private void IncrementCount() { currentCount++; } -} + +} \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Pages/Error.razor b/services/FilterLists.Web/Components/Pages/Error.razor index fcaa7c6ef..049dd5b3d 100644 --- a/services/FilterLists.Web/Components/Pages/Error.razor +++ b/services/FilterLists.Web/Components/Pages/Error.razor @@ -25,8 +25,7 @@

@code{ - [CascadingParameter] - public HttpContext? HttpContext { get; set; } + [CascadingParameter] public HttpContext? HttpContext { get; set; } private string? requestId; private bool ShowRequestId => !string.IsNullOrEmpty(requestId); @@ -35,4 +34,5 @@ { requestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; } -} + +} \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Pages/Home.razor b/services/FilterLists.Web/Components/Pages/Home.razor index 9001e0bd2..dfcdf758c 100644 --- a/services/FilterLists.Web/Components/Pages/Home.razor +++ b/services/FilterLists.Web/Components/Pages/Home.razor @@ -4,4 +4,4 @@

Hello, world!

-Welcome to your new app. +Welcome to your new app. \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Pages/Weather.razor b/services/FilterLists.Web/Components/Pages/Weather.razor index 77e18cde4..041a23349 100644 --- a/services/FilterLists.Web/Components/Pages/Weather.razor +++ b/services/FilterLists.Web/Components/Pages/Weather.razor @@ -1,5 +1,5 @@ @page "/weather" -@attribute [StreamRendering(true)] +@attribute [StreamRendering] @attribute [OutputCache(Duration = 5)] @inject WeatherApiClient WeatherApi @@ -12,29 +12,31 @@ @if (forecasts == null) { -

Loading...

+

+ Loading... +

} else { - - - - - - + + + + + + - @foreach (var forecast in forecasts) - { - - - - - - - } + @foreach (var forecast in forecasts) + { + + + + + + + }
DateTemp. (C)Temp. (F)Summary
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
} @@ -46,4 +48,5 @@ else { forecasts = await WeatherApi.GetWeatherAsync(); } -} + +} \ No newline at end of file diff --git a/services/FilterLists.Web/Components/Routes.razor b/services/FilterLists.Web/Components/Routes.razor index d0df78161..d26744705 100644 --- a/services/FilterLists.Web/Components/Routes.razor +++ b/services/FilterLists.Web/Components/Routes.razor @@ -1,6 +1,7 @@ - +@using FilterLists.Web.Components.Layout + - - + + - + \ No newline at end of file diff --git a/services/FilterLists.Web/Components/_Imports.razor b/services/FilterLists.Web/Components/_Imports.razor index fbd4daa45..0912ea7d0 100644 --- a/services/FilterLists.Web/Components/_Imports.razor +++ b/services/FilterLists.Web/Components/_Imports.razor @@ -8,4 +8,4 @@ @using Microsoft.AspNetCore.OutputCaching @using Microsoft.JSInterop @using FilterLists.Web -@using FilterLists.Web.Components +@using FilterLists.Web.Components \ No newline at end of file diff --git a/services/FilterLists.Web/FilterLists.Web.csproj b/services/FilterLists.Web/FilterLists.Web.csproj index 223cc6ed5..62b2b4f44 100644 --- a/services/FilterLists.Web/FilterLists.Web.csproj +++ b/services/FilterLists.Web/FilterLists.Web.csproj @@ -1,13 +1,13 @@ - - net8.0 - enable - enable - + + net8.0 + enable + enable + - - - + + + diff --git a/services/FilterLists.Web/Program.cs b/services/FilterLists.Web/Program.cs index d78409244..abb95173e 100644 --- a/services/FilterLists.Web/Program.cs +++ b/services/FilterLists.Web/Program.cs @@ -13,17 +13,17 @@ builder.Services.AddOutputCache(); builder.Services.AddHttpClient(client => - { - // This URL uses "https+http://" to indicate HTTPS is preferred over HTTP. - // Learn more about service discovery scheme resolution at https://aka.ms/dotnet/sdschemes. - client.BaseAddress = new("https+http://apiservice"); - }); +{ + // This URL uses "https+http://" to indicate HTTPS is preferred over HTTP. + // Learn more about service discovery scheme resolution at https://aka.ms/dotnet/sdschemes. + client.BaseAddress = new Uri("https+http://apiservice"); +}); var app = builder.Build(); if (!app.Environment.IsDevelopment()) { - app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseExceptionHandler("/Error", true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } @@ -40,4 +40,4 @@ app.MapDefaultEndpoints(); -app.Run(); +app.Run(); \ No newline at end of file diff --git a/services/FilterLists.Web/WeatherApiClient.cs b/services/FilterLists.Web/WeatherApiClient.cs index fda4b9ae5..4658f10f9 100644 --- a/services/FilterLists.Web/WeatherApiClient.cs +++ b/services/FilterLists.Web/WeatherApiClient.cs @@ -2,16 +2,15 @@ namespace FilterLists.Web; public class WeatherApiClient(HttpClient httpClient) { - public async Task GetWeatherAsync(int maxItems = 10, CancellationToken cancellationToken = default) + public async Task GetWeatherAsync(int maxItems = 10, + CancellationToken cancellationToken = default) { List? forecasts = null; - await foreach (var forecast in httpClient.GetFromJsonAsAsyncEnumerable("/weatherforecast", cancellationToken)) + await foreach (var forecast in httpClient.GetFromJsonAsAsyncEnumerable("/weatherforecast", + cancellationToken)) { - if (forecasts?.Count >= maxItems) - { - break; - } + if (forecasts?.Count >= maxItems) break; if (forecast is not null) { forecasts ??= []; @@ -26,4 +25,4 @@ public async Task GetWeatherAsync(int maxItems = 10, Cancella public record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) { public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); -} +} \ No newline at end of file diff --git a/services/FilterLists.Web/wwwroot/app.css b/services/FilterLists.Web/wwwroot/app.css index f3c0ba4db..a5503914b 100644 --- a/services/FilterLists.Web/wwwroot/app.css +++ b/services/FilterLists.Web/wwwroot/app.css @@ -20,6 +20,6 @@ h1:focus { color: white; } - .blazor-error-boundary::after { - content: "An error has occurred." - } +.blazor-error-boundary::after { + content: "An error has occurred." +}