< Summary - Combined Code Coverage

Information
Class: NLightning.Transport.Ipc.MessagePack.NLightningFormatterResolver
Assembly: NLightning.Transport.Ipc
File(s): /home/runner/work/NLightning/NLightning/src/NLightning.Transport.Ipc/MessagePack/NLightningFormatterResolver.cs
Tag: 57_24045730253
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 46
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
.cctor()100%210%
GetFormatter()0%620%
GetFormatter()0%620%

File(s)

/home/runner/work/NLightning/NLightning/src/NLightning.Transport.Ipc/MessagePack/NLightningFormatterResolver.cs

#LineLine coverage
 1using MessagePack;
 2using MessagePack.Formatters;
 3using MessagePack.Resolvers;
 4
 5namespace NLightning.Transport.Ipc.MessagePack;
 6
 7using Domain.Bitcoin.ValueObjects;
 8using Domain.Channels.ValueObjects;
 9using Domain.Crypto.ValueObjects;
 10using Domain.Money;
 11using Domain.Node;
 12using Domain.Node.ValueObjects;
 13using Domain.Protocol.ValueObjects;
 14using Formatters;
 15
 16public class NLightningFormatterResolver : IFormatterResolver
 17{
 018    private readonly Dictionary<Type, object> _formatters = new();
 19
 020    public static readonly IFormatterResolver Instance = new NLightningFormatterResolver();
 21
 022    private NLightningFormatterResolver()
 023    {
 024        _formatters[typeof(Hash)] = new HashFormatter();
 025        _formatters[typeof(BitcoinNetwork)] = new BitcoinNetworkFormatter();
 026        _formatters[typeof(PeerAddressInfo?)] = new PeerAddressInfoNullableFormatter();
 027        _formatters[typeof(PeerAddressInfo)] = new PeerAddressInfoFormatter();
 028        _formatters[typeof(CompactPubKey?)] = new CompactPubKeyNullableFormatter();
 029        _formatters[typeof(CompactPubKey)] = new CompactPubKeyFormatter();
 030        _formatters[typeof(FeatureSet)] = new FeatureSetFormatter();
 031        _formatters[typeof(LightningMoney)] = new LightningMoneyFormatter();
 032        _formatters[typeof(SignedTransaction)] = new SignedTransactionFormatter();
 033        _formatters[typeof(ChannelId)] = new ChannelIdFormatter();
 034        _formatters[typeof(TxId)] = new TxIdFormatter();
 035    }
 36
 37    public IMessagePackFormatter<T>? GetFormatter<T>()
 038    {
 039        if (_formatters.TryGetValue(typeof(T), out var formatter))
 040        {
 041            return (IMessagePackFormatter<T>)formatter;
 42        }
 43
 044        return StandardResolver.Instance.GetFormatter<T>();
 045    }
 46}