From 9097a09fcbe7c2dfc09f4b72f08a3d987822ede6 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 27 Sep 2024 16:52:49 +0200 Subject: [PATCH] Add TimeSpan overloads for C# timeout (#2809) --- .../Ice/Internal/CollocatedRequestHandler.cs | 2 +- .../src/Ice/Internal/DefaultsAndOverrides.cs | 27 ++----- csharp/src/Ice/Internal/LocatorInfo.cs | 26 +++---- csharp/src/Ice/Internal/OutgoingAsync.cs | 14 ++-- csharp/src/Ice/Internal/Reference.cs | 34 ++++----- csharp/src/Ice/Internal/ReferenceFactory.cs | 42 ++--------- csharp/src/Ice/Proxy.cs | 60 ++++++++++----- csharp/test/Ice/location/AllTests.cs | 2 +- csharp/test/Ice/proxy/AllTests.cs | 74 ++++--------------- 9 files changed, 108 insertions(+), 173 deletions(-) diff --git a/csharp/src/Ice/Internal/CollocatedRequestHandler.cs b/csharp/src/Ice/Internal/CollocatedRequestHandler.cs index f8044b48aaf..631e7e1088c 100644 --- a/csharp/src/Ice/Internal/CollocatedRequestHandler.cs +++ b/csharp/src/Ice/Internal/CollocatedRequestHandler.cs @@ -97,7 +97,7 @@ internal int invokeAsyncRequest(OutgoingAsyncBase outAsync, int batchRequestCoun } outAsync.attachCollocatedObserver(_adapter, requestId); - if (!synchronous || !_response || _reference.getInvocationTimeout() > 0) + if (!synchronous || !_response || _reference.getInvocationTimeout() > TimeSpan.Zero) { // Don't invoke from the user thread if async or invocation timeout is set _adapter.getThreadPool().execute( diff --git a/csharp/src/Ice/Internal/DefaultsAndOverrides.cs b/csharp/src/Ice/Internal/DefaultsAndOverrides.cs index b58932b2ecf..095d654f194 100644 --- a/csharp/src/Ice/Internal/DefaultsAndOverrides.cs +++ b/csharp/src/Ice/Internal/DefaultsAndOverrides.cs @@ -80,25 +80,10 @@ internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) throw new ParseException($"illegal value '{val}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'"); } - defaultLocatorCacheTimeout = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout"); - if (defaultLocatorCacheTimeout < -1) - { - defaultLocatorCacheTimeout = -1; - StringBuilder msg = new StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `"); - msg.Append(properties.getIceProperty("Ice.Default.LocatorCacheTimeout")); - msg.Append("': defaulting to -1"); - logger.warning(msg.ToString()); - } - - defaultInvocationTimeout = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout"); - if (defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1) - { - defaultInvocationTimeout = -1; - StringBuilder msg = new StringBuilder("invalid value for Ice.Default.InvocationTimeout `"); - msg.Append(properties.getIceProperty("Ice.Default.InvocationTimeout")); - msg.Append("': defaulting to -1"); - logger.warning(msg.ToString()); - } + defaultLocatorCacheTimeout = TimeSpan.FromSeconds( + properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout")); + defaultInvocationTimeout = TimeSpan.FromMilliseconds( + properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout")); defaultPreferSecure = properties.getIcePropertyAsInt("Ice.Default.PreferSecure") > 0; @@ -117,8 +102,8 @@ internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) public string defaultProtocol; public bool defaultCollocationOptimization; public Ice.EndpointSelectionType defaultEndpointSelection; - public int defaultLocatorCacheTimeout; - public int defaultInvocationTimeout; + public TimeSpan defaultLocatorCacheTimeout; + public TimeSpan defaultInvocationTimeout; public bool defaultPreferSecure; public Ice.EncodingVersion defaultEncoding; public Ice.FormatType defaultFormat; diff --git a/csharp/src/Ice/Internal/LocatorInfo.cs b/csharp/src/Ice/Internal/LocatorInfo.cs index fd61aa8a5e6..5f2eee0eb05 100644 --- a/csharp/src/Ice/Internal/LocatorInfo.cs +++ b/csharp/src/Ice/Internal/LocatorInfo.cs @@ -80,7 +80,7 @@ public void } public - RequestCallback(Reference @ref, int ttl, GetEndpointsCallback cb) + RequestCallback(Reference @ref, TimeSpan ttl, GetEndpointsCallback cb) { _ref = @ref; _ttl = ttl; @@ -88,14 +88,14 @@ public void } private readonly Reference _ref; - private readonly int _ttl; + private readonly TimeSpan _ttl; private readonly GetEndpointsCallback _callback; } private abstract class Request { public void - addCallback(Reference @ref, Reference wellKnownRef, int ttl, GetEndpointsCallback cb) + addCallback(Reference @ref, Reference wellKnownRef, TimeSpan ttl, GetEndpointsCallback cb) { RequestCallback callback = new RequestCallback(@ref, ttl, cb); lock (_mutex) @@ -304,13 +304,13 @@ public Ice.LocatorRegistryPrx getLocatorRegistry() } public void - getEndpoints(Reference @ref, int ttl, GetEndpointsCallback callback) + getEndpoints(Reference @ref, TimeSpan ttl, GetEndpointsCallback callback) { getEndpoints(@ref, null, ttl, callback); } public void - getEndpoints(Reference @ref, Reference wellKnownRef, int ttl, GetEndpointsCallback callback) + getEndpoints(Reference @ref, Reference wellKnownRef, TimeSpan ttl, GetEndpointsCallback callback) { Debug.Assert(@ref.isIndirect()); EndpointI[] endpoints = null; @@ -803,9 +803,9 @@ internal void clear() } } - internal EndpointI[] getAdapterEndpoints(string adapter, int ttl, out bool cached) + internal EndpointI[] getAdapterEndpoints(string adapter, TimeSpan ttl, out bool cached) { - if (ttl == 0) // Locator cache disabled. + if (ttl == TimeSpan.Zero) // Locator cache disabled. { cached = false; return null; @@ -847,9 +847,9 @@ internal EndpointI[] removeAdapterEndpoints(string adapter) } } - internal Reference getObjectReference(Ice.Identity id, int ttl, out bool cached) + internal Reference getObjectReference(Ice.Identity id, TimeSpan ttl, out bool cached) { - if (ttl == 0) // Locator cache disabled. + if (ttl == TimeSpan.Zero) // Locator cache disabled. { cached = false; return null; @@ -890,16 +890,16 @@ internal Reference removeObjectReference(Ice.Identity id) } } - private bool checkTTL(long time, int ttl) + private bool checkTTL(long time, TimeSpan ttl) { - Debug.Assert(ttl != 0); - if (ttl < 0) // TTL = infinite + Debug.Assert(ttl != TimeSpan.Zero); + if (ttl < TimeSpan.Zero) // TTL = infinite { return true; } else { - return Time.currentMonotonicTimeMillis() - time <= ((long)ttl * 1000); + return Time.currentMonotonicTimeMillis() - time <= ttl.TotalMilliseconds; } } diff --git a/csharp/src/Ice/Internal/OutgoingAsync.cs b/csharp/src/Ice/Internal/OutgoingAsync.cs index 930746c39ac..df6d8ba95c5 100644 --- a/csharp/src/Ice/Internal/OutgoingAsync.cs +++ b/csharp/src/Ice/Internal/OutgoingAsync.cs @@ -520,10 +520,10 @@ protected void invokeImpl(bool userThread) { if (userThread) { - int invocationTimeout = proxy_.iceReference().getInvocationTimeout(); - if (invocationTimeout > 0) + TimeSpan invocationTimeout = proxy_.iceReference().getInvocationTimeout(); + if (invocationTimeout > TimeSpan.Zero) { - instance_.timer().schedule(this, invocationTimeout); + instance_.timer().schedule(this, (long)invocationTimeout.TotalMilliseconds); } } else if (observer_ != null) @@ -606,7 +606,7 @@ protected override bool sentImpl(bool done) _sent = true; if (done) { - if (proxy_.iceReference().getInvocationTimeout() != -1) + if (proxy_.iceReference().getInvocationTimeout() > TimeSpan.Zero) { instance_.timer().cancel(this); } @@ -616,7 +616,7 @@ protected override bool sentImpl(bool done) protected override bool exceptionImpl(Ice.Exception ex) { - if (proxy_.iceReference().getInvocationTimeout() != -1) + if (proxy_.iceReference().getInvocationTimeout() > TimeSpan.Zero) { instance_.timer().cancel(this); } @@ -625,7 +625,7 @@ protected override bool exceptionImpl(Ice.Exception ex) protected override bool responseImpl(bool userThread, bool ok, bool invoke) { - if (proxy_.iceReference().getInvocationTimeout() != -1) + if (proxy_.iceReference().getInvocationTimeout() > TimeSpan.Zero) { instance_.timer().cancel(this); } @@ -1040,7 +1040,7 @@ public override int invokeRemote(Ice.ConnectionI connection, bool compress, bool public override int invokeCollocated(CollocatedRequestHandler handler) { // The stream cannot be cached if the proxy is not a twoway or there is an invocation timeout set. - if (!proxy_.ice_isTwoway() || proxy_.iceReference().getInvocationTimeout() != -1) + if (!proxy_.ice_isTwoway() || proxy_.iceReference().getInvocationTimeout() > TimeSpan.Zero) { // Disable caching by marking the streams as cached! state_ |= StateCachedBuffers; diff --git a/csharp/src/Ice/Internal/Reference.cs b/csharp/src/Ice/Internal/Reference.cs index f94b06a3aae..99a819bd76a 100644 --- a/csharp/src/Ice/Internal/Reference.cs +++ b/csharp/src/Ice/Internal/Reference.cs @@ -92,7 +92,7 @@ public Dictionary getContext() return _context; } - public int + public TimeSpan getInvocationTimeout() { return _invocationTimeout; @@ -125,7 +125,7 @@ public Ice.Communicator getCommunicator() public abstract Ice.EndpointSelectionType getEndpointSelection(); - public abstract int getLocatorCacheTimeout(); + public abstract TimeSpan getLocatorCacheTimeout(); public abstract string getConnectionId(); @@ -185,7 +185,7 @@ public Reference changeFacet(string newFacet) return r; } - public Reference changeInvocationTimeout(int newTimeout) + public Reference changeInvocationTimeout(TimeSpan newTimeout) { Reference r = _instance.referenceFactory().copy(this); r._invocationTimeout = newTimeout; @@ -222,7 +222,7 @@ public virtual Reference changeCompress(bool newCompress) public abstract Reference changeEndpointSelection(Ice.EndpointSelectionType newType); - public abstract Reference changeLocatorCacheTimeout(int newTimeout); + public abstract Reference changeLocatorCacheTimeout(TimeSpan newTimeout); public abstract Reference changeConnectionId(string connectionId); @@ -446,7 +446,7 @@ public virtual bool Equals(Reference other) protected bool secure_; private Ice.ProtocolVersion _protocol; private Ice.EncodingVersion _encoding; - private int _invocationTimeout; + private TimeSpan _invocationTimeout; private bool? _compress; protected Reference( @@ -459,7 +459,7 @@ protected Reference( bool? compress, Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, - int invocationTimeout, + TimeSpan invocationTimeout, Dictionary context) { // Validate string arguments. @@ -496,7 +496,7 @@ public FixedReference( Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, Ice.ConnectionI connection, - int invocationTimeout, + TimeSpan invocationTimeout, Dictionary context) : base(instance, communicator, identity, facet, mode, secure, compress, protocol, encoding, invocationTimeout, context) { @@ -543,9 +543,9 @@ public override Ice.EndpointSelectionType getEndpointSelection() return Ice.EndpointSelectionType.Random; } - public override int getLocatorCacheTimeout() + public override TimeSpan getLocatorCacheTimeout() { - return 0; + return TimeSpan.Zero; } public override string getConnectionId() @@ -603,7 +603,7 @@ public override Reference changeEndpointSelection(Ice.EndpointSelectionType newT throw new Ice.FixedProxyException(); } - public override Reference changeLocatorCacheTimeout(int newTimeout) + public override Reference changeLocatorCacheTimeout(TimeSpan newTimeout) { throw new Ice.FixedProxyException(); } @@ -756,7 +756,7 @@ public override Ice.EndpointSelectionType getEndpointSelection() return _endpointSelection; } - public override int getLocatorCacheTimeout() + public override TimeSpan getLocatorCacheTimeout() { return _locatorCacheTimeout; } @@ -872,7 +872,7 @@ public override Reference changeEndpointSelection(Ice.EndpointSelectionType newT return r; } - public override Reference changeLocatorCacheTimeout(int newTimeout) + public override Reference changeLocatorCacheTimeout(TimeSpan newTimeout) { RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this); r._locatorCacheTimeout = newTimeout; @@ -1000,8 +1000,8 @@ public override Dictionary toProperty(string prefix) properties[prefix + ".PreferSecure"] = _preferSecure ? "1" : "0"; properties[prefix + ".EndpointSelection"] = _endpointSelection == Ice.EndpointSelectionType.Random ? "Random" : "Ordered"; - properties[prefix + ".LocatorCacheTimeout"] = _locatorCacheTimeout.ToString(CultureInfo.InvariantCulture); - properties[prefix + ".InvocationTimeout"] = getInvocationTimeout().ToString(CultureInfo.InvariantCulture); + properties[prefix + ".LocatorCacheTimeout"] = _locatorCacheTimeout.TotalSeconds.ToString(CultureInfo.InvariantCulture); + properties[prefix + ".InvocationTimeout"] = getInvocationTimeout().TotalMilliseconds.ToString(CultureInfo.InvariantCulture); if (_routerInfo != null) { @@ -1243,8 +1243,8 @@ public RoutableReference( bool cacheConnection, bool preferSecure, Ice.EndpointSelectionType endpointSelection, - int locatorCacheTimeout, - int invocationTimeout, + TimeSpan locatorCacheTimeout, + TimeSpan invocationTimeout, Dictionary context) : base( instance, @@ -1577,7 +1577,7 @@ public int Compare(EndpointI le, EndpointI re) private bool _cacheConnection; private bool _preferSecure; private Ice.EndpointSelectionType _endpointSelection; - private int _locatorCacheTimeout; + private TimeSpan _locatorCacheTimeout; private string _connectionId = ""; } diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index b43e3254261..79b0b69da4c 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -72,7 +72,7 @@ internal Reference create(Ice.Identity ident, Ice.ConnectionI connection) Ice.Util.Protocol_1_0, _instance.defaultsAndOverrides().defaultEncoding, connection, - -1, + TimeSpan.FromMilliseconds(-1), null); } @@ -725,8 +725,8 @@ private Reference create( bool cacheConnection = true; bool preferSecure = defaultsAndOverrides.defaultPreferSecure; Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection; - int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; - int invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; + TimeSpan locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; + TimeSpan invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; Dictionary context = null; // @@ -805,40 +805,12 @@ private Reference create( } property = propertyPrefix + ".LocatorCacheTimeout"; - string val = properties.getProperty(property); - if (val.Length > 0) - { - locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); - if (locatorCacheTimeout < -1) - { - locatorCacheTimeout = -1; - - StringBuilder msg = new StringBuilder("invalid value for "); - msg.Append(property); - msg.Append(" `"); - msg.Append(properties.getProperty(property)); - msg.Append("': defaulting to -1"); - _instance.initializationData().logger.warning(msg.ToString()); - } - } + locatorCacheTimeout = TimeSpan.FromSeconds( + properties.getPropertyAsIntWithDefault(property, (int)locatorCacheTimeout.TotalSeconds)); property = propertyPrefix + ".InvocationTimeout"; - val = properties.getProperty(property); - if (val.Length > 0) - { - invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); - if (invocationTimeout < 1 && invocationTimeout != -1) - { - invocationTimeout = -1; - - StringBuilder msg = new StringBuilder("invalid value for "); - msg.Append(property); - msg.Append(" `"); - msg.Append(properties.getProperty(property)); - msg.Append("': defaulting to -1"); - _instance.initializationData().logger.warning(msg.ToString()); - } - } + invocationTimeout = TimeSpan.FromMilliseconds( + properties.getPropertyAsIntWithDefault(property, (int)invocationTimeout.TotalMilliseconds)); property = propertyPrefix + ".Context."; Dictionary contexts = properties.getPropertiesForPrefix(property); diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index 71a984588cf..c1f4f59015e 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -210,8 +210,8 @@ bool ice_invoke( /// /// Returns the locator cache timeout of this proxy. /// - /// The locator cache timeout value (in seconds). - int ice_getLocatorCacheTimeout(); + /// The locator cache timeout value. + TimeSpan ice_getLocatorCacheTimeout(); /// /// Creates a new proxy that is identical to this proxy, except for the locator cache timeout. @@ -219,17 +219,29 @@ bool ice_invoke( /// The new locator cache timeout (in seconds). ObjectPrx ice_locatorCacheTimeout(int newTimeout); + /// + /// Creates a new proxy that is identical to this proxy, except for the locator cache timeout. + /// + /// The new locator cache timeout. + ObjectPrx ice_locatorCacheTimeout(TimeSpan newTimeout); + /// /// Creates a new proxy that is identical to this proxy, except for the invocation timeout. /// - /// The new invocation timeout (in seconds). + /// The new invocation timeout (in milliseconds). ObjectPrx ice_invocationTimeout(int newTimeout); + /// + /// Creates a new proxy that is identical to this proxy, except for the invocation timeout. + /// + /// The new invocation timeout. + ObjectPrx ice_invocationTimeout(TimeSpan newTimeout); + /// /// Returns the invocation timeout of this proxy. /// - /// The invocation timeout value (in seconds). - int ice_getInvocationTimeout(); + /// The invocation timeout value. + TimeSpan ice_getInvocationTimeout(); /// /// Returns whether this proxy caches connections. @@ -1033,8 +1045,8 @@ public ObjectPrx ice_endpoints(Endpoint[] newEndpoints) /// /// Returns the locator cache timeout of this proxy. /// - /// The locator cache timeout value (in seconds). - public int ice_getLocatorCacheTimeout() + /// The locator cache timeout value. + public TimeSpan ice_getLocatorCacheTimeout() { return _reference.getLocatorCacheTimeout(); } @@ -1046,10 +1058,16 @@ public int ice_getLocatorCacheTimeout() /// The new proxy with the specified locator cache timeout. public ObjectPrx ice_locatorCacheTimeout(int newTimeout) { - if (newTimeout < -1) - { - throw new ArgumentException("invalid value passed to ice_locatorCacheTimeout: " + newTimeout); - } + return ice_locatorCacheTimeout(TimeSpan.FromSeconds(newTimeout)); + } + + /// + /// Creates a new proxy that is identical to this proxy, except for the locator cache timeout. + /// + /// The new locator cache timeout. + /// The new proxy with the specified locator cache timeout. + public ObjectPrx ice_locatorCacheTimeout(TimeSpan newTimeout) + { if (newTimeout == _reference.getLocatorCacheTimeout()) { return this; @@ -1063,8 +1081,8 @@ public ObjectPrx ice_locatorCacheTimeout(int newTimeout) /// /// Returns the invocation timeout of this proxy. /// - /// The invocation timeout value (in seconds). - public int ice_getInvocationTimeout() + /// The invocation timeout value. + public TimeSpan ice_getInvocationTimeout() { return _reference.getInvocationTimeout(); } @@ -1072,14 +1090,20 @@ public int ice_getInvocationTimeout() /// /// Creates a new proxy that is identical to this proxy, except for the invocation timeout. /// - /// The new invocation timeout (in seconds). + /// The new invocation timeout (in milliseconds). /// The new proxy with the specified invocation timeout. public ObjectPrx ice_invocationTimeout(int newTimeout) { - if (newTimeout < 1 && newTimeout != -1) - { - throw new ArgumentException("invalid value passed to ice_invocationTimeout: " + newTimeout); - } + return ice_invocationTimeout(TimeSpan.FromMilliseconds(newTimeout)); + } + + /// + /// Creates a new proxy that is identical to this proxy, except for the invocation timeout. + /// + /// The new invocation timeout. + /// The new proxy with the specified invocation timeout. + public ObjectPrx ice_invocationTimeout(TimeSpan newTimeout) + { if (newTimeout == _reference.getInvocationTimeout()) { return this; diff --git a/csharp/test/Ice/location/AllTests.cs b/csharp/test/Ice/location/AllTests.cs index 754b28d6927..68f10a8c308 100644 --- a/csharp/test/Ice/location/AllTests.cs +++ b/csharp/test/Ice/location/AllTests.cs @@ -245,7 +245,7 @@ public static async Task allTests(global::Test.TestHelper helper) communicator.stringToProxy("test").ice_ping(); test(count == locator.getRequestCount()); - test(communicator.stringToProxy("test").ice_locatorCacheTimeout(99).ice_getLocatorCacheTimeout() == 99); + test(communicator.stringToProxy("test").ice_locatorCacheTimeout(99).ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(99)); output.WriteLine("ok"); diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index c0238e5da4a..486d3f3dc51 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -403,10 +403,10 @@ public class AllTests : global::Test.AllTests test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name == "locator"); prop.setProperty(property, ""); property = propertyPrefix + ".LocatorCacheTimeout"; - test(b1.ice_getLocatorCacheTimeout() == -1); + test(b1.ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(-1)); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); - test(b1.ice_getLocatorCacheTimeout() == 1); + test(b1.ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(1)); prop.setProperty(property, ""); // Now retest with an indirect proxy. @@ -418,10 +418,10 @@ public class AllTests : global::Test.AllTests prop.setProperty(property, ""); property = propertyPrefix + ".LocatorCacheTimeout"; - test(b1.ice_getLocatorCacheTimeout() == -1); + test(b1.ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(-1)); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); - test(b1.ice_getLocatorCacheTimeout() == 1); + test(b1.ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(1)); prop.setProperty(property, ""); // This cannot be tested so easily because the property is cached @@ -456,10 +456,10 @@ public class AllTests : global::Test.AllTests prop.setProperty(property, ""); property = propertyPrefix + ".InvocationTimeout"; - test(b1.ice_getInvocationTimeout() == -1); + test(b1.ice_getInvocationTimeout() == TimeSpan.FromMilliseconds(-1)); prop.setProperty(property, "1000"); b1 = communicator.propertyToProxy(propertyPrefix); - test(b1.ice_getInvocationTimeout() == 1000); + test(b1.ice_getInvocationTimeout() == TimeSpan.FromSeconds(1)); prop.setProperty(property, ""); property = propertyPrefix + ".EndpointSelection"; @@ -582,59 +582,13 @@ public class AllTests : global::Test.AllTests test(baseProxy.ice_preferSecure(true).ice_isPreferSecure()); test(!baseProxy.ice_preferSecure(false).ice_isPreferSecure()); - try - { - baseProxy.ice_invocationTimeout(0); - test(false); - } - catch (ArgumentException) - { - } - - try - { - baseProxy.ice_invocationTimeout(-1); - } - catch (ArgumentException) - { - test(false); - } - - try - { - baseProxy.ice_invocationTimeout(-2); - test(false); - } - catch (ArgumentException) - { - } + test(baseProxy.ice_invocationTimeout(0).ice_getInvocationTimeout() == TimeSpan.Zero); + test(baseProxy.ice_invocationTimeout(-1).ice_getInvocationTimeout() == TimeSpan.FromMilliseconds(-1)); + test(baseProxy.ice_invocationTimeout(-2).ice_getInvocationTimeout() == TimeSpan.FromMilliseconds(-2)); - try - { - baseProxy.ice_locatorCacheTimeout(0); - } - catch (ArgumentException) - { - test(false); - } - - try - { - baseProxy.ice_locatorCacheTimeout(-1); - } - catch (ArgumentException) - { - test(false); - } - - try - { - baseProxy.ice_locatorCacheTimeout(-2); - test(false); - } - catch (ArgumentException) - { - } + test(baseProxy.ice_locatorCacheTimeout(0).ice_getLocatorCacheTimeout() == TimeSpan.Zero); + test(baseProxy.ice_locatorCacheTimeout(-1).ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(-1)); + test(baseProxy.ice_locatorCacheTimeout(-2).ice_getLocatorCacheTimeout() == TimeSpan.FromSeconds(-2)); output.WriteLine("ok"); @@ -792,8 +746,8 @@ public class AllTests : global::Test.AllTests ctx["two"] = "world"; test(cl.ice_fixed(connection).ice_getContext().Count == 0); test(cl.ice_context(ctx).ice_fixed(connection).ice_getContext().Count == 2); - test(cl.ice_fixed(connection).ice_getInvocationTimeout() == -1); - test(cl.ice_invocationTimeout(10).ice_fixed(connection).ice_getInvocationTimeout() == 10); + test(cl.ice_fixed(connection).ice_getInvocationTimeout() == TimeSpan.FromMilliseconds(-1)); + test(cl.ice_invocationTimeout(10).ice_fixed(connection).ice_getInvocationTimeout() == TimeSpan.FromMilliseconds(10)); test(cl.ice_fixed(connection).ice_getConnection() == connection); test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection); test(cl.ice_compress(true).ice_fixed(connection).ice_getCompress().Value);