Skip to content

Commit d618b6c

Browse files
refactor: config resource wip
* Add initial D10.1 tests
1 parent 3f3ccc4 commit d618b6c

22 files changed

+261
-98
lines changed

.editorconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion
219219
dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables
220220
dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase
221221

222-
dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion
223-
dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants
224-
dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase
222+
dotnet_naming_rule.local_constants_should_be_pascalcase.severity = suggestion
223+
dotnet_naming_rule.local_constants_should_be_pascalcase.symbols = local_constants
224+
dotnet_naming_rule.local_constants_should_be_pascalcase.style = pascalcase
225225

226226
dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion
227227
dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters

Shockky.Sandbox/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void HandleExtractCommand(IEnumerable<System.IO.FileInfo> input, Director
148148
//
149149
//if (associationTable.ResourceMap.TryGetValue(paletterResId, out int paletteChunkIndex))
150150
//{
151-
// var palette = shockwaveFile[paletteChunkIndex] as Palette;
151+
// var palette = shockwaveFile[paletteResourceIndex] as Palette;
152152
// bitmapData.PopulateMedia(bitmapProperties);
153153
// if (!TryExtractBitmapResource(fileOutputDirectory, outputFileName, bitmapData, palette.Colors))
154154
// continue;

Shockky.SourceGeneration/AnalyzerReleases.Shipped.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; Shipped analyzer releases
1+
; Shipped analyzer releases
22
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
33

44
## Release 1.0

Shockky.SourceGeneration/Helpers/ImmutableArrayBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public readonly ReadOnlySpan<T> WrittenSpan
6262
/// No other data should be written to the builder while the returned <see cref="Span{T}"/>
6363
/// is in use, as it could invalidate the memory area wrapped by it, if resizing occurs.
6464
/// </remarks>
65-
public readonly Span<T> Advance(int requestedSize) => _writer!.Advance(requestedSize);
65+
public readonly Span<T?> Advance(int requestedSize) => _writer!.Advance(requestedSize);
6666

6767
/// <inheritdoc cref="ImmutableArray{T}.Builder.Add(T)"/>
6868
public readonly void Add(T item) => _writer!.Add(item);

Shockky.Tests/Data/d101_empty.dcr

1.04 KB
Binary file not shown.

Shockky.Tests/Data/d101_empty.dir

11 KB
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Shockky.Resources;
2+
using Xunit;
3+
4+
namespace Shockky.Tests.FunctionalTests;
5+
6+
public class Director10FileTests(Director10FileTests.Fixture fixture) : IClassFixture<Director10FileTests.Fixture>
7+
{
8+
public class Fixture
9+
{
10+
public ShockwaveFile EmptyFile { get; } = ShockwaveFile.Read("./Data/d101_empty.dir");
11+
public ShockwaveFile EmptyFileAfterburned { get; } = ShockwaveFile.Read("./Data/d101_empty.dcr");
12+
}
13+
14+
[Fact]
15+
public void EmptyFile_HasKeyMapWithHardcodedResourceId()
16+
{
17+
bool found = fixture.EmptyFile.Resources.TryGetValue(3, out var resource);
18+
19+
Assert.True(found);
20+
Assert.IsType<KeyMapResource>(resource);
21+
}
22+
23+
[Fact]
24+
public void EmptyFileAfterburned_HasKeyMapWithHardcodedResourceId()
25+
{
26+
bool found = fixture.EmptyFileAfterburned.Resources.TryGetValue(3, out var resource);
27+
28+
Assert.True(found);
29+
Assert.IsType<KeyMapResource>(resource);
30+
}
31+
}

Shockky.Tests/IO/ShockwaveWriterTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public void Write_VariableInteger_AreEqual(int value)
4040

4141
private void Write_NumericValues_AreEqual(bool reverseEndianness)
4242
{
43-
const int OUTPUT_SIZE = sizeof(byte)
43+
const int OutputSize = sizeof(byte)
4444
+ sizeof(short) * 2
4545
+ sizeof(ushort) * 2
4646
+ sizeof(int) * 2
4747
+ sizeof(uint) * 2;
4848

49-
Span<byte> buffer = stackalloc byte[OUTPUT_SIZE];
49+
Span<byte> buffer = stackalloc byte[OutputSize];
5050
var output = new ShockwaveWriter(buffer, reverseEndianness);
5151
var input = new ShockwaveReader(buffer, reverseEndianness);
5252

Shockky.Tests/Shockky.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111
<ItemGroup>
1212
<ProjectReference Include="..\Shockky\Shockky.csproj" />
1313
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\d101_empty.dcr" CopyToOutputDirectory="PreserveNewest" />
17+
<None Update="Data\d101_empty.dir" CopyToOutputDirectory="PreserveNewest" />
18+
</ItemGroup>
1419
</Project>

Shockky/IO/ShockwaveReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public Rectangle ReadRectBigEndian()
241241
return Rectangle.FromLTRB(left, top, right, bottom);
242242
}
243243

244-
public unsafe IResource ReadCompressedResource(AfterburnerMapEntry entry, ReaderContext context)
244+
public IResource ReadCompressedResource(AfterburnerMapEntry entry, ReaderContext context)
245245
{
246246
const int StackallocThreshold = 512;
247247

0 commit comments

Comments
 (0)