From a9e33bfd2d21f2840f5a5dfc3e278cb383c4b0b9 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 4 Nov 2020 16:10:45 +0800 Subject: [PATCH 1/4] Remove duplicate TrySetId method. --- .../Volo/Abp/Domain/Entities/EntityHelper.cs | 31 ------------------- .../JsonConverters/EntityJsonConverter.cs | 3 +- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs index b778ec2b67..ecb9252779 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs @@ -266,36 +266,5 @@ namespace Volo.Abp.Domain.Entities property?.SetValue(entity, idFactory()); } - - public static void TrySetId( - object entity, - TKey id, - bool checkForDisableIdGenerationAttribute = false) - { - var property = CachedIdProperties.GetOrAdd( - $"{entity.GetType().FullName}-{checkForDisableIdGenerationAttribute}", () => - { - var idProperty = entity - .GetType() - .GetProperties() - .FirstOrDefault(x => x.Name == nameof(IEntity.Id) && - x.GetSetMethod(true) != null); - - if (idProperty == null) - { - return null; - } - - if (checkForDisableIdGenerationAttribute && - idProperty.IsDefined(typeof(DisableIdGenerationAttribute), true)) - { - return null; - } - - return idProperty; - }); - - property?.SetValue(entity, id); - } } } diff --git a/framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs b/framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs index 8723ce8958..576e7512fa 100644 --- a/framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs +++ b/framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs @@ -6,6 +6,7 @@ using Volo.Abp.Domain.Entities; namespace Volo.Abp.MemoryDb.JsonConverters { public class EntityJsonConverter : JsonConverter + where TEntity : IEntity { public override TEntity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { @@ -16,7 +17,7 @@ namespace Volo.Abp.MemoryDb.JsonConverters var id = JsonSerializer.Deserialize(idJsonElement.GetRawText()); if (id != null) { - EntityHelper.TrySetId(entity, id); + EntityHelper.TrySetId(entity, () => id); } return entity; From f2ebe9c6185fea7c86652672838845a3da423a65 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 4 Nov 2020 16:36:50 +0800 Subject: [PATCH 2/4] Remove Newtonsoft.Json from Volo.Abp.Auditing module. --- framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj b/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj index 2685236a89..4ac2420c8f 100644 --- a/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj +++ b/framework/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj @@ -23,8 +23,4 @@ - - - - From 2b5704a6db4374719dd087ed334e8b897d49e6eb Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 4 Nov 2020 16:39:28 +0800 Subject: [PATCH 3/4] Use TryAddTransient for DefaultObjectPoolProvider. --- .../Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs index 5a01cafb22..9ff3ac21b0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs @@ -23,7 +23,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Json return new SystemTextJsonInputFormatter(jsonOptions.Value, logger); }); - builder.Services.AddTransient(); + builder.Services.TryAddTransient(); //NewtonsoftJsonInputFormatter builder.Services.AddTransient(provider => { From 4cfcfdbc0d0630155384c48c550291a4fbb420c3 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 4 Nov 2020 16:45:54 +0800 Subject: [PATCH 4/4] Remove Newtonsoft.Json from Volo.Docs.Domain.Shared project. --- .../Volo.Docs.Domain.Shared/Volo.Docs.Domain.Shared.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Domain.Shared/Volo.Docs.Domain.Shared.csproj b/modules/docs/src/Volo.Docs.Domain.Shared/Volo.Docs.Domain.Shared.csproj index d655e05df0..99066c0b9b 100644 --- a/modules/docs/src/Volo.Docs.Domain.Shared/Volo.Docs.Domain.Shared.csproj +++ b/modules/docs/src/Volo.Docs.Domain.Shared/Volo.Docs.Domain.Shared.csproj @@ -13,9 +13,5 @@ - - - -