Skip to content

Commit a2cfe28

Browse files
authored
Merge pull request #12 from ChaosEngine/No-NewtonsoftJson
Removed use of Newtonsoft.Json
2 parents 449d067 + 3a44344 commit a2cfe28

9 files changed

Lines changed: 18 additions & 17 deletions

File tree

src/IdentityManager2/Api/Controllers/PageController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using System;
2+
using System.Text.Json;
23
using System.Threading.Tasks;
34
using IdentityManager2.Api.Models;
45
using IdentityManager2.Configuration;
56
using Microsoft.AspNetCore.Authentication;
67
using Microsoft.AspNetCore.Authorization;
78
using Microsoft.AspNetCore.Mvc;
89
using Microsoft.Extensions.Options;
9-
using Newtonsoft.Json;
1010

1111
namespace IdentityManager2.Api.Controllers
1212
{
@@ -29,7 +29,7 @@ public async Task<IActionResult> Index()
2929
return View("/Areas/IdentityManager/Pages/Index.cshtml", new PageModel
3030
{
3131
PathBase = Request.PathBase,
32-
Model = JsonConvert.SerializeObject(new
32+
Model = JsonSerializer.Serialize(new PageModelParams
3333
{
3434
PathBase = Request.PathBase,
3535
ShowLoginButton = !authResult.Succeeded

src/IdentityManager2/Api/Models/PageModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ public class PageModel
55
public string PathBase { get; set; }
66
public string Model { get; set; }
77
}
8+
9+
class PageModelParams
10+
{
11+
public string PathBase { get; set; }
12+
public bool ShowLoginButton { get; set; }
13+
public string TitleNavBarLinkTarget { get; set; }
14+
}
815
}

src/IdentityManager2/Api/Models/RoleQueryResultResource.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ public RoleQueryResultResource(QueryResult<RoleSummary> result, IUrlHelper url,
2929
}
3030
}
3131

32-
public class RoleQueryResultResourceData : QueryResult<RoleSummary>
32+
public class RoleQueryResultResourceData : QueryResult<RoleResultResource>
3333
{
34-
public new IEnumerable<RoleResultResource> Items { get; set; }
35-
3634
public RoleQueryResultResourceData(QueryResult<RoleSummary> result, IUrlHelper url, RoleMetadata meta)
3735
{
3836
if (result == null) throw new ArgumentNullException(nameof(result));

src/IdentityManager2/Api/Models/UserQueryResultResource.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ public UserQueryResultResource(QueryResult<UserSummary> result, IUrlHelper url,
3030
}
3131
}
3232

33-
public class UserQueryResultResourceData : QueryResult<UserSummary>
33+
public class UserQueryResultResourceData : QueryResult<UserResultResource>
3434
{
35-
public new IEnumerable<UserResultResource> Items { get; set; }
36-
3735
public UserQueryResultResourceData(QueryResult<UserSummary> result, IUrlHelper url, UserMetadata meta)
3836
{
3937
if (result == null) throw new ArgumentNullException(nameof(result));

src/IdentityManager2/Assets/EmbeddedHtmlResult.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using System.Text;
2+
using System.Text.Json;
23
using System.Threading.Tasks;
4+
using IdentityManager2.Api.Models;
35
using IdentityManager2.Configuration;
46
using Microsoft.AspNetCore.Http;
57
using Microsoft.AspNetCore.Mvc;
6-
using Newtonsoft.Json;
78

89
namespace IdentityManager2.Assets
910
{
@@ -26,7 +27,7 @@ public async Task ExecuteResultAsync(ActionContext context)
2627
new
2728
{
2829
pathBase = path,
29-
model = JsonConvert.SerializeObject(new
30+
model = JsonSerializer.Serialize(new PageModelParams
3031
{
3132
PathBase = path,
3233
ShowLoginButton = securityConfiguration.ShowLoginButton

src/IdentityManager2/Assets/Scripts/App/ttIdmUsers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
var props = properties.map(function (item) {
8686
return {
8787
type: item.meta.type,
88-
value: item.data
88+
value: item.data.toString()
8989
};
9090
});
9191
idmUsers.createUser(props)

src/IdentityManager2/Assets/Scripts/Bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/IdentityManager2/Configuration/DependencyInjection/IdentityManagerServiceCollectionExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ public static IIdentityManagerBuilder AddIdentityManager(this IServiceCollection
1616
var identityManagerOptions = services.BuildServiceProvider().GetRequiredService<IOptions<IdentityManagerOptions>>().Value;
1717
identityManagerOptions.Validate();
1818

19-
services.AddControllersWithViews()
20-
.AddNewtonsoftJson();
21-
19+
services.AddControllersWithViews();
20+
2221
// IdentityManager API authentication scheme
2322
services.AddAuthentication()
2423
.AddCookie(IdentityManagerConstants.LocalApiScheme, options =>

src/IdentityManager2/IdentityManager2.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
<ItemGroup>
3939
<FrameworkReference Include="Microsoft.AspNetCore.App" />
40-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
41-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.1.0" />
4240
</ItemGroup>
4341

4442
<ItemGroup>

0 commit comments

Comments
 (0)