JetBrains / YouTrackSharp

.NET Standard 2.0 Library to access YouTrack API.
https://www.jetbrains.com/youtrack
Apache License 2.0
135 stars 105 forks source link

issue.GetField("Assignee").AsCollection() returns a List<string> with "System.Collections.Generic.List`1[YouTrackSharp.Issues.Assignee]", rather than the actual Assignee name #76

Closed MarkHutchings closed 6 years ago

MarkHutchings commented 6 years ago

See: https://github.com/JetBrains/YouTrackSharp/blob/c591920981c9e0b8a4717856934be281b27251ad/src/YouTrackSharp/Issues/Field.cs#L71

maartenba commented 6 years ago

How many assignees does the issue have?

MarkHutchings commented 6 years ago

Just one!

For now I'm doing: var list = (List<Assignee>)issue.GetField("Assignee").Value;

perhaps that's the preferred solution?

maartenba commented 6 years ago

You can just get the issue.Assignee[0] as well.

MarkHutchings commented 6 years ago

Ah, that works if the type is dynamic (i.e. issue.AsDynamic().Assignee[0]).

I have a wrapper class anyway so it's fine for me to do this:

    if( _native.GetField( "Assignee" ).Value is List<Assignee> list )
        return list[0].UserName;