Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The guild emblem is optional #10

Closed
Sejsel opened this issue Aug 9, 2019 · 1 comment · Fixed by #11
Closed

The guild emblem is optional #10

Sejsel opened this issue Aug 9, 2019 · 1 comment · Fixed by #11
Assignees
Labels
Area: Web API v2 Related to the v2 web API Duration: Medium Between 2 and 8 hours of estimated work Priority: Medium Medium priority Resolution: Fixed The issue has been fixed Type: Bug Something isn't working

Comments

@Sejsel
Copy link

Sejsel commented Aug 9, 2019

There are quite a few guilds that have no emblem in the API, for example: https://api.guildwars2.com/v2/guild/bd558153-0f8e-e911-81a8-cde2ac1eed30

{
  "id": "BD558153-0F8E-E911-81A8-CDE2AC1EED30",
  "name": "Aomi",
  "tag": "Aomi"
}

The Emblem value is defaulted to an emblem with values of 0, but more importantly the Flags do not work correctly. An InvalidCastException is thrown when getting Gw2Sharp.WebApi.V2.Models.ApiFlags.List in this case.

To reproduce:

static async Task Main(string[] args)
{
	var client = new Gw2Client();
	var guild = await client.WebApi.V2.Guild["bd558153-0f8e-e911-81a8-cde2ac1eed30"].GetAsync();
	Console.WriteLine(guild.Emblem.Flags.List);
}

Exception:

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[Gw2Sharp.WebApi.V2.Models.ApiEnum]' to type 'System.Collections.Generic.IReadOnlyList`1[Gw2Sharp.WebApi.V2.Models.ApiEnum`1[Gw2Sharp.WebApi.V2.Models.GuildEmblemFlag]]'.
   at Gw2Sharp.WebApi.V2.Models.ApiFlags`1.get_List()
   at Gw2SharpTest.Program.Main(String[] args) in /tmp/Gw2SharpTest/Gw2SharpTest/Program.cs:line 13
   at Gw2SharpTest.Program.<Main>(String[] args)
@Archomeda
Copy link
Owner

Ah. I never thought that a guild wouldn't have the guild emblem set. I'll make that nullable.

Regarding the ApiFlags. It would seem that it's a side effect when constructing the default. I'll see if I can get rid of the base non-generic ApiFlags and ApiEnum, as these seem to be causing the issue.

@Archomeda Archomeda added Area: Web API v2 Related to the v2 web API Duration: Medium Between 2 and 8 hours of estimated work Priority: Medium Medium priority Status: In progress This is being worked on Type: Bug Something isn't working labels Aug 10, 2019
@Archomeda Archomeda self-assigned this Aug 10, 2019
Archomeda added a commit that referenced this issue Aug 10, 2019
@Archomeda Archomeda added Status: Waiting for release Work has finished and is waiting to be released and removed Status: In progress This is being worked on labels Aug 10, 2019
@Archomeda Archomeda added Resolution: Fixed The issue has been fixed and removed Status: Waiting for release Work has finished and is waiting to be released labels Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Web API v2 Related to the v2 web API Duration: Medium Between 2 and 8 hours of estimated work Priority: Medium Medium priority Resolution: Fixed The issue has been fixed Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants