From 62dd979a80a9ae6c1fbe500d79f03f0adfbc347c Mon Sep 17 00:00:00 2001 From: Mark Ettema Date: Sun, 9 May 2021 20:36:41 +0700 Subject: [PATCH] Updated packages and remove Newtonsoft.Json in favor of System.Text.Json --- .../Models/GetPlayerSummariesResponse.cs | 4 +- src/Profile/Models/Player.cs | 37 ++++++++++--------- src/Profile/Models/SteamResponse.cs | 4 +- src/Profile/SteamProfileService.cs | 4 +- src/Startup.cs | 1 - src/SteamOpenIdConnectProvider.csproj | 23 +++++------- 6 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/Profile/Models/GetPlayerSummariesResponse.cs b/src/Profile/Models/GetPlayerSummariesResponse.cs index 12cb571..5cb0846 100644 --- a/src/Profile/Models/GetPlayerSummariesResponse.cs +++ b/src/Profile/Models/GetPlayerSummariesResponse.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace SteamOpenIdConnectProvider.Profile.Models { public sealed class GetPlayerSummariesResponse { - [JsonProperty("players")] + [JsonPropertyName("players")] public ICollection Players { get; set; } } } \ No newline at end of file diff --git a/src/Profile/Models/Player.cs b/src/Profile/Models/Player.cs index 74af6d6..2873c3d 100644 --- a/src/Profile/Models/Player.cs +++ b/src/Profile/Models/Player.cs @@ -1,58 +1,59 @@ -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; namespace SteamOpenIdConnectProvider.Profile.Models { public sealed class Player { - [JsonProperty("steamid")] + [JsonPropertyName("steamid")] public ulong SteamId { get; set; } - [JsonProperty("communityvisibilitystate")] + [JsonPropertyName("communityvisibilitystate")] public int CommunityVisibilityState { get; set; } - [JsonProperty("profilestate")] + [JsonPropertyName("profilestate")] public int ProfileState { get; set; } - [JsonProperty("personaname")] + [JsonPropertyName("personaname")] public string PersonaName { get; set; } - [JsonProperty("commentpermission")] + [JsonPropertyName("commentpermission")] public int CommentPermission { get; set; } - [JsonProperty("profileurl")] + [JsonPropertyName("profileurl")] public string ProfileUrl { get; set; } - [JsonProperty("avatar")] + [JsonPropertyName("avatar")] public string Avatar { get; set; } - [JsonProperty("avatarmedium")] + [JsonPropertyName("avatarmedium")] public string AvatarMedium { get; set; } - [JsonProperty("avatarfull")] + [JsonPropertyName("avatarfull")] public string AvatarFull { get; set; } - [JsonProperty("avatarhash")] + [JsonPropertyName("avatarhash")] public string AvatarHash { get; set; } - [JsonProperty("lastlogoff")] + [JsonPropertyName("lastlogoff")] public int LastLogoff { get; set; } - [JsonProperty("personastate")] + [JsonPropertyName("personastate")] public int PersonaState { get; set; } - [JsonProperty("realname")] + [JsonPropertyName("realname")] public string RealName { get; set; } - [JsonProperty("primaryclanid")] + [JsonPropertyName("primaryclanid")] public ulong PrimaryClanId { get; set; } - [JsonProperty("timecreated")] + [JsonPropertyName("timecreated")] public int TimeCreated { get; set; } - [JsonProperty("personastateflags")] + [JsonPropertyName("personastateflags")] public int PersonaStateFlags { get; set; } - [JsonProperty("loccountrycode")] + [JsonPropertyName("loccountrycode")] public string LocCountryCode { get; set; } } } \ No newline at end of file diff --git a/src/Profile/Models/SteamResponse.cs b/src/Profile/Models/SteamResponse.cs index 2b43afb..7799ea6 100644 --- a/src/Profile/Models/SteamResponse.cs +++ b/src/Profile/Models/SteamResponse.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace SteamOpenIdConnectProvider.Profile.Models { public sealed class SteamResponse { - [JsonProperty("response")] + [JsonPropertyName("response")] public T Response { get; set; } } } \ No newline at end of file diff --git a/src/Profile/SteamProfileService.cs b/src/Profile/SteamProfileService.cs index 795f8b9..9800ded 100644 --- a/src/Profile/SteamProfileService.cs +++ b/src/Profile/SteamProfileService.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Security.Claims; +using System.Text.Json; using System.Threading.Tasks; using IdentityServer4.Extensions; using IdentityServer4.Models; using IdentityServer4.Services; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Configuration; -using Newtonsoft.Json; using SteamOpenIdConnectProvider.Profile.Models; namespace SteamOpenIdConnectProvider.Profile @@ -28,7 +28,7 @@ namespace SteamOpenIdConnectProvider.Profile var url = $"{baseurl}/?key={applicationKey}&steamids={string.Join(',', steamIds)}"; var res = await _httpClient.GetStringAsync(url); - var response = JsonConvert.DeserializeObject>(res); + var response = JsonSerializer.Deserialize>(res); return response.Response; } diff --git a/src/Startup.cs b/src/Startup.cs index 7a98d35..f056b07 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -29,7 +29,6 @@ namespace SteamOpenIdConnectProvider public void ConfigureServices(IServiceCollection services) { services.AddControllers() - .AddNewtonsoftJson() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddSingleton(Configuration); diff --git a/src/SteamOpenIdConnectProvider.csproj b/src/SteamOpenIdConnectProvider.csproj index 34b6d46..293fe6e 100644 --- a/src/SteamOpenIdConnectProvider.csproj +++ b/src/SteamOpenIdConnectProvider.csproj @@ -1,27 +1,24 @@  - netcoreapp3.1 + net5.0 InProcess 9f8cb9ce-f696-422f-901a-563af9413684 8 - - - - - + + + + - - - - - - + + + + - +