© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
Joreyk ( IXLLEGACYIXL )

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)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ problem with understanding delegates and generics
C#CC# / help
3y ago
Help with Generics
C#CC# / help
2y ago
❔ Builder with generics
C#CC# / help
3y ago
Opperators with generics.
C#CC# / help
4y ago