Compare commits

...

5 Commits
1.4.0 ... 1.4.2

Author SHA1 Message Date
Deterous
69e1f5ff0b De/Serialize XboxOne/XSX catalog.js files (#6)
* Add JSON/catalog.js logic

* Proper json deserialize

* Update packages

* Catalog is UTF-16 LE, make BaseJsonFile encoding independent

* Bump version, use ST.Models 1.4.1

* Implement JsonFile as interface with UTF8 as default

* typo
2024-04-02 08:46:12 -07:00
Matt Nadareski
d265c14841 Bump version 2024-03-25 14:25:28 -04:00
Matt Nadareski
1148245226 Surface NE/LE/PE methods for other library use 2024-03-24 21:09:12 -04:00
Matt Nadareski
f53d9f94e6 Break if StringFileInfo child is total size 0 2024-03-22 23:46:05 -04:00
Matt Nadareski
4e3d832834 Ensure Listrom serializes to the correct model type 2024-03-19 15:47:13 -04:00
16 changed files with 243 additions and 41 deletions

View File

@@ -65,8 +65,8 @@ namespace SabreTools.Serialization.CrossModel
datItems.Add(ConvertToInternalModel(file));
}
machine[Models.Metadata.Machine.DiskKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "disk")?.ToArray();
machine[Models.Metadata.Machine.RomKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "rom")?.ToArray();
machine[Models.Metadata.Machine.DiskKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "disk").Select(d => d as Models.Metadata.Disk).ToArray();
machine[Models.Metadata.Machine.RomKey] = datItems.Where(i => i.ReadString(Models.Metadata.DatItem.TypeKey) == "rom").Select(d => d as Models.Metadata.Rom).ToArray();
}
return machine;

View File

@@ -1309,6 +1309,8 @@ namespace SabreTools.Serialization
}
stringTableChildren.Add(stringData);
if (stringData.Length == 0 && stringData.ValueLength == 0)
break;
}
stringTable.Children = [.. stringTableChildren];

View File

@@ -0,0 +1,11 @@
using System.Text;
namespace SabreTools.Serialization.Files
{
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
{
// Catalog.js file is a UTF-16 LE JSON
public new Models.Xbox.Catalog? Deserialize(string? path)
=> Deserialize(path, new UnicodeEncoding());
}
}

View File

@@ -0,0 +1,11 @@
using System.Text;
namespace SabreTools.Serialization.Files
{
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
{
// Catalog.js file is a UTF-16 LE JSON
public new bool Serialize(Models.Xbox.Catalog? obj, string? path)
=> Serialize(obj, path, new UnicodeEncoding());
}
}

View File

@@ -0,0 +1,31 @@
using System.Text;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
/// <summary>
/// Base class for other JSON serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class JsonFile<T> : IFileSerializer<T>
{
/// <inheritdoc/>
public T? Deserialize(string? path)
=> Deserialize(path, new UTF8Encoding(false));
/// <summary>
/// Deserialize a file into <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to deserialize to</typeparam>
/// <param name="path">Path to deserialize from</param>
/// <param name="encoding">Encoding to parse text as</param>
/// <returns>Filled object on success, null on error</returns>
public T? Deserialize(string? path, Encoding encoding)
{
using (var data = PathProcessor.OpenStream(path))
{
return new Streams.JsonFile<T>().Deserialize(data, encoding);
}
}
}
}

View File

@@ -0,0 +1,40 @@
using System.IO;
using System.Text;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Files
{
/// <summary>
/// Base class for other JSON serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class JsonFile<T> : IFileSerializer<T>
{
/// <inheritdoc/>
public bool Serialize(T? obj, string? path)
=> Serialize(obj, path, new UTF8Encoding(false));
/// <summary>
/// Serialize a <typeparamref name="T"/> into a file
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>
/// <param name="path">Path to the file to serialize to</param>
/// <param name="encoding">Encoding to parse text as</param>
/// <returns>True on successful serialization, false otherwise</returns>
public bool Serialize(T? obj, string? path, Encoding encoding)
{
if (string.IsNullOrEmpty(path))
return false;
using var stream = new Streams.JsonFile<T>().Serialize(obj, encoding);
if (stream == null)
return false;
using var fs = File.OpenWrite(path);
stream.CopyTo(fs);
return true;
}
}
}

View File

@@ -18,7 +18,6 @@ namespace SabreTools.Serialization.Files
/// </summary>
/// <param name="obj">Data to serialize</param>
/// <param name="path">Path to the file to serialize to</param>
/// <param name="obj">Data to serialize</param>
/// <param name="name">Optional DOCTYPE name</param>
/// <param name="pubid">Optional DOCTYPE pubid</param>
/// <param name="sysid">Optional DOCTYPE sysid</param>

View File

@@ -8,7 +8,7 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.4.0</Version>
<Version>1.4.2</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
@@ -27,8 +27,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.IO" Version="1.3.2" />
<PackageReference Include="SabreTools.Models" Version="1.4.0" />
<PackageReference Include="SabreTools.Models" Version="1.4.1" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,12 @@
using System.IO;
using System.Text;
namespace SabreTools.Serialization.Streams
{
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
{
// Catalog JSON is encoded as UTF-16 LE
public new Models.Xbox.Catalog? Deserialize(Stream? data)
=> Deserialize(data, new UnicodeEncoding());
}
}

View File

@@ -0,0 +1,12 @@
using System.IO;
using System.Text;
namespace SabreTools.Serialization.Streams
{
public partial class Catalog : JsonFile<Models.Xbox.Catalog>
{
// Catalog JSON is encoded as UTF-16 LE
public new Stream? Serialize(Models.Xbox.Catalog? obj)
=> Serialize(obj, new UnicodeEncoding());
}
}

View File

@@ -0,0 +1,40 @@
using System.IO;
using System.Text;
using Newtonsoft.Json;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Streams
{
/// <summary>
/// Base class for other JSON serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class JsonFile<T> : IStreamSerializer<T>
{
/// <inheritdoc/>
public T? Deserialize(Stream? data)
=> Deserialize(data, new UTF8Encoding(false));
/// <summary>
/// Deserialize a Stream into <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to deserialize to</typeparam>
/// <param name="data">Stream to parse</param>
/// <param name="encoding">Text encoding to use</param>
/// <returns>Filled object on success, null on error</returns>
public T? Deserialize(Stream? data, Encoding encoding)
{
// If the stream is null
if (data == null)
return default;
// Setup the serializer and the reader
var serializer = JsonSerializer.Create();
var streamReader = new StreamReader(data, encoding);
var jsonReader = new JsonTextReader(streamReader);
// Perform the deserialization and return
return serializer.Deserialize<T>(jsonReader);
}
}
}

View File

@@ -0,0 +1,43 @@
using System.IO;
using System.Text;
using Newtonsoft.Json;
using SabreTools.Serialization.Interfaces;
namespace SabreTools.Serialization.Streams
{
/// <summary>
/// Base class for other JSON serializers
/// </summary>
/// <typeparam name="T"></typeparam>
public partial class JsonFile<T> : IStreamSerializer<T>
{
/// <inheritdoc/>
public Stream? Serialize(T? obj)
=> Serialize(obj, new UTF8Encoding(false));
/// <summary>
/// Serialize a <typeparamref name="T"/> into a Stream
/// </summary>
/// <typeparam name="T">Type of object to serialize from</typeparam>
/// <param name="obj">Data to serialize</param>
/// <param name="encoding"></param>
/// <returns>Filled object on success, null on error</returns>
public Stream? Serialize(T? obj, Encoding encoding)
{
// If the object is null
if (obj == null)
return null;
// Setup the serializer and the writer
var serializer = JsonSerializer.Create();
var stream = new MemoryStream();
var streamWriter = new StreamWriter(stream, encoding);
var jsonWriter = new JsonTextWriter(streamWriter);
// Perform the deserialization and return
serializer.Serialize(jsonWriter, obj);
stream.Seek(0, SeekOrigin.Begin);
return stream;
}
}
}

View File

@@ -424,7 +424,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled information block on success, null on error</returns>
private static InformationBlock? ParseInformationBlock(Stream data)
public static InformationBlock? ParseInformationBlock(Stream data)
{
// TODO: Use marshalling here instead of building
var informationBlock = new InformationBlock();
@@ -491,7 +491,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled object table entry on success, null on error</returns>
private static ObjectTableEntry ParseObjectTableEntry(Stream data)
public static ObjectTableEntry ParseObjectTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ObjectTableEntry();
@@ -511,7 +511,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled object page map entry on success, null on error</returns>
private static ObjectPageMapEntry ParseObjectPageMapEntry(Stream data)
public static ObjectPageMapEntry ParseObjectPageMapEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ObjectPageMapEntry();
@@ -528,7 +528,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled resource table entry on success, null on error</returns>
private static ResourceTableEntry ParseResourceTableEntry(Stream data)
public static ResourceTableEntry ParseResourceTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ResourceTableEntry();
@@ -547,7 +547,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled resident names table entry on success, null on error</returns>
private static ResidentNamesTableEntry ParseResidentNamesTableEntry(Stream data)
public static ResidentNamesTableEntry ParseResidentNamesTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ResidentNamesTableEntry();
@@ -569,7 +569,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled entry table bundle on success, null on error</returns>
private static EntryTableBundle? ParseEntryTableBundle(Stream data)
public static EntryTableBundle? ParseEntryTableBundle(Stream data)
{
// TODO: Use marshalling here instead of building
var bundle = new EntryTableBundle();
@@ -632,7 +632,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled module format directives table entry on success, null on error</returns>
private static ModuleFormatDirectivesTableEntry ParseModuleFormatDirectivesTableEntry(Stream data)
public static ModuleFormatDirectivesTableEntry ParseModuleFormatDirectivesTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ModuleFormatDirectivesTableEntry();
@@ -649,7 +649,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled verify record directive table entry on success, null on error</returns>
private static VerifyRecordDirectiveTableEntry ParseVerifyRecordDirectiveTableEntry(Stream data)
public static VerifyRecordDirectiveTableEntry ParseVerifyRecordDirectiveTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new VerifyRecordDirectiveTableEntry();
@@ -670,7 +670,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled fix-up page table entry on success, null on error</returns>
private static FixupPageTableEntry ParseFixupPageTableEntry(Stream data)
public static FixupPageTableEntry ParseFixupPageTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new FixupPageTableEntry();
@@ -685,7 +685,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled fix-up record table entry on success, null on error</returns>
private static FixupRecordTableEntry? ParseFixupRecordTableEntry(Stream data)
public static FixupRecordTableEntry? ParseFixupRecordTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new FixupRecordTableEntry();
@@ -904,7 +904,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled import module name table entry on success, null on error</returns>
private static ImportModuleNameTableEntry ParseImportModuleNameTableEntry(Stream data)
public static ImportModuleNameTableEntry ParseImportModuleNameTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ImportModuleNameTableEntry();
@@ -925,7 +925,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled import module name table entry on success, null on error</returns>
private static ImportModuleProcedureNameTableEntry ParseImportModuleProcedureNameTableEntry(Stream data)
public static ImportModuleProcedureNameTableEntry ParseImportModuleProcedureNameTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new ImportModuleProcedureNameTableEntry();
@@ -946,7 +946,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled per-page checksum table entry on success, null on error</returns>
private static PerPageChecksumTableEntry ParsePerPageChecksumTableEntry(Stream data)
public static PerPageChecksumTableEntry ParsePerPageChecksumTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new PerPageChecksumTableEntry();
@@ -961,7 +961,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled non-resident names table entry on success, null on error</returns>
private static NonResidentNamesTableEntry ParseNonResidentNameTableEntry(Stream data)
public static NonResidentNamesTableEntry ParseNonResidentNameTableEntry(Stream data)
{
// TODO: Use marshalling here instead of building
var entry = new NonResidentNamesTableEntry();
@@ -984,7 +984,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="size">Total size of the debug information</param>
/// <returns>Filled debug information on success, null on error</returns>
private static DebugInformation? ParseDebugInformation(Stream data, long size)
public static DebugInformation? ParseDebugInformation(Stream data, long size)
{
// TODO: Use marshalling here instead of building
var debugInformation = new DebugInformation();

View File

@@ -213,7 +213,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled executable header on success, null on error</returns>
private static ExecutableHeader? ParseExecutableHeader(Stream data)
public static ExecutableHeader? ParseExecutableHeader(Stream data)
{
// TODO: Use marshalling here instead of building
var header = new ExecutableHeader();
@@ -266,7 +266,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="count">Number of segment table entries to read</param>
/// <returns>Filled segment table on success, null on error</returns>
private static SegmentTableEntry[] ParseSegmentTable(Stream data, int count)
public static SegmentTableEntry[] ParseSegmentTable(Stream data, int count)
{
// TODO: Use marshalling here instead of building
var segmentTable = new SegmentTableEntry[count];
@@ -290,7 +290,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="count">Number of resource table entries to read</param>
/// <returns>Filled resource table on success, null on error</returns>
private static ResourceTable ParseResourceTable(Stream data, int count)
public static ResourceTable ParseResourceTable(Stream data, int count)
{
long initialOffset = data.Position;
@@ -355,7 +355,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="endOffset">First address not part of the resident-name table</param>
/// <returns>Filled resident-name table on success, null on error</returns>
private static ResidentNameTableEntry[] ParseResidentNameTable(Stream data, int endOffset)
public static ResidentNameTableEntry[] ParseResidentNameTable(Stream data, int endOffset)
{
// TODO: Use marshalling here instead of building
var residentNameTable = new List<ResidentNameTableEntry>();
@@ -378,7 +378,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="count">Number of module-reference table entries to read</param>
/// <returns>Filled module-reference table on success, null on error</returns>
private static ModuleReferenceTableEntry[] ParseModuleReferenceTable(Stream data, int count)
public static ModuleReferenceTableEntry[] ParseModuleReferenceTable(Stream data, int count)
{
// TODO: Use marshalling here instead of building
var moduleReferenceTable = new ModuleReferenceTableEntry[count];
@@ -399,7 +399,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="endOffset">First address not part of the imported-name table</param>
/// <returns>Filled imported-name table on success, null on error</returns>
private static Dictionary<ushort, ImportedNameTableEntry?> ParseImportedNameTable(Stream data, int endOffset)
public static Dictionary<ushort, ImportedNameTableEntry?> ParseImportedNameTable(Stream data, int endOffset)
{
// TODO: Use marshalling here instead of building
var importedNameTable = new Dictionary<ushort, ImportedNameTableEntry?>();
@@ -422,7 +422,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="endOffset">First address not part of the entry table</param>
/// <returns>Filled entry table on success, null on error</returns>
private static EntryTableBundle[] ParseEntryTable(Stream data, int endOffset)
public static EntryTableBundle[] ParseEntryTable(Stream data, int endOffset)
{
// TODO: Use marshalling here instead of building
var entryTable = new List<EntryTableBundle>();
@@ -461,7 +461,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="endOffset">First address not part of the nonresident-name table</param>
/// <returns>Filled nonresident-name table on success, null on error</returns>
private static NonResidentNameTableEntry[] ParseNonResidentNameTable(Stream data, int endOffset)
public static NonResidentNameTableEntry[] ParseNonResidentNameTable(Stream data, int endOffset)
{
// TODO: Use marshalling here instead of building
var residentNameTable = new List<NonResidentNameTableEntry>();

View File

@@ -292,7 +292,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled executable header on success, null on error</returns>
private static COFFFileHeader ParseCOFFFileHeader(Stream data)
public static COFFFileHeader ParseCOFFFileHeader(Stream data)
{
// TODO: Use marshalling here instead of building
var fileHeader = new COFFFileHeader();
@@ -314,7 +314,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="optionalSize">Size of the optional header</param>
/// <returns>Filled optional header on success, null on error</returns>
private static OptionalHeader ParseOptionalHeader(Stream data, int optionalSize)
public static OptionalHeader ParseOptionalHeader(Stream data, int optionalSize)
{
long initialOffset = data.Position;
@@ -484,7 +484,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="count">Number of section table entries to read</param>
/// <returns>Filled section table on success, null on error</returns>
private static SectionHeader[] ParseSectionTable(Stream data, int count)
public static SectionHeader[] ParseSectionTable(Stream data, int count)
{
// TODO: Use marshalling here instead of building
var sectionTable = new SectionHeader[count];
@@ -524,7 +524,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="count">Number of COFF symbol table entries to read</param>
/// <returns>Filled COFF symbol table on success, null on error</returns>
private static COFFSymbolTableEntry[] ParseCOFFSymbolTable(Stream data, uint count)
public static COFFSymbolTableEntry[] ParseCOFFSymbolTable(Stream data, uint count)
{
// TODO: Use marshalling here instead of building
var coffSymbolTable = new COFFSymbolTableEntry[count];
@@ -681,7 +681,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled COFF string table on success, null on error</returns>
private static COFFStringTable ParseCOFFStringTable(Stream data)
public static COFFStringTable ParseCOFFStringTable(Stream data)
{
// TODO: Use marshalling here instead of building
var coffStringTable = new COFFStringTable();
@@ -712,7 +712,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="endOffset">First address not part of the attribute certificate table</param>
/// <returns>Filled attribute certificate on success, null on error</returns>
private static AttributeCertificateTableEntry[] ParseAttributeCertificateTable(Stream data, int endOffset)
public static AttributeCertificateTableEntry[] ParseAttributeCertificateTable(Stream data, int endOffset)
{
var attributeCertificateTable = new List<AttributeCertificateTableEntry>();
@@ -743,7 +743,7 @@ namespace SabreTools.Serialization.Streams
/// </summary>
/// <param name="data">Stream to parse</param>
/// <returns>Filled delay-load directory table on success, null on error</returns>
private static DelayLoadDirectoryTable ParseDelayLoadDirectoryTable(Stream data)
public static DelayLoadDirectoryTable ParseDelayLoadDirectoryTable(Stream data)
{
// TODO: Use marshalling here instead of building
var delayLoadDirectoryTable = new DelayLoadDirectoryTable();
@@ -767,7 +767,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="endOffset">First address not part of the base relocation table</param>
/// <param name="sections">Section table to use for virtual address translation</param>
/// <returns>Filled base relocation table on success, null on error</returns>
private static BaseRelocationBlock[] ParseBaseRelocationTable(Stream data, int endOffset, SectionHeader?[] sections)
public static BaseRelocationBlock[] ParseBaseRelocationTable(Stream data, int endOffset, SectionHeader?[] sections)
{
// TODO: Use marshalling here instead of building
var baseRelocationTable = new List<BaseRelocationBlock>();
@@ -808,7 +808,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="endOffset">First address not part of the debug table</param>
/// <param name="sections">Section table to use for virtual address translation</param>
/// <returns>Filled debug table on success, null on error</returns>
private static DebugTable ParseDebugTable(Stream data, int endOffset, SectionHeader?[] sections)
public static DebugTable ParseDebugTable(Stream data, int endOffset, SectionHeader?[] sections)
{
// TODO: Use marshalling here instead of building
var debugTable = new DebugTable();
@@ -845,7 +845,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="data">Stream to parse</param>
/// <param name="sections">Section table to use for virtual address translation</param>
/// <returns>Filled export table on success, null on error</returns>
private static ExportTable ParseExportTable(Stream data, SectionHeader?[] sections)
public static ExportTable ParseExportTable(Stream data, SectionHeader?[] sections)
{
// TODO: Use marshalling here instead of building
var exportTable = new ExportTable();
@@ -962,7 +962,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="magic">Optional header magic number indicating PE32 or PE32+</param>
/// <param name="sections">Section table to use for virtual address translation</param>
/// <returns>Filled import table on success, null on error</returns>
private static ImportTable ParseImportTable(Stream data, OptionalHeaderMagicNumber magic, SectionHeader?[] sections)
public static ImportTable ParseImportTable(Stream data, OptionalHeaderMagicNumber magic, SectionHeader?[] sections)
{
// TODO: Use marshalling here instead of building
var importTable = new ImportTable();
@@ -1187,7 +1187,7 @@ namespace SabreTools.Serialization.Streams
/// <param name="sections">Section table to use for virtual address translation</param>
/// <param name="topLevel">Indicates if this is the top level or not</param>
/// <returns>Filled resource directory table on success, null on error</returns>
private static ResourceDirectoryTable? ParseResourceDirectoryTable(Stream data, long initialOffset, SectionHeader?[] sections, bool topLevel = false)
public static ResourceDirectoryTable? ParseResourceDirectoryTable(Stream data, long initialOffset, SectionHeader?[] sections, bool topLevel = false)
{
// TODO: Use marshalling here instead of building
var resourceDirectoryTable = new ResourceDirectoryTable();

View File

@@ -35,7 +35,7 @@ namespace SabreTools.Serialization.Streams
if (obj == null)
return null;
// Setup the serializer and the reader
// Setup the serializer and the writer
var serializer = new XmlSerializer(typeof(T));
var settings = new XmlWriterSettings
{