V14: Remove Newtonsoft from packed projects (#15811)
* Migrate ObjectJsonExtensions * Use more generic exception to not use Newtonsoft It should matter if it's a JsonReaderException, if we can't read we can't read * Remove obsoleted constructors * Use more generic exception in ContentValueSetBuilder * Fix constructors * Remove UdiRangeJsonConverter * Remove more legacy newtonsoft stuff * Migrate away from newtonsoft in CacheInstructionService * Remove unused model binders * Remove more newtonsoft * Remove newtonsoft from DatabaseServerMessenger * Remove now irrelevant benchmark * Remove the usage of Newtonsoft from ImageCropperTemplateCoreExtensions The value converter will never return JObject, JsonDocument, or JsonNode * Remove usages of newtonsoft in ComplexPropertyEditorContentNotificationHandler JTokens are no longer returned, so we don't need to check for it * Remove newtonsoft references * Re-add newtonsoft dependency to Umbraco.Tests.Common * Fix package references * move dependency --------- Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
</ItemGroup>
|
||||
<!-- Microsoft packages -->
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
|
||||
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.1" />
|
||||
@@ -56,7 +55,6 @@
|
||||
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" />
|
||||
<PackageVersion Include="MiniProfiler.Shared" Version="4.3.8" />
|
||||
<PackageVersion Include="ncrontab" Version="3.3.3" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageVersion Include="NPoco" Version="5.7.1" />
|
||||
<PackageVersion Include="NPoco.SqlServer" Version="5.7.1" />
|
||||
<PackageVersion Include="OpenIddict.Abstractions" Version="4.10.1" />
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// using Newtonsoft.Json;
|
||||
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Cms.Core.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -41,7 +42,9 @@ public static partial class UmbracoBuilderExtensions
|
||||
factory.GetRequiredService<IShortStringHelper>(),
|
||||
factory.GetRequiredService<IScopeProvider>(),
|
||||
true,
|
||||
factory.GetRequiredService<ILocalizationService>()));
|
||||
factory.GetRequiredService<ILocalizationService>(),
|
||||
factory.GetRequiredService<IContentTypeService>(),
|
||||
factory.GetRequiredService<ILogger<ContentValueSetBuilder>>()));
|
||||
builder.Services.AddUnique<IContentValueSetBuilder>(factory =>
|
||||
new ContentValueSetBuilder(
|
||||
factory.GetRequiredService<PropertyEditorCollection>(),
|
||||
@@ -50,7 +53,9 @@ public static partial class UmbracoBuilderExtensions
|
||||
factory.GetRequiredService<IShortStringHelper>(),
|
||||
factory.GetRequiredService<IScopeProvider>(),
|
||||
false,
|
||||
factory.GetRequiredService<ILocalizationService>()));
|
||||
factory.GetRequiredService<ILocalizationService>(),
|
||||
factory.GetRequiredService<IContentTypeService>(),
|
||||
factory.GetRequiredService<ILogger<ContentValueSetBuilder>>()));
|
||||
builder.Services.AddUnique<IValueSetBuilder<IMedia>, MediaValueSetBuilder>();
|
||||
builder.Services.AddUnique<IValueSetBuilder<IMember>, MemberValueSetBuilder>();
|
||||
builder.Services.AddUnique<IDeliveryApiContentIndexValueSetBuilder, DeliveryApiContentIndexValueSetBuilder>();
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using Examine;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
using Umbraco.Cms.Web.Common.DependencyInjection;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Examine;
|
||||
@@ -52,72 +49,6 @@ public class ContentValueSetBuilder : BaseValueSetBuilder<IContent>, IContentVal
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[Obsolete("Use non-obsolete ctor, scheduled for removal in v14")]
|
||||
public ContentValueSetBuilder(
|
||||
PropertyEditorCollection propertyEditors,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
IUserService userService,
|
||||
IShortStringHelper shortStringHelper,
|
||||
ICoreScopeProvider scopeProvider,
|
||||
bool publishedValuesOnly,
|
||||
ILocalizationService localizationService,
|
||||
IContentTypeService contentTypeService)
|
||||
: this(
|
||||
propertyEditors,
|
||||
urlSegmentProviders,
|
||||
userService,
|
||||
shortStringHelper,
|
||||
scopeProvider,
|
||||
publishedValuesOnly,
|
||||
localizationService,
|
||||
StaticServiceProvider.Instance.GetRequiredService<IContentTypeService>(),
|
||||
StaticServiceProvider.Instance.GetRequiredService<ILogger<ContentValueSetBuilder>>())
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("Use non-obsolete ctor, scheduled for removal in v14")]
|
||||
public ContentValueSetBuilder(
|
||||
PropertyEditorCollection propertyEditors,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
IUserService userService,
|
||||
IShortStringHelper shortStringHelper,
|
||||
IScopeProvider scopeProvider,
|
||||
bool publishedValuesOnly,
|
||||
ILocalizationService localizationService)
|
||||
: this(
|
||||
propertyEditors,
|
||||
urlSegmentProviders,
|
||||
userService,
|
||||
shortStringHelper,
|
||||
scopeProvider,
|
||||
publishedValuesOnly,
|
||||
localizationService,
|
||||
StaticServiceProvider.Instance.GetRequiredService<IContentTypeService>(),
|
||||
StaticServiceProvider.Instance.GetRequiredService<ILogger<ContentValueSetBuilder>>())
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("Use non-obsolete ctor, scheduled for removal in v14")]
|
||||
public ContentValueSetBuilder(
|
||||
PropertyEditorCollection propertyEditors,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
IUserService userService,
|
||||
IShortStringHelper shortStringHelper,
|
||||
IScopeProvider scopeProvider,
|
||||
bool publishedValuesOnly)
|
||||
: this(
|
||||
propertyEditors,
|
||||
urlSegmentProviders,
|
||||
userService,
|
||||
shortStringHelper,
|
||||
scopeProvider,
|
||||
publishedValuesOnly,
|
||||
StaticServiceProvider.Instance.GetRequiredService<ILocalizationService>(),
|
||||
StaticServiceProvider.Instance.GetRequiredService<IContentTypeService>(),
|
||||
StaticServiceProvider.Instance.GetRequiredService<ILogger<ContentValueSetBuilder>>())
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<ValueSet> GetValueSets(params IContent[] content)
|
||||
{
|
||||
@@ -222,7 +153,7 @@ public class ContentValueSetBuilder : BaseValueSetBuilder<IContent>, IContentVal
|
||||
{
|
||||
AddPropertyValue(property, null, null, values, availableCultures, contentTypeDictionary);
|
||||
}
|
||||
catch (JsonSerializationException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to add property '{PropertyAlias}' to index for content {ContentId}", property.Alias, c.Id);
|
||||
throw;
|
||||
@@ -236,7 +167,7 @@ public class ContentValueSetBuilder : BaseValueSetBuilder<IContent>, IContentVal
|
||||
{
|
||||
AddPropertyValue(property, culture.ToLowerInvariant(), null, values, availableCultures, contentTypeDictionary);
|
||||
}
|
||||
catch (JsonSerializationException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(
|
||||
ex,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Umbraco.Cms.Core;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
@@ -27,8 +27,8 @@ public static class ObjectJsonExtensions
|
||||
|
||||
string DefaultNamer(PropertyInfo property)
|
||||
{
|
||||
JsonPropertyAttribute? jsonProperty = property.GetCustomAttribute<JsonPropertyAttribute>();
|
||||
return jsonProperty?.PropertyName ?? property.Name;
|
||||
JsonPropertyNameAttribute? jsonProperty = property.GetCustomAttribute<JsonPropertyNameAttribute>();
|
||||
return jsonProperty?.Name ?? property.Name;
|
||||
}
|
||||
|
||||
Type t = obj.GetType();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Serilog.Events;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@@ -16,7 +14,6 @@ public class LogMessage
|
||||
/// <summary>
|
||||
/// The level of the event.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public LogEventLevel Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Umbraco.Cms.Core.Logging.Viewer;
|
||||
|
||||
public class SavedLogSearch
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public required string Name { get; set; }
|
||||
|
||||
[JsonProperty("query")]
|
||||
public required string Query { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog.Events;
|
||||
using Serilog.Formatting.Compact.Reader;
|
||||
using ILogger = Serilog.ILogger;
|
||||
@@ -121,7 +120,7 @@ internal class SerilogJsonLogViewer : SerilogLogViewerSourceBase
|
||||
{
|
||||
return reader.TryRead(out evt);
|
||||
}
|
||||
catch (JsonReaderException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// As we are reading/streaming one line at a time in the JSON file
|
||||
// Thus we can not report the line number, as it will always be 1
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
@@ -55,17 +53,13 @@ public abstract class ComplexPropertyEditorContentNotificationHandler :
|
||||
foreach (IPropertyValue cultureVal in propVals)
|
||||
{
|
||||
// Remove keys from published value & any nested properties
|
||||
var publishedValue = cultureVal.PublishedValue is JToken jsonPublishedValue
|
||||
? jsonPublishedValue.ToString(Formatting.None)
|
||||
: cultureVal.PublishedValue?.ToString();
|
||||
var publishedValue = cultureVal.PublishedValue?.ToString();
|
||||
var updatedPublishedVal =
|
||||
FormatPropertyValue(publishedValue!, onlyMissingKeys).NullOrWhiteSpaceAsNull();
|
||||
cultureVal.PublishedValue = updatedPublishedVal;
|
||||
|
||||
// Remove keys from edited/draft value & any nested properties
|
||||
var editedValue = cultureVal.EditedValue is JToken jsonEditedValue
|
||||
? jsonEditedValue.ToString(Formatting.None)
|
||||
: cultureVal.EditedValue?.ToString();
|
||||
var editedValue = cultureVal.EditedValue?.ToString();
|
||||
var updatedEditedVal = FormatPropertyValue(editedValue!, onlyMissingKeys).NullOrWhiteSpaceAsNull();
|
||||
cultureVal.EditedValue = updatedEditedVal;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
@@ -189,11 +189,10 @@ namespace Umbraco.Cms
|
||||
=> new(
|
||||
0,
|
||||
DateTime.UtcNow,
|
||||
JsonConvert.SerializeObject(instructions, new JsonSerializerSettings()
|
||||
JsonSerializer.Serialize(instructions, new JsonSerializerOptions
|
||||
{
|
||||
Formatting = Formatting.None,
|
||||
DefaultValueHandling = DefaultValueHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
WriteIndented = false,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
|
||||
}),
|
||||
localIdentity,
|
||||
instructions.Sum(x => x.JsonIdCount));
|
||||
@@ -252,13 +251,13 @@ namespace Umbraco.Cms
|
||||
}
|
||||
|
||||
// Deserialize remote instructions & skip if it fails.
|
||||
if (!TryDeserializeInstructions(instruction, out JArray? jsonInstructions))
|
||||
if (TryDeserializeInstructions(instruction, out JsonDocument? jsonInstructions) is false && jsonInstructions is null)
|
||||
{
|
||||
lastId = instruction.Id; // skip
|
||||
continue;
|
||||
}
|
||||
|
||||
List<RefreshInstruction> instructionBatch = GetAllInstructions(jsonInstructions);
|
||||
List<RefreshInstruction> instructionBatch = GetAllInstructions(jsonInstructions?.RootElement);
|
||||
|
||||
// Process as per-normal.
|
||||
var success = ProcessDatabaseInstructions(cacheRefreshers, instructionBatch, instruction, processed, cancellationToken, ref lastId);
|
||||
@@ -280,7 +279,7 @@ namespace Umbraco.Cms
|
||||
/// <summary>
|
||||
/// Attempts to deserialize the instructions to a JArray.
|
||||
/// </summary>
|
||||
private bool TryDeserializeInstructions(CacheInstruction instruction, out JArray? jsonInstructions)
|
||||
private bool TryDeserializeInstructions(CacheInstruction instruction, out JsonDocument? jsonInstructions)
|
||||
{
|
||||
if (instruction.Instructions is null)
|
||||
{
|
||||
@@ -291,10 +290,10 @@ namespace Umbraco.Cms
|
||||
|
||||
try
|
||||
{
|
||||
jsonInstructions = JsonConvert.DeserializeObject<JArray>(instruction.Instructions);
|
||||
jsonInstructions = JsonDocument.Parse(instruction.Instructions);
|
||||
return true;
|
||||
}
|
||||
catch (JsonException ex)
|
||||
catch (System.Text.Json.JsonException ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to deserialize instructions ({DtoId}: '{DtoInstructions}').", instruction.Id, instruction.Instructions);
|
||||
jsonInstructions = null;
|
||||
@@ -305,7 +304,7 @@ namespace Umbraco.Cms
|
||||
/// <summary>
|
||||
/// Parses out the individual instructions to be processed.
|
||||
/// </summary>
|
||||
private static List<RefreshInstruction> GetAllInstructions(IEnumerable<JToken>? jsonInstructions)
|
||||
private static List<RefreshInstruction> GetAllInstructions(JsonElement? jsonInstructions)
|
||||
{
|
||||
var result = new List<RefreshInstruction>();
|
||||
if (jsonInstructions is null)
|
||||
@@ -313,13 +312,13 @@ namespace Umbraco.Cms
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (JToken jsonItem in jsonInstructions)
|
||||
foreach (JsonElement jsonItem in jsonInstructions.Value.EnumerateArray())
|
||||
{
|
||||
// Could be a JObject in which case we can convert to a RefreshInstruction.
|
||||
// Otherwise it could be another JArray - in which case we'll iterate that.
|
||||
if (jsonItem is JObject jsonObj)
|
||||
if (jsonItem.ValueKind is JsonValueKind.Object)
|
||||
{
|
||||
RefreshInstruction? instruction = jsonObj.ToObject<RefreshInstruction>();
|
||||
RefreshInstruction? instruction = jsonItem.Deserialize<RefreshInstruction>();
|
||||
if (instruction is not null)
|
||||
{
|
||||
result.Add(instruction);
|
||||
@@ -327,8 +326,7 @@ namespace Umbraco.Cms
|
||||
}
|
||||
else
|
||||
{
|
||||
var jsonInnerArray = (JArray)jsonItem;
|
||||
result.AddRange(GetAllInstructions(jsonInnerArray)); // recurse
|
||||
result.AddRange(GetAllInstructions(jsonItem)); // recurse
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +463,7 @@ namespace Umbraco.Cms
|
||||
return;
|
||||
}
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<int[]>(jsonIds);
|
||||
var ids = JsonSerializer.Deserialize<int[]>(jsonIds);
|
||||
if (ids is not null)
|
||||
{
|
||||
foreach (var id in ids)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Serilog.Formatting.Compact.Reader;
|
||||
@@ -172,7 +171,7 @@ public class LogViewerRepository : ILogViewerRepository
|
||||
{
|
||||
return reader.TryRead(out evt);
|
||||
}
|
||||
catch (JsonReaderException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
// As we are reading/streaming one line at a time in the JSON file
|
||||
// Thus we can not report the line number, as it will always be 1
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class DatabaseServerMessenger : ServerMessengerBase, IDisposable
|
||||
IJsonSerializer jsonSerializer,
|
||||
LastSyncedFileManager lastSyncedFileManager,
|
||||
IOptionsMonitor<GlobalSettings> globalSettings)
|
||||
: base(distributedEnabled)
|
||||
: base(distributedEnabled, jsonSerializer)
|
||||
{
|
||||
_cancellationToken = _cancellationTokenSource.Token;
|
||||
_mainDom = mainDom;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Serialization;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Sync;
|
||||
@@ -11,12 +13,26 @@ namespace Umbraco.Cms.Infrastructure.Sync;
|
||||
/// </summary>
|
||||
public abstract class ServerMessengerBase : IServerMessenger
|
||||
{
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ServerMessengerBase"/> class.
|
||||
/// </summary>
|
||||
/// <param name="distributedEnabled">If set to <c>true</c> makes distributed calls when messaging a cache refresher.</param>
|
||||
/// <param name="jsonSerializer"></param>
|
||||
public ServerMessengerBase(bool distributedEnabled, IJsonSerializer jsonSerializer)
|
||||
{
|
||||
DistributedEnabled = distributedEnabled;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
}
|
||||
|
||||
[Obsolete("Use constructor that takes IJsonSerializer, scheduled for removal in V16")]
|
||||
protected ServerMessengerBase(bool distributedEnabled)
|
||||
=> DistributedEnabled = distributedEnabled;
|
||||
: this(
|
||||
distributedEnabled,
|
||||
StaticServiceProvider.Instance.GetRequiredService<IJsonSerializer>())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether distributed calls are made when messaging a cache refresher.
|
||||
@@ -377,7 +393,7 @@ public abstract class ServerMessengerBase : IServerMessenger
|
||||
}
|
||||
|
||||
// deliver remote
|
||||
var json = JsonConvert.SerializeObject(payload);
|
||||
var json = _jsonSerializer.Serialize(payload);
|
||||
DeliverRemote(refresher, MessageType.RefreshByJson, null, json);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" />
|
||||
<PackageReference Include="MiniProfiler.Shared" />
|
||||
<PackageReference Include="ncrontab" />
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
<PackageReference Include="NPoco" />
|
||||
<PackageReference Include="OpenIddict.Abstractions" />
|
||||
<PackageReference Include="Serilog" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Media;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -535,11 +534,6 @@ public static class ImageCropperTemplateCoreExtensions
|
||||
|
||||
var mediaCrops = cropperValue as ImageCropperValue;
|
||||
|
||||
if (mediaCrops == null && cropperValue is JObject jobj)
|
||||
{
|
||||
mediaCrops = jobj.ToObject<ImageCropperValue>();
|
||||
}
|
||||
|
||||
if (mediaCrops == null && cropperValue is string imageCropperValue &&
|
||||
string.IsNullOrEmpty(imageCropperValue) == false && imageCropperValue.DetectIsJson())
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<PackageReference Include="Asp.Versioning.Mvc" />
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" />
|
||||
<PackageReference Include="Dazinator.Extensions.FileProviders" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
|
||||
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" />
|
||||
<PackageReference Include="Serilog.AspNetCore" />
|
||||
|
||||
@@ -21,5 +21,6 @@
|
||||
<PackageVersion Include="Moq" Version="4.18.4" />
|
||||
<PackageVersion Include="NUnit" Version="3.14.0" />
|
||||
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" PrivateAssets="all" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Tests.Benchmarks.Config;
|
||||
|
||||
namespace Umbraco.Tests.Benchmarks;
|
||||
|
||||
[QuickRunConfig]
|
||||
[MemoryDiagnoser]
|
||||
public class JsonSerializerSettingsBenchmarks
|
||||
{
|
||||
[Benchmark]
|
||||
public void SerializerSettingsInstantiation()
|
||||
{
|
||||
var instances = 1000;
|
||||
for (var i = 0; i < instances; i++)
|
||||
{
|
||||
new JsonSerializerSettings();
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public void SerializerSettingsSingleInstantiation() => new JsonSerializerSettings();
|
||||
|
||||
// // * Summary *
|
||||
|
||||
// BenchmarkDotNet=v0.11.3, OS=Windows 10.0.18362
|
||||
//Intel Core i5-8265U CPU 1.60GHz(Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
|
||||
// [Host] : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.8.4250.0
|
||||
// Job-JIATTD : .NET Framework 4.7.2 (CLR 4.0.30319.42000), 32bit LegacyJIT-v4.8.4250.0
|
||||
|
||||
//IterationCount=3 IterationTime=100.0000 ms LaunchCount = 1
|
||||
//WarmupCount=3
|
||||
|
||||
// Method | Mean | Error | StdDev | Ratio | RatioSD | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op |
|
||||
//-------------------------------------- |-------------:|-------------:|------------:|-------:|--------:|------------:|------------:|------------:|--------------------:|
|
||||
// SerializerSettingsInstantiation | 29,120.48 ns | 5,532.424 ns | 303.2508 ns | 997.84 | 23.66 | 73.8122 | - | - | 232346 B |
|
||||
// SerializerSettingsSingleInstantiation | 29.19 ns | 8.089 ns | 0.4434 ns | 1.00 | 0.00 | 0.0738 | - | - | 232 B |
|
||||
|
||||
//// * Warnings *
|
||||
//MinIterationTime
|
||||
// JsonSerializerSettingsBenchmarks.SerializerSettingsSingleInstantiation: IterationCount= 3, IterationTime= 100.0000 ms, LaunchCount= 1, WarmupCount= 3->MinIterationTime = 96.2493 ms which is very small. It's recommended to increase it.
|
||||
|
||||
//// * Legends *
|
||||
// Mean : Arithmetic mean of all measurements
|
||||
// Error : Half of 99.9% confidence interval
|
||||
// StdDev : Standard deviation of all measurements
|
||||
// Ratio : Mean of the ratio distribution ([Current]/[Baseline])
|
||||
// RatioSD : Standard deviation of the ratio distribution([Current]/[Baseline])
|
||||
// Gen 0/1k Op : GC Generation 0 collects per 1k Operations
|
||||
// Gen 1/1k Op : GC Generation 1 collects per 1k Operations
|
||||
// Gen 2/1k Op : GC Generation 2 collects per 1k Operations
|
||||
// Allocated Memory/Op : Allocated memory per single operation(managed only, inclusive, 1KB = 1024B)
|
||||
// 1 ns : 1 Nanosecond(0.000000001 sec)
|
||||
|
||||
//// * Diagnostic Output - MemoryDiagnoser *
|
||||
|
||||
|
||||
// // ***** BenchmarkRunner: End *****
|
||||
// Run time: 00:00:04 (4.88 sec), executed benchmarks: 2
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="AutoFixture.NUnit3" />
|
||||
<PackageReference Include="NUnit" />
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -16,6 +16,7 @@ using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
using Umbraco.Cms.Infrastructure.Scoping;
|
||||
using Umbraco.Cms.Infrastructure.Serialization;
|
||||
using Umbraco.Cms.Infrastructure.Sync;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Testing;
|
||||
@@ -328,7 +329,7 @@ public class ScopedRepositoryTests : UmbracoIntegrationTest
|
||||
public class LocalServerMessenger : ServerMessengerBase
|
||||
{
|
||||
public LocalServerMessenger()
|
||||
: base(false)
|
||||
: base(false, new SystemTextJsonSerializer())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
using Umbraco.Cms.Infrastructure.Serialization;
|
||||
using Umbraco.Cms.Infrastructure.Sync;
|
||||
using Umbraco.Cms.Tests.Common.Attributes;
|
||||
using Umbraco.Cms.Tests.Common.Builders;
|
||||
@@ -2088,7 +2089,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
public class LocalServerMessenger : ServerMessengerBase
|
||||
{
|
||||
public LocalServerMessenger()
|
||||
: base(false)
|
||||
: base(false, new SystemTextJsonSerializer())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Extensions;
|
||||
@@ -752,7 +752,7 @@ public class ReflectionUtilitiesTests
|
||||
|
||||
public class Class5 : Class4
|
||||
{
|
||||
[JsonProperty("intValue2")]
|
||||
[JsonPropertyName("intValue2")]
|
||||
public int IntValue2 { get; set; }
|
||||
|
||||
public string StringValue2 { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user