dahomey-technologies/Dahomey.Cbor

Issue with Xamarin Forms linker and default constructor

Closed this issue · 4 comments

I'm trying to link my whole Xamarin Forms project that uses Dahomey.Cbor and I get this exception from this line:

throw new CborException($"Cannot find a default constructor on type {typeof(T)}");

No suitable constructor found for converter type:

'Dahomey.Cbor.Serialization.Converters.ObjectConverter`1[[Project.Models.Responses.WebserviceResponse`1[[System.Collections.Generic.List`1[[Project.Chat.ViewModels.ChatViewModel, Project, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Project, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]'.

I already tried to exclude the whole name space and different classes above but I still get this error. All other deserialization with Cbor and Newtonsoft.Json work. Do you have any clue about why it can not find the default constructor in this case?

is this issue still relevant?

Well I guess it is. I just changed to link only the SDK's but it would be nice to Link out all the unused code.
I believe it needs a PreserveAttribute to make sure that the default constructor does not get linked away.

Please, can you provide a sample ? and full exception stack please ?
The error is not clear for me, which class is missing a default constructor ?

For now, I'm going to close this issue. If you can reproduce it in the future, please, feel free to open it again.