babelshift / SteamWebAPI2

🎮 C# / .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes.
MIT License
263 stars 43 forks source link

Achievement.DefaultValue throws JsonReaderException for large values #60

Closed ckuepker closed 6 years ago

ckuepker commented 6 years ago

Hi,

I stumbled upon a problem when trying to load achievements for a game using ISteamUserStats.GetSchemaForGameAsync(appid). Problem is that some games, e.g. CSS (240), CS GO (730) and Stanley Parable (221910), each have achievements with default values which exceed the int32 range: 4294967295

From what I can see I think that the property SchemaGameAchievement.DefaultValue should be int64 instead of int.

To reproduce simply call GetSchemaForGameAsync for any of the App IDs given above.

Exception: System.AggregateException : Mindestens ein Fehler ist aufgetreten. ----> Newtonsoft.Json.JsonReaderException : JSON integer 4294967295 is too large or small for an Int32. Path 'game.availableGameStats.stats[0].defaultvalue', line 1, position 148.

babelshift commented 6 years ago

I believe this should actually be a uint rather than a long. I made an effort last year to migrate all models to use the unsigned data types because the Steam Web API seems to work based on those.

For this specific case, 4294967295 is actually UInt32.MaxValue.

ckuepker commented 6 years ago

Oh, yes you are right about the unsigned range including the problematic value. In the PR I "upgraded" to long because the original data type was signed.

ckuepker commented 6 years ago

I tried it with uint as well and it also fixes the initial problem. I noticed however, that any of the changes causes some errors on the same interface for games which previously worked. Somehow the auto mapping fails. But that is a technology I know nothing about. Let me know if you'd like to have further details.

babelshift commented 6 years ago

Thanks. I'll take a look.

babelshift commented 6 years ago

Should be fixed on the newest nuget package release (4.0.7).