From 7d191bff01ba5723c574eedf26f1a2b3d0d72e13 Mon Sep 17 00:00:00 2001 From: Elwetana Date: Mon, 26 Oct 2020 15:28:32 +0100 Subject: [PATCH 1/2] Changes to JetBrains implementation --- src/YouTrackSharp/Issues/Field.cs | 2 ++ src/YouTrackSharp/Issues/Issue.cs | 9 ++++++++- src/YouTrackSharp/Issues/IssuesService.Querying.cs | 4 ++-- src/YouTrackSharp/YouTrackSharp.csproj | 5 ++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/YouTrackSharp/Issues/Field.cs b/src/YouTrackSharp/Issues/Field.cs index a991a985..d1dc94a4 100644 --- a/src/YouTrackSharp/Issues/Field.cs +++ b/src/YouTrackSharp/Issues/Field.cs @@ -48,6 +48,8 @@ public string AsString() return null; case ICollection collection: return collection.SingleOrDefault(); + case ICollection collection: + return collection.SingleOrDefault().FullName; } return Value.ToString(); diff --git a/src/YouTrackSharp/Issues/Issue.cs b/src/YouTrackSharp/Issues/Issue.cs index 28774d23..6169d8b2 100644 --- a/src/YouTrackSharp/Issues/Issue.cs +++ b/src/YouTrackSharp/Issues/Issue.cs @@ -88,6 +88,11 @@ public bool IsMarkdown { /// public ICollection Fields => _fields.Values; + /// + /// Get all field names + /// + public ICollection FieldNames => _fields.Keys; + /// /// Issue comments. /// @@ -156,7 +161,9 @@ public override bool TrySetMember(SetMemberBinder binder, object value) if (fieldElement.Value is JArray fieldElementAsArray) { // Map collection - if (string.Equals(fieldElement.Name, "assignee", StringComparison.OrdinalIgnoreCase)) + // Heuristics for finding fields of the type List + var children = new List(fieldElementAsArray.First.Children()); + if(children.Count == 2 && children[0].Path == "[0].value" && children[1].Path == "[0].fullName") { // For assignees, we can do a strong-typed list. fieldElement.Value = fieldElementAsArray.ToObject>(); diff --git a/src/YouTrackSharp/Issues/IssuesService.Querying.cs b/src/YouTrackSharp/Issues/IssuesService.Querying.cs index fe20055b..6f389d11 100644 --- a/src/YouTrackSharp/Issues/IssuesService.Querying.cs +++ b/src/YouTrackSharp/Issues/IssuesService.Querying.cs @@ -106,8 +106,8 @@ public async Task> GetIssues(string filter = null, int? skip response.EnsureSuccessStatusCode(); - var wrapper = - JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var res = await response.Content.ReadAsStringAsync(); + var wrapper = JsonConvert.DeserializeObject(res); return wrapper.Issues; } diff --git a/src/YouTrackSharp/YouTrackSharp.csproj b/src/YouTrackSharp/YouTrackSharp.csproj index a8cad908..3ec5cff4 100644 --- a/src/YouTrackSharp/YouTrackSharp.csproj +++ b/src/YouTrackSharp/YouTrackSharp.csproj @@ -18,11 +18,10 @@ https://github.com/JetBrains/YouTrackSharp.git Git 3.5.0 + AnyCPU;x86 - - 10.0.2 - + From b20eebfe2f7003aa8e3b9a8eedef93315ca40dab Mon Sep 17 00:00:00 2001 From: Elwetana Date: Wed, 28 Oct 2020 12:53:15 +0100 Subject: [PATCH 2/2] Changed Assignee-type check when parsing JSON from server --- src/YouTrackSharp/Issues/Issue.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/YouTrackSharp/Issues/Issue.cs b/src/YouTrackSharp/Issues/Issue.cs index 2a1bfcda..6f3bb29b 100644 --- a/src/YouTrackSharp/Issues/Issue.cs +++ b/src/YouTrackSharp/Issues/Issue.cs @@ -165,7 +165,8 @@ public override bool TrySetMember(SetMemberBinder binder, object value) // Map collection // Heuristics for finding fields of the type List var children = new List(fieldElementAsArray.First.Children()); - if(children.Count == 2 && children[0].Path == "[0].value" && children[1].Path == "[0].fullName") + if (children.Count == 2 && children[0] is JProperty && ((JProperty)children[0]).Name == "value" + && children[1] is JProperty && ((JProperty)children[1]).Name == "fullName") { // For assignees, we can do a strong-typed list. fieldElement.Value = fieldElementAsArray.ToObject>();