< Summary

Class:DCL.ECS7.ComponentWrapper.ProtobufWrappedComponent[T]
Assembly:ECS7Plugin.ComponentWrapper
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ComponentWrapper/ProtobufWrappedComponent.cs
Covered lines:8
Uncovered lines:8
Coverable lines:16
Total lines:45
Line coverage:50% (8 of 16)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:6
Method coverage:50% (3 of 6)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
implicit operator T(...)0%2100%
ProtobufWrappedComponent(...)0%110100%
SerializeTo(...)0%2100%
DeserializeFrom(...)0%2100%
ClearFields()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/ECS7/ComponentWrapper/ProtobufWrappedComponent.cs

#LineLine coverage
 1using DCL.ECS7.ComponentWrapper.Generic;
 2using Google.Protobuf;
 3using System;
 4using System.IO;
 5
 6namespace DCL.ECS7.ComponentWrapper
 7{
 8    public record ProtobufWrappedComponent<T> : IWrappedComponent<T> where T: class, IMessage<T>
 9    {
 10        private readonly T model;
 11
 12512        public T Model => model;
 13
 14        public static implicit operator T(ProtobufWrappedComponent<T> wrapped) =>
 015            wrapped.model;
 16
 8017        public ProtobufWrappedComponent(T model)
 18        {
 8019            this.model = model;
 8020        }
 21
 22        public void SerializeTo(MemoryStream buffer, CodedOutputStream stream)
 23        {
 024            buffer.SetLength(0);
 025            model.WriteTo(stream);
 026            stream.Flush();
 027        }
 28
 29        public void DeserializeFrom(ReadOnlySpan<byte> bytes)
 30        {
 031            ClearFields();
 032            model.MergeFrom(bytes);
 033        }
 34
 35        public void ClearFields()
 36        {
 337            var fields = model.Descriptor.Fields.InDeclarationOrder();
 38
 4239            for (int i = 0; i < fields.Count; i++)
 40            {
 1841                fields[i].Accessor.Clear(model);
 42            }
 343        }
 44    }
 45}