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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,4 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
/src/Imcodec.ObjectProperty/Generated
/src/Imcodec.ObjectProperty/GeneratorInput
8 changes: 1 addition & 7 deletions omnisharp.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
"EnableDecompilationSupport": true,
"LocationPaths": []
},
"FormattingOptions": {
"EnableEditorConfigSupport": true
},
"RoslynExtensionsOptions": {
"EnableAnalyzersSupport": true,
"EnableDecompilationSupport": true
},
"FileOptions": {
"SystemExcludeSearchPatterns": [
"**/node_modules/**/*",
Expand All @@ -29,6 +22,7 @@
"InsertionBehavior": "WithOtherMembersOfTheSameKind"
},
"FormattingOptions": {
"EnableEditorConfigSupport": true,
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
Expand Down
116 changes: 0 additions & 116 deletions src/Imcodec.Benchmarks/DummyTypeRegistry.cs

This file was deleted.

32 changes: 15 additions & 17 deletions src/Imcodec.Benchmarks/ObjectSerializerBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ this software without specific prior written permission.
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Imcodec.ObjectProperty;
using Imcodec.ObjectProperty.TypeCache;

namespace Imcodec.Benchmarks;

Expand All @@ -38,10 +39,10 @@ public class ObjectSerializerBenchmarks {

[GlobalSetup]
public void Setup() {
// Initialize the serializer and test data
_serializer = new ObjectSerializer(false, SerializerFlags.None, new DummyTypeRegistry());
// Initialize the serializer and test data.
_serializer = new ObjectSerializer(false, SerializerFlags.None);

// Create a sample loot table
// Create a sample loot table.
_lootTable = new LootInfoList {
m_goldInfo = new GoldLootInfo {
m_goldAmount = 2,
Expand All @@ -56,39 +57,36 @@ public void Setup() {
]
};

// Pre-serialize data for deserialization benchmark
// Pre-serialize data for deserialization benchmark.
_serializedData = Convert.FromHexString(LootTableBlob);
_compressedData = Convert.FromHexString(LootTableBlobCompressed);
}

[Benchmark]
public void SerializeLootTable() {
_serializer.Serialize(_lootTable, (PropertyFlags) 31, out var _);
}
public void SerializeLootTable()
=> _ = _serializer.Serialize(_lootTable, (PropertyFlags) 31, out var _);

[Benchmark]
public void DeserializeLootTable() {
_serializer.Deserialize<LootInfoList>(_serializedData, (PropertyFlags) 31, out var _);
}
public void DeserializeLootTable()
=> _ = _serializer.Deserialize<LootInfoList>(_serializedData, (PropertyFlags) 31, out var _);

[Benchmark]
public void SerializeWithCompression() {
var compressedSerializer = new ObjectSerializer(false, SerializerFlags.Compress, new DummyTypeRegistry());
compressedSerializer.Serialize(_lootTable, (PropertyFlags) 31, out var _);
var compressedSerializer = new ObjectSerializer(false, SerializerFlags.Compress);
_ = compressedSerializer.Serialize(_lootTable, (PropertyFlags) 31, out var _);
}

[Benchmark]
public void DeserializeWithCompression() {
var compressedSerializer = new ObjectSerializer(false, SerializerFlags.Compress, new DummyTypeRegistry());
compressedSerializer.Deserialize<LootInfoList>(_compressedData, (PropertyFlags) 31, out var _);
var compressedSerializer = new ObjectSerializer(false, SerializerFlags.Compress);
_ = compressedSerializer.Deserialize<LootInfoList>(_compressedData, (PropertyFlags) 31, out var _);
}

}

public class Program {

public static void Main(string[] args) {
var summary = BenchmarkRunner.Run<ObjectSerializerBenchmarks>();
}
public static void Main()
=> _ = BenchmarkRunner.Run<ObjectSerializerBenchmarks>();

}
4 changes: 2 additions & 2 deletions src/Imcodec.Cli/ArchiveCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void UnpackArchive(
// If the output directory does not exist, create it.
outputPath = GetOutputDirectory(archivePath, outputPath, archiveName!);
if (!Directory.Exists(outputPath)) {
Directory.CreateDirectory(outputPath);
_ = Directory.CreateDirectory(outputPath);
}

var files = UnpackArchiveFiles(archive);
Expand Down Expand Up @@ -152,7 +152,7 @@ private static string CreateFileOutputPath(string basePath, string fileName) {
var fullDirectoryPath = Path.Combine(basePath, directoryPath);

// Create all necessary directories
Directory.CreateDirectory(fullDirectoryPath);
_ = Directory.CreateDirectory(fullDirectoryPath);

// Return the full path including the file name
return Path.Combine(fullDirectoryPath, actualFileName);
Expand Down
16 changes: 8 additions & 8 deletions src/Imcodec.Cli/Deserialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ public static class Deserialization {
// Create configurations for all serializers to try.
var serializerConfigs = new List<(string Name, Func<ObjectSerializer> Factory, bool IsVerbose)> {
// Standard serializers.
("ObjectCompact", () => new ObjectSerializer(false, SerializerFlags.None), false),
("ObjectCompactCompressed", () => new ObjectSerializer(false, SerializerFlags.UseFlags | SerializerFlags.Compress), false),
("ObjectVerbose", () => new ObjectSerializer(true, SerializerFlags.None), true),
("ObjectVerboseCompressed", () => new ObjectSerializer(true, SerializerFlags.UseFlags | SerializerFlags.Compress), true),
("ObjectCompact", static () => new ObjectSerializer(false, SerializerFlags.None), false),
("ObjectCompactCompressed", static () => new ObjectSerializer(false, SerializerFlags.UseFlags | SerializerFlags.Compress), false),
("ObjectVerbose", static () => new ObjectSerializer(true, SerializerFlags.None), true),
("ObjectVerboseCompressed", static () => new ObjectSerializer(true, SerializerFlags.UseFlags | SerializerFlags.Compress), true),

// Core serializers.
("CoreObject", () => new CoreObjectSerializer(false, SerializerFlags.None), false),
("CoreObjectCompressed", () => new CoreObjectSerializer(false, SerializerFlags.UseFlags | SerializerFlags.Compress), false),
("CoreObjectVerbose", () => new CoreObjectSerializer(true, SerializerFlags.None), true),
("CoreObjectVerboseCompressed", () => new CoreObjectSerializer(true, SerializerFlags.UseFlags | SerializerFlags.Compress), true)
("CoreObject", static () => new CoreObjectSerializer(false, SerializerFlags.None), false),
("CoreObjectCompressed", static () => new CoreObjectSerializer(false, SerializerFlags.UseFlags | SerializerFlags.Compress), false),
("CoreObjectVerbose", static () => new CoreObjectSerializer(true, SerializerFlags.None), true),
("CoreObjectVerboseCompressed", static () => new CoreObjectSerializer(true, SerializerFlags.UseFlags | SerializerFlags.Compress), true)
};

// Attempt to deserialize the blob using a number of methods.
Expand Down
4 changes: 4 additions & 0 deletions src/Imcodec.Cli/IOUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ internal static string ExtractFileName(string path) {
// Get the file name after the last directory separator.
// Verify it's a file name and not a directory.
var fileName = path.Split(Path.DirectorySeparatorChar).Last();

return fileName.Contains('.') ? fileName : "";
}

Expand All @@ -51,6 +52,7 @@ internal static string ExtractDirectoryPath(string path) {
}

var pathWithoutFileName = path[..idx];

return pathWithoutFileName.Contains('.') ? "" : pathWithoutFileName;
}

Expand All @@ -62,6 +64,7 @@ internal static string ExtractDirectoryPath(string path) {
internal static string ExtractFileExtension(string path) {
// Get the file extension from the file name.
var fileName = ExtractFileName(path);

return fileName?.Split('.').Last() ?? "";
}

Expand All @@ -73,6 +76,7 @@ internal static string ExtractFileExtension(string path) {
internal static string RemoveExtension(string path) {
// Split on the last index of '.'.
var idx = path.LastIndexOf('.');

return idx == -1 ? path : path[..idx];
}

Expand Down
29 changes: 0 additions & 29 deletions src/Imcodec.CoreObject/BehaviorInstance.cs

This file was deleted.

29 changes: 0 additions & 29 deletions src/Imcodec.CoreObject/BehaviorTemplate.cs

This file was deleted.

34 changes: 0 additions & 34 deletions src/Imcodec.CoreObject/CoreObject.cs

This file was deleted.

Loading