< Summary

Information
Class: IceRpc.Features.FeatureCollectionExtensions
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Features/FeatureCollectionExtensions.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 32
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage
100%
Covered methods: 2
Total methods: 2
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AsReadOnly(...)50%22100%
With(...)100%22100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Features.Internal;
 4
 5namespace IceRpc.Features;
 6
 7/// <summary>Provides extension methods for <see cref="IFeatureCollection" />.</summary>
 8public static class FeatureCollectionExtensions
 9{
 10    /// <summary>Creates a read-only collection decorator over this feature collection.</summary>
 11    /// <param name="features">This feature collection.</param>
 12    /// <returns>A new read-only decorator over this feature collection, or the feature collection itself if it's
 13    /// already read-only.</returns>
 14    public static IFeatureCollection AsReadOnly(this IFeatureCollection features) =>
 1415        features.IsReadOnly ? features : new ReadOnlyFeatureCollectionDecorator(features);
 16
 17    /// <summary>Updates this feature collection (if read-write) or creates a new feature collection (if read-only)
 18    /// and sets its T to the provided value.</summary>
 19    /// <typeparam name="T">The type of the value to set in the feature collection.</typeparam>
 20    /// <param name="features">This feature collection.</param>
 21    /// <param name="value">The new value.</param>
 22    /// <returns>The updated feature collection.</returns>
 23    public static IFeatureCollection With<T>(this IFeatureCollection features, T value)
 29624    {
 29625        if (features.IsReadOnly)
 17526        {
 17527            features = new FeatureCollection(features);
 17528        }
 29629        features.Set(value);
 29630        return features;
 29631    }
 32}