Skip to content

Commit b33ec4f

Browse files
authored
Merge pull request #1 from MagnetForensics/dev/tool
Code review fixes and .NET 10 upgrade
2 parents e400c5f + 5a47c27 commit b33ec4f

18 files changed

Lines changed: 243 additions & 163 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v4
1919
with:
20-
dotnet-version: 8.0.x
20+
dotnet-version: 10.0.x
2121

2222
- name: Restore dependencies
2323
run: dotnet restore

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Setup .NET
4747
uses: actions/setup-dotnet@v4
4848
with:
49-
dotnet-version: 8.0.x
49+
dotnet-version: 10.0.x
5050

5151
- name: Restore dependencies
5252
run: dotnet restore
@@ -79,6 +79,9 @@ jobs:
7979
Compress-Archive -Path artifacts/osx-x64/DotSchema -DestinationPath artifacts/dotschema-osx-x64-${{ steps.tag.outputs.tag }}.zip
8080
Compress-Archive -Path artifacts/osx-arm64/DotSchema -DestinationPath artifacts/dotschema-osx-arm64-${{ steps.tag.outputs.tag }}.zip
8181
82+
- name: Push to Azure Artifacts
83+
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
84+
8285
- name: Create Release
8386
uses: softprops/action-gh-release@v2
8487
with:
@@ -87,4 +90,3 @@ jobs:
8790
artifacts/*.nupkg
8891
artifacts/*.zip
8992
generate_release_notes: true
90-

DotSchema.Tests/Analyzers/SchemaAnalyzerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ private static SchemaInput LoadEmbeddedSchema(string filename)
1717

1818
using var stream = assembly.GetManifestResourceStream(resourceName)
1919
?? throw new InvalidOperationException($"Embedded resource not found: {resourceName}");
20+
2021
using var reader = new StreamReader(stream);
2122

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

25-
private static List<SchemaInput> GetTestSchemas() =>
26-
[
27-
LoadEmbeddedSchema("windows.schema.json"),
28-
LoadEmbeddedSchema("linux.schema.json")
29-
];
26+
private static List<SchemaInput> GetTestSchemas()
27+
{
28+
return [LoadEmbeddedSchema("windows.schema.json"), LoadEmbeddedSchema("linux.schema.json")];
29+
}
3030

3131
[Fact]
3232
public async Task AnalyzeAsync_DetectsSharedTypes()

DotSchema.Tests/CodePostProcessorTests.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace DotSchema.Tests;
22

33
public class CodePostProcessorTests
44
{
5+
private static readonly HashSet<string> EmptySet = [];
6+
57
[Fact]
68
public void Process_SharedMode_RemovesVariantSpecificTypes()
79
{
@@ -25,9 +27,9 @@ public partial class VariantOnlyType
2527
code,
2628
GenerationMode.Shared,
2729
"",
28-
[],
30+
EmptySet,
2931
variantTypes,
30-
[],
32+
EmptySet,
3133
"Config");
3234

3335
Assert.Contains("SharedType", result);
@@ -57,8 +59,8 @@ public partial class ConflictingType
5759
code,
5860
GenerationMode.Shared,
5961
"",
60-
[],
61-
[],
62+
EmptySet,
63+
EmptySet,
6264
conflictingTypes,
6365
"Config");
6466

@@ -90,8 +92,8 @@ public partial class WindowsConfig
9092
GenerationMode.Variant,
9193
"Windows",
9294
sharedTypes,
93-
[],
94-
[],
95+
EmptySet,
96+
EmptySet,
9597
"Config");
9698

9799
Assert.DoesNotContain("public sealed class SharedType", result);
@@ -114,11 +116,10 @@ public partial class WindowsConfig
114116
code,
115117
GenerationMode.Variant,
116118
"Windows",
117-
[],
118-
[],
119-
[],
120-
"Config",
121-
true);
119+
EmptySet,
120+
EmptySet,
121+
EmptySet,
122+
"Config");
122123

123124
Assert.Contains("WindowsConfig : IConfig", result);
124125
}
@@ -139,9 +140,9 @@ public partial class WindowsConfig
139140
code,
140141
GenerationMode.Variant,
141142
"Windows",
142-
[],
143-
[],
144-
[],
143+
EmptySet,
144+
EmptySet,
145+
EmptySet,
145146
"Config",
146147
false);
147148

@@ -164,9 +165,9 @@ public partial class MyType
164165
code,
165166
GenerationMode.All,
166167
"",
167-
[],
168-
[],
169-
[],
168+
EmptySet,
169+
EmptySet,
170+
EmptySet,
170171
"Config");
171172

172173
Assert.Contains("public sealed class MyType", result);
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<IsPackable>false</IsPackable>
8-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
99

10-
<ItemGroup>
11-
<PackageReference Include="coverlet.collector" Version="6.0.4" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
13-
<PackageReference Include="xunit" Version="2.9.3" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0" />
15-
</ItemGroup>
10+
<ItemGroup>
11+
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
12+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3"/>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
14+
<PackageReference Include="xunit" Version="2.9.3"/>
15+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0"/>
16+
</ItemGroup>
1617

17-
<ItemGroup>
18-
<ProjectReference Include="..\DotSchema\DotSchema.csproj" />
19-
</ItemGroup>
18+
<ItemGroup>
19+
<ProjectReference Include="..\DotSchema\DotSchema.csproj"/>
20+
</ItemGroup>
2021

21-
<ItemGroup>
22-
<Using Include="Xunit" />
23-
</ItemGroup>
22+
<ItemGroup>
23+
<Using Include="Xunit"/>
24+
</ItemGroup>
2425

25-
<ItemGroup>
26-
<EmbeddedResource Include="TestData\**\*" />
27-
</ItemGroup>
26+
<ItemGroup>
27+
<EmbeddedResource Include="TestData\**\*"/>
28+
</ItemGroup>
2829

29-
</Project>
30+
</Project>

DotSchema.Tests/Generators/CleanTypeNameGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Generate_PreservesSimpleNames(string input, string expected)
3838
[Fact]
3939
public void Generate_RenamesRootTypeWithVariant()
4040
{
41-
var generator = new CleanTypeNameGenerator("Windows", "Config", []);
41+
var generator = new CleanTypeNameGenerator("Windows", "Config", new HashSet<string>());
4242
var schema = new JsonSchema();
4343

4444
var result = generator.Generate(schema, "Config", []);

DotSchema.Tests/TestData/linux.schema.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,31 @@
1717
"SharedType": {
1818
"type": "object",
1919
"properties": {
20-
"name": { "type": "string" },
21-
"value": { "type": "integer" }
20+
"name": {
21+
"type": "string"
22+
},
23+
"value": {
24+
"type": "integer"
25+
}
2226
}
2327
},
2428
"ProcessConfig": {
2529
"type": "object",
2630
"properties": {
27-
"exe_path": { "type": "string" },
28-
"systemd_unit": { "type": "string" }
31+
"exe_path": {
32+
"type": "string"
33+
},
34+
"systemd_unit": {
35+
"type": "string"
36+
}
2937
}
3038
},
3139
"LinuxOnlyType": {
3240
"type": "object",
3341
"properties": {
34-
"systemd": { "type": "string" }
42+
"systemd": {
43+
"type": "string"
44+
}
3545
}
3646
}
3747
}

DotSchema.Tests/TestData/windows.schema.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,31 @@
1717
"SharedType": {
1818
"type": "object",
1919
"properties": {
20-
"name": { "type": "string" },
21-
"value": { "type": "integer" }
20+
"name": {
21+
"type": "string"
22+
},
23+
"value": {
24+
"type": "integer"
25+
}
2226
}
2327
},
2428
"ProcessConfig": {
2529
"type": "object",
2630
"properties": {
27-
"exe_path": { "type": "string" },
28-
"registry_key": { "type": "string" }
31+
"exe_path": {
32+
"type": "string"
33+
},
34+
"registry_key": {
35+
"type": "string"
36+
}
2937
}
3038
},
3139
"WindowsOnlyType": {
3240
"type": "object",
3341
"properties": {
34-
"registry": { "type": "string" }
42+
"registry": {
43+
"type": "string"
44+
}
3545
}
3646
}
3747
}

0 commit comments

Comments
 (0)