Skip to content

Commit 22e35c8

Browse files
committed
refactor: tidyed up and replaced some missing usings
1 parent cc86bfd commit 22e35c8

5 files changed

Lines changed: 22 additions & 18 deletions

File tree

src/src/AspireC4/AspireC4.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<PropertyGroup>
33
<IsPackable>true</IsPackable>
44
<AssemblyTitle>AspireC4 Hosting</AssemblyTitle>
5-
<Description>Aspire hosting extensions for the AspireC4 plugin: builder API, lifecycle hook, and server resource.</Description>
6-
<COPYRIGHT_YEAR>2025</COPYRIGHT_YEAR>
5+
<Description>Aspire hosting extensions for the AspireC4 plugin, generating dynamic a LikeC4 model for your Aspire application.</Description>
6+
<COPYRIGHT_YEAR>2026</COPYRIGHT_YEAR>
77
<PackageId>AspireC4</PackageId>
8-
<Title>AspireC4 - Aspire LikeC4 Visualization</Title>
8+
<Title>AspireC4 - Aspire LikeC4 Visualisation</Title>
99
<Authors>Kieron Lanning</Authors>
1010
<Company>KJL Solutions Ltd.</Company>
1111
<Copyright>KJL Solutions Ltd., $(COPYRIGHT_YEAR) | All rights reserved.</Copyright>
1212
<PackageIcon>kjldev-logo.png</PackageIcon>
1313
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
1414
<PackageReadmeFile>README.md</PackageReadmeFile>
1515
<PackageProjectUrl>https://github.com/kjldev/aspirec4</PackageProjectUrl>
16-
<PackageTags>aspire;dotnet;aspnetcore;c4;likec4;architecture;diagram;visualization;</PackageTags>
16+
<PackageTags>aspire;dotnet;aspnetcore;c4;likec4;architecture;diagram;visualisation;visualization;</PackageTags>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

src/src/AspireC4/AspireC4Builder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public IAspireC4Builder WithoutConfigFileGeneration()
142142
/// On non-Windows the path is returned unchanged.
143143
/// </remarks>
144144
internal static string NormalizeBindMountPath(string absolutePath) =>
145-
NormalizeBindMountPath(absolutePath, _containerRuntime.Value);
145+
NormalizeBindMountPath(absolutePath, ContainerRuntime.Value);
146146

147147
/// <summary>Overload with an explicit runtime — used by unit tests to avoid
148148
/// spawning a <c>docker</c> process.</summary>
@@ -153,7 +153,7 @@ internal static string NormalizeBindMountPath(string absolutePath, ContainerRunt
153153
// Rancher Desktop exposes Windows drives under /mnt/<letter>/ inside WSL2.
154154
// CA1308: intentional — Linux paths require lower-case.
155155
if (
156-
runtime == ContainerRuntime.RancherDesktop
156+
runtime == AspireC4.ContainerRuntime.RancherDesktop
157157
&& fullPath.Length >= 2
158158
&& char.IsAsciiLetter(fullPath[0])
159159
&& fullPath[1] == ':'
@@ -171,7 +171,7 @@ internal static string NormalizeBindMountPath(string absolutePath, ContainerRunt
171171
return fullPath;
172172
}
173173

174-
static readonly Lazy<ContainerRuntime> _containerRuntime = new(
174+
static readonly Lazy<ContainerRuntime> ContainerRuntime = new(
175175
DetectContainerRuntime,
176176
LazyThreadSafetyMode.ExecutionAndPublication
177177
);
@@ -184,12 +184,12 @@ internal static string NormalizeBindMountPath(string absolutePath, ContainerRunt
184184
internal static ContainerRuntime DetectContainerRuntime()
185185
{
186186
if (!OperatingSystem.IsWindows())
187-
return ContainerRuntime.Linux;
187+
return AspireC4.ContainerRuntime.Linux;
188188

189189
// If Podman is explicitly requested, podman.exe handles path translation itself.
190190
var runtimeEnv = Environment.GetEnvironmentVariable("ASPIRE_CONTAINER_RUNTIME");
191191
if (runtimeEnv?.Equals("podman", StringComparison.OrdinalIgnoreCase) == true)
192-
return ContainerRuntime.Podman;
192+
return AspireC4.ContainerRuntime.Podman;
193193

194194
// Query the Docker daemon OS string to distinguish Docker Desktop from Rancher Desktop.
195195
try
@@ -210,11 +210,11 @@ internal static ContainerRuntime DetectContainerRuntime()
210210
var os = process?.StandardOutput.ReadToEnd().Trim() ?? "";
211211

212212
if (os.Contains("Rancher Desktop", StringComparison.OrdinalIgnoreCase))
213-
return ContainerRuntime.RancherDesktop;
213+
return AspireC4.ContainerRuntime.RancherDesktop;
214214
}
215215
catch { }
216216

217-
return ContainerRuntime.DockerDesktop;
217+
return AspireC4.ContainerRuntime.DockerDesktop;
218218
}
219219

220220
static LikeC4LocalCLIRuntime DetectRuntime()

src/tests/AspireC4.IntegrationTests/AspireC4.IntegrationTests.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<DisableGenerateAssemblyInfoClass>true</DisableGenerateAssemblyInfoClass>
44
</PropertyGroup>
@@ -12,7 +12,6 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<!--<ProjectReference Include="..\..\src\AspireC4\AspireC4.csproj" />-->
1615
<ProjectReference Include="..\AspireC4.TestAppHost\AspireC4.TestAppHost.csproj" />
1716
</ItemGroup>
1817

src/tests/AspireC4.IntegrationTests/AspireC4HostTests.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static async Task ClassSetUpAsync(CancellationToken cancellationToken)
5353
// configure callback that sets ValidateBeforeStart=true and the default FormatGeneratedFile=true.
5454
// Both invoke `npx likec4 …` which traverses up the directory tree and scans the entire
5555
// repository workspace when run from within the repo — hanging the BeforeStartEvent handler.
56-
appBuilder.Services.PostConfigure<AspireC4DiagramOptions>(opts =>
56+
appBuilder.Services.PostConfigure<AspireC4DiagramOptions>(static opts =>
5757
{
5858
opts.ValidateBeforeStart = false;
5959
opts.FormatGeneratedFile = false;
@@ -257,7 +257,7 @@ public async Task GeneratedAndAdditionalDSLFiles_PassLikeC4Validate(Cancellation
257257
CancellationToken cancellationToken
258258
)
259259
{
260-
var useDotFlag = IsDotAvailable() ? " --use-dot" : "";
260+
var useDotFlag = await IsDotAvailableAsync(cancellationToken) ? " --use-dot" : "";
261261

262262
string shellFile,
263263
shellArgs;
@@ -312,7 +312,7 @@ CancellationToken cancellationToken
312312
"CA1031:Do not catch general exception types",
313313
Justification = "dot availability check is best-effort; any failure means dot is unavailable"
314314
)]
315-
static bool IsDotAvailable()
315+
static async Task<bool> IsDotAvailableAsync(CancellationToken cancellationToken)
316316
{
317317
try
318318
{
@@ -326,8 +326,12 @@ static bool IsDotAvailable()
326326
CreateNoWindow = true,
327327
}
328328
);
329-
proc?.WaitForExit();
330-
return proc?.ExitCode == 0;
329+
330+
if (proc is null)
331+
return false;
332+
333+
await proc.WaitForExitAsync(cancellationToken);
334+
return proc.ExitCode == 0;
331335
}
332336
catch
333337
{

src/tests/AspireC4.TestAppHost/Extensions/AspireC4Extensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static IAspireC4Builder ConfigureTestHost(this IAspireC4Builder builder)
1919
builder.WithAdditionalDSLFolder(extensionsDir);
2020
}
2121

22+
// There are some assets in the repo root that we'll include.
2223
builder.WithImageAliasFolder("@", Path.Combine(AppContext.BaseDirectory, "../../../../../../assets/images/"));
2324
var imagesDir = Path.Combine(
2425
Path.GetDirectoryName(typeof(TestAppHostProgram).Assembly.Location)!,

0 commit comments

Comments
 (0)