-
-
Notifications
You must be signed in to change notification settings - Fork 53
Full feature list & planned features
- Very fast, comparable to MessagePackCSharp
- Very small binary output (equal or smaller than MessagePack)
- Full support for circular references
- Full support for polymorphism / inheritance / interfaces
- Can serialize objects into parts as "ExtenalObjects" (very useful for usage with databases)
- Can serialize Fields, Properties, and even
readonly
fields (Check out the Tutorial to see all the different configuration options, and Feature Demos/Tests for readonly handling (check the ReadonlyTest() method) )-
ShouldSerialize
Callback > Member-Attribute > Class-Attribute > Global Default
-
- No need to place attributes on members to make member-ordering "stable" across platforms!
- Fields/Props are ordered by a combination of name + type-name + declaring type name + element type + ... which means you never have to manually add something like
[Order]
or[Key]
attributes to your classes.
- Fields/Props are ordered by a combination of name + type-name + declaring type name + element type + ... which means you never have to manually add something like
- Efficient:
- By default no type-, versioning-, or other meta-data is written, only what is strictly needed.
- Utilizes both VarInt & Zig-Zag encoding (example: values up to 128 only take 1 byte instead of 4...)
- Encodes type-information in 0 or 1 byte in most cases
- If the type already matches no types are written at all (vast majority of cases)
- KnownTypes are encoded as 1 byte
- Ceras can dynamically learns new/unknown types while serializing (if you allow it). New types are written once in compressed form, thus automatically becoming a known type.
- No slowdown through type lookups! (except for polymorphic types of course)
- Can serialize in parts. You want to save your
Monster
,Spell
, andPlayer
objects each into their own file, but they all reference each other in many ways? No problem at all! Ceras can automatically split and reassemble entire object-graphs for you. And it's pretty easy: seeIExternalRootObject
- No allocations
- Generates no "garbage" (garbage-collector pressure) by recycling all internal objects.
- Integrates with user object-pools as well with
ObjectFactory
andDiscardObject
methods. Especially useful for use as a network protocol or in games so Ceras will not allocate new user-objects and instead get them from your pools. - Recycles serialization buffers (just pass in the buffer by ref)
- Can overwrite objects you already have (by using the
Deserialize(ref existingObject)
method). Works even when an object already contains references to wrong types, Ceras will optionally use yourDiscardObject
-Method then. (can be used to eliminate allocations/GC pressure). - Advanced caching settings to remember objects and typing information over multiple serialization calls to save even more space
- Can be used as a very efficient binary network protocol
- Can generate a checksum of all types, fields, attributes, ... which can be used to ensure binary compatability (very useful for networking where you want to check if the server/client are using the same protocol...)
-
Very easy to add new Formatters
- Ceras has its own DI system to make writing a custom formatter as smooth as possible, simply declare a
public IFormatter<Bla> BlaFormatter;
and Ceras will automatically inject it.
- Ceras has its own DI system to make writing a custom formatter as smooth as possible, simply declare a
- Easy configuration of your own types through attributes (
[MemberConfig]
,[Ignore]
,[Include]
, ...) - Fully automatic version tolerance. Simply turn on
.VersionTolerance
in the settings to let Ceras embedd schema information, so when you change your objects, Ceras can still load older data. Supports all changes: adding / renaming / reordering / deleting members. - Ceras is fully "reentrant" meaning that the same serializer-instance can start a new nested serialization while the other one is still in progress. Very useful when dealing with
IExternalRootObject
s (simplifies your code a lot). - Support for readonly fields: Just set
ReadonlyFieldHandling.Members
and Ceras will populate the contents of objects in readonly fields. Or setReadonlyFieldHandling.ForcedOverwrite
to overwrite readonly field itself as well (using reflection). (Default isOff
because readonly fields are very rarely serialized) - Helpful exceptions: All exceptions Ceras throws contain reasons why something went wrong and what to do about it.
Built-in support for many commonly used .NET types:
-
Primitives(
int
,string
, ...),Enum
-
Any type that implements
ICollection<>
: soList<>
,Dictionary<,>
, ... -
Pretty much all commonly used BCL types:
decimal
,DateTime
,TimeSpan
,DateTimeOffset
,Guid
,Array[]
,KeyValuePair<,>
,Nullable<>
,BitVector32
,BigInteger
,Tuple<>
,ValueTuple<>
, many more... -
Full support for generic types
-
Can serialize
Type
itself and all derivatives ofMemberInfo
(MethodInfo
,MethodBase
, ...) -
Serializes any
delegate
,MulticastDelegate
,System.Action<...>
,System.Func<...>
,event
(if you allow it! limitations) -
All other types are automatically supported: Ceras generates an optimized formatter at runtime for each unknown type it encounters automatically!
-
Some common type missing? Report it and I'll most likely add a formatter for it
-
Planned: Will include an (optional) set of formatters for Unity3D objects (almost done)
This list is quite long, I put pretty much every idea I have here (or ideas suggested by the community). If you urgently need any of those just let me know. Entries are in no particular order.
- Some sort of log that tells you exactly what members are included in the serialization and why, and why the excluded ones are excluded, and what Ceras has tried to determine inclusion/exclusion. Maybe something like
ceras.GetMemberInclusionLog(typeof(MyType));
- "Serialization Constructors" for immutable collections (also supporting private static methods for construction)
- Performance comparisons beyond simple micro benchmarks
- Better exceptions (specific types per for each exception so they can be individually caught)
- Wider range of unit tests instead of manual test cases / debug asserts
- Use FastExpressionCompiler when all its bugs are fixed
- Optional set of formatters for Unity3D (almost done)
- Override formatter per-member (aka
[Formatter(...)]
attribute) - Built-in LZ4 and GZip(Zlib) support, including support for Sync-Flush (especially useful for networking scenarios)
- Serialize/Deserialize callbacks. When a user-object has a
OnSerialize()
orOnDeserialize()
method Ceras should call it. Or maybe support any sort of method with some attribute that users can place? - It would be really cool to support the "capacity-constructor" for List<>, Dictionary<> etc... Shouldn't even be that hard to do and improve performance somewhat when dealing with large collections.
- VersionTolerance could be optimized a bit (if anyone even needs that). We could have settings for the field-size-prefix; or maybe also allow changing the type of a field/property and allow the user to provide some sort of converter. We could also embed a hash per schema and skip reading it when we already have that schema (which improves reading speed)
- Allow specifying something like [MaxStringLength(...)] or so for strings and all collections to protect against malicious data (probably interesting for networking scenarios).
- Allow overriding the used formatter per field. Not sure in what situations that'd be useful though, so not very high on the priority list...
- Maybe use Span<> instead of byte arrays, is it possible/compatible with EnsureCapacity?
- Use array pool, create a new api to help total beginners by managing buffers for them?
- Improved string encoding performance
- Handling for
readonly
fields - .NET standard build target
- Making Ceras available as a nuget package
- Automatic release builds
- Automatic version tolerance can now be enabled through config.
config.VersionTolerance = VersionTolerance.AutomaticEmbedded;
. More options will follow in the future including manual version tolerance if you want to go the extra mile to optimize your code. - Ceras supports fields and properties now, checkout the
tutorial.cs
file to see all the ways to configure what gets serialized