msgpack-cli
msgpack-cli copied to clipboard
It is possible to pre-compile serialized objects?
To avoid to have a slow time (1.5 seconds) in my case to get the Serializer is possible to compile them?
I've tried to use this:
SerializerGenerator.GenerateCode(
new SerializerCodeGenerationConfiguration
{
Namespace = "Example.MessagePackSerializers",
OutputDirectory = "../../GeneratedSerializers",
EnumSerializationMethod = EnumSerializationMethod.ByName, // You can tweak it to use ByUnderlyingValue as you like.
IsRecursive = true, // Set depenendent serializers are also generated.
PreferReflectionBasedSerializer = false, // Set true if you want to use reflection based collection serializer, false if you want to get generated collection serializers.
SerializationMethod = SerializationMethod.Array // You tweak it to generate 'map' based serializers.
}
}
but I've not understood well where this method call should be written? An external application that generate serializers? But how this would find what should serialize? Using Namespace maybe?
One time something is generated in OutputDirectory how I'll use them?
Thanks for your help!
Sorry, I missed this issue. Specify types as rest arguments like following:
SerializerGenerator.GenerateCode(
new SerializerCodeGenerationConfiguration
{...},
typeof(Foo), typeof(Bar)
)
Note that you can specify types as IEnumerable<Type>
, so you can use LINQ to filter types from some assemblies.
You can also use mpu.exe
utility to generate serializer code.