< Summary

Information
Class: Ice.Internal.EndpointI
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Internal/EndpointI.cs
Tag: 71_18251537082
Line coverage
81%
Covered lines: 26
Uncovered lines: 6
Coverable lines: 32
Total lines: 199
Line coverage: 81.2%
Branch coverage
80%
Covered branches: 16
Total branches: 20
Branch coverage: 80%
Method coverage
66%
Covered methods: 4
Total methods: 6
Method coverage: 66.6%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToString()100%11100%
Equals(...)50%2.15266.67%
GetHashCode()100%210%
streamWrite(...)100%11100%
initWithOptions(...)83.33%18.821886.36%
checkOption(...)100%210%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/Internal/EndpointI.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Diagnostics;
 4using System.Net.Security;
 5
 6namespace Ice.Internal;
 7
 8public interface EndpointI_connectors
 9{
 10    void connectors(List<Connector> connectors);
 11
 12    void exception(Ice.LocalException ex);
 13}
 14
 15public abstract class EndpointI : Ice.Endpoint, IComparable<EndpointI>
 16{
 17    public override string ToString() =>
 18        //
 19        // WARNING: Certain features, such as proxy validation in Glacier2,
 20        // depend on the format of proxy strings. Changes to toString() and
 21        // methods called to generate parts of the reference string could break
 22        // these features. Please review for all features that depend on the
 23        // format of proxyToString() before changing this and related code.
 24        //
 125        protocol() + options();
 26
 27    public abstract Ice.EndpointInfo getInfo();
 28
 29    public override bool Equals(object obj)
 30    {
 131        if (!(obj is EndpointI))
 32        {
 033            return false;
 34        }
 135        return CompareTo((EndpointI)obj) == 0;
 36    }
 37
 38    public override int GetHashCode() // Avoids a compiler warning.
 39    {
 40        Debug.Assert(false);
 041        return 0;
 42    }
 43
 44    //
 45    // Marshal the endpoint.
 46    //
 47    public virtual void streamWrite(Ice.OutputStream s)
 48    {
 149        s.startEncapsulation();
 150        streamWriteImpl(s);
 151        s.endEncapsulation();
 152    }
 53
 54    public abstract void streamWriteImpl(Ice.OutputStream s);
 55
 56    //
 57    // Return the endpoint type.
 58    //
 59    public abstract short type();
 60
 61    //
 62    // Return the protocol name.
 63    //
 64    public abstract string protocol();
 65
 66    //
 67    // Return the timeout for the endpoint in milliseconds. 0 means
 68    // non-blocking, -1 means no timeout.
 69    //
 70    public abstract int timeout();
 71
 72    //
 73    // Return a new endpoint with a different timeout value, provided
 74    // that timeouts are supported by the endpoint. Otherwise the same
 75    // endpoint is returned.
 76    //
 77    public abstract EndpointI timeout(int t);
 78
 79    //
 80    // Return the connection ID.
 81    //
 82    public abstract string connectionId();
 83
 84    //
 85    // Return a new endpoint with a different connection id.
 86    //
 87    public abstract EndpointI connectionId(string connectionId);
 88
 89    //
 90    // Return true if the endpoints support bzip2 compress, or false
 91    // otherwise.
 92    //
 93    public abstract bool compress();
 94
 95    //
 96    // Return a new endpoint with a different compression value,
 97    // provided that compression is supported by the
 98    // endpoint. Otherwise the same endpoint is returned.
 99    //
 100    public abstract EndpointI compress(bool co);
 101
 102    //
 103    // Return true if the endpoint is datagram-based.
 104    //
 105    public abstract bool datagram();
 106
 107    //
 108    // Return true if the endpoint is secure.
 109    //
 110    public abstract bool secure();
 111
 112    //
 113    // Return a server side transceiver for this endpoint, or null if a
 114    // transceiver can only be created by an acceptor.
 115    //
 116    public abstract Transceiver transceiver();
 117
 118    //
 119    // Return a connector for this endpoint, or empty list if no connector
 120    // is available.
 121    //
 122    public abstract void connectors_async(EndpointI_connectors callback);
 123
 124    //
 125    // Return an acceptor for this endpoint, or null if no acceptors
 126    // is available.
 127    //
 128    public abstract Acceptor acceptor(string adapterName, SslServerAuthenticationOptions serverAuthenticationOptions);
 129
 130    // Expand endpoint into separate endpoints for each IP address returned by the DNS resolver.
 131    // Used only for server endpoints.
 132    public abstract List<EndpointI> expandHost();
 133
 134    // Returns true when the most underlying endpoint is an IP endpoint with a loopback or multicast address.
 135    public abstract bool isLoopbackOrMulticast();
 136
 137    // Returns a new endpoint with the specified host (if not empty) and all local options cleared. May return this.
 138    public abstract EndpointI toPublishedEndpoint(string publishedHost);
 139
 140    //
 141    // Check whether the endpoint is equivalent to another one.
 142    //
 143    public abstract bool equivalent(EndpointI endpoint);
 144
 145    public abstract int CompareTo(EndpointI other);
 146
 147    public abstract string options();
 148
 149    public virtual void initWithOptions(List<string> args)
 150    {
 1151        var unknown = new List<string>();
 152
 1153        string str = "`" + protocol() + " ";
 1154        foreach (string p in args)
 155        {
 1156            if (Ice.UtilInternal.StringUtil.findFirstOf(p, " \t\n\r") != -1)
 157            {
 0158                str += " \"" + p + "\"";
 159            }
 160            else
 161            {
 1162                str += " " + p;
 163            }
 164        }
 1165        str += "'";
 166
 1167        for (int n = 0; n < args.Count; ++n)
 168        {
 1169            string option = args[n];
 1170            if (option.Length < 2 || option[0] != '-')
 171            {
 0172                unknown.Add(option);
 0173                continue;
 174            }
 175
 1176            string argument = null;
 1177            if (n + 1 < args.Count && args[n + 1][0] != '-')
 178            {
 1179                argument = args[++n];
 180            }
 181
 1182            if (!checkOption(option, argument, str))
 183            {
 1184                unknown.Add(option);
 1185                if (argument != null)
 186                {
 1187                    unknown.Add(argument);
 188                }
 189            }
 190        }
 191
 1192        args.Clear();
 1193        args.AddRange(unknown);
 1194    }
 195
 196    protected virtual bool checkOption(string option, string argument, string endpoint) =>
 197        // Must be overridden to check for options.
 0198        false;
 199}