Skip to content

Commit

Permalink
Upgrade to Corvus.JsonSchema 4 (#1081)
Browse files Browse the repository at this point in the history
- Upgraded dependencies to their latest version
- Upgraded to Corvus.Json 4
- Switched to using a source generator for the schema parser/validator
  • Loading branch information
dalyIsaac authored Nov 19, 2024
1 parent a9adcf4 commit 580e1d0
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- name: Build schema
run: |
.\scripts\Generate-SourceFromSchema.ps1
- name: Build
run: |
msbuild Whim.sln `
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/docs_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,19 @@ jobs:
run: |
dotnet tool restore
- name: Build schema
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- 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
4 changes: 0 additions & 4 deletions .github/workflows/docs_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- name: Build schema
run: |
.\scripts\Generate-SourceFromSchema.ps1
- name: Build
run: |
msbuild Whim.sln `
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,3 @@ bin/whim-install.exe
# docfx
api
_site

# Whim.Yaml generated files
src/Whim.Yaml/Generated/
21 changes: 11 additions & 10 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Corvus.Json.ExtendedTypes" Version="3.1.1" />
<PackageVersion Include="DotNext" Version="5.11.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Scripting" Version="4.10.0" />
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
<PackageVersion Include="Corvus.Json.ExtendedTypes" Version="4.0.9" />
<PackageVersion Include="Corvus.Json.SourceGenerator" Version="4.0.9" />
<PackageVersion Include="DotNext" Version="5.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Scripting" Version="4.11.0" />
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="9.0.0" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.106" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.5.240627000" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageVersion Include="Octokit" Version="13.0.1" />
<PackageVersion Include="Serilog" Version="4.0.1" />
<PackageVersion Include="Serilog.Sinks.Async" Version="2.0.0" />
<PackageVersion Include="Serilog" Version="4.1.0" />
<PackageVersion Include="Serilog.Sinks.Async" Version="2.1.0" />
<PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.7" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.0" />
<PackageVersion Include="Yaml2JsonNode" Version="2.1.1" />
<PackageVersion Include="YamlDotNet" Version="16.1.3" />
<PackageVersion Include="YamlDotNet" Version="16.2.0" />
</ItemGroup>
<!-- Test dependencies -->
<ItemGroup>
Expand Down
49 changes: 0 additions & 49 deletions scripts/Generate-SourceFromSchema.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<YamlLoaderCustomization>(nameof(DisabledFloatingWindowConfig))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<YamlLoaderCustomization>(nameof(DisabledFocusIndicatorConfig))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<YamlLoaderCustomization>(nameof(DisabledLayoutPreviewConfig))]
Expand Down
6 changes: 6 additions & 0 deletions src/Whim.Yaml/Schema.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Corvus.Json;

namespace Whim.Yaml;

[JsonSchemaTypeGenerator("./schema.json")]
public readonly partial struct Schema { }
13 changes: 7 additions & 6 deletions src/Whim.Yaml/Whim.Yaml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@

<ItemGroup>
<PackageReference Include="Corvus.Json.ExtendedTypes" />
<PackageReference Include="Corvus.Json.SourceGenerator">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Yaml2JsonNode" />
<PackageReference Include="YamlDotNet" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="schema.json" />
</ItemGroup>

<ItemGroup>
<None Remove="ErrorWindow.xaml" />
</ItemGroup>
Expand All @@ -63,10 +70,4 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

<Target Name="GenerateSchema" BeforeTargets="BeforeCompile">
<Exec Command="powershell.exe -NonInteractive -ExecutionPolicy Unrestricted .\scripts\Generate-SourceFromSchema.ps1" WorkingDirectory="..\..\" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
</Target>
</Project>
Loading

0 comments on commit 580e1d0

Please sign in to comment.