< 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: 275_13775359185
Line coverage
58%
Covered lines: 7
Uncovered lines: 5
Coverable lines: 12
Total lines: 42
Line coverage: 58.3%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
37%
Covered methods: 3
Total methods: 8
Method coverage: 37.5%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_IsReadOnly()100%11100%
get_Item(...)100%210%
set_Item(...)100%210%
System.Collections.IEnumerable.GetEnumerator()100%210%
GetEnumerator()100%210%
Get()100%11100%
Set(...)100%210%
.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/>
 17512    public bool IsReadOnly => true;
 13
 14    private readonly IFeatureCollection _decoratee;
 15
 16    /// <inheritdoc/>
 17    public object? this[Type key]
 18    {
 019        get => _decoratee[key];
 020        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 />
 50730    public TFeature? Get<TFeature>() => _decoratee.Get<TFeature>();
 31
 32    /// <inheritdoc />
 033    public void Set<TFeature>(TFeature? feature) => _decoratee.Set(feature);
 34
 35    /// <summary>Constructs a read-only feature collection over another feature collection.</summary>
 36    /// <param name="decoratee">The decoratee.</param>
 1437    internal ReadOnlyFeatureCollectionDecorator(IFeatureCollection decoratee)
 1438    {
 1439        Debug.Assert(!decoratee.IsReadOnly);
 1440        _decoratee = decoratee;
 1441    }
 42}