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
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CoreVersion>4.5.3</CoreVersion>
<CoreVersion>4.6.0</CoreVersion>
<Configurations>Debug;Release;SourceGen Highlighting</Configurations>
<Platforms>AnyCPU</Platforms>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
Expand Down
66 changes: 42 additions & 24 deletions build-tools/build-scripts/GBTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,11 @@ await RunDotnetCommandWithOutputAsync(testProjectDir, "run", buildArgs, environm
double passedPercentage = (double)progress.Passed / ran * 100;
Console.WriteLine($"PASSED TESTS: {progress.Passed} / {ran} TESTS RAN ({passedPercentage:F2}%).");
Console.WriteLine($"FAILED: {progress.Failed} / SKIPPED: {progress.Skipped}");

if (passedPercentage < percentage)
{
Console.WriteLine($"TEST RUN FAILED: Passed percentage {passedPercentage:F2}% is below the required {
percentage}%.");
failed = true;
}
}

// A cancelled run never completed, so it can never be reported as a pass.
Console.WriteLine("TEST RUN FAILED: Test run was cancelled before completion.");
failed = true;
}
else
{
Expand All @@ -178,35 +175,56 @@ await RunDotnetCommandWithOutputAsync(testProjectDir, "run", buildArgs, environm

Regex finalCountRegex = new(@"^.*FINAL_SUMMARY: PASSED TESTS: (?<passed>\d+) / (?<total>\d+)\s*$");

bool summaryFound = false;
int total = 0;
int passed = 0;
foreach (string line in await File.ReadAllLinesAsync(testOutputLogPath))

if (File.Exists(testOutputLogPath))
{
if (line.Contains("FINAL_SUMMARY"))
foreach (string line in await File.ReadAllLinesAsync(testOutputLogPath))
{
string content = line.Substring(38); // 38 is the timestamp plus FINAL_SUMMARY:

if (finalCountRegex.Match(line) is { Success: true } match)
{
total = int.Parse(match.Groups["total"].Value);
passed = int.Parse(match.Groups["passed"].Value);
}
else
if (line.Contains("FINAL_SUMMARY"))
{
Console.WriteLine(content);
string content = line.Substring(38); // 38 is the timestamp plus FINAL_SUMMARY:

if (finalCountRegex.Match(line) is { Success: true } match)
{
total = int.Parse(match.Groups["total"].Value);
passed = int.Parse(match.Groups["passed"].Value);
summaryFound = true;
}
else
{
Console.WriteLine(content);
}
}
}
}

double passedPercentage = total > 0 ? (double)passed / total * 100 : 100;
Console.WriteLine($"PASSED TESTS: {passed} / {total} TESTS PASSED ({passedPercentage:F2}%).");

if (passedPercentage < percentage)
if (!summaryFound || total == 0)
{
Console.WriteLine($"TEST RUN FAILED: Passed percentage {passedPercentage
:F2}% is below the required {percentage}%.");
// No completed-test summary was produced. This happens when the run aborts before any
// test executes - e.g. AssemblyInitialize throws because the test web app never became
// reachable, so AssemblyCleanup (which writes the FINAL_SUMMARY) never runs. Previously
// this was reported as 100% passing because the percentage defaulted to 100 when total
// was 0, masking a hard failure as a green run.
Console.WriteLine("TEST RUN FAILED: No completed test results were recorded. The test run "
+ "aborted before any tests ran (for example, AssemblyInitialize failed or the test web "
+ "app was not reachable). Review the log output above for the root cause.");
failed = true;
}
else
{
double passedPercentage = (double)passed / total * 100;
Console.WriteLine($"PASSED TESTS: {passed} / {total} TESTS PASSED ({passedPercentage:F2}%).");

if (passedPercentage < percentage)
{
Console.WriteLine($"TEST RUN FAILED: Passed percentage {passedPercentage
:F2}% is below the required {percentage}%.");
failed = true;
}
}
}

if (failed)
Expand Down
51 changes: 50 additions & 1 deletion build-tools/build-scripts/ScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.RegularExpressions;

bool excludeMode = false;
Expand Down Expand Up @@ -424,10 +425,58 @@ static async Task<int> BuildScript(string scriptName, string scriptsDir, string
process.BeginOutputReadLine();
process.BeginErrorReadLine();
await process.WaitForExitAsync(cancellationToken);

// The file-based-app SDK bakes the source .cs file's absolute path into the generated
// runtimeconfig.json. Rewrite it to a stable relative value so the committed output doesn't churn across machines.
if (process.ExitCode == 0 && scriptName.EndsWith(".cs", StringComparison.OrdinalIgnoreCase))
{
RewriteRuntimeConfigPaths(scriptName, outDir);
}

return process.ExitCode;
}

static async Task<int> CleanScript(string scriptName, string scriptsDir, string outDir, string runtime,
/// <summary>
/// Replaces the absolute EntryPointFilePath/EntryPointFileDirectoryPath that the file-based-app SDK
/// writes into a script's runtimeconfig.json with machine-independent relative values.
/// </summary>
static void RewriteRuntimeConfigPaths(string scriptName, string outDir)
{
string runtimeConfigPath = Path.Combine(outDir, Path.GetFileNameWithoutExtension(scriptName) + ".runtimeconfig.json");
if (!File.Exists(runtimeConfigPath))
{
return;
}

try
{
if (JsonNode.Parse(File.ReadAllText(runtimeConfigPath)) is not { } root
|| root["runtimeOptions"] is not JsonObject runtimeOptions)
{
return;
}

// Remove the dead doubly-nested block left by the old runtimeconfig.template.json
runtimeOptions.Remove("runtimeOptions");

if (runtimeOptions["configProperties"] is not JsonObject configProperties
|| !configProperties.ContainsKey("EntryPointFilePath"))
{
return;
}

configProperties["EntryPointFilePath"] = $".\\{scriptName}";
configProperties["EntryPointFileDirectoryPath"] = ".";

File.WriteAllText(runtimeConfigPath, root.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
}
catch (Exception ex)
{
Trace.WriteLine($"Failed to rewrite runtime config paths for {scriptName}: {ex.Message}");
}
}

static async Task<int> CleanScript(string scriptName, string scriptsDir, string outDir, string runtime,
CancellationToken cancellationToken)
{
Console.WriteLine($"Cleaning script: {scriptName} for runtime: {runtime}");
Expand Down
8 changes: 0 additions & 8 deletions build-tools/build-scripts/runtimeconfig.template.json

This file was deleted.

Binary file modified build-tools/linux-x64/GBTest
Binary file not shown.
Binary file modified build-tools/linux-x64/GBTest.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions build-tools/linux-x64/GBTest.runtimeconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
},
"configProperties": {
"EntryPointFilePath": "/Users/timpurdum/repos/GeoBlazor/GeoBlazor.Pro/GeoBlazor/build-tools/build-scripts/GBTest.cs",
"EntryPointFileDirectoryPath": "/Users/timpurdum/repos/GeoBlazor/GeoBlazor.Pro/GeoBlazor/build-tools/build-scripts",
"EntryPointFilePath": "D:\\dymaptic.GeoBlazor.CodeGen\\GeoBlazor.Pro\\GeoBlazor\\build-tools\\build-scripts\\GBTest.cs",
"EntryPointFileDirectoryPath": "D:\\dymaptic.GeoBlazor.CodeGen\\GeoBlazor.Pro\\GeoBlazor\\build-tools\\build-scripts",
Comment thread
TimPurdum marked this conversation as resolved.
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
"System.ComponentModel.DefaultValueAttribute.IsSupported": false,
"System.ComponentModel.Design.IDesignerHost.IsSupported": false,
Expand Down
Binary file modified build-tools/linux-x64/Utilities.dll
Binary file not shown.
Binary file modified build-tools/osx-arm64/GBTest
Binary file not shown.
Binary file modified build-tools/osx-arm64/GBTest.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions build-tools/osx-arm64/GBTest.runtimeconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
},
"configProperties": {
"EntryPointFilePath": "/Users/timpurdum/repos/GeoBlazor/GeoBlazor.Pro/GeoBlazor/build-tools/build-scripts/GBTest.cs",
"EntryPointFileDirectoryPath": "/Users/timpurdum/repos/GeoBlazor/GeoBlazor.Pro/GeoBlazor/build-tools/build-scripts",
"EntryPointFilePath": "D:\\dymaptic.GeoBlazor.CodeGen\\GeoBlazor.Pro\\GeoBlazor\\build-tools\\build-scripts\\GBTest.cs",
"EntryPointFileDirectoryPath": "D:\\dymaptic.GeoBlazor.CodeGen\\GeoBlazor.Pro\\GeoBlazor\\build-tools\\build-scripts",
Comment thread
TimPurdum marked this conversation as resolved.
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
"System.ComponentModel.DefaultValueAttribute.IsSupported": false,
"System.ComponentModel.Design.IDesignerHost.IsSupported": false,
Expand Down
Binary file modified build-tools/osx-arm64/Utilities.dll
Binary file not shown.
Binary file modified build-tools/win-x64/GBTest.dll
Binary file not shown.
Binary file modified build-tools/win-x64/GBTest.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions build-tools/win-x64/GBTest.runtimeconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
},
"configProperties": {
"EntryPointFilePath": "/Users/timpurdum/repos/GeoBlazor/GeoBlazor.Pro/GeoBlazor/build-tools/build-scripts/GBTest.cs",
"EntryPointFileDirectoryPath": "/Users/timpurdum/repos/GeoBlazor/GeoBlazor.Pro/GeoBlazor/build-tools/build-scripts",
"EntryPointFilePath": "D:\\dymaptic.GeoBlazor.CodeGen\\GeoBlazor.Pro\\GeoBlazor\\build-tools\\build-scripts\\GBTest.cs",
"EntryPointFileDirectoryPath": "D:\\dymaptic.GeoBlazor.CodeGen\\GeoBlazor.Pro\\GeoBlazor\\build-tools\\build-scripts",
Comment thread
TimPurdum marked this conversation as resolved.
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
"System.ComponentModel.DefaultValueAttribute.IsSupported": false,
"System.ComponentModel.Design.IDesignerHost.IsSupported": false,
Expand Down
Binary file modified build-tools/win-x64/Utilities.dll
Binary file not shown.
86 changes: 0 additions & 86 deletions src/dymaptic.GeoBlazor.Core/Components/ActiveLayerInfo.gb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,50 +286,6 @@ public ActiveLayerInfo(
return IsScaleDriven;
}

/// <summary>
/// Asynchronously retrieve the current value of the Layer property.
/// </summary>
public async Task<Layer?> GetLayer()
{
if (CoreJsModule is null)
{
return Layer;
}

try
{
JsComponentReference ??= await CoreJsModule.InvokeAsync<IJSObjectReference?>(
"getJsComponent", CancellationTokenSource.Token, Id);
}
catch (JSException)
{
// this is expected if the component is not yet built
}

if (JsComponentReference is null)
{
return Layer;
}

Layer? result = await JsComponentReference.InvokeAsync<Layer?>(
"getLayer", CancellationTokenSource.Token);

if (result is not null)
{
if (Layer is not null)
{
result.Id = Layer.Id;
}
result.UpdateGeoBlazorReferences(CoreJsModule!, ProJsModule, View, this, Layer);

#pragma warning disable BL0005
Layer = result;
#pragma warning restore BL0005
ModifiedParameters[nameof(Layer)] = Layer;
}

return Layer;
}

/// <summary>
/// Asynchronously retrieve the current value of the LayerView property.
Expand Down Expand Up @@ -733,48 +689,6 @@ await CoreJsModule.InvokeVoidAsync("setProperty", CancellationTokenSource.Token,
JsComponentReference, "hideLayersNotInCurrentView", value);
}

/// <summary>
/// Asynchronously set the value of the Layer property after render.
/// </summary>
/// <param name="value">
/// The value to set.
/// </param>
public async Task SetLayer(Layer? value)
{
if (value is not null)
{
value.UpdateGeoBlazorReferences(CoreJsModule!, ProJsModule, View, this, Layer);
}

#pragma warning disable BL0005
Layer = value;
#pragma warning restore BL0005
ModifiedParameters[nameof(Layer)] = value;

if (CoreJsModule is null)
{
return;
}

try
{
JsComponentReference ??= await CoreJsModule.InvokeAsync<IJSObjectReference?>(
"getJsComponent", CancellationTokenSource.Token, Id);
}
catch (JSException)
{
// this is expected if the component is not yet built
}

if (JsComponentReference is null)
{
return;
}

await CoreJsModule.InvokeVoidAsync("setProperty", CancellationTokenSource.Token,
JsComponentReference, "layer", value);
}

/// <summary>
/// Asynchronously set the value of the LayerView property after render.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,50 +99,6 @@ public FeatureSnappingLayerSource(
return Enabled;
}

/// <summary>
/// Asynchronously retrieve the current value of the Layer property.
/// </summary>
public async Task<Layer?> GetLayer()
{
if (CoreJsModule is null)
{
return Layer;
}

try
{
JsComponentReference ??= await CoreJsModule.InvokeAsync<IJSObjectReference?>(
"getJsComponent", CancellationTokenSource.Token, Id);
}
catch (JSException)
{
// this is expected if the component is not yet built
}

if (JsComponentReference is null)
{
return Layer;
}

Layer? result = await JsComponentReference.InvokeAsync<Layer?>(
"getLayer", CancellationTokenSource.Token);

if (result is not null)
{
if (Layer is not null)
{
result.Id = Layer.Id;
}
result.UpdateGeoBlazorReferences(CoreJsModule!, ProJsModule, View, this, Layer);

#pragma warning disable BL0005
Layer = result;
#pragma warning restore BL0005
ModifiedParameters[nameof(Layer)] = Layer;
}

return Layer;
}

#endregion

Expand Down
2 changes: 1 addition & 1 deletion src/dymaptic.GeoBlazor.Core/Components/Graphic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public Graphic(
/// Retrieves the <see cref = "Layer"/> from the rendered graphic.
/// </summary>
[CodeGenerationIgnore]
public Task<Layer?> GetLayer()
public override Task<Layer?> GetLayer()
{
return Task.FromResult(Parent as Layer);
}
Expand Down
Loading
Loading