SerdesNet 3.0.1

dotnet add package SerdesNet --version 3.0.1                
NuGet\Install-Package SerdesNet -Version 3.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SerdesNet" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SerdesNet --version 3.0.1                
#r "nuget: SerdesNet, 3.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SerdesNet as a Cake Addin
#addin nuget:?package=SerdesNet&version=3.0.1

// Install SerdesNet as a Cake Tool
#tool nuget:?package=SerdesNet&version=3.0.1                

SerdesNet

A .NET serialisation library where the same function can both serialize and deserialize (i.e. Serdes = SERialize-DESerialize)

The basic usage pattern is:

class SomeObject
{
	public int Field1;
	public string Field2;
	public ushort Field3;
}

static SomeObject Serdes(SomeObject existing, ISerdes s) // This method handles both serialization and deserialization.
{
	existing ??= new SomeType(); // If we're reading then typically 'existing' will be null, when writing it will be the object to write.

	// When writing, each of these will basically be equivalent to
	// "existing.Field1 = existing.Field1", but with the side-effect
	// of serializing the value to the underlying stream.

	// When reading, the values passed in will just be the defaults for the type and the return value will be the deserialized value.

	existing.Field1 = s.Int32(nameof(existing.Field1), existing.Field1);
	existing.Field2 = s.NullTerminatedString(nameof(existing.Field2), existing.Field2);
	existing.Field3 = s.UInt16(nameof(existing.Field3), existing.Field3);

	return existing;
}

The serdes methods like Int32(string name, int value), UInt16(string name, ushort value) etc should maintain these invariants:

  • When serializing, the return value should be value (i.e. serializing an object should not change it).
  • When deserializing, value should be ignored and the return value should be the deserialized value.
  • The name parameter is only used to identify the field when using an annotation serdes for debugging. For the basic reader/writer serializers it is ignored.
  • For most types, an integer can be used rather than a name. This is helpful for things like arrays / lists.

In cases where using the same code for reading and writing is impractical the flags can be checked to see if we are reading or writing. For example:


static SomeObject Serdes(SomeObject existing, ISerdes s)
{
	if (s.IsReading)
	{
		// Don't need to use 'existing' at all when reading
		var result = new SomeObject();
		result.Field1 = s.Int32(nameof(result.Field1), 0);
		result.Field2 = s.NullTerminatedString(nameof(result.Field2), "");
		result.Field3 = s.UInt16(nameof(result.Field3), 0);
		return result;
	}
	else
	{
		// Don't care about any return value when writing
		if (existing == null) throw new ArgumentNullException(nameof(existing));
		s.Int32(nameof(existing.Field1), existing.Field1);
		s.NullTerminatedString(nameof(existing.Field2), existing.Field2);
		s.UInt16(nameof(existing.Field3), existing.Field3);
		return existing;
	}
}

Features

  • ReaderSerdes and WriterSerdes: Basic implementations of ISerdes for reading and writing with a stream.
  • AnnotationProxySerdes: Delegates reading/writing to an underlying serdes and generates a textual representation of the read/write operations for debugging.
  • BreakpointProxySerdes: For debugging. When a certain offset range is read/written then an event will be raised.
  • EmptySerdes: A null implementation of ISerdes which represents a non-existent file. Will error on most calls.
  • WindowingProxySerdes: Delegates reading/writing to an underlying serdes to simulate a subset of the underlying stream.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SerdesNet:

Package Downloads
ADLMidi.NET

A .NET wrapper for the libADLMIDI library, a free Software MIDI synthesizer library with OPL3 emulation

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on SerdesNet:

Repository Stars
csinkers/ualbion
A remake of the 1995 RPG Albion (requires data from an install of the original game)
Version Downloads Last updated
3.0.1 108 11/16/2024
3.0.0 70 11/16/2024
2.0.1 379 2/19/2023
2.0.0 1,783 6/6/2022
1.8.0 982 1/27/2022
1.7.2 1,051 3/14/2021
1.7.1 543 3/13/2021
1.6.1 555 2/28/2021
1.5.1 379 2/17/2021
1.5.0 567 2/1/2021
1.4.1 2,083 11/22/2020
1.3.1 451 10/17/2020
1.2.1 449 9/7/2020
1.2.0 2,082 9/6/2020
1.1.4 652 8/15/2020
1.1.3 1,356 8/4/2020
1.1.2 690 7/11/2020
1.1.1 913 7/4/2020
1.0.4 1,114 3/24/2020
1.0.3 495 3/22/2020
1.0.2 485 3/11/2020