Skip to content
Closed
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
32 changes: 16 additions & 16 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/"/>
<Folder Name="/Solution Items/.github/">
<File Path=".github\codeql.yml" />
<File Path=".github\copilot-instructions.md" />
<File Path=".github\dependabot.yml" />
<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" />
<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" />
<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" />
<File Path=".github\workflows\main_astar-dev.yml"/>
</Folder>
<Folder Name="/src/" />
<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" />
<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/"/>
<Folder Name="/src/modules/apis/">
<Project Path="src/modules/apis/AStar.Web.ApiService/AStar.Web.ApiService.csproj" />
<Project Path="src/modules/apis/AStar.Web.ApiService/AStar.Web.ApiService.csproj"/>
</Folder>
<Folder Name="/src/uis/">
<Project Path="src\uis\AStar.Dev.Web\AStar.Dev.Web.csproj" />
<Project Path="src\uis\AStar.Dev.Web\AStar.Dev.Web.csproj"/>
</Folder>
<Folder Name="/test/" />
<Folder Name="/test/"/>
<Folder Name="/test/aspire/">
<Project Path="test/aspire/AStar.Web.Tests/AStar.Web.Tests.csproj" />
<Project Path="test/aspire/AStar.Web.Tests/AStar.Web.Tests.csproj"/>
</Folder>
</Solution>
22 changes: 22 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<InterceptorsNamespaces>
$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated
</InterceptorsNamespaces>
<Features>$(Features);InterceptorsPreview</Features>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1701;1702;</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1701;1702;</NoWarn>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/aspire/AStar.Web.AppHost/AStar.Web.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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

</Project>
2 changes: 1 addition & 1 deletion src/aspire/AStar.Web.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
.WithReference(apiService)
.WaitFor(apiService);

builder.Build().Run();
builder.Build().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="10.0.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.13.1"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.13.1"/>
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.13.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.13.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.14.0"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.14.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.14.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.14.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.14.0"/>
</ItemGroup>

</Project>
28 changes: 13 additions & 15 deletions src/aspire/AStar.Web.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,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)
// options.AllowedSchemes = ["https"];
// });

Expand All @@ -62,11 +62,10 @@
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation(tracing =>
.AddAspNetCoreInstrumentation(instrumentationOptions =>
// Exclude health check requests from tracing
tracing.Filter = context =>
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
instrumentationOptions.Filter = context => !context.Request.Path.StartsWithSegments(HealthEndpointPath)
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
)
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
Expand All @@ -87,7 +86,7 @@

// 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 89 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 All @@ -109,18 +108,17 @@
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath);
if (!app.Environment.IsDevelopment()) return app;

// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath);

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
}
// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});

return app;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0"/>
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0"/>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0"/>
<PackageReference Include="TestableIO.System.IO.Abstractions" Version="22.0.16"/>
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.0.16"/>
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="1.2.0"/>
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 20 additions & 8 deletions src/modules/apis/AStar.Web.ApiService/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
using Asp.Versioning;

var builder = WebApplication.CreateBuilder(args);

// Add service defaults & Aspire client integrations.
builder.AddServiceDefaults();

_ = builder.Services.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(1, 0);
options.AssumeDefaultVersionWhenUnspecified = true;
options.ReportApiVersions = true;
})
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});
// Add services to the container.
builder.Services.AddProblemDetails();

Expand All @@ -23,13 +36,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)]
))
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)]
))
.ToArray();
return forecast;
})
Expand All @@ -37,9 +49,9 @@

app.MapDefaultEndpoints();

app.Run();

Check warning on line 52 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)

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

Check warning on line 54 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);
}
}
35 changes: 32 additions & 3 deletions src/uis/AStar.Dev.Web/AStar.Dev.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<UserSecretsId>d7e61e34-084f-4c2b-9be8-5925170dc3b7</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.4.0"/>
<PackageReference Include="FluentUI.Demo.Shared" Version="4.10.4"/>
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2"/>
<PackageReference Include="Markdig" Version="0.43.0"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.0"/>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.23.0"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.0"/>
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.13.1"/>
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.13.1"/>
<PackageReference Include="Microsoft.Identity.Web" Version="4.0.1"/>
<PackageReference Include="Microsoft.Identity.Web.UI" Version="4.0.1"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.14.0"/>
<PackageReference Include="Scalar.AspNetCore" Version="2.10.3"/>
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="22.0.16"/>
<PackageReference Include="Testably.Abstractions.FileSystem.Interface" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.0.0"/>
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="1.2.0"/>
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\assets\"/>
</ItemGroup>

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

<ItemGroup>
<Using Include="JetBrains.Annotations"/>
</ItemGroup>

</Project>
47 changes: 40 additions & 7 deletions src/uis/AStar.Dev.Web/Components/App.razor
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<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.Dev.Web.styles.css"]"/>
<ImportMap/>
<link rel="icon" type="image/png" href="favicon.png"/>
<HeadOutlet/>
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<HeadOutlet @rendermode="InteractiveServer"/>
<script src="_content/Microsoft.FluentUI.AspNetCore.Components/js/loading-theme.js" type="text/javascript"></script>
<loading-theme storage-name="theme"></loading-theme>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>
window.highlightMarkdown = () => {
if (window.hljs) {
window.hljs.highlightAll();
}
};
</script>
<!-- Add marked (Markdown parser) and DOMPurify (sanitizer) -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script>
<script>
// md: markdown text
// allowHtml: when true, bypass sanitizer (only do this if you trust the source)
window.renderMarkdown = (md, allowHtml) => {
const html = window.marked?.parse(md ?? "") ?? "";
if (allowHtml) {
return html;
}
// Sanitize, but allow common code/formatting tags and classes used by highlight.js
const cfg = {
ALLOWED_TAGS: [
'pre', 'code', 'span', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'ul', 'ol', 'li', 'a', 'strong', 'em', 'table', 'thead', 'tbody',
'tr', 'th', 'td', 'blockquote', 'hr', 'br', 'img'
],
ALLOWED_ATTR: ['href', 'title', 'alt', 'class', 'rel', 'target', 'src']
};
return window.DOMPurify ? window.DOMPurify.sanitize(html, cfg) : html;
};
</script>
</head>

<body>
<Routes/>
<script src="@Assets["_framework/blazor.web.js"]"></script>
<Routes @rendermode="InteractiveServer"/>
<script src="_framework/blazor.web.js"></script>
</body>

</html>
</html>
6 changes: 6 additions & 0 deletions src/uis/AStar.Dev.Web/Components/App.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace AStar.Dev.Web.Components;

public partial class App
{
public static string PageTitle(string page) => $"{page} - AStar Development";
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

48 changes: 30 additions & 18 deletions src/uis/AStar.Dev.Web/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
@inherits LayoutComponentBase
@using Microsoft.FluentUI.AspNetCore.Components.Icons.Regular
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu/>
</div>
<FluentLayout>
<FluentHeader>
<img src="@Assets["assets/astar-logo.png"]" alt="AStar.Dev" style="height: 40px;"/>
<FluentSpacer/>
<FluentButton Appearance="Appearance.Stealth"
IconStart="@(new Size20.Settings())"
@onclick="OpenSettingsDialog"
Title="Settings"/>

<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
</FluentHeader>
<FluentStack Class="main" Orientation="Orientation.Horizontal" Width="100%">
<NavMenu/>
<FluentBodyContent Class="body-content">
<div class="content">
@Body
</div>
</FluentBodyContent>
</FluentStack>
<FluentFooter>
<FluentStack Orientation="Orientation.Horizontal" HorizontalAlignment="HorizontalAlignment.Center" Width="100%">
Copyright ©: AStar Development, 2009 - @(DateTime.Now.Year)
</FluentStack>
</FluentFooter>
</FluentLayout>

<article class="content px-4">
@Body
</article>
</main>
</div>
<SettingsPanel IsOpen="_settingsPanelOpen" OnClose="CloseSettingsPanel"/>

<div id="blazor-error-ui">
<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
10 changes: 10 additions & 0 deletions src/uis/AStar.Dev.Web/Components/Layout/MainLayout.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace AStar.Dev.Web.Components.Layout;

public partial class MainLayout
{
private bool _settingsPanelOpen;

private void OpenSettingsDialog() => _settingsPanelOpen = true;

private void CloseSettingsPanel() => _settingsPanelOpen = false;
}
Loading
Loading