< Summary

Information
Class: IceRpc.Features.Internal.ReadOnlyFeatureCollectionDecorator
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Features/Internal/ReadOnlyFeatureCollectionDecorator.cs
Tag: 2300_35243572715
Line coverage
75%
Covered lines: 9
Uncovered lines: 3
Coverable lines: 12
Total lines: 43
Line coverage: 75%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
62%
Covered methods: 5
Fully covered methods: 5
Total methods: 8
Method coverage: 62.5%
Full method coverage: 62.5%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IsReadOnly()100%11100%
get_Item(...)100%210%
set_Item(...)100%11100%
System.Collections.IEnumerable.GetEnumerator()100%210%
GetEnumerator()100%210%
Get()100%11100%
Set(...)100%11100%
.ctor(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Features/Internal/ReadOnlyFeatureCollectionDecorator.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Collections;
 4using System.Diagnostics;
 5
 6namespace IceRpc.Features.Internal;
 7
 8/// <summary>A feature collection decorator that does not allow updates to the underlying feature collection.</summary>
 9internal class ReadOnlyFeatureCollectionDecorator : IFeatureCollection
 10{
 11    /// <inheritdoc/>
 17312    public bool IsReadOnly => true;
 13
 14    private readonly IFeatureCollection _decoratee;
 15
 16    /// <inheritdoc/>
 17    public object? this[Type key]
 18    {
 019        get => _decoratee[key];
 120        set => throw new InvalidOperationException("Cannot update a read-only feature collection.");
 21    }
 22
 23    /// <inheritdoc />
 024    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
 25
 26    /// <inheritdoc />
 027    public IEnumerator<KeyValuePair<Type, object>> GetEnumerator() => _decoratee.GetEnumerator();
 28
 29    /// <inheritdoc />
 64030    public TFeature? Get<TFeature>() => _decoratee.Get<TFeature>();
 31
 32    /// <inheritdoc />
 33    public void Set<TFeature>(TFeature? feature) =>
 234        throw new InvalidOperationException("Cannot update a read-only feature collection.");
 35
 36    /// <summary>Constructs a read-only feature collection over another feature collection.</summary>
 37    /// <param name="decoratee">The decoratee.</param>
 1838    internal ReadOnlyFeatureCollectionDecorator(IFeatureCollection decoratee)
 1839    {
 1840        Debug.Assert(!decoratee.IsReadOnly);
 1841        _decoratee = decoratee;
 1842    }
 43}