cdmdotnet / Manatee.Trello

A fully object-oriented .Net wrapper for Trello's RESTful API written in C#.
MIT License
121 stars 43 forks source link

Updating CheckItem.State causes Exception #121

Closed JAYDEV-DE closed 6 years ago

JAYDEV-DE commented 6 years ago

Hello,

first of all: Thank you for providing this project, it saved me a lot of time so far.

The issue appears after setting the CheckItem.State to "CheckItemState.Complete".

Here the Exception details:

I'm using a brand new clone of this repository.

Error-Class: "Manatee.Trello.ManateeJson.GeneralExtensions" Error-Function: "public static void Serialize(this T obj, JsonObject json, JsonSerializer serializer, string key, bool force = false)"

Error-Details:"System.ArgumentException occurred HResult=0x80070057 Message=Type provided must be an Enum. Parameter name: enumType Source=mscorlib StackTrace: at System.RuntimeType.GetEnumValues() at System.Enum.GetValues(Type enumType) at Manatee.Json.Serialization.Internal.Serializers.EnumNameSerializer._EnsureDescriptions[T]() at Manatee.Json.Serialization.Internal.Serializers.EnumNameSerializer.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.Internal.Serializers.DefaultValueSerializer.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.Internal.Serializers.SchemaValidator.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.JsonSerializer.Serialize[T](T obj) at Manatee.Trello.ManateeJson.GeneralExtensions.Serialize[T](T obj, JsonObject json, JsonSerializer serializer, String key, Boolean force) in C:\Users\Jansen\Documents\Development\TrelloConnector\Manatee.Trello-master\Manatee.Trello.ManateeJson\GeneralExtensions.cs:line 26 at Manatee.Trello.ManateeJson.Entities.ManateeCheckItem.ToJson(JsonSerializer serializer) in C:\Users\Jansen\Documents\Development\TrelloConnector\Manatee.Trello-master\Manatee.Trello.ManateeJson\Entities\ManateeCheckItem.cs:line 29 at Manatee.Json.Serialization.Internal.Serializers.JsonSerializableSerializer.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.Internal.Serializers.ReferencingSerializer.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.Internal.Serializers.DefaultValueSerializer.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.Internal.Serializers.SchemaValidator.Serialize[T](T obj, JsonSerializer serializer) at Manatee.Json.Serialization.JsonSerializer.Serialize[T](T obj)"

It can be reproduced with the following lines of code:

` var serializer = new ManateeSerializer(); TrelloConfiguration.Serializer = serializer; TrelloConfiguration.Deserializer = serializer; TrelloConfiguration.JsonFactory = new ManateeFactory(); TrelloConfiguration.RestClientProvider = new WebApiClientProvider(); TrelloAuthorization.Default.AppKey = ""; TrelloAuthorization.Default.UserToken = "";

        Member MainUser = new Member("<MemberID>");

        Board myBoard = MainUser.Boards.FirstOrDefault();
        Card myCard = myBoard.Cards.FirstOrDefault();
        CheckList myChecklist = myCard.CheckLists.Add("Demo");
        CheckItem myItem = myChecklist.CheckItems.Add("To be 100 %");
        myItem.State = CheckItemState.Complete;

`

Hope someone can help me fixing this problem.

Thanks

Julian

gregsdennis commented 6 years ago

Thanks for reporting the issue. I'll look into it tonight.

gregsdennis commented 6 years ago

Looks like this is actually an issue with Manatee.Json trying to serialize a nullable enum. I'll create an issue over there.

gregsdennis commented 6 years ago

@JAYDEV-DE please download Manatee.Json v9.6.1 (available on Nuget soon). This should resolve the problem.

JAYDEV-DE commented 6 years ago

@gregsdennis Awesome, that was really quick, i appreciate that.

I tested the code snipped, all works fine now - thanks :-)