Skip to content
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
144 changes: 94 additions & 50 deletions .github/copilot-instructions.md

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions .github/instructions/blazor.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ applyTo: '**/*.razor, **/*.razor.cs, **/*.razor.css'
## Error Handling and Validation

- Implement proper error handling for Blazor pages and API calls.
- Use logging for error tracking in the backend and consider capturing UI-level errors in Blazor with tools like ErrorBoundary.
- Use logging for error tracking in the backend and consider capturing UI-level errors in Blazor with tools like
ErrorBoundary.
- Implement validation using FluentValidation or DataAnnotations in forms.

## Blazor API and Performance Optimization
Expand All @@ -42,17 +43,23 @@ applyTo: '**/*.razor, **/*.razor.cs, **/*.razor.css'

## Caching Strategies

- Implement in-memory caching for frequently used data, especially for Blazor Server apps. Use IMemoryCache for lightweight caching solutions.
- Implement in-memory caching for frequently used data, especially for Blazor Server apps. Use IMemoryCache for
lightweight caching solutions.
- For Blazor WebAssembly, utilize localStorage or sessionStorage to cache application state between user sessions.
- Consider Distributed Cache strategies (like Redis or SQL Server Cache) for larger applications that need shared state across multiple users or clients.
- Cache API calls by storing responses to avoid redundant calls when data is unlikely to change, thus improving the user experience.
- Consider Distributed Cache strategies (like Redis or SQL Server Cache) for larger applications that need shared state
across multiple users or clients.
- Cache API calls by storing responses to avoid redundant calls when data is unlikely to change, thus improving the user
experience.

## State Management Libraries

- Use Blazor's built-in Cascading Parameters and EventCallbacks for basic state sharing across components.
- Implement advanced state management solutions using libraries like Fluxor or BlazorState when the application grows in complexity.
- For client-side state persistence in Blazor WebAssembly, consider using Blazored.LocalStorage or Blazored.SessionStorage to maintain state between page reloads.
- For server-side Blazor, use Scoped Services and the StateContainer pattern to manage state within user sessions while minimizing re-renders.
- Implement advanced state management solutions using libraries like Fluxor or BlazorState when the application grows in
complexity.
- For client-side state persistence in Blazor WebAssembly, consider using Blazored.LocalStorage or
Blazored.SessionStorage to maintain state between page reloads.
- For server-side Blazor, use Scoped Services and the StateContainer pattern to manage state within user sessions while
minimizing re-renders.

## API Design and Integration

Expand All @@ -64,13 +71,16 @@ applyTo: '**/*.razor, **/*.razor.cs, **/*.razor.css'
- All unit testing and integration testing should be done in Visual Studio Enterprise.
- Test Blazor components and services using xUnit.V3 and bUnit for component testing.
- Use NSubstitute for mocking dependencies during tests.
- Use Shouldly for fluent assertions in tests. Fallback to xUnit built-in assertions when Shouldly does not provide the needed functionality.
- Debug Blazor UI issues using browser developer tools and Visual Studio's debugging tools for backend and server-side issues.
- Use Shouldly for fluent assertions in tests. Fallback to xUnit built-in assertions when Shouldly does not provide the
needed functionality.
- Debug Blazor UI issues using browser developer tools and Visual Studio's debugging tools for backend and server-side
issues.
- For performance profiling and optimization, rely on Visual Studio's diagnostics tools.

## Security and Authentication

- Implement Authentication and Authorization in the Blazor app where necessary using ASP.NET Identity or JWT tokens for API authentication.
- Implement Authentication and Authorization in the Blazor app where necessary using ASP.NET Identity or JWT tokens for
API authentication.
- Use HTTPS for all web communication and ensure proper CORS policies are implemented.

## API Documentation and Scalar
Expand Down
3 changes: 2 additions & 1 deletion .github/prompts/astar.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ description: 'Create ASP.NET Minimal API endpoints with proper OpenAPI documenta

# ASP.NET Minimal API with OpenAPI

Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.
Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive
OpenAPI/Swagger documentation.

## API Organization

Expand Down
6 changes: 4 additions & 2 deletions .github/prompts/xunit.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ description: 'Get best practices for XUnit unit testing, including data-driven t

# XUnit Best Practices

Your goal is to help me write effective unit tests with XUnit.V3, covering both standard and data-driven testing approaches.
Your goal is to help me write effective unit tests with XUnit.V3, covering both standard and data-driven testing
approaches.

## Project Setup

Expand Down Expand Up @@ -48,7 +49,8 @@ Your goal is to help me write effective unit tests with XUnit.V3, covering both

## Assertions

- Use the `Shouldly` NuGet package for more readable assertions. Only use the xUnit built-in assertions when Shouldly does not provide the needed functionality.
- Use the `Shouldly` NuGet package for more readable assertions. Only use the xUnit built-in assertions when Shouldly
does not provide the needed functionality.
- Use `Assert.Equal` for value equality
- Use `Assert.Same` for reference equality
- Use `Assert.True`/`Assert.False` for boolean conditions
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main_astar-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'

- name: 🛠 Set up JDK 17
uses: actions/setup-java@v4
with:
Expand Down
64 changes: 32 additions & 32 deletions AStar.Web.slnx
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Solution>
<Folder Name="/Solution Items/" />
<Folder Name="/Solution Items/.github/">
<File Path=".github\codeql.yml" />
<File Path=".github\copilot-instructions.md" />
<File Path=".github\dependabot.yml" />
</Folder>
<Folder Name="/Solution Items/.github/instructions/">
<File Path=".github\instructions\blazor.instructions.md" />
</Folder>
<Folder Name="/Solution Items/.github/prompts/">
<File Path=".github\prompts\astar.prompt.md" />
<File Path=".github\prompts\xunit.prompt.md" />
</Folder>
<Folder Name="/Solution Items/.github/workflows/">
<File Path=".github\workflows\main_astar-dev.yml" />
</Folder>
<Folder Name="/src/" />
<Folder Name="/src/aspire/">
<Project Path="src/aspire/AStar.Web.AppHost/AStar.Web.AppHost.csproj" />
<Project Path="src/aspire/AStar.Web.ServiceDefaults/AStar.Web.ServiceDefaults.csproj" />
</Folder>
<Folder Name="/src/modules/" />
<Folder Name="/src/modules/apis/">
<Project Path="src/modules/apis/AStar.Web.ApiService/AStar.Web.ApiService.csproj" />
</Folder>
<Folder Name="/src/uis/">
<Project Path="src/uis/AStar.Web.Web/AStar.Web.Web.csproj" />
</Folder>
<Folder Name="/test/" />
<Folder Name="/test/aspire/">
<Project Path="test/aspire/AStar.Web.Tests/AStar.Web.Tests.csproj" />
</Folder>
<Folder Name="/Solution Items/"/>
<Folder Name="/Solution Items/.github/">
<File Path=".github\codeql.yml"/>
<File Path=".github\copilot-instructions.md"/>
<File Path=".github\dependabot.yml"/>
</Folder>
<Folder Name="/Solution Items/.github/instructions/">
<File Path=".github\instructions\blazor.instructions.md"/>
</Folder>
<Folder Name="/Solution Items/.github/prompts/">
<File Path=".github\prompts\astar.prompt.md"/>
<File Path=".github\prompts\xunit.prompt.md"/>
</Folder>
<Folder Name="/Solution Items/.github/workflows/">
<File Path=".github\workflows\main_astar-dev.yml"/>
</Folder>
<Folder Name="/src/"/>
<Folder Name="/src/aspire/">
<Project Path="src/aspire/AStar.Web.AppHost/AStar.Web.AppHost.csproj"/>
<Project Path="src/aspire/AStar.Web.ServiceDefaults/AStar.Web.ServiceDefaults.csproj"/>
</Folder>
<Folder Name="/src/modules/"/>
<Folder Name="/src/modules/apis/">
<Project Path="src/modules/apis/AStar.Web.ApiService/AStar.Web.ApiService.csproj"/>
</Folder>
<Folder Name="/src/uis/">
<Project Path="src\uis\AStar.Web\AStar.Web.csproj"/>
</Folder>
<Folder Name="/test/"/>
<Folder Name="/test/aspire/">
<Project Path="test/aspire/AStar.Web.Tests/AStar.Web.Tests.csproj"/>
</Folder>
</Solution>
4 changes: 2 additions & 2 deletions src/aspire/AStar.Web.AppHost/AStar.Web.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\modules\apis\AStar.Web.ApiService\AStar.Web.ApiService.csproj" />
<ProjectReference Include="..\..\uis\AStar.Web.Web\AStar.Web.Web.csproj" />
<ProjectReference Include="..\..\modules\apis\AStar.Web.ApiService\AStar.Web.ApiService.csproj"/>
<ProjectReference Include="..\..\uis\AStar.Web\AStar.Web.csproj"/>
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions src/aspire/AStar.Web.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Projects;

var builder = DistributedApplication.CreateBuilder(args);

var apiService = builder.AddProject<Projects.AStar_Web_ApiService>("apiservice")
var apiService = builder.AddProject<AStar_Web_ApiService>("apiservice")
.WithHttpHealthCheck("/health");

builder.AddProject<Projects.AStar_Web_Web>("webfrontend")
builder.AddProject<AStar_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithHttpHealthCheck("/health")
.WithReference(apiService)
.WaitFor(apiService);

Expand Down
6 changes: 1 addition & 5 deletions src/aspire/AStar.Web.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
Expand Down Expand Up @@ -37,7 +36,7 @@

// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {

Check warning on line 39 in src/aspire/AStar.Web.ServiceDefaults/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)

Check warning on line 39 in src/aspire/AStar.Web.ServiceDefaults/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
// options.AllowedSchemes = ["https"];
// });

Expand Down Expand Up @@ -84,14 +83,11 @@
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}
if (useOtlpExporter) builder.Services.AddOpenTelemetry().UseOtlpExporter();

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{

Check warning on line 90 in src/aspire/AStar.Web.ServiceDefaults/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)

Check warning on line 90 in src/aspire/AStar.Web.ServiceDefaults/Extensions.cs

View workflow job for this annotation

GitHub Actions / build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\aspire\AStar.Web.ServiceDefaults\AStar.Web.ServiceDefaults.csproj" />
<ProjectReference Include="..\..\..\aspire\AStar.Web.ServiceDefaults\AStar.Web.ServiceDefaults.csproj"/>
</ItemGroup>

</Project>
7 changes: 2 additions & 5 deletions src/modules/apis/AStar.Web.ApiService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
// Configure the HTTP request pipeline.
app.UseExceptionHandler();

if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
if (app.Environment.IsDevelopment()) app.MapOpenApi();

string[] summaries =
["Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"];
Expand All @@ -40,9 +37,9 @@

app.MapDefaultEndpoints();

app.Run();

Check warning on line 40 in src/modules/apis/AStar.Web.ApiService/Program.cs

View workflow job for this annotation

GitHub Actions / build

Await RunAsync instead. (https://rules.sonarsource.com/csharp/RSPEC-6966)

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)

Check warning on line 42 in src/modules/apis/AStar.Web.ApiService/Program.cs

View workflow job for this annotation

GitHub Actions / build

Move 'WeatherForecast' into a named namespace. (https://rules.sonarsource.com/csharp/RSPEC-3903)

Check warning on line 42 in src/modules/apis/AStar.Web.ApiService/Program.cs

View workflow job for this annotation

GitHub Actions / build

Move 'WeatherForecast' into a named namespace. (https://rules.sonarsource.com/csharp/RSPEC-3903)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
6 changes: 0 additions & 6 deletions src/uis/AStar.Web.Web/Components/Routes.razor

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\aspire\AStar.Web.ServiceDefaults\AStar.Web.ServiceDefaults.csproj" />
<ProjectReference Include="..\..\aspire\AStar.Web.ServiceDefaults\AStar.Web.ServiceDefaults.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<base href="/"/>
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]"/>
<link rel="stylesheet" href="@Assets["app.css"]"/>
<link rel="stylesheet" href="@Assets["AStar.Web.Web.styles.css"]"/>
<link rel="stylesheet" href="@Assets["AStar.Web.styles.css"]"/>
<ImportMap/>
<link rel="icon" type="image/png" href="favicon.png"/>
<HeadOutlet/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

.top-row {
min-height: 3.5rem;
background-color: rgba(0,0,0,0.4);
background-color: rgba(0, 0, 0, 0.4);
}

.navbar-brand {
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;
private int currentCount;

private void IncrementCount()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
Swapping to <strong>Development</strong> environment will display more detailed information about the error that
occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong>
environment variable to <strong>Development</strong>
and restarting the app.
</p>

Expand Down
Loading
Loading