Updated packages and remove Newtonsoft.Json in favor of System.Text.Json

This commit is contained in:
Mark Ettema 2021-05-09 20:36:41 +07:00
parent 94de2a3363
commit 62dd979a80
6 changed files with 35 additions and 38 deletions

View file

@ -1,11 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using System.Text.Json.Serialization;
namespace SteamOpenIdConnectProvider.Profile.Models namespace SteamOpenIdConnectProvider.Profile.Models
{ {
public sealed class GetPlayerSummariesResponse public sealed class GetPlayerSummariesResponse
{ {
[JsonProperty("players")] [JsonPropertyName("players")]
public ICollection<Player> Players { get; set; } public ICollection<Player> Players { get; set; }
} }
} }

View file

@ -1,58 +1,59 @@
using Newtonsoft.Json; using System.Text.Json;
using System.Text.Json.Serialization;
namespace SteamOpenIdConnectProvider.Profile.Models namespace SteamOpenIdConnectProvider.Profile.Models
{ {
public sealed class Player public sealed class Player
{ {
[JsonProperty("steamid")] [JsonPropertyName("steamid")]
public ulong SteamId { get; set; } public ulong SteamId { get; set; }
[JsonProperty("communityvisibilitystate")] [JsonPropertyName("communityvisibilitystate")]
public int CommunityVisibilityState { get; set; } public int CommunityVisibilityState { get; set; }
[JsonProperty("profilestate")] [JsonPropertyName("profilestate")]
public int ProfileState { get; set; } public int ProfileState { get; set; }
[JsonProperty("personaname")] [JsonPropertyName("personaname")]
public string PersonaName { get; set; } public string PersonaName { get; set; }
[JsonProperty("commentpermission")] [JsonPropertyName("commentpermission")]
public int CommentPermission { get; set; } public int CommentPermission { get; set; }
[JsonProperty("profileurl")] [JsonPropertyName("profileurl")]
public string ProfileUrl { get; set; } public string ProfileUrl { get; set; }
[JsonProperty("avatar")] [JsonPropertyName("avatar")]
public string Avatar { get; set; } public string Avatar { get; set; }
[JsonProperty("avatarmedium")] [JsonPropertyName("avatarmedium")]
public string AvatarMedium { get; set; } public string AvatarMedium { get; set; }
[JsonProperty("avatarfull")] [JsonPropertyName("avatarfull")]
public string AvatarFull { get; set; } public string AvatarFull { get; set; }
[JsonProperty("avatarhash")] [JsonPropertyName("avatarhash")]
public string AvatarHash { get; set; } public string AvatarHash { get; set; }
[JsonProperty("lastlogoff")] [JsonPropertyName("lastlogoff")]
public int LastLogoff { get; set; } public int LastLogoff { get; set; }
[JsonProperty("personastate")] [JsonPropertyName("personastate")]
public int PersonaState { get; set; } public int PersonaState { get; set; }
[JsonProperty("realname")] [JsonPropertyName("realname")]
public string RealName { get; set; } public string RealName { get; set; }
[JsonProperty("primaryclanid")] [JsonPropertyName("primaryclanid")]
public ulong PrimaryClanId { get; set; } public ulong PrimaryClanId { get; set; }
[JsonProperty("timecreated")] [JsonPropertyName("timecreated")]
public int TimeCreated { get; set; } public int TimeCreated { get; set; }
[JsonProperty("personastateflags")] [JsonPropertyName("personastateflags")]
public int PersonaStateFlags { get; set; } public int PersonaStateFlags { get; set; }
[JsonProperty("loccountrycode")] [JsonPropertyName("loccountrycode")]
public string LocCountryCode { get; set; } public string LocCountryCode { get; set; }
} }
} }

View file

@ -1,10 +1,10 @@
using Newtonsoft.Json; using System.Text.Json.Serialization;
namespace SteamOpenIdConnectProvider.Profile.Models namespace SteamOpenIdConnectProvider.Profile.Models
{ {
public sealed class SteamResponse<T> public sealed class SteamResponse<T>
{ {
[JsonProperty("response")] [JsonPropertyName("response")]
public T Response { get; set; } public T Response { get; set; }
} }
} }

View file

@ -2,13 +2,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Security.Claims; using System.Security.Claims;
using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using IdentityServer4.Extensions; using IdentityServer4.Extensions;
using IdentityServer4.Models; using IdentityServer4.Models;
using IdentityServer4.Services; using IdentityServer4.Services;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using SteamOpenIdConnectProvider.Profile.Models; using SteamOpenIdConnectProvider.Profile.Models;
namespace SteamOpenIdConnectProvider.Profile namespace SteamOpenIdConnectProvider.Profile
@ -28,7 +28,7 @@ namespace SteamOpenIdConnectProvider.Profile
var url = $"{baseurl}/?key={applicationKey}&steamids={string.Join(',', steamIds)}"; var url = $"{baseurl}/?key={applicationKey}&steamids={string.Join(',', steamIds)}";
var res = await _httpClient.GetStringAsync(url); var res = await _httpClient.GetStringAsync(url);
var response = JsonConvert.DeserializeObject<SteamResponse<GetPlayerSummariesResponse>>(res); var response = JsonSerializer.Deserialize<SteamResponse<GetPlayerSummariesResponse>>(res);
return response.Response; return response.Response;
} }

View file

@ -29,7 +29,6 @@ namespace SteamOpenIdConnectProvider
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddControllers() services.AddControllers()
.AddNewtonsoftJson()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0); .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddSingleton(Configuration); services.AddSingleton(Configuration);

View file

@ -1,27 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>9f8cb9ce-f696-422f-901a-563af9413684</UserSecretsId> <UserSecretsId>9f8cb9ce-f696-422f-901a-563af9413684</UserSecretsId>
<LangVersion>8</LangVersion> <LangVersion>8</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNet.Security.OpenId.Steam" Version="3.1.0" /> <PackageReference Include="AspNet.Security.OpenId.Steam" Version="5.0.0" />
<PackageReference Include="AspNet.Security.OpenIdConnect.Server" Version="2.0.0" /> <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.2" /> <PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="IdentityServer4" Version="4.1.1" /> <PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.2" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.8" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
<PackageReference Include="Serilog" Version="2.10.0" /> <PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" /> <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup> </ItemGroup>