diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs index f574240dc8..c877dccc58 100644 --- a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs +++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs @@ -6,11 +6,11 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed [Serializable] public abstract class EtoBase { - public Dictionary Properties { get; } + public Dictionary Properties { get; set; } protected EtoBase() { - Properties = new Dictionary(); + Properties = new Dictionary(); } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs index eb44e51820..f719eb68f8 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpHybridJsonSerializer_Tests.cs @@ -63,6 +63,23 @@ namespace Volo.Abp.Json json.ShouldContain("SystemTextJson"); } + + [Fact] + public void SystemTextJsonSerialize_With_Dictionary_Test() + { + var json = _jsonSerializer.Serialize(new MyClassWithDictionary + { + Properties = + { + {"A", "AV"}, + {"B", "BV"} + } + }); + + var deserialized = _jsonSerializer.Deserialize(json); + deserialized.Properties.ShouldContain(p => p.Key == "A" && p.Value == "AV"); + deserialized.Properties.ShouldContain(p => p.Key == "B" && p.Value == "BV"); + } public class MyClass1 { @@ -83,6 +100,16 @@ namespace Volo.Abp.Json public string Provider { get; set; } } + public class MyClassWithDictionary + { + public Dictionary Properties { get; set; } + + public MyClassWithDictionary() + { + Properties = new Dictionary(); + } + } + class NewtonsoftJsonConverter : JsonConverter, ITransientDependency { public override void WriteJson(JsonWriter writer, MyClass1 value, JsonSerializer serializer)