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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down Expand Up @@ -79,6 +79,9 @@ jobs:
Compress-Archive -Path artifacts/osx-x64/DotSchema -DestinationPath artifacts/dotschema-osx-x64-${{ steps.tag.outputs.tag }}.zip
Compress-Archive -Path artifacts/osx-arm64/DotSchema -DestinationPath artifacts/dotschema-osx-arm64-${{ steps.tag.outputs.tag }}.zip

- name: Push to Azure Artifacts
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.AZURE_ARTIFACTS_PAT }} --source https://pkgs.dev.azure.com/gauss-dev/Magnet/_packaging/Engineering/nuget/v3/index.json

- name: Create Release
uses: softprops/action-gh-release@v2
with:
Expand All @@ -87,4 +90,3 @@ jobs:
artifacts/*.nupkg
artifacts/*.zip
generate_release_notes: true

10 changes: 5 additions & 5 deletions DotSchema.Tests/Analyzers/SchemaAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ private static SchemaInput LoadEmbeddedSchema(string filename)

using var stream = assembly.GetManifestResourceStream(resourceName)
?? throw new InvalidOperationException($"Embedded resource not found: {resourceName}");

using var reader = new StreamReader(stream);

return SchemaInput.FromContent(filename, reader.ReadToEnd());
}

private static List<SchemaInput> GetTestSchemas() =>
[
LoadEmbeddedSchema("windows.schema.json"),
LoadEmbeddedSchema("linux.schema.json")
];
private static List<SchemaInput> GetTestSchemas()
{
return [LoadEmbeddedSchema("windows.schema.json"), LoadEmbeddedSchema("linux.schema.json")];
}

[Fact]
public async Task AnalyzeAsync_DetectsSharedTypes()
Expand Down
35 changes: 18 additions & 17 deletions DotSchema.Tests/CodePostProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ namespace DotSchema.Tests;

public class CodePostProcessorTests
{
private static readonly HashSet<string> EmptySet = [];

[Fact]
public void Process_SharedMode_RemovesVariantSpecificTypes()
{
Expand All @@ -25,9 +27,9 @@ public partial class VariantOnlyType
code,
GenerationMode.Shared,
"",
[],
EmptySet,
variantTypes,
[],
EmptySet,
"Config");

Assert.Contains("SharedType", result);
Expand Down Expand Up @@ -57,8 +59,8 @@ public partial class ConflictingType
code,
GenerationMode.Shared,
"",
[],
[],
EmptySet,
EmptySet,
conflictingTypes,
"Config");

Expand Down Expand Up @@ -90,8 +92,8 @@ public partial class WindowsConfig
GenerationMode.Variant,
"Windows",
sharedTypes,
[],
[],
EmptySet,
EmptySet,
"Config");

Assert.DoesNotContain("public sealed class SharedType", result);
Expand All @@ -114,11 +116,10 @@ public partial class WindowsConfig
code,
GenerationMode.Variant,
"Windows",
[],
[],
[],
"Config",
true);
EmptySet,
EmptySet,
EmptySet,
"Config");

Assert.Contains("WindowsConfig : IConfig", result);
}
Expand All @@ -139,9 +140,9 @@ public partial class WindowsConfig
code,
GenerationMode.Variant,
"Windows",
[],
[],
[],
EmptySet,
EmptySet,
EmptySet,
"Config",
false);

Expand All @@ -164,9 +165,9 @@ public partial class MyType
code,
GenerationMode.All,
"",
[],
[],
[],
EmptySet,
EmptySet,
EmptySet,
"Config");

Assert.Contains("public sealed class MyType", result);
Expand Down
45 changes: 23 additions & 22 deletions DotSchema.Tests/DotSchema.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DotSchema\DotSchema.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotSchema\DotSchema.csproj"/>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="TestData\**\*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestData\**\*"/>
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion DotSchema.Tests/Generators/CleanTypeNameGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Generate_PreservesSimpleNames(string input, string expected)
[Fact]
public void Generate_RenamesRootTypeWithVariant()
{
var generator = new CleanTypeNameGenerator("Windows", "Config", []);
var generator = new CleanTypeNameGenerator("Windows", "Config", new HashSet<string>());
var schema = new JsonSchema();

var result = generator.Generate(schema, "Config", []);
Expand Down
20 changes: 15 additions & 5 deletions DotSchema.Tests/TestData/linux.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,31 @@
"SharedType": {
"type": "object",
"properties": {
"name": { "type": "string" },
"value": { "type": "integer" }
"name": {
"type": "string"
},
"value": {
"type": "integer"
}
}
},
"ProcessConfig": {
"type": "object",
"properties": {
"exe_path": { "type": "string" },
"systemd_unit": { "type": "string" }
"exe_path": {
"type": "string"
},
"systemd_unit": {
"type": "string"
}
}
},
"LinuxOnlyType": {
"type": "object",
"properties": {
"systemd": { "type": "string" }
"systemd": {
"type": "string"
}
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions DotSchema.Tests/TestData/windows.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,31 @@
"SharedType": {
"type": "object",
"properties": {
"name": { "type": "string" },
"value": { "type": "integer" }
"name": {
"type": "string"
},
"value": {
"type": "integer"
}
}
},
"ProcessConfig": {
"type": "object",
"properties": {
"exe_path": { "type": "string" },
"registry_key": { "type": "string" }
"exe_path": {
"type": "string"
},
"registry_key": {
"type": "string"
}
}
},
"WindowsOnlyType": {
"type": "object",
"properties": {
"registry": { "type": "string" }
"registry": {
"type": "string"
}
}
}
}
Expand Down
Loading