CslaGeneratorSerialization 0.1.0
See the version list below for details.
dotnet add package CslaGeneratorSerialization --version 0.1.0
NuGet\Install-Package CslaGeneratorSerialization -Version 0.1.0
<PackageReference Include="CslaGeneratorSerialization" Version="0.1.0" />
paket add CslaGeneratorSerialization --version 0.1.0
#r "nuget: CslaGeneratorSerialization, 0.1.0"
// Install CslaGeneratorSerialization as a Cake Addin #addin nuget:?package=CslaGeneratorSerialization&version=0.1.0 // Install CslaGeneratorSerialization as a Cake Tool #tool nuget:?package=CslaGeneratorSerialization&version=0.1.0
GeneratorSerialization
A custom CSLA serializer using C# source generators.
Getting Started
Reference the CslaGeneratorSerialization
NuGet package. You also need to reference CSLA
as well, though if you're using this generator, you are probably already referencing CSLA
.
Prerequisites
The CslaGeneratorSerialization
package targets .NET Standard 2.0, though the code it emits is not limited to .NET Standard 2.0.
Usage
To enable custom serialization, simply make your BO partial
:
[Serializable]
public sealed partial class Person
: BusinessBase<Person>
{
[Create]
private void Create() =>
this.Id = Guid.NewGuid();
public static readonly PropertyInfo<uint> AgeProperty =
RegisterProperty<uint>(_ => _.Age);
[Required]
public uint Age
{
get => this.GetProperty(Person.AgeProperty);
set => this.SetProperty(Person.AgeProperty, value);
}
public static readonly PropertyInfo<Guid> IdProperty =
RegisterProperty<Guid>(_ => _.Id);
[Required]
public Guid Id
{
get => this.GetProperty(Person.IdProperty);
set => this.SetProperty(Person.IdProperty, value);
}
public static readonly PropertyInfo<string> NameProperty =
RegisterProperty<string>(_ => _.Name);
[Required]
public string Name
{
get => this.GetProperty(Person.NameProperty);
set => this.SetProperty(Person.NameProperty, value);
}
}
The generator will create a custom implementation of IGeneratorSerializable
. Note that you must do this for all of your BOs, even ones in other libraries. The generator assumes that this interface will be implemented and attempt to cast all BOs to this type.
You will also need to register the custom serializer during application configuration:
var services = new ServiceCollection();
services.AddCsla(o =>
o.Serialization(so => so.SerializationFormatter(typeof(GeneratorFormatter))));
var provider = services.BuildServiceProvider();
That should do it to get your application to start using this custom serialization formatter.
Additional Documentation
Feedback
If you run into any issues, please add them here.
Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-alpha.1 | 36 | 2/8/2025 |
0.3.0 | 69 | 2/2/2025 |
0.2.0 | 143 | 4/16/2024 |
0.1.0 | 142 | 4/3/2024 |
A changelog is available at https://github.com/JasonBock/CslaGeneratorSerialization/blob/main/changelog.md