Skip to content

Commit a36c4f1

Browse files
chore: housekeeping
1 parent 5603fb4 commit a36c4f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+507
-320
lines changed

.editorconfig

Lines changed: 355 additions & 52 deletions
Large diffs are not rendered by default.

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<Nullable>enable</Nullable>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<UseArtifactsOutput>true</UseArtifactsOutput>
7+
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
8+
</PropertyGroup>
9+
</Project>

Directory.Packages.props

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
<PropertyGroup Label="Centralized Package Versions">
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
5+
56
<ItemGroup>
6-
<PackageVersion Include="PolySharp" Version="1.14.1" />
7-
7+
<PackageVersion Include="PolySharp" Version="1.15.0" />
88
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.9.2" />
9-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
10-
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
11-
12-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
13-
<PackageVersion Include="xunit" Version="2.8.1" />
14-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
15-
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
16-
17-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.4" />
18-
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
9+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
10+
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.103" />
11+
<PackageVersion Include="xunit.v3" Version="3.2.2" />
12+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.12" />
13+
<PackageVersion Include="System.CommandLine" Version="2.0.3" />
1914
</ItemGroup>
20-
</Project>
15+
</Project>

Shockky.Sandbox/Program.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Runtime.InteropServices;
1+
using System.Runtime.InteropServices;
22

33
using Shockky;
44
using Shockky.Resources;
@@ -16,25 +16,28 @@
1616
{
1717
Arity = ArgumentArity.OneOrMore,
1818
Description = "Director movie (.d[ixc]r) or external cast (.c[sxc]t) file(s)."
19-
}.ExistingOnly();
19+
}.AcceptExistingOnly();
2020

21-
var outputOption = new Option<DirectoryInfo>("--output",
22-
getDefaultValue: () => new DirectoryInfo("Output"),
23-
description: "Directory for the extracted resources")
24-
.LegalFilePathsOnly();
25-
26-
outputOption.AddAlias("-o");
21+
var outputOption = new Option<DirectoryInfo>("--output", "-o")
22+
{
23+
Description = "Directory for the extracted resources",
24+
DefaultValueFactory = _ => new DirectoryInfo("Output")
25+
}.AcceptLegalFilePathsOnly();
2726

2827
var rootCommand = new RootCommand()
2928
{
3029
inputArgument,
3130
outputOption
3231
};
3332

34-
rootCommand.SetHandler(HandleExtractCommand,
35-
inputArgument, outputOption);
33+
rootCommand.SetAction(parseResult => {
34+
var input = parseResult.GetRequiredValue(inputArgument);
35+
var output = parseResult.GetRequiredValue(outputOption);
36+
37+
HandleExtractCommand(input, output);
38+
});
3639

37-
return rootCommand.Invoke(args);
40+
return rootCommand.Parse(args).Invoke();
3841

3942
static IReadOnlyDictionary<int, System.Drawing.Color[]> ReadPalettes()
4043
{
Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
4-
<ImplicitUsings>enable</ImplicitUsings>
5-
<TargetFramework>net8.0</TargetFramework>
6-
7-
<IsPackable>false</IsPackable>
8-
</PropertyGroup>
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<IsPackable>false</IsPackable>
5+
</PropertyGroup>
96

10-
<ItemGroup>
11-
<ProjectReference Include="..\Shockky\Shockky.csproj" />
12-
</ItemGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="..\Shockky\Shockky.csproj" />
9+
</ItemGroup>
1310

14-
<ItemGroup>
15-
<PackageReference Include="SixLabors.ImageSharp" />
16-
<PackageReference Include="System.CommandLine" />
17-
</ItemGroup>
11+
<ItemGroup>
12+
<PackageReference Include="SixLabors.ImageSharp" />
13+
<PackageReference Include="System.CommandLine" />
14+
</ItemGroup>
1815

19-
<ItemGroup>
20-
<None Include="Palettes\*" CopyToOutputDirectory="PreserveNewest" />
21-
</ItemGroup>
22-
</Project>
16+
<ItemGroup>
17+
<None Include="Palettes\*" CopyToOutputDirectory="PreserveNewest" />
18+
</ItemGroup>
19+
</Project>

Shockky.SourceGeneration.Tests/GlobalUsings.cs

Lines changed: 0 additions & 1 deletion
This file was deleted.

Shockky.SourceGeneration.Tests/InstructionGeneratorTests.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
using System.Collections.Immutable;
2+
using System.Diagnostics.CodeAnalysis;
23

34
using Microsoft.CodeAnalysis;
45
using Microsoft.CodeAnalysis.CSharp;
56

67
using Shockky.Lingo.Instructions;
78

9+
using Xunit;
10+
811
namespace Shockky.SourceGeneration.Tests;
912

1013
public sealed class InstructionGeneratorTests
1114
{
15+
/* lang=C# */
1216
public const string ExpectedReturnOutput = """
1317
namespace Shockky.Lingo.Instructions;
1418
@@ -31,6 +35,8 @@ public void WriteTo(global::Shockky.IO.ShockwaveWriter output)
3135
}
3236
}
3337
""";
38+
39+
/* lang=C# */
3440
public const string ExpectedPushIntOutput = """
3541
namespace Shockky.Lingo.Instructions;
3642
@@ -73,6 +79,8 @@ public void WriteTo(global::Shockky.IO.ShockwaveWriter output)
7379
}
7480
}
7581
""";
82+
83+
/* lang=C# */
7684
public const string ExpectedSharedReadMethod = """
7785
namespace Shockky.Lingo.Instructions;
7886
@@ -106,6 +114,7 @@ public static IInstruction Read(ref global::Shockky.IO.ShockwaveReader input)
106114
[Fact]
107115
public void InstructionGenerator_Generates_OpWithoutImmediate()
108116
{
117+
/* lang=C# */
109118
string source = """
110119
namespace Shockky.Lingo.Instructions;
111120
@@ -123,6 +132,7 @@ [new InstructionGenerator()],
123132
[Fact]
124133
public void InstructionGenerator_Generates_OpWithImmediate()
125134
{
135+
/* lang=C# */
126136
string source = """
127137
namespace Shockky.Lingo.Instructions;
128138
@@ -140,6 +150,7 @@ [new InstructionGenerator()],
140150
[Fact]
141151
public void InstructionGenerator_Generates_SharedReadLogic()
142152
{
153+
/* lang=C# */
143154
string source = """
144155
namespace Shockky.Lingo.Instructions;
145156
@@ -165,7 +176,7 @@ [new InstructionGenerator()],
165176
/// <param name="source">The input source to process.</param>
166177
/// <param name="generators">The generators to apply to the input syntax tree.</param>
167178
/// <param name="results">The source files to compare.</param>
168-
private static void VerifyGenerateSources(string source, IIncrementalGenerator[] generators, params (string Filename, string? Text)[] results)
179+
private static void VerifyGenerateSources([StringSyntax("C#")] string source, IIncrementalGenerator[] generators, params (string Filename, string? Text)[] results)
169180
{
170181
VerifyGenerateSources(source, generators, LanguageVersion.CSharp12, results);
171182
}
@@ -177,7 +188,7 @@ private static void VerifyGenerateSources(string source, IIncrementalGenerator[]
177188
/// <param name="generators">The generators to apply to the input syntax tree.</param>
178189
/// <param name="languageVersion">The language version to use.</param>
179190
/// <param name="results">The source files to compare.</param>
180-
private static void VerifyGenerateSources(string source, IIncrementalGenerator[] generators, LanguageVersion languageVersion, params (string Filename, string? Text)[] results)
191+
private static void VerifyGenerateSources([StringSyntax("C#")] string source, IIncrementalGenerator[] generators, LanguageVersion languageVersion, params (string Filename, string? Text)[] results)
181192
{
182193
// Ensure Shockky is loaded
183194
Type observableObjectType = typeof(OPAttribute);
@@ -214,7 +225,7 @@ from assembly in AppDomain.CurrentDomain.GetAssemblies()
214225
string filePath = filename;
215226

216227
// Update the assembly version using the version from the assembly of the input generators.
217-
// This allows the tests to not need updates whenever the version of the MVVM Toolkit changes.
228+
// This allows the tests to not need updates whenever the version of the library changes.
218229
string expectedText = text.Replace("<ASSEMBLY_VERSION>", $"\"{generators[0].GetType().Assembly.GetName().Version}\"");
219230

220231
SyntaxTree generatedTree = outputCompilation.SyntaxTrees.Single(tree => Path.GetFileName(tree.FilePath) == filePath);
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
4+
<OutputType>Exe</OutputType>
85
<IsPackable>false</IsPackable>
96
<IsTestProject>true</IsTestProject>
107
</PropertyGroup>
118

129
<ItemGroup>
1310
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
15-
<PackageReference Include="xunit" />
16-
<PackageReference Include="xunit.runner.visualstudio">
17-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18-
<PrivateAssets>all</PrivateAssets>
19-
</PackageReference>
20-
<PackageReference Include="coverlet.collector">
21-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22-
<PrivateAssets>all</PrivateAssets>
23-
</PackageReference>
11+
<PackageReference Include="xunit.v3" />
2412
</ItemGroup>
2513

2614
<ItemGroup>
2715
<ProjectReference Include="..\Shockky.SourceGeneration\Shockky.SourceGeneration.csproj"/>
2816
<ProjectReference Include="..\Shockky\Shockky.csproj" />
2917
</ItemGroup>
3018

31-
</Project>
19+
</Project>

Shockky.SourceGeneration/Extensions/AttributeDataExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// This file is ported and adapted from ComputeSharp (Sergio0694/ComputeSharp),
66
// more info in ThirdPartyNotices.txt in the root of the project.
77

8-
using System.Collections.Generic;
98
using System.Diagnostics.CodeAnalysis;
109

1110
using Microsoft.CodeAnalysis;

Shockky.SourceGeneration/Extensions/CompilationExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
// This file is ported and adapted from CommunityToolkit.Mvvm (CommunityToolkit/dotnet),
66
// more info in ThirdPartyNotices.txt in the root of the project.
77

8-
using System;
9-
using System.Collections.Generic;
108
using System.Collections.Immutable;
119
using System.Diagnostics.CodeAnalysis;
10+
1211
using Microsoft.CodeAnalysis;
1312
using Microsoft.CodeAnalysis.CSharp;
1413

0 commit comments

Comments
 (0)