Problem with Generics

https://github.com/NexStandard/NexVYaml/tree/master/VYaml.Core/Serialization I dont know how to get further here In the NexYamlSerializerRegistry all Serializers are registered. Like So , tinherit implements iCLoneable but it doesnt matter its just for having an interface
NexYamlSerializerRegistry.Default.RegisterFormatter(new GeneratedYamlSerializerTInherit());
NexYamlSerializerRegistry.Default.RegisterInterface(x, typeof(ICloneable));
NexYamlSerializerRegistry.Default.RegisterFormatter(new GeneratedYamlSerializerTInherit());
NexYamlSerializerRegistry.Default.RegisterInterface(x, typeof(ICloneable));
` Now the https://github.com/NexStandard/NexVYaml/blob/master/VYaml.Core/Serialization/YamlSerializer.cs#L41 serializer calls the redirector because i dont know which path to go when i have Serialize(ICloneable) so i need to find it in the registry and now the trouble starts as i cant search it as the generic type doesnt fit here https://github.com/NexStandard/NexVYaml/blob/master/VYaml.Core/Serialization/Resolvers/RedirectFormatter.cs#L56 because T is ICloneable which and the serialize method uses T value ( the one to serialize ) but i cant convert IYamlFormatter<TInherit> to IYamlFormatter<ICloneable> because of the covariance i guess... i have no clue actually to what i should convert it... in the formatter variable is the correct one there but its just a IYamlFormatter and not the generic one so it doesnt have the Serialize(T value, blabla)
1 Reply
Joreyk ( IXLLEGACYIXL )
to test it you can get the vyaml repo and the https://github.com/NexStandard/StrideSourceGenerator repo for the generator for this project https://github.com/IXLLEGACYIXL/StrideSourceGened i tried it with method invocation BUT the emitter is a ref struct so i cant put it in as its only a feature proposal