diff --git a/common/ASC.EventBus/Serializers/ProtobufSerializer.cs b/common/ASC.EventBus/Serializers/ProtobufSerializer.cs index c84f973937..5fa9ed22b4 100644 --- a/common/ASC.EventBus/Serializers/ProtobufSerializer.cs +++ b/common/ASC.EventBus/Serializers/ProtobufSerializer.cs @@ -2,7 +2,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer { - private SynchronizedCollection _processedProtoTypes; + private readonly SynchronizedCollection _processedProtoTypes; private readonly int _baseFieldNumber; public ProtobufSerializer() @@ -14,8 +14,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer /// public byte[] Serialize(T? item) { - if (item == null) - return Array.Empty(); + if (item == null) return Array.Empty(); ProcessProtoType(item.GetType()); @@ -29,7 +28,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer /// public T Deserialize(byte[] serializedObject) { - // ProcessProtoType(returnType); + ProcessProtoType(typeof(T)); using var ms = new MemoryStream(serializedObject); @@ -58,12 +57,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer if (!baseType.GetSubtypes().Any(s => s.DerivedType == itemType)) { - baseType.AddSubType(_baseFieldNumber, protoType); - - //foreach (var field in baseType.GetFields()) - //{ - // myType.Add(field.FieldNumber + _baseTypeIncrement, field.Name); - //} + baseType.AddSubType(_baseFieldNumber, protoType); } _processedProtoTypes.Add(protoType.FullName);