< Summary

Information
Class: Ice.Internal.DefaultsAndOverrides
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Internal/DefaultsAndOverrides.cs
Tag: 71_18251537082
Line coverage
72%
Covered lines: 31
Uncovered lines: 12
Coverable lines: 43
Total lines: 111
Line coverage: 72%
Branch coverage
53%
Covered branches: 14
Total branches: 26
Branch coverage: 53.8%
Method coverage
100%
Covered methods: 1
Total methods: 1
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)53.85%40.72672.09%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Net;
 4using System.Text;
 5
 6namespace Ice.Internal;
 7
 8public sealed class DefaultsAndOverrides
 9{
 110    internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger)
 11    {
 12        string val;
 13
 114        defaultProtocol = properties.getIceProperty("Ice.Default.Protocol");
 15
 116        val = properties.getIceProperty("Ice.Default.Host");
 117        if (val.Length != 0)
 18        {
 119            defaultHost = val;
 20        }
 21        else
 22        {
 123            defaultHost = null;
 24        }
 25
 126        val = properties.getIceProperty("Ice.Default.SourceAddress");
 127        if (val.Length > 0)
 28        {
 029            defaultSourceAddress = Network.getNumericAddress(val);
 030            if (defaultSourceAddress == null)
 31            {
 032                throw new Ice.InitializationException("invalid IP address set for Ice.Default.SourceAddress: `" +
 033                                                      val + "'");
 34            }
 35        }
 36        else
 37        {
 138            defaultSourceAddress = null;
 39        }
 40
 141        val = properties.getIceProperty("Ice.Override.Compress");
 142        if (val.Length > 0)
 43        {
 144            overrideCompress = properties.getIcePropertyAsInt("Ice.Override.Compress") > 0;
 145            if (!BZip2.isLoaded(logger) && overrideCompress.Value)
 46            {
 047                Console.Error.WriteLine("warning: BZip2 library not found, Ice.Override.Compress ignored.");
 048                overrideCompress = null;
 49            }
 50        }
 51        else
 52        {
 153            overrideCompress = BZip2.isLoaded(logger) ? null : false;
 54        }
 55
 156        defaultCollocationOptimization =
 157            properties.getIcePropertyAsInt("Ice.Default.CollocationOptimized") > 0;
 58
 159        val = properties.getIceProperty("Ice.Default.EndpointSelection");
 160        if (val == "Random")
 61        {
 162            defaultEndpointSelection = Ice.EndpointSelectionType.Random;
 63        }
 064        else if (val == "Ordered")
 65        {
 066            defaultEndpointSelection = Ice.EndpointSelectionType.Ordered;
 67        }
 68        else
 69        {
 070            throw new ParseException(
 071                $"illegal value '{val}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'");
 72        }
 73
 74        {
 175            int value = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout");
 176            if (value < -1)
 77            {
 078                throw new InitializationException($"invalid value for Ice.Default.LocatorCacheTimeout: {value}");
 79            }
 180            defaultLocatorCacheTimeout = TimeSpan.FromSeconds(value);
 81        }
 82
 83        {
 184            int value = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout");
 185            if (value < 1 && value != -1)
 86            {
 087                throw new InitializationException($"invalid value for Ice.Default.InvocationTimeout: {value}");
 88            }
 189            defaultInvocationTimeout = TimeSpan.FromMilliseconds(value);
 90        }
 91
 192        val = properties.getIceProperty("Ice.Default.EncodingVersion");
 193        defaultEncoding = Ice.Util.stringToEncodingVersion(val);
 194        Protocol.checkSupportedEncoding(defaultEncoding);
 95
 196        bool slicedFormat = properties.getIcePropertyAsInt("Ice.Default.SlicedFormat") > 0;
 197        defaultFormat = slicedFormat ? FormatType.SlicedFormat : FormatType.CompactFormat;
 198    }
 99
 100    public string defaultHost;
 101    public EndPoint defaultSourceAddress;
 102    public string defaultProtocol;
 103    public bool defaultCollocationOptimization;
 104    public Ice.EndpointSelectionType defaultEndpointSelection;
 105    public TimeSpan defaultLocatorCacheTimeout;
 106    public TimeSpan defaultInvocationTimeout;
 107    public Ice.EncodingVersion defaultEncoding;
 108    public Ice.FormatType defaultFormat;
 109
 110    public bool? overrideCompress;
 111}