diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index aaf8e5c71..a214c9009 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -13,12 +13,12 @@
"rollForward": false
},
"docfx": {
- "version": "2.77.0",
+ "version": "2.78.0",
"commands": ["docfx"],
"rollForward": false
},
"corvus.json.jsonschema.typegeneratortool": {
- "version": "3.1.1",
+ "version": "4.0.9",
"commands": ["generatejsonschematypes"],
"rollForward": false
}
diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml
index 0b0eeef09..0fc1800dc 100644
--- a/.github/workflows/commit.yml
+++ b/.github/workflows/commit.yml
@@ -92,10 +92,6 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2.0.0
- - name: Build schema
- run: |
- .\scripts\Generate-SourceFromSchema.ps1
-
- name: Build
run: |
msbuild Whim.sln `
diff --git a/.github/workflows/docs_commit.yml b/.github/workflows/docs_commit.yml
index 07b8c65d5..765cd4dfc 100644
--- a/.github/workflows/docs_commit.yml
+++ b/.github/workflows/docs_commit.yml
@@ -57,9 +57,19 @@ jobs:
run: |
dotnet tool restore
- - name: Build schema
+ - name: Add msbuild to PATH
+ uses: microsoft/setup-msbuild@v2.0.0
+
+ - name: Build
run: |
- .\scripts\Generate-SourceFromSchema.ps1
+ msbuild Whim.sln `
+ -p:Configuration=$env:Configuration `
+ -p:Platform=$env:Platform `
+ -p:BuildInParallel=true `
+ -maxCpuCount
+
+ - name: Run docfx metadata
+ run: dotnet docfx metadata .\docs\docfx.json
- name: Run docfx
run: dotnet docfx .\docs\docfx.json
diff --git a/.github/workflows/docs_deploy.yml b/.github/workflows/docs_deploy.yml
index 088b4f555..8db84333a 100644
--- a/.github/workflows/docs_deploy.yml
+++ b/.github/workflows/docs_deploy.yml
@@ -55,10 +55,6 @@ jobs:
run: |
dotnet tool restore
- - name: Build schema
- run: |
- .\scripts\Generate-SourceFromSchema.ps1
-
- run: dotnet tool update -g docfx
- run: docfx docs/docfx.json
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index dad2879aa..227ea4806 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -100,10 +100,6 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2.0.0
- - name: Build schema
- run: |
- .\scripts\Generate-SourceFromSchema.ps1
-
- name: Build
run: |
msbuild Whim.sln `
diff --git a/.gitignore b/.gitignore
index 2286cd15e..d8f12c1f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -361,6 +361,3 @@ bin/whim-install.exe
# docfx
api
_site
-
-# Whim.Yaml generated files
-src/Whim.Yaml/Generated/
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 70aada601..d9bcae2d5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -3,21 +3,22 @@
true
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
+
diff --git a/scripts/Generate-SourceFromSchema.ps1 b/scripts/Generate-SourceFromSchema.ps1
deleted file mode 100644
index 003d839d6..000000000
--- a/scripts/Generate-SourceFromSchema.ps1
+++ /dev/null
@@ -1,49 +0,0 @@
-Write-Host "Generating source from schema..."
-
-$schemaPath = ".\src\Whim.Yaml\schema.json"
-$outputPath = ".\src\Whim.Yaml\Generated"
-$metadataPath = "$outputPath\metadata.json"
-
-$schemaHash = (Get-FileHash $schemaPath -Algorithm SHA256).Hash
-
-function Test-Regenerate {
- if (!(Test-Path $outputPath)) {
- Write-Host "Output directory does not exist, generating..."
- New-Item $outputPath -ItemType Directory
- return $true
- }
-
- Write-Host "Output directory exists..."
-
- if ((Test-Path $schemaPath) -eq $false) {
- Write-Host "Schema file does not exist, skipping..."
- return $false
- }
-
- $metadata = Get-Content $metadataPath | ConvertFrom-Json
- if ($metadata.schemaHash -ne $schemaHash) {
- Write-Host "Schema has changed since last generation, regenerating..."
- Write-Host "Old hash: $($metadata.schemaHash)"
- Write-Host "New hash: $schemaHash"
- return $true
- }
-
- return $false
-}
-
-if (!(Test-Regenerate -schemaPath $schemaPath -outputPath $outputPath)) {
- Write-Host "Skipping generation..."
- return
-}
-
-dotnet tool run generatejsonschematypes `
- $schemaPath `
- --rootNamespace Whim.Yaml `
- --useSchema Draft7 `
- --outputPath $outputPath
-
-# If not in CI, write metadata file
-if ($LASTEXITCODE -eq 0 -and $null -eq $env:CI) {
- Write-Host "Writing metadata file..."
- @{ schemaHash = $schemaHash } | ConvertTo-Json | Set-Content $metadataPath
-}
diff --git a/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFloatingWindowPluginTests.cs b/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFloatingWindowPluginTests.cs
index 44ec50078..91e33bd33 100644
--- a/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFloatingWindowPluginTests.cs
+++ b/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFloatingWindowPluginTests.cs
@@ -95,6 +95,28 @@ public void LoadFloatingWindowPlugin(string config, bool isYaml, IContext ctx)
""",
false
},
+ // YAML, invalid
+ {
+ """
+ plugins:
+ floating_window:
+ bob: true
+ """,
+ true
+ },
+ // JSON, invalid
+ {
+ """
+ {
+ "plugins": {
+ "floating_window": {
+ "bob": true
+ }
+ }
+ }
+ """,
+ false
+ },
};
[Theory, MemberAutoSubstituteData(nameof(DisabledFloatingWindowConfig))]
diff --git a/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFocusIndicatorPluginTests.cs b/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFocusIndicatorPluginTests.cs
index dbd88d6ab..089c373c5 100644
--- a/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFocusIndicatorPluginTests.cs
+++ b/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadFocusIndicatorPluginTests.cs
@@ -212,6 +212,28 @@ IContext ctx
""",
false
},
+ // YAML, invalid
+ {
+ """
+ plugins:
+ focus_indicator:
+ bob: true
+ """,
+ true
+ },
+ // JSON, invalid
+ {
+ """
+ {
+ "plugins": {
+ "focus_indicator": {
+ "bob": true
+ }
+ }
+ }
+ """,
+ false
+ },
};
[Theory, MemberAutoSubstituteData(nameof(DisabledFocusIndicatorConfig))]
diff --git a/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadLayoutPreviewPluginTests.cs b/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadLayoutPreviewPluginTests.cs
index f9fd56599..45f8dc88d 100644
--- a/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadLayoutPreviewPluginTests.cs
+++ b/src/Whim.Yaml.Tests/Plugins/YamlLoader_LoadLayoutPreviewPluginTests.cs
@@ -96,6 +96,28 @@ public void LoadLayoutPreviewPlugin(string yaml, bool isYaml, bool isEnabled, IC
""",
false
},
+ // YAML, invalid
+ {
+ """
+ plugins:
+ layout_preview:
+ bob: true
+ """,
+ true
+ },
+ // JSON, invalid
+ {
+ """
+ {
+ "plugins": {
+ "layout_preview": {
+ "bob": true
+ }
+ }
+ }
+ """,
+ false
+ },
};
[Theory, MemberAutoSubstituteData(nameof(DisabledLayoutPreviewConfig))]
diff --git a/src/Whim.Yaml/Schema.cs b/src/Whim.Yaml/Schema.cs
new file mode 100644
index 000000000..eb4043f21
--- /dev/null
+++ b/src/Whim.Yaml/Schema.cs
@@ -0,0 +1,6 @@
+using Corvus.Json;
+
+namespace Whim.Yaml;
+
+[JsonSchemaTypeGenerator("./schema.json")]
+public readonly partial struct Schema { }
diff --git a/src/Whim.Yaml/Whim.Yaml.csproj b/src/Whim.Yaml/Whim.Yaml.csproj
index 368a29391..dfee11c6a 100644
--- a/src/Whim.Yaml/Whim.Yaml.csproj
+++ b/src/Whim.Yaml/Whim.Yaml.csproj
@@ -50,10 +50,17 @@
+
+ all
+
+
+
+
+
@@ -63,10 +70,4 @@
MSBuild:Compile
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Whim.Yaml/YamlBarPluginLoader.cs b/src/Whim.Yaml/YamlBarPluginLoader.cs
index a7227a585..c73edbba6 100644
--- a/src/Whim.Yaml/YamlBarPluginLoader.cs
+++ b/src/Whim.Yaml/YamlBarPluginLoader.cs
@@ -13,9 +13,13 @@ internal static class YamlBarPluginLoader
"CA2000:Dispose objects before losing scope",
Justification = "Items will be disposed by the context where appropriate."
)]
- public static void LoadBarPlugin(IContext ctx, Schema schema)
+ public static void LoadBarPlugin(IContext ctx, Schema.PluginsEntity plugins)
{
- var bar = schema.Plugins.Bar;
+ if (plugins.Bar is not { } bar)
+ {
+ Logger.Debug("Bar plugin configuration not found.");
+ return;
+ }
if (!bar.IsValid())
{
@@ -23,7 +27,7 @@ public static void LoadBarPlugin(IContext ctx, Schema schema)
return;
}
- if (bar.IsEnabled.AsOptional() is { } isEnabled && !isEnabled)
+ if (bar.IsEnabled is { } isEnabled && !isEnabled)
{
Logger.Debug("Bar plugin is not enabled.");
return;
@@ -35,12 +39,12 @@ public static void LoadBarPlugin(IContext ctx, Schema schema)
BarConfig config = new(leftComponents, centerComponents, rightComponents);
- if (bar.Height.AsOptional() is { } height)
+ if (bar.Height is { } height)
{
config.Height = (int)height;
}
- if (bar.Backdrop.AsOptional() is { } backdrop)
+ if (bar.Backdrop is { } backdrop)
{
config.Backdrop = YamlLoaderUtils.ParseWindowBackdropConfig(backdrop);
}
@@ -48,82 +52,79 @@ public static void LoadBarPlugin(IContext ctx, Schema schema)
ctx.PluginManager.AddPlugin(new BarPlugin(ctx, config));
}
- private static List GetBarComponents(IContext ctx, Schema.DefsRequiredEntries componentsWrapper)
+ private static List GetBarComponents(IContext ctx, Schema.SchemaRequiredEntries? componentsWrapper)
{
- if (componentsWrapper.Entries.AsOptional() is not { } entries)
+ if (componentsWrapper is not { } components)
{
return [];
}
- List components = [];
+ List barComponents = [];
- foreach (var entry in entries)
+ foreach (var entry in components.Entries)
{
entry.Match