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

Remove Newtonsoft #14572

Merged
merged 117 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
1c9d4a4
Remove Newtonsoft
jtkech Oct 24, 2023
4c4a22e
Start fixing setup
jtkech Oct 25, 2023
90d1588
Node Merging and related Settings
jtkech Oct 26, 2023
e93c897
wip
jtkech Oct 26, 2023
d6d36a1
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Oct 26, 2023
af6ecc8
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Oct 26, 2023
13ed8e0
Complete json Merge() and SelectNode() by path
jtkech Oct 27, 2023
e9bc0cb
Start on Polymorphism
jtkech Oct 27, 2023
67cf965
Start fixing unit tests
jtkech Oct 27, 2023
37590f2
Fix Lucene Apis Unit Tests
jtkech Oct 28, 2023
e784533
Derived types and wip on unit tests
jtkech Oct 29, 2023
ad4398f
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Oct 31, 2023
332090c
Fix more unit tests by using a dynamic converter
jtkech Oct 31, 2023
217fa3f
Revert converter changes and refactoring
jtkech Oct 31, 2023
1fabe7d
Fix unit tests, only target 8.0
jtkech Oct 31, 2023
d14e4ba
Target only 8.0 for Cypress too
jtkech Oct 31, 2023
a877bd3
Fix functional tests
jtkech Oct 31, 2023
db3dac5
Remove comingsoon-test.js for now
jtkech Oct 31, 2023
1c31e16
Remove Newton in Tests Global Usings
jtkech Nov 1, 2023
0d3648d
wip
jtkech Nov 1, 2023
5282f86
Test
jtkech Nov 1, 2023
f9c5e49
wip
jtkech Nov 3, 2023
72470a0
testing
jtkech Nov 3, 2023
e7b72b6
Testing and Re-use Comingsoon Functional Test
jtkech Nov 4, 2023
7e40c54
Tweaks and cleanups
jtkech Nov 5, 2023
860a31d
Debug and Dynamic views
jtkech Nov 5, 2023
b773446
Tweaks and Cleanups
jtkech Nov 6, 2023
314fcc2
Tweaks and fix Functional tests
jtkech Nov 7, 2023
5f8443e
Lazy deserialize dynamic value
jtkech Nov 7, 2023
60628ca
wip
jtkech Nov 8, 2023
154f4aa
Tweaks and fix Debug Dynamic Views
jtkech Nov 8, 2023
014be71
Easier changes ;)
jtkech Nov 8, 2023
ae46fdd
Minor changes
jtkech Nov 8, 2023
5db1c5f
wip
jtkech Nov 9, 2023
ad59a6e
Missing testing change
jtkech Nov 9, 2023
97e3493
tweaks
jtkech Nov 9, 2023
8eb2d51
Migrate Deployments
jtkech Nov 10, 2023
5800003
Merge main and fix conflicts
jtkech Nov 10, 2023
9aba9e6
tweaks
jtkech Nov 10, 2023
888def0
tweaks
jtkech Nov 10, 2023
2b5b050
Minor change
jtkech Nov 10, 2023
a7ecd1f
Centralize options and wip in razor views
jtkech Nov 10, 2023
10022dc
Tweaks and Migrate Configurations
jtkech Nov 11, 2023
61bfd73
Fix build
jtkech Nov 11, 2023
b91329b
Fix unit tests
jtkech Nov 11, 2023
d08888f
wip
jtkech Nov 12, 2023
e01013c
Fix json files writting
jtkech Nov 12, 2023
004359b
Separate class for json options
jtkech Nov 12, 2023
22747bf
tweaks
jtkech Nov 12, 2023
9c15e5d
wip
jtkech Nov 12, 2023
2c5fdc1
wip
jtkech Nov 12, 2023
0957b81
Remove Newton Dependency
jtkech Nov 12, 2023
ad5e414
Some refactoring
jtkech Nov 13, 2023
b7e8586
Fix build
jtkech Nov 13, 2023
b4e63c7
Renaming
jtkech Nov 13, 2023
9413d94
Refactoring
jtkech Nov 13, 2023
9c02e49
Gets the raw value of a JsonValue without specifying a type.
jtkech Nov 13, 2023
bea0e37
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Nov 17, 2023
81a58f3
Minor tweaks and start testing BigInteger
jtkech Nov 17, 2023
43417b4
tweaks
jtkech Nov 18, 2023
7724fdf
Sync with other PR
jtkech Nov 19, 2023
81d6499
Tweak on type discriminator for backward compatibility
jtkech Nov 19, 2023
ec3198b
Use 'Dictionary' in place of 'ExpandoObject' in 'JsonDynamicConverter'
jtkech Dec 3, 2023
ffdc37f
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Dec 3, 2023
65994b4
Updates after merging dev
jtkech Dec 3, 2023
1318d12
Tweaks after merging dev
jtkech Dec 3, 2023
d99bf88
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Dec 3, 2023
6ee90cb
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Dec 3, 2023
722f81e
Update after merging dev
jtkech Dec 3, 2023
3a6aa75
Merge remote-tracking branch 'origin/main' into jtkech/remove-newton
jtkech Dec 8, 2023
20cfe12
Updates after merging main
jtkech Dec 8, 2023
2caf92b
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Dec 22, 2023
9761ecb
Update YesSql to 5.0.0-beta-0001
MikeAlhayek Dec 22, 2023
c845a6e
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Dec 22, 2023
ec99235
fix build
MikeAlhayek Dec 22, 2023
3ea3ca4
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 3, 2024
6bb7a62
Fix build errors
MikeAlhayek Jan 4, 2024
de14fab
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 4, 2024
e568787
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 9, 2024
bee4a99
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 11, 2024
4fb79b2
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 23, 2024
2309540
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 25, 2024
3d8a5b9
Fix build
MikeAlhayek Jan 25, 2024
d37d12b
Merge branch 'jtkech/remove-newton' of https://github.com/OrchardCMS/…
MikeAlhayek Jan 25, 2024
b0c32db
Fix AdminMenu and DeploymentPlan json support
sebastienros Jan 25, 2024
85818e2
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 26, 2024
7945a62
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 26, 2024
157f112
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 28, 2024
7371a94
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 29, 2024
3e468a9
Fix conflicts
MikeAlhayek Jan 29, 2024
084b3fc
conflicts
MikeAlhayek Jan 29, 2024
519be9b
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 30, 2024
b917888
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 30, 2024
d01de06
Fix tests
MikeAlhayek Jan 30, 2024
42982d4
Add PathStringJsonConverter
MikeAlhayek Jan 30, 2024
41e21c7
fix serializer
MikeAlhayek Jan 30, 2024
f1ee043
add default settings
MikeAlhayek Jan 30, 2024
2891c52
Fix AdminMenu serialization
sebastienros Jan 31, 2024
f461000
Use FrozenDictionary for JsonPolymorphicResolver cache
sebastienros Jan 31, 2024
55c6c78
Using NewtonSoft.JSon way of storing type names
sebastienros Jan 31, 2024
c0c2ca4
fix PathString converter
MikeAlhayek Jan 31, 2024
d74ffd1
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Jan 31, 2024
f77fb2c
cleanup
MikeAlhayek Jan 31, 2024
4cf0901
Merge branch 'jtkech/remove-newton' of https://github.com/OrchardCMS/…
MikeAlhayek Jan 31, 2024
7d3abeb
document the step to migrate
MikeAlhayek Feb 1, 2024
168d818
update release notes
MikeAlhayek Feb 1, 2024
f5ddcb7
Fix CustomSettingsStep
sebastienros Feb 1, 2024
4525156
Fix workflow
MikeAlhayek Feb 1, 2024
4a8000d
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Feb 1, 2024
f774dd0
remove using
MikeAlhayek Feb 1, 2024
ed2f21d
Merge branch 'jtkech/remove-newton' of https://github.com/OrchardCMS/…
MikeAlhayek Feb 1, 2024
7114400
Fix condition and operators serialization
sebastienros Feb 2, 2024
b3a9ab4
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Feb 2, 2024
2bdcea0
update release notes
MikeAlhayek Feb 2, 2024
ac17a2c
Use options instead of DI for derived types
sebastienros Feb 2, 2024
620b212
Merge branch 'main' into jtkech/remove-newton
MikeAlhayek Feb 2, 2024
6f4fe1e
Update release notes
sebastienros Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion src/OrchardCore.Build/Dependencies.AspNetCore.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<PackageManagement Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetCorePackagesVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Authentication.Twitter" Version="$(AspNetCorePackagesVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="$(AspNetCorePackagesVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(AspNetCorePackagesVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="$(AspNetCorePackagesVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(AspNetCorePackagesVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Owin" Version="$(AspNetCorePackagesVersion)" />
Expand Down
11 changes: 5 additions & 6 deletions src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<PackageManagement Include="Moq" Version="4.20.70" />
<PackageManagement Include="ncrontab" Version="3.3.3" />
<PackageManagement Include="NEST" Version="7.17.5" />
<PackageManagement Include="Newtonsoft.Json" Version="13.0.3" />
<PackageManagement Include="NJsonSchema" Version="11.0.0" />
<PackageManagement Include="NLog.Web.AspNetCore" Version="5.3.8" />
<PackageManagement Include="NodaTime" Version="3.1.10" />
Expand All @@ -64,11 +63,11 @@
<PackageManagement Include="xunit" Version="2.6.6" />
<PackageManagement Include="xunit.analyzers" Version="1.10.0" />
<PackageManagement Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageManagement Include="YesSql" Version="4.1.0" />
<PackageManagement Include="YesSql.Abstractions" Version="4.1.0" />
<PackageManagement Include="YesSql.Core" Version="4.1.0" />
<PackageManagement Include="YesSql.Filters.Abstractions" Version="4.1.0" />
<PackageManagement Include="YesSql.Filters.Query" Version="4.1.0" />
<PackageManagement Include="YesSql" Version="5.0.0-beta-0002" />
<PackageManagement Include="YesSql.Abstractions" Version="5.0.0-beta-0002" />
<PackageManagement Include="YesSql.Core" Version="5.0.0-beta-0002" />
<PackageManagement Include="YesSql.Filters.Abstractions" Version="5.0.0-beta-0002" />
<PackageManagement Include="YesSql.Filters.Query" Version="5.0.0-beta-0002" />
<PackageManagement Include="ZString" Version="2.5.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OrchardCore.AdminMenu.Services;
using OrchardCore.Deployment;

Expand All @@ -24,18 +23,16 @@ public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlan
return;
}

var data = new JArray();
result.Steps.Add(new JObject(
new JProperty("name", "AdminMenu"),
new JProperty("data", data)
));

// For each AdminNode, store info about its concrete type: linkAdminNode, contentTypesAdminNode etc...
var serializer = new JsonSerializer() { TypeNameHandling = TypeNameHandling.Auto };
var data = new JsonArray();
result.Steps.Add(new JsonObject
{
["name"] = "AdminMenu",
["data"] = data,
});

foreach (var adminMenu in (await _adminMenuService.GetAdminMenuListAsync()).AdminMenu)
{
var objectData = JObject.FromObject(adminMenu, serializer);
var objectData = JObject.FromObject(adminMenu);
data.Add(objectData);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System.Linq;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OrchardCore.AdminMenu.Services;
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
Expand Down Expand Up @@ -30,11 +29,11 @@ public async Task ExecuteAsync(RecipeExecutionContext context)

var model = context.Step.ToObject<AdminMenuStepModel>();

var serializer = new JsonSerializer() { TypeNameHandling = TypeNameHandling.Auto };
// var serializer = new JsonSerializer() { TypeNameHandling = TypeNameHandling.Auto };

foreach (var token in model.Data.Cast<JObject>())
foreach (var token in model.Data.Cast<JsonObject>())
{
var adminMenu = token.ToObject<Models.AdminMenu>(serializer);
var adminMenu = token.ToObject<Models.AdminMenu>(/*serializer*/);

// When the id is not supplied generate an id, otherwise replace the menu if it exists, or create a new menu.
if (string.IsNullOrEmpty(adminMenu.Id))
Expand All @@ -51,6 +50,6 @@ public async Task ExecuteAsync(RecipeExecutionContext context)

public class AdminMenuStepModel
{
public JArray Data { get; set; }
public JsonArray Data { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public override void ConfigureServices(IServiceCollection services)
services.AddSingleton<IAdminNodeProviderFactory>(new AdminNodeProviderFactory<LinkAdminNode>());
services.AddScoped<IAdminNodeNavigationBuilder, LinkAdminNodeNavigationBuilder>();
services.AddScoped<IDisplayDriver<MenuItem>, LinkAdminNodeDriver>();

services.AddAdminNode<LinkAdminNode>();
services.AddAdminNode<PlaceholderAdminNode>();
}

public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@model LinkAdminNodeViewModel
@using Newtonsoft.Json
@using Newtonsoft.Json.Serialization
@using System.Text.Json
@using System.Text.Json.Nodes

<style asp-src="~/OrchardCore.AdminMenu/Styles/admin-menu.min.css" debug-src="~/OrchardCore.AdminMenu/Styles/admin-menu.css" at="Head" depends-on="admin"></style>
<style asp-src="~/OrchardCore.AdminMenu/Styles/admin-menu-icon-picker.min.css" debug-src="~/OrchardCore.AdminMenu/Styles/admin-menu-icon-picker.css" at="Head" depends-on="admin"></style>
Expand Down Expand Up @@ -73,8 +73,8 @@

<div class="mb-3">
@{
var selectedItems = JsonConvert.SerializeObject(Model.SelectedItems, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
var allItems = JsonConvert.SerializeObject(Model.AllItems, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
var selectedItems = JConvert.SerializeObject(Model.SelectedItems, JOptions.CamelCase);
var allItems = JConvert.SerializeObject(Model.AllItems, JOptions.CamelCase);
}

<script asp-name="admin-menu-permission-picker" asp-src="~/OrchardCore.AdminMenu/Scripts/admin-menu-permission-picker.min.js" debug-src="~/OrchardCore.AdminMenu/Scripts/admin-menu-permission-picker.js" at="Foot" depends-on="vuejs, vue-multiselect"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@model PlaceholderAdminNodeViewModel
@using Newtonsoft.Json
@using Newtonsoft.Json.Serialization
@using System.Text.Json
@using System.Text.Json.Nodes

<style asp-src="~/OrchardCore.AdminMenu/Styles/admin-menu.min.css" debug-src="~/OrchardCore.AdminMenu/Styles/admin-menu.css" at="Head" depends-on="admin"></style>
<style asp-src="~/OrchardCore.AdminMenu/Styles/admin-menu-icon-picker.min.css" debug-src="~/OrchardCore.AdminMenu/Styles/admin-menu-icon-picker.css" at="Head" depends-on="admin"></style>
Expand Down Expand Up @@ -63,8 +63,8 @@

<div class="mb-3">
@{
var selectedItems = JsonConvert.SerializeObject(Model.SelectedItems, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
var allItems = JsonConvert.SerializeObject(Model.AllItems, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
var selectedItems = JConvert.SerializeObject(Model.SelectedItems, JOptions.CamelCase);
var allItems = JConvert.SerializeObject(Model.AllItems, JOptions.CamelCase);
}

<script asp-name="admin-menu-permission-picker" asp-src="~/OrchardCore.AdminMenu/Scripts/admin-menu-permission-picker.min.js" debug-src="~/OrchardCore.AdminMenu/Scripts/admin-menu-permission-picker.js" at="Foot" depends-on="vuejs, vue-multiselect"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ public class GraphQLMiddleware
private readonly GraphQLSettings _settings;
private readonly IDocumentExecuter _executer;
internal static readonly Encoding _utf8Encoding = new UTF8Encoding(false);
private readonly static MediaType _jsonMediaType = new("application/json");
private readonly static MediaType _graphQlMediaType = new("application/graphql");
private readonly static JsonSerializerOptions _jsonSerializerOptions = new() { WriteIndented = false, PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
private static readonly MediaType _jsonMediaType = new("application/json");
private static readonly MediaType _graphQlMediaType = new("application/graphql");

public GraphQLMiddleware(
RequestDelegate next,
Expand Down Expand Up @@ -101,7 +100,7 @@ private async Task ExecuteAsync(HttpContext context, ISchemaFactory schemaServic
}
else
{
request = await JsonSerializer.DeserializeAsync<GraphQLRequest>(context.Request.Body, _jsonSerializerOptions);
request = await JsonSerializer.DeserializeAsync<GraphQLRequest>(context.Request.Body, JOptions.CamelCase);
}
}
else
Expand Down Expand Up @@ -189,7 +188,7 @@ private static GraphQLRequest CreateRequestFromQueryString(HttpContext context,

if (context.Request.Query.ContainsKey("variables"))
{
request.Variables = JsonSerializer.Deserialize<JsonElement>(context.Request.Query["variables"], _jsonSerializerOptions);
request.Variables = JConvert.DeserializeObject<JsonElement>(context.Request.Query["variables"], JOptions.CamelCase);
}

if (context.Request.Query.ContainsKey("operationName"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using System.Text.Json.Settings;
using System.Threading.Tasks;
using Fluid;
using Fluid.Values;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using OrchardCore.Autoroute.Core.Indexes;
using OrchardCore.Autoroute.Models;
using OrchardCore.Autoroute.ViewModels;
Expand Down Expand Up @@ -70,7 +71,7 @@ public override async Task PublishedAsync(PublishContentContext context, Autorou
{
_contentManager ??= _serviceProvider.GetRequiredService<IContentManager>();
var containedAspect = await _contentManager.PopulateAspectAsync<ContainedContentItemsAspect>(context.PublishingItem);
await CheckContainedHomeRouteAsync(part.ContentItem.ContentItemId, containedAspect, context.PublishingItem.Content);
await CheckContainedHomeRouteAsync(part.ContentItem.ContentItemId, containedAspect, (JsonObject)context.PublishingItem.Content);
}

// Update entries from the index table after the session is committed.
Expand Down Expand Up @@ -193,13 +194,13 @@ private Task RemoveTagAsync(AutoroutePart part)
return _tagCache.RemoveTagAsync($"slug:{part.Path}");
}

private async Task CheckContainedHomeRouteAsync(string containerContentItemId, ContainedContentItemsAspect containedAspect, JObject content)
private async Task CheckContainedHomeRouteAsync(string containerContentItemId, ContainedContentItemsAspect containedAspect, JsonObject content)
{
foreach (var accessor in containedAspect.Accessors)
{
var jItems = accessor.Invoke(content);

foreach (var jItem in jItems.Cast<JObject>())
foreach (var jItem in jItems.Cast<JsonObject>())
{
var contentItem = jItem.ToObject<ContentItem>();
var handlerAspect = await _contentManager.PopulateAspectAsync<RouteHandlerAspect>(contentItem);
Expand All @@ -213,7 +214,7 @@ private async Task CheckContainedHomeRouteAsync(string containerContentItemId, C
await SetHomeRouteAsync(autoroutePart, homeRoute =>
{
homeRoute[_options.ContentItemIdKey] = containerContentItemId;
homeRoute[_options.JsonPathKey] = jItem.Path;
homeRoute[_options.JsonPathKey] = jItem.GetNormalizedPath();
});

break;
Expand All @@ -236,18 +237,18 @@ private async Task GenerateContainedPathsFromPatternAsync(ContentItem contentIte

// Build the entries for this content item to evaluate for duplicates.
var entries = new List<AutorouteEntry>();
await PopulateContainedContentItemRoutesAsync(entries, part.ContentItem.ContentItemId, containedAspect, contentItem.Content, part.Path);
await PopulateContainedContentItemRoutesAsync(entries, part.ContentItem.ContentItemId, containedAspect, (JsonObject)contentItem.Content, part.Path);

await ValidateContainedContentItemRoutesAsync(entries, part.ContentItem.ContentItemId, containedAspect, contentItem.Content, part.Path);
await ValidateContainedContentItemRoutesAsync(entries, part.ContentItem.ContentItemId, containedAspect, (JsonObject)contentItem.Content, part.Path);
}

private async Task PopulateContainedContentItemRoutesAsync(List<AutorouteEntry> entries, string containerContentItemId, ContainedContentItemsAspect containedContentItemsAspect, JObject content, string basePath)
private async Task PopulateContainedContentItemRoutesAsync(List<AutorouteEntry> entries, string containerContentItemId, ContainedContentItemsAspect containedContentItemsAspect, JsonObject content, string basePath)
{
foreach (var accessor in containedContentItemsAspect.Accessors)
{
var jItems = accessor.Invoke(content);

foreach (var jItem in jItems.Cast<JObject>())
foreach (var jItem in jItems.Cast<JsonObject>())
{
var contentItem = jItem.ToObject<ContentItem>();
var handlerAspect = await _contentManager.PopulateAspectAsync<RouteHandlerAspect>(contentItem);
Expand All @@ -260,7 +261,7 @@ private async Task PopulateContainedContentItemRoutesAsync(List<AutorouteEntry>
path = (basePath.EndsWith('/') ? basePath : basePath + '/') + handlerAspect.Path.TrimStart('/');
}

entries.Add(new AutorouteEntry(containerContentItemId, path, contentItem.ContentItemId, jItem.Path)
entries.Add(new AutorouteEntry(containerContentItemId, path, contentItem.ContentItemId, jItem.GetNormalizedPath())
{
DocumentId = contentItem.Id
});
Expand All @@ -273,13 +274,13 @@ private async Task PopulateContainedContentItemRoutesAsync(List<AutorouteEntry>
}
}

private async Task ValidateContainedContentItemRoutesAsync(List<AutorouteEntry> entries, string containerContentItemId, ContainedContentItemsAspect containedContentItemsAspect, JObject content, string basePath)
private async Task ValidateContainedContentItemRoutesAsync(List<AutorouteEntry> entries, string containerContentItemId, ContainedContentItemsAspect containedContentItemsAspect, JsonObject content, string basePath)
{
foreach (var accessor in containedContentItemsAspect.Accessors)
{
var jItems = accessor.Invoke(content);

foreach (var jItem in jItems.Cast<JObject>())
foreach (var jItem in jItems.Cast<JsonObject>())
{
var contentItem = jItem.ToObject<ContentItem>();
var containedAutoroutePart = contentItem.As<AutoroutePart>();
Expand All @@ -297,7 +298,7 @@ private async Task ValidateContainedContentItemRoutesAsync(List<AutorouteEntry>
containedAutoroutePart.Apply();

// Merge because we have disconnected the content item from it's json owner.
jItem.Merge(contentItem.Content, new JsonMergeSettings
jItem.Merge((JsonObject)contentItem.Content, new JsonMergeSettings
{
MergeArrayHandling = MergeArrayHandling.Replace,
MergeNullValueHandling = MergeNullValueHandling.Merge
Expand All @@ -315,7 +316,7 @@ private async Task ValidateContainedContentItemRoutesAsync(List<AutorouteEntry>
containedAutoroutePart.Apply();

// Merge because we have disconnected the content item from it's json owner.
jItem.Merge(contentItem.Content, new JsonMergeSettings
jItem.Merge((JsonObject)contentItem.Content, new JsonMergeSettings
{
MergeArrayHandling = MergeArrayHandling.Replace,
MergeNullValueHandling = MergeNullValueHandling.Merge
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Text.Json.Nodes;

namespace OrchardCore.ContentManagement.Metadata.Models;

Expand All @@ -13,8 +13,8 @@ public static TField GetContentField<TField>(
ContentItem contentItem)
where TField : ContentField
{
if (((JObject)contentItem.Content)[fieldDefinition.PartDefinition.Name] is not JObject jPart ||
jPart[fieldDefinition.Name] is not JObject jField)
if (((JsonObject)contentItem.Content)[fieldDefinition.PartDefinition.Name] is not JsonObject jPart ||
jPart[fieldDefinition.Name] is not JsonObject jField)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Newtonsoft.Json.Linq;
using System.Text.Json.Nodes;

namespace OrchardCore.ContentFields.Fields
{
Expand All @@ -13,9 +13,9 @@ public static class UserNamesExtensions
/// </remarks>
public static string[] GetUserNames(this UserPickerField userPickerField)
{
var userNames = userPickerField.Content["UserNames"] as JArray;
var userNames = (JsonArray)userPickerField.Content["UserNames"];

return userNames != null ? userNames.ToObject<string[]>() : [];
return userNames is not null ? userNames.ToObject<string[]>() : [];
}

/// <summary>
Expand Down
Loading
Loading