< Summary

Information
Class: Ice.TCPEndpointInfo
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Endpoint.cs
Tag: 71_18251537082
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 177
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 3
Total methods: 3
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
type()100%11100%
secure()100%11100%
.ctor(...)100%11100%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/Endpoint.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3#nullable enable
 4
 5namespace Ice;
 6
 7/// <summary>
 8/// Base class for all endpoints.
 9/// </summary>
 10public interface Endpoint
 11{
 12    /// <summary>
 13    /// Returns the endpoint information.
 14    /// </summary>
 15    /// <returns>The endpoint information class.</returns>
 16    EndpointInfo getInfo();
 17}
 18
 19/// <summary>
 20/// Base class providing access to the endpoint details.
 21/// </summary>
 22public class EndpointInfo
 23{
 24    /// <summary>
 25    /// Gets the information for the underlying endpoint, or null if there's no underlying endpoint.
 26    /// </summary>
 27    public readonly EndpointInfo? underlying;
 28
 29    /// <summary>
 30    /// Gets a value indicating whether or not compression should be used if available when using this endpoint.
 31    /// </summary>
 32    public readonly bool compress;
 33
 34    /// <summary>Gets a 16-bit integer that identifies the transport of this endpoint.</summary>
 35    /// <returns>The endpoint type.</returns>
 36    /// <remarks>The type of an underlying endpoint is always the same as the type its enclosing endpoint.</remarks>
 37    public virtual short type() => underlying?.type() ?? -1;
 38
 39    /// <summary>Checks if this endpoint's transport is a datagram transport such as UDP.</summary>
 40    /// <returns>True for a datagram endpoint; otherwise, false.</returns>
 41    public virtual bool datagram() => underlying?.datagram() ?? false;
 42
 43    /// <summary>Checks if this endpoint's transport is secure.</summary>
 44    /// <returns>True if the endpoint's transport is secure; otherwise, false.</returns>
 45    /// <remarks>The value returned for an underlying endpoint is the same as the value returned for the enclosing
 46    /// endpoint.</remarks>
 47    public virtual bool secure() => underlying?.secure() ?? false;
 48
 49    protected EndpointInfo(EndpointInfo underlying)
 50    {
 51        this.underlying = underlying;
 52        compress = underlying.compress;
 53    }
 54
 55    protected EndpointInfo(bool compress) => this.compress = compress;
 56}
 57
 58/// <summary>
 59/// Provides access to the details of an IP endpoint.
 60/// </summary>
 61public class IPEndpointInfo : EndpointInfo
 62{
 63    /// <summary>
 64    /// Gets the host or address configured with the endpoint.
 65    /// </summary>
 66    public readonly string host;
 67
 68    /// <summary>
 69    /// Gets the endpoint's port number.
 70    /// </summary>
 71    public readonly int port;
 72
 73    /// <summary>
 74    /// Gets the source IP address.
 75    /// </summary>
 76    public readonly string sourceAddress;
 77
 78    protected IPEndpointInfo(bool compress, string host, int port, string sourceAddress)
 79        : base(compress)
 80    {
 81        this.host = host;
 82        this.port = port;
 83        this.sourceAddress = sourceAddress;
 84    }
 85}
 86
 87public sealed class TCPEndpointInfo : IPEndpointInfo
 88{
 89    private readonly bool _secure;
 90    private readonly short _type;
 91
 192    public override short type() => _type;
 93
 194    public override bool secure() => _secure;
 95
 96    internal TCPEndpointInfo(
 97        bool compress,
 98        string host,
 99        int port,
 100        string sourceAddress,
 101        short type,
 102        bool secure)
 1103        : base(compress, host, port, sourceAddress)
 104    {
 1105        _type = type;
 1106        _secure = secure;
 1107    }
 108}
 109
 110/// <summary>
 111/// Provides access to a UDP endpoint information.
 112/// </summary>
 113public sealed class UDPEndpointInfo : IPEndpointInfo
 114{
 115    public readonly string mcastInterface;
 116
 117    public readonly int mcastTtl;
 118
 119    public override short type() => UDPEndpointType.value;
 120
 121    public override bool datagram() => true;
 122
 123    internal UDPEndpointInfo(
 124        bool compress,
 125        string host,
 126        int port,
 127        string sourceAddress,
 128        string mcastInterface,
 129        int mcastTtl)
 130        : base(compress, host, port, sourceAddress)
 131    {
 132        this.mcastInterface = mcastInterface;
 133        this.mcastTtl = mcastTtl;
 134    }
 135}
 136
 137/// <summary>
 138/// Provides access to a WebSocket endpoint information.
 139/// </summary>
 140public sealed class WSEndpointInfo : EndpointInfo
 141{
 142    /// <summary>
 143    /// Gets the URI configured for this endpoint.
 144    /// </summary>
 145    public readonly string resource;
 146
 147    internal WSEndpointInfo(EndpointInfo underlying, string resource)
 148        : base(underlying) => this.resource = resource;
 149}
 150
 151/// <summary>
 152/// Provides access to the details of an opaque endpoint.
 153/// </summary>
 154public sealed class OpaqueEndpointInfo : EndpointInfo
 155{
 156    /// <summary>
 157    /// Gets the raw encoding (to decode the rawBytes).
 158    /// </summary>
 159    public readonly EncodingVersion rawEncoding;
 160
 161    /// <summary>
 162    /// Gets the raw bytes of the opaque endpoint.
 163    /// </summary>
 164    public readonly byte[] rawBytes;
 165
 166    private readonly short _type;
 167
 168    public override short type() => _type;
 169
 170    internal OpaqueEndpointInfo(short type, EncodingVersion rawEncoding, byte[] rawBytes)
 171        : base(compress: false)
 172    {
 173        _type = type;
 174        this.rawEncoding = rawEncoding;
 175        this.rawBytes = rawBytes;
 176    }
 177}