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 => { 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 @@ - - - - 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 0b16c7ac4d..5e81e2270d 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 @@ -246,36 +246,5 @@ namespace Volo.Abp.Domain.Entities ? new Type[] { typeof(DisableIdGenerationAttribute) } : new Type[] { }); } - - 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; 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 @@ - - - -