diff options
author | Jose <jose@zeroc.com> | 2016-12-29 21:01:16 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-12-29 21:01:16 +0100 |
commit | 54941beff80f3ebab2b15af4609c7ec8bc0d941e (patch) | |
tree | bdd4eb6573f5c4673c2129cc2eb616b1188fc543 /csharp/src | |
parent | JavaScript Ice.Long fixes and improvements (diff) | |
download | ice-54941beff80f3ebab2b15af4609c7ec8bc0d941e.tar.bz2 ice-54941beff80f3ebab2b15af4609c7ec8bc0d941e.tar.xz ice-54941beff80f3ebab2b15af4609c7ec8bc0d941e.zip |
CSharp cleanup and fixes:
- Add EditorBrowsable(EditorBrowsableState.Never) to
hidde internal public methods from Intellisense,
see ICE-7448.
- Remove Base64 and replace it with .NET System.Convert
see ICE-7477
- Remove SysLogger as that was only used by Mono
- Simplify ThreadPriority setting
- Remove using statements that are not required
- Normalize string, char, object spell, preferred over
String, Char, Object
- Shorthen qualifier names avoiding redundant scopes.
Diffstat (limited to 'csharp/src')
90 files changed, 747 insertions, 1390 deletions
diff --git a/csharp/src/Glacier2/Application.cs b/csharp/src/Glacier2/Application.cs index 273ba6b5372..da761dfd956 100644 --- a/csharp/src/Glacier2/Application.cs +++ b/csharp/src/Glacier2/Application.cs @@ -133,7 +133,7 @@ public abstract class Application : Ice.Application /// Returns the Glacier2 session proxy. /// </summary> /// <returns>The session proxy.</returns> - public static Glacier2.SessionPrx + public static SessionPrx session() { return _session; @@ -246,7 +246,7 @@ public abstract class Application : Ice.Application { iceCommunicator = Ice.Util.initialize(ref args, initData); - _router = Glacier2.RouterPrxHelper.uncheckedCast(communicator().getDefaultRouter()); + _router = RouterPrxHelper.uncheckedCast(communicator().getDefaultRouter()); if(_router == null) { Ice.Util.getProcessLogger().error(iceAppName + ": no Glacier2 router configured"); @@ -294,7 +294,7 @@ public abstract class Application : Ice.Application { Ice.Connection connection = _router.ice_getCachedConnection(); Debug.Assert(connection != null); - connection.setACM((int)acmTimeout, Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways); + connection.setACM(acmTimeout, Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways); connection.setCloseCallback(_ => sessionDestroyed()); } _category = _router.getCategoryForClient(); @@ -342,7 +342,7 @@ public abstract class Application : Ice.Application Ice.Util.getProcessLogger().error(ex.ToString()); status = 1; } - catch(System.Exception ex) + catch(Exception ex) { Ice.Util.getProcessLogger().error("unknown exception:\n" + ex.ToString()); status = 1; @@ -392,13 +392,13 @@ public abstract class Application : Ice.Application // Expected if another thread invoked on an object from the session concurrently. // } - catch(Glacier2.SessionNotExistException) + catch(SessionNotExistException) { // // This can also occur. // } - catch(System.Exception ex) + catch(Exception ex) { // // Not expected. @@ -420,7 +420,7 @@ public abstract class Application : Ice.Application Ice.Util.getProcessLogger().error(ex.ToString()); status = 1; } - catch(System.Exception ex) + catch(Exception ex) { Ice.Util.getProcessLogger().error("unknown exception:\n" + ex.ToString()); status = 1; @@ -443,8 +443,8 @@ public abstract class Application : Ice.Application } private static Ice.ObjectAdapter _adapter; - private static Glacier2.RouterPrx _router; - private static Glacier2.SessionPrx _session; + private static RouterPrx _router; + private static SessionPrx _session; private static bool _createdSession = false; private static string _category; } diff --git a/csharp/src/Glacier2/SessionFactoryHelper.cs b/csharp/src/Glacier2/SessionFactoryHelper.cs index 28832b36b5b..9545b4ce3b7 100644 --- a/csharp/src/Glacier2/SessionFactoryHelper.cs +++ b/csharp/src/Glacier2/SessionFactoryHelper.cs @@ -153,7 +153,7 @@ public class SessionFactoryHelper /// </summary> /// <param name="protocol">The protocol.</param> public void - setProtocol(String protocol) + setProtocol(string protocol) { lock(this) { @@ -177,7 +177,7 @@ public class SessionFactoryHelper /// Returns the protocol that will be used by the session factory to establish the connection. /// </summary> /// <returns>The protocol.</returns> - public String + public string getProtocol() { lock(this) diff --git a/csharp/src/Glacier2/SessionHelper.cs b/csharp/src/Glacier2/SessionHelper.cs index e18531d8008..d65b07ebb7e 100644 --- a/csharp/src/Glacier2/SessionHelper.cs +++ b/csharp/src/Glacier2/SessionHelper.cs @@ -310,7 +310,7 @@ public class SessionHelper { _callback.connected(this); } - catch(Glacier2.SessionNotExistException) + catch(SessionNotExistException) { destroy(); } @@ -320,7 +320,7 @@ public class SessionHelper private void destroyInternal() { - Glacier2.RouterPrx router; + RouterPrx router; Ice.Communicator communicator; lock(this) { @@ -393,7 +393,7 @@ public class SessionHelper } } - delegate Glacier2.SessionPrx ConnectStrategy(Glacier2.RouterPrx router); + delegate SessionPrx ConnectStrategy(RouterPrx router); private void connectImpl(ConnectStrategy factory) @@ -453,8 +453,8 @@ public class SessionHelper _callback.createdCommunicator(this); }); - Glacier2.RouterPrx routerPrx = Glacier2.RouterPrxHelper.uncheckedCast(_communicator.getDefaultRouter()); - Glacier2.SessionPrx session = factory(routerPrx); + RouterPrx routerPrx = RouterPrxHelper.uncheckedCast(_communicator.getDefaultRouter()); + SessionPrx session = factory(routerPrx); connected(routerPrx, session); } catch(Exception ex) @@ -474,13 +474,8 @@ public class SessionHelper })).Start(); } -#if COMPACT private void - dispatchCallback(Ice.VoidAction callback, Ice.Connection conn) -#else - private void - dispatchCallback(System.Action callback, Ice.Connection conn) -#endif + dispatchCallback(Action callback, Ice.Connection conn) { if(_initData.dispatcher != null) { @@ -492,13 +487,8 @@ public class SessionHelper } } -#if COMPACT - private void - dispatchCallbackAndWait(Ice.VoidAction callback) -#else private void - dispatchCallbackAndWait(System.Action callback) -#endif + dispatchCallbackAndWait(Action callback) { if(_initData.dispatcher != null) { @@ -519,8 +509,8 @@ public class SessionHelper private readonly Ice.InitializationData _initData; private Ice.Communicator _communicator; private Ice.ObjectAdapter _adapter; - private Glacier2.RouterPrx _router; - private Glacier2.SessionPrx _session; + private RouterPrx _router; + private SessionPrx _session; private bool _connected = false; private string _category; private string _finderStr; diff --git a/csharp/src/Ice/Application.cs b/csharp/src/Ice/Application.cs index 412d8efec4d..bcf965fbd68 100644 --- a/csharp/src/Ice/Application.cs +++ b/csharp/src/Ice/Application.cs @@ -78,19 +78,13 @@ namespace Ice } /// <summary> - /// Initializes an instance that calls Communicator.shutdown if a signal is received. - /// </summary> - public Application() - { - } - - /// <summary> /// Initializes an instance that handles signals according to the signal policy. + /// If not signal policy is provided the default SinalPolicy.NoSignalHandling + /// will be used, which calls Communicator.shutdown if a signal is received. /// </summary> /// <param name="signalPolicy">Determines how to respond to signals.</param> - public Application(SignalPolicy signalPolicy) + public Application(SignalPolicy signalPolicy = SignalPolicy.NoSignalHandling) { - iceSignalPolicy = signalPolicy; } /// <summary> diff --git a/csharp/src/Ice/Arrays.cs b/csharp/src/Ice/Arrays.cs index f1544780160..17bd0345196 100644 --- a/csharp/src/Ice/Arrays.cs +++ b/csharp/src/Ice/Arrays.cs @@ -12,7 +12,6 @@ using System.Collections; namespace IceUtilInternal { - public sealed class Arrays { public static bool Equals(object[] arr1, object[] arr2) diff --git a/csharp/src/Ice/AssemblyUtil.cs b/csharp/src/Ice/AssemblyUtil.cs index 58b14133fd4..f3de5b4555b 100644 --- a/csharp/src/Ice/AssemblyUtil.cs +++ b/csharp/src/Ice/AssemblyUtil.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System; using System.Collections; using System.Collections.Generic; @@ -139,7 +138,7 @@ namespace IceInternal _loadedAssemblies[ra.FullName] = ra; loadReferencedAssemblies(ra); } - catch(System.Exception) + catch(Exception) { // Ignore assemblies that cannot be loaded. } diff --git a/csharp/src/Ice/AsyncIOThread.cs b/csharp/src/Ice/AsyncIOThread.cs index 0d9db92604f..b93e1548a94 100644 --- a/csharp/src/Ice/AsyncIOThread.cs +++ b/csharp/src/Ice/AsyncIOThread.cs @@ -21,16 +21,8 @@ namespace IceInternal _thread = new HelperThread(this); updateObserver(); - if(instance.initializationData().properties.getProperty("Ice.ThreadPriority").Length > 0) - { - ThreadPriority priority = IceInternal.Util.stringToThreadPriority( - instance.initializationData().properties.getProperty("Ice.ThreadPriority")); - _thread.Start(priority); - } - else - { - _thread.Start(ThreadPriority.Normal); - } + _thread.Start(Util.stringToThreadPriority( + instance.initializationData().properties.getProperty("Ice.ThreadPriority"))); } public void @@ -59,7 +51,7 @@ namespace IceInternal { Debug.Assert(!_destroyed); _queue.AddLast(callback); - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); } } @@ -69,7 +61,7 @@ namespace IceInternal { Debug.Assert(!_destroyed); _destroyed = true; - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); } } @@ -103,7 +95,7 @@ namespace IceInternal while(!_destroyed && _queue.Count == 0) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } LinkedList<ThreadPoolWorkItem> tmp = queue; @@ -140,7 +132,7 @@ namespace IceInternal if(_observer != null) { - _observer.detach(); + _observer.detach(); } } diff --git a/csharp/src/Ice/AsyncResult.cs b/csharp/src/Ice/AsyncResult.cs index 95729efe018..3ba9ebf65b7 100644 --- a/csharp/src/Ice/AsyncResult.cs +++ b/csharp/src/Ice/AsyncResult.cs @@ -47,9 +47,9 @@ namespace Ice { void cancel(); - Ice.Communicator getCommunicator(); + Communicator getCommunicator(); - Ice.Connection getConnection(); + Connection getConnection(); ObjectPrx getProxy(); @@ -66,17 +66,17 @@ namespace Ice string getOperation(); - AsyncResult whenSent(Ice.AsyncCallback cb); - AsyncResult whenSent(Ice.SentCallback cb); - AsyncResult whenCompleted(Ice.ExceptionCallback excb); + AsyncResult whenSent(AsyncCallback cb); + AsyncResult whenSent(SentCallback cb); + AsyncResult whenCompleted(ExceptionCallback excb); } public interface AsyncResult<T> : AsyncResult { - AsyncResult<T> whenCompleted(T cb, Ice.ExceptionCallback excb); + AsyncResult<T> whenCompleted(T cb, ExceptionCallback excb); - new AsyncResult<T> whenCompleted(Ice.ExceptionCallback excb); - new AsyncResult<T> whenSent(Ice.SentCallback cb); + new AsyncResult<T> whenCompleted(ExceptionCallback excb); + new AsyncResult<T> whenSent(SentCallback cb); } } diff --git a/csharp/src/Ice/Base64.cs b/csharp/src/Ice/Base64.cs deleted file mode 100644 index 37838f58e1e..00000000000 --- a/csharp/src/Ice/Base64.cs +++ /dev/null @@ -1,276 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -namespace IceUtilInternal -{ - -public class Base64 -{ - -public static string -encode(byte[] plainSeq) -{ - if(plainSeq == null || plainSeq.Length == 0) - { - return ""; - } - - System.Text.StringBuilder retval = new System.Text.StringBuilder(); - int base64Bytes = (((plainSeq.Length * 4) / 3) + 1); - int newlineBytes = (((base64Bytes * 2) / 76) + 1); - int totalBytes = base64Bytes + newlineBytes; - - retval.Capacity = totalBytes; - - byte by1; - byte by2; - byte by3; - byte by4; - byte by5; - byte by6; - byte by7; - - for(int i = 0; i < plainSeq.Length; i += 3) - { - by1 = plainSeq[i]; - by2 = 0; - by3 = 0; - - if((i + 1) < plainSeq.Length) - { - by2 = plainSeq[i+1]; - } - - if((i + 2) < plainSeq.Length) - { - by3 = plainSeq[i+2]; - } - - by4 = (byte)(by1 >> 2); - by5 = (byte)(((by1 & 0x3) << 4) | (by2 >> 4)); - by6 = (byte)(((by2 & 0xf) << 2) | (by3 >> 6)); - by7 = (byte)(by3 & 0x3f); - - retval.Append(encode(by4)); - retval.Append(encode(by5)); - - if((i + 1) < plainSeq.Length) - { - retval.Append(encode(by6)); - } - else - { - retval.Append('='); - } - - if((i + 2) < plainSeq.Length) - { - retval.Append(encode(by7)); - } - else - { - retval.Append('='); - } - } - - System.Text.StringBuilder outString = new System.Text.StringBuilder(); - outString.Capacity = totalBytes; - int iter = 0; - - while((retval.Length - iter) > 76) - { - outString.Append(retval.ToString().Substring(iter, 76)); - outString.Append("\r\n"); - iter += 76; - } - - outString.Append(retval.ToString().Substring(iter)); - - return outString.ToString(); -} - -public static byte[] -decode(string str) -{ - System.Text.StringBuilder newStr = new System.Text.StringBuilder(); - - newStr.Capacity = str.Length; - - for(int j = 0; j < str.Length; j++) - { - char c = str[j]; - if(isBase64(c)) - { - newStr.Append(c); - } - } - - if(newStr.Length == 0) - { - return null; - } - - // Note: This is how we were previously computing the size of the return - // sequence. The method below is more efficient (and correct). - // size_t lines = str.size() / 78; - // size_t totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4); - - // Figure out how long the final sequence is going to be. - int totalBytes = (newStr.Length * 3 / 4) + 1; - - IceInternal.ByteBuffer retval = IceInternal.ByteBuffer.allocate(totalBytes); - - byte by1; - byte by2; - byte by3; - byte by4; - - char c1, c2, c3, c4; - - int pos = 0; - for(int i = 0; i < newStr.Length; i += 4) - { - c1 = 'A'; - c2 = 'A'; - c3 = 'A'; - c4 = 'A'; - - c1 = newStr[i]; - - if((i + 1) < newStr.Length) - { - c2 = newStr[i + 1]; - } - - if((i + 2) < newStr.Length) - { - c3 = newStr[i + 2]; - } - - if((i + 3) < newStr.Length) - { - c4 = newStr[i + 3]; - } - - by1 = decode(c1); - by2 = decode(c2); - by3 = decode(c3); - by4 = decode(c4); - - retval.put((byte)((by1 << 2) | (by2 >> 4))); - ++pos; - - if(c3 != '=') - { - retval.put((byte)(((by2 & 0xf) << 4) | (by3 >> 2))); - ++pos; - } - - if(c4 != '=') - { - retval.put((byte)(((by3 & 0x3) << 6) | by4)); - ++pos; - } - } - - return retval.toArray(0, pos); -} - -public static bool -isBase64(char c) -{ - if(c >= 'A' && c <= 'Z') - { - return true; - } - - if(c >= 'a' && c <= 'z') - { - return true; - } - - if(c >= '0' && c <= '9') - { - return true; - } - - if(c == '+') - { - return true; - } - - if(c == '/') - { - return true; - } - - if(c == '=') - { - return true; - } - - return false; -} - -private static char -encode(byte uc) -{ - if(uc < 26) - { - return (char)('A' + uc); - } - - if(uc < 52) - { - return (char)('a' + (uc - 26)); - } - - if(uc < 62) - { - return (char)('0' + (uc - 52)); - } - - if(uc == 62) - { - return '+'; - } - - return '/'; -} - -private static byte -decode(char c) -{ - if(c >= 'A' && c <= 'Z') - { - return (byte)(c - 'A'); - } - - if(c >= 'a' && c <= 'z') - { - return (byte)(c - 'a' + 26); - } - - if(c >= '0' && c <= '9') - { - return (byte)(c - '0' + 52); - } - - if(c == '+') - { - return 62; - } - - return 63; -} - -} - -} - diff --git a/csharp/src/Ice/BatchRequestInterceptor.cs b/csharp/src/Ice/BatchRequestInterceptor.cs index 5eb12d7f59d..cef30f1666d 100644 --- a/csharp/src/Ice/BatchRequestInterceptor.cs +++ b/csharp/src/Ice/BatchRequestInterceptor.cs @@ -32,7 +32,7 @@ namespace Ice /// The proxy used to invoke the batch request. /// </summary> /// <returns>The request proxy.</returns> - Ice.ObjectPrx getProxy(); + ObjectPrx getProxy(); } /// <summary> @@ -52,6 +52,6 @@ namespace Ice /// <param name="request">The batch request.</param> /// <param name="queueBatchRequestCount">The number of batch request queued.</param> /// <param name="queueBatchRequestSize">The size of the queued batch requests.</param> - void enqueue(Ice.BatchRequest request, int queueBatchRequestCount, int queueBatchRequestSize); + void enqueue(BatchRequest request, int queueBatchRequestCount, int queueBatchRequestSize); } } diff --git a/csharp/src/Ice/Collections.cs b/csharp/src/Ice/Collections.cs index dd87ad517d4..0506a3897d9 100644 --- a/csharp/src/Ice/Collections.cs +++ b/csharp/src/Ice/Collections.cs @@ -17,7 +17,7 @@ namespace IceUtilInternal { public static bool SequenceEquals(ICollection seq1, ICollection seq2) { - if(object.ReferenceEquals(seq1, seq2)) + if(ReferenceEquals(seq1, seq2)) { return true; } @@ -55,7 +55,7 @@ namespace IceUtilInternal public static bool SequenceEquals(IEnumerable seq1, IEnumerable seq2) { - if(object.ReferenceEquals(seq1, seq2)) + if(ReferenceEquals(seq1, seq2)) { return true; } @@ -107,7 +107,7 @@ namespace IceUtilInternal public static bool DictionaryEquals(IDictionary d1, IDictionary d2) { - if(object.ReferenceEquals(d1, d2)) + if(ReferenceEquals(d1, d2)) { return true; } diff --git a/csharp/src/Ice/CollocatedRequestHandler.cs b/csharp/src/Ice/CollocatedRequestHandler.cs index 04a4ba34185..2dc31a14b49 100644 --- a/csharp/src/Ice/CollocatedRequestHandler.cs +++ b/csharp/src/Ice/CollocatedRequestHandler.cs @@ -190,7 +190,7 @@ namespace IceInternal _sendAsyncRequests.Add(outAsync, requestId); } } - catch(System.Exception) + catch(Exception) { _adapter.decDirectCount(); throw; @@ -222,7 +222,7 @@ namespace IceInternal } else // Optimization: directly call invokeAll if there's no dispatcher. { - if (sentAsync(outAsync)) + if(sentAsync(outAsync)) { invokeAll(outAsync.getOs(), requestId, batchRequestNum); } diff --git a/csharp/src/Ice/CommunicatorI.cs b/csharp/src/Ice/CommunicatorI.cs index 29a1196573b..73a9d0b0dbb 100644 --- a/csharp/src/Ice/CommunicatorI.cs +++ b/csharp/src/Ice/CommunicatorI.cs @@ -38,34 +38,34 @@ namespace Ice return _instance.objectAdapterFactory().isShutdown(); } - public Ice.ObjectPrx stringToProxy(string s) + public ObjectPrx stringToProxy(string s) { return _instance.proxyFactory().stringToProxy(s); } - public string proxyToString(Ice.ObjectPrx proxy) + public string proxyToString(ObjectPrx proxy) { return _instance.proxyFactory().proxyToString(proxy); } - public Ice.ObjectPrx propertyToProxy(string s) + public ObjectPrx propertyToProxy(string s) { return _instance.proxyFactory().propertyToProxy(s); } - public Dictionary<string, string> proxyToProperty(Ice.ObjectPrx proxy, string prefix) + public Dictionary<string, string> proxyToProperty(ObjectPrx proxy, string prefix) { return _instance.proxyFactory().proxyToProperty(proxy, prefix); } - public Ice.Identity stringToIdentity(string s) + public Identity stringToIdentity(string s) { - return Ice.Util.stringToIdentity(s); + return Util.stringToIdentity(s); } - public string identityToString(Ice.Identity ident) + public string identityToString(Identity ident) { - return Ice.Util.identityToString(ident, _instance.toStringMode()); + return Util.identityToString(ident, _instance.toStringMode()); } public ObjectAdapter createObjectAdapter(string name) @@ -77,7 +77,7 @@ namespace Ice { if(name.Length == 0) { - name = System.Guid.NewGuid().ToString(); + name = Guid.NewGuid().ToString(); } getProperties().setProperty(name + ".Endpoints", endpoints); @@ -88,7 +88,7 @@ namespace Ice { if(name.Length == 0) { - name = System.Guid.NewGuid().ToString(); + name = Guid.NewGuid().ToString(); } // @@ -128,7 +128,7 @@ namespace Ice return _instance.initializationData().logger; } - public Ice.Instrumentation.CommunicatorObserver getObserver() + public Instrumentation.CommunicatorObserver getObserver() { return _instance.initializationData().observer; } @@ -186,24 +186,24 @@ namespace Ice private class CommunicatorFlushBatchCompletionCallback : AsyncResultCompletionCallback { - public CommunicatorFlushBatchCompletionCallback(Ice.Communicator communicator, + public CommunicatorFlushBatchCompletionCallback(Communicator communicator, Instance instance, string op, object cookie, - Ice.AsyncCallback callback) + AsyncCallback callback) : base(communicator, instance, op, cookie, callback) { } - protected override Ice.AsyncCallback getCompletedCallback() + protected override AsyncCallback getCompletedCallback() { - return (Ice.AsyncResult result) => + return (AsyncResult result) => { try { result.throwLocalException(); } - catch(Ice.Exception ex) + catch(Exception ex) { if(exceptionCallback_ != null) { @@ -244,22 +244,22 @@ namespace Ice return _instance.getAdmin(); } - public void addAdminFacet(Ice.Object servant, string facet) + public void addAdminFacet(Object servant, string facet) { _instance.addAdminFacet(servant, facet); } - public Ice.Object removeAdminFacet(string facet) + public Object removeAdminFacet(string facet) { return _instance.removeAdminFacet(facet); } - public Ice.Object findAdminFacet(string facet) + public Object findAdminFacet(string facet) { return _instance.findAdminFacet(facet); } - public Dictionary<string, Ice.Object> findAllAdminFacets() + public Dictionary<string, Object> findAllAdminFacets() { return _instance.findAllAdminFacets(); } @@ -271,7 +271,7 @@ namespace Ice internal CommunicatorI(InitializationData initData) { - _instance = new IceInternal.Instance(this, initData); + _instance = new Instance(this, initData); } /* @@ -312,11 +312,11 @@ namespace Ice // // For use by Util.getInstance() // - internal IceInternal.Instance getInstance() + internal Instance getInstance() { return _instance; } - private IceInternal.Instance _instance; + private Instance _instance; } } diff --git a/csharp/src/Ice/Compare.cs b/csharp/src/Ice/Compare.cs index 4c1f5394054..bed9f248bb9 100644 --- a/csharp/src/Ice/Compare.cs +++ b/csharp/src/Ice/Compare.cs @@ -7,9 +7,6 @@ // // ********************************************************************** -using System; -using System.Reflection; - namespace Ice { public class CollectionComparer @@ -25,7 +22,7 @@ namespace Ice System.Collections.ICollection c2, out bool result) { - if(object.ReferenceEquals(c1, c2)) + if(ReferenceEquals(c1, c2)) { result = true; return true; // Equal references means the collections are equal. @@ -138,7 +135,7 @@ namespace Ice { try { - if(object.ReferenceEquals(c1, c2)) + if(ReferenceEquals(c1, c2)) { return true; // Equal references means the collections are equal. } diff --git a/csharp/src/Ice/ConnectRequestHandler.cs b/csharp/src/Ice/ConnectRequestHandler.cs index 76fadf29fd8..370d855ded2 100644 --- a/csharp/src/Ice/ConnectRequestHandler.cs +++ b/csharp/src/Ice/ConnectRequestHandler.cs @@ -7,12 +7,9 @@ // // ********************************************************************** -using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Threading; -using Ice.Instrumentation; namespace IceInternal { @@ -202,7 +199,7 @@ namespace IceInternal { while(_flushing && _exception == null) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } if(_exception != null) diff --git a/csharp/src/Ice/ConnectionFactory.cs b/csharp/src/Ice/ConnectionFactory.cs index ef41ce0143a..b7695e45f0b 100644 --- a/csharp/src/Ice/ConnectionFactory.cs +++ b/csharp/src/Ice/ConnectionFactory.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System; using System.Collections.Generic; using System.Diagnostics; @@ -21,7 +20,7 @@ namespace IceInternal Add(K key, V value) { ICollection<V> list = null; - if(!this.TryGetValue(key, out list)) + if(!TryGetValue(key, out list)) { list = new List<V>(); Add(key, list); @@ -690,7 +689,7 @@ namespace IceInternal TraceLevels traceLevels = _instance.traceLevels(); if(traceLevels.retry >= 2) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("connection to endpoint failed"); if(ex is Ice.CommunicatorDestroyedException) { @@ -770,7 +769,7 @@ namespace IceInternal TraceLevels traceLevels = _instance.traceLevels(); if(traceLevels.retry >= 2) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("couldn't resolve endpoint host"); if(ex is Ice.CommunicatorDestroyedException) { @@ -1298,7 +1297,7 @@ namespace IceInternal } finally { - System.Environment.FailFast(s); + Environment.FailFast(s); } return false; } @@ -1322,7 +1321,7 @@ namespace IceInternal } finally { - System.Environment.FailFast(s); + Environment.FailFast(s); } return false; } @@ -1400,7 +1399,7 @@ namespace IceInternal } finally { - System.Environment.FailFast(s); + Environment.FailFast(s); } } @@ -1551,7 +1550,7 @@ namespace IceInternal createAcceptor(); } } - catch(System.Exception ex) + catch(Exception ex) { // // Clean up. diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 5988800b523..8943a4d48bc 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -40,7 +40,7 @@ namespace Ice _connection.timedOut(); } - private Ice.ConnectionI _connection; + private ConnectionI _connection; } public void start(StartCallback callback) @@ -102,7 +102,7 @@ namespace Ice // while(_state <= StateNotValidated) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } if(_state >= StateClosing) @@ -200,7 +200,7 @@ namespace Ice // while(_asyncRequests.Count != 0) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } setState(StateClosing, new CloseConnectionException()); @@ -223,7 +223,7 @@ namespace Ice // threads operating in this connection object, connection // destruction is considered as not yet finished. // - if(!System.Threading.Monitor.TryEnter(this)) + if(!Monitor.TryEnter(this)) { return false; } @@ -240,7 +240,7 @@ namespace Ice } finally { - System.Threading.Monitor.Exit(this); + Monitor.Exit(this); } } @@ -262,7 +262,7 @@ namespace Ice { while(_state < StateHolding || _dispatchCount > 0) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } } } @@ -279,7 +279,7 @@ namespace Ice // while(_state < StateFinished || _dispatchCount > 0) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } Debug.Assert(_state == StateFinished); @@ -448,7 +448,7 @@ namespace Ice OutgoingMessage message = new OutgoingMessage(og, os, compress, requestId); status = sendMessage(message); } - catch(Ice.LocalException ex) + catch(LocalException ex) { setState(StateClosed, ex); Debug.Assert(_exception != null); @@ -478,31 +478,31 @@ namespace Ice private class ConnectionFlushBatchCompletionCallback : AsyncResultCompletionCallback { - public ConnectionFlushBatchCompletionCallback(Ice.Connection connection, - Ice.Communicator communicator, + public ConnectionFlushBatchCompletionCallback(Connection connection, + Communicator communicator, Instance instance, string op, object cookie, - Ice.AsyncCallback callback) + AsyncCallback callback) : base(communicator, instance, op, cookie, callback) { _connection = connection; } - public override Ice.Connection getConnection() + public override Connection getConnection() { return _connection; } - protected override Ice.AsyncCallback getCompletedCallback() + protected override AsyncCallback getCompletedCallback() { - return (Ice.AsyncResult result) => + return (AsyncResult result) => { try { result.throwLocalException(); } - catch(Ice.Exception ex) + catch(Exception ex) { if(exceptionCallback_ != null) { @@ -512,7 +512,7 @@ namespace Ice }; } - private Ice.Connection _connection; + private Connection _connection; } public Task flushBatchRequestsAsync(IProgress<bool> progress = null, @@ -604,7 +604,7 @@ namespace Ice } else if(_state == StateActive && _acmLastActivity == -1) { - _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + _acmLastActivity = Time.currentMonotonicTimeMillis(); } if(_state == StateActive) @@ -622,7 +622,7 @@ namespace Ice } } - public void asyncRequestCanceled(IceInternal.OutgoingAsyncBase outAsync, Ice.LocalException ex) + public void asyncRequestCanceled(OutgoingAsyncBase outAsync, LocalException ex) { // // NOTE: This isn't called from a thread pool thread. @@ -644,7 +644,7 @@ namespace Ice _asyncRequests.Remove(o.requestId); } - if(ex is Ice.ConnectionTimeoutException) + if(ex is ConnectionTimeoutException) { setState(StateClosed, ex); } @@ -671,13 +671,13 @@ namespace Ice return; } - if(outAsync is IceInternal.OutgoingAsync) + if(outAsync is OutgoingAsync) { - foreach(KeyValuePair<int, IceInternal.OutgoingAsyncBase> kvp in _asyncRequests) + foreach(KeyValuePair<int, OutgoingAsyncBase> kvp in _asyncRequests) { if(kvp.Value == outAsync) { - if(ex is Ice.ConnectionTimeoutException) + if(ex is ConnectionTimeoutException) { setState(StateClosed, ex); } @@ -710,7 +710,7 @@ namespace Ice { reap(); } - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } if(_state >= StateClosed) @@ -747,7 +747,7 @@ namespace Ice { reap(); } - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } if(_state >= StateClosed) @@ -768,7 +768,7 @@ namespace Ice } } - public bool systemException(int requestId, Ice.SystemException ex, bool amd) + public bool systemException(int requestId, SystemException ex, bool amd) { return false; // System exceptions aren't marshalled. } @@ -794,18 +794,18 @@ namespace Ice { reap(); } - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } } } } - public IceInternal.EndpointI endpoint() + public EndpointI endpoint() { return _endpoint; // No mutex protection necessary, _endpoint is immutable. } - public IceInternal.Connector connector() + public Connector connector() { return _connector; // No mutex protection necessary, _endpoint is immutable. } @@ -875,7 +875,7 @@ namespace Ice try { - if((operation & IceInternal.SocketOperation.Write) != 0) + if((operation & SocketOperation.Write) != 0) { if(_observer != null) { @@ -890,7 +890,7 @@ namespace Ice _sendStreams.First.Value.isSent = true; } } - else if((operation & IceInternal.SocketOperation.Read) != 0) + else if((operation & SocketOperation.Read) != 0) { if(_observer != null && !_readHeader) { @@ -900,7 +900,7 @@ namespace Ice completedSynchronously = _transceiver.startRead(_readStream.getBuffer(), cb, this); } } - catch(Ice.LocalException ex) + catch(LocalException ex) { setState(StateClosed, ex); return false; @@ -912,7 +912,7 @@ namespace Ice { try { - if((operation & IceInternal.SocketOperation.Write) != 0) + if((operation & SocketOperation.Write) != 0) { IceInternal.Buffer buf = _writeStream.getBuffer(); int start = buf.b.position(); @@ -938,7 +938,7 @@ namespace Ice observerFinishWrite(_writeStream.getBuffer()); } } - else if((operation & IceInternal.SocketOperation.Read) != 0) + else if((operation & SocketOperation.Read) != 0) { IceInternal.Buffer buf = _readStream.getBuffer(); int start = buf.b.position(); @@ -969,21 +969,21 @@ namespace Ice } } } - catch(Ice.LocalException ex) + catch(LocalException ex) { setState(StateClosed, ex); } return _state < StateClosed; } - public override void message(ref IceInternal.ThreadPoolCurrent current) + public override void message(ref ThreadPoolCurrent current) { StartCallback startCB = null; Queue<OutgoingMessage> sentCBs = null; MessageInfo info = new MessageInfo(); int dispatchCount = 0; - IceInternal.ThreadPoolMessage msg = new IceInternal.ThreadPoolMessage(this); + ThreadPoolMessage msg = new ThreadPoolMessage(this); try { lock(this) @@ -1003,22 +1003,22 @@ namespace Ice { unscheduleTimeout(current.operation); - int writeOp = IceInternal.SocketOperation.None; - int readOp = IceInternal.SocketOperation.None; - if((readyOp & IceInternal.SocketOperation.Write) != 0) + int writeOp = SocketOperation.None; + int readOp = SocketOperation.None; + if((readyOp & SocketOperation.Write) != 0) { if(_observer != null) { observerStartWrite(_writeStream.getBuffer()); } writeOp = write(_writeStream.getBuffer()); - if(_observer != null && (writeOp & IceInternal.SocketOperation.Write) == 0) + if(_observer != null && (writeOp & SocketOperation.Write) == 0) { observerFinishWrite(_writeStream.getBuffer()); } } - while((readyOp & IceInternal.SocketOperation.Read) != 0) + while((readyOp & SocketOperation.Read) != 0) { IceInternal.Buffer buf = _readStream.getBuffer(); @@ -1028,7 +1028,7 @@ namespace Ice } readOp = read(buf); - if((readOp & IceInternal.SocketOperation.Read) != 0) + if((readOp & SocketOperation.Read) != 0) { break; } @@ -1044,16 +1044,16 @@ namespace Ice if(_observer != null) { - _observer.receivedBytes(IceInternal.Protocol.headerSize); + _observer.receivedBytes(Protocol.headerSize); } int pos = _readStream.pos(); - if(pos < IceInternal.Protocol.headerSize) + if(pos < Protocol.headerSize) { // // This situation is possible for small UDP packets. // - throw new Ice.IllegalMessageSizeException(); + throw new IllegalMessageSizeException(); } _readStream.pos(0); @@ -1062,31 +1062,31 @@ namespace Ice m[1] = _readStream.readByte(); m[2] = _readStream.readByte(); m[3] = _readStream.readByte(); - if(m[0] != IceInternal.Protocol.magic[0] || m[1] != IceInternal.Protocol.magic[1] || - m[2] != IceInternal.Protocol.magic[2] || m[3] != IceInternal.Protocol.magic[3]) + if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] || + m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) { - Ice.BadMagicException ex = new Ice.BadMagicException(); + BadMagicException ex = new BadMagicException(); ex.badMagic = m; throw ex; } ProtocolVersion pv = new ProtocolVersion(); pv.ice_readMembers(_readStream); - IceInternal.Protocol.checkSupportedProtocol(pv); + Protocol.checkSupportedProtocol(pv); EncodingVersion ev = new EncodingVersion(); ev.ice_readMembers(_readStream); - IceInternal.Protocol.checkSupportedProtocolEncoding(ev); + Protocol.checkSupportedProtocolEncoding(ev); _readStream.readByte(); // messageType _readStream.readByte(); // compress int size = _readStream.readInt(); - if(size < IceInternal.Protocol.headerSize) + if(size < Protocol.headerSize) { - throw new Ice.IllegalMessageSizeException(); + throw new IllegalMessageSizeException(); } if(size > _messageSizeMax) { - IceInternal.Ex.throwMemoryLimitException(size, _messageSizeMax); + Ex.throwMemoryLimitException(size, _messageSizeMax); } if(size > _readStream.size()) { @@ -1099,7 +1099,7 @@ namespace Ice { if(_endpoint.datagram()) { - throw new Ice.DatagramLimitException(); // The message was truncated. + throw new DatagramLimitException(); // The message was truncated. } continue; } @@ -1157,13 +1157,13 @@ namespace Ice // We parse messages first, if we receive a close // connection message we won't send more messages. // - if((readyOp & IceInternal.SocketOperation.Read) != 0) + if((readyOp & SocketOperation.Read) != 0) { newOp |= parseMessage(ref info); dispatchCount += info.messageDispatchCount; } - if((readyOp & IceInternal.SocketOperation.Write) != 0) + if((readyOp & SocketOperation.Write) != 0) { newOp |= sendNextMessage(out sentCBs); if(sentCBs != null) @@ -1181,7 +1181,7 @@ namespace Ice if(_acmLastActivity > -1) { - _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + _acmLastActivity = Time.currentMonotonicTimeMillis(); } if(dispatchCount == 0) @@ -1197,9 +1197,9 @@ namespace Ice { if(_warnUdp) { - _logger.warning("maximum datagram size of " + _readStream.pos() + " exceeded"); + _logger.warning(string.Format("maximum datagram size of {0} exceeded", _readStream.pos())); } - _readStream.resize(IceInternal.Protocol.headerSize); + _readStream.resize(Protocol.headerSize); _readStream.pos(0); _readHeader = true; return; @@ -1215,10 +1215,9 @@ namespace Ice { if(_warn) { - String s = "datagram connection exception:\n" + ex + '\n' + _desc; - _logger.warning(s); + _logger.warning(string.Format("datagram connection exception:\n{0}\n{1}", ex, _desc)); } - _readStream.resize(IceInternal.Protocol.headerSize); + _readStream.resize(Protocol.headerSize); _readStream.pos(0); _readHeader = true; } @@ -1229,7 +1228,7 @@ namespace Ice return; } - IceInternal.ThreadPoolCurrent c = current; + ThreadPoolCurrent c = current; _threadPool.dispatch(() => { dispatch(startCB, sentCBs, info); @@ -1271,7 +1270,7 @@ namespace Ice } if(m.receivedReply) { - IceInternal.OutgoingAsync outAsync = (IceInternal.OutgoingAsync)m.outAsync; + OutgoingAsync outAsync = (OutgoingAsync)m.outAsync; if(outAsync.response()) { outAsync.invokeResponse(); @@ -1351,18 +1350,18 @@ namespace Ice { reap(); } - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } } } } - public override void finished(ref IceInternal.ThreadPoolCurrent current) + public override void finished(ref ThreadPoolCurrent current) { lock(this) { Debug.Assert(_state == StateClosed); - unscheduleTimeout(IceInternal.SocketOperation.Read | IceInternal.SocketOperation.Write); + unscheduleTimeout(SocketOperation.Read | SocketOperation.Write); } // @@ -1459,7 +1458,7 @@ namespace Ice } if(message.receivedReply) { - IceInternal.OutgoingAsync outAsync = (IceInternal.OutgoingAsync)message.outAsync; + OutgoingAsync outAsync = (OutgoingAsync)message.outAsync; if(outAsync.response()) { outAsync.invokeResponse(); @@ -1480,7 +1479,7 @@ namespace Ice _sendStreams.Clear(); // Must be cleared before _requests because of Outgoing* references in OutgoingMessage } - foreach(IceInternal.OutgoingAsyncBase o in _asyncRequests.Values) + foreach(OutgoingAsyncBase o in _asyncRequests.Values) { if(o.exception(_exception)) { @@ -1605,9 +1604,8 @@ namespace Ice _compressionSupported = IceInternal.BZip2.supported(); } - internal ConnectionI(Communicator communicator, IceInternal.Instance instance, - IceInternal.ACMMonitor monitor, IceInternal.Transceiver transceiver, - IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapterI adapter) + internal ConnectionI(Communicator communicator, Instance instance, ACMMonitor monitor, Transceiver transceiver, + Connector connector, EndpointI endpoint, ObjectAdapterI adapter) { _communicator = communicator; _instance = instance; @@ -1631,7 +1629,7 @@ namespace Ice _cacheBuffers = instance.cacheMessageBuffers() > 0; if(_monitor != null && _monitor.getACM().timeout > 0) { - _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + _acmLastActivity = Time.currentMonotonicTimeMillis(); } else { @@ -1639,7 +1637,7 @@ namespace Ice } _nextRequestId = 1; _messageSizeMax = adapter != null ? adapter.messageSizeMax() : instance.messageSizeMax(); - _batchRequestQueue = new IceInternal.BatchRequestQueue(instance, _endpoint.datagram()); + _batchRequestQueue = new BatchRequestQueue(instance, _endpoint.datagram()); _readStream = new InputStream(instance, Util.currentProtocolEncoding); _readHeader = false; _readStreamPos = -1; @@ -1798,7 +1796,7 @@ namespace Ice { return; } - _threadPool.register(this, IceInternal.SocketOperation.Read); + _threadPool.register(this, SocketOperation.Read); break; } @@ -1814,7 +1812,7 @@ namespace Ice } if(_state == StateActive) { - _threadPool.unregister(this, IceInternal.SocketOperation.Read); + _threadPool.unregister(this, SocketOperation.Read); } break; } @@ -1854,7 +1852,7 @@ namespace Ice } } } - catch(Ice.LocalException ex) + catch(LocalException ex) { _logger.error("unexpected connection exception:\n" + ex + "\n" + _transceiver.ToString()); } @@ -1871,7 +1869,7 @@ namespace Ice { if(_acmLastActivity > -1) { - _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + _acmLastActivity = Time.currentMonotonicTimeMillis(); } _monitor.add(this); } @@ -1916,7 +1914,7 @@ namespace Ice } _state = state; - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); if(_state == StateClosing && _dispatchCount == 0) { @@ -1948,15 +1946,14 @@ namespace Ice // Before we shut down, we send a close connection message. // OutputStream os = new OutputStream(_instance, Util.currentProtocolEncoding); - os.writeBlob(IceInternal.Protocol.magic); - Ice.Util.currentProtocol.ice_writeMembers(os); - Ice.Util.currentProtocolEncoding.ice_writeMembers(os); - os.writeByte(IceInternal.Protocol.closeConnectionMsg); + os.writeBlob(Protocol.magic); + Util.currentProtocol.ice_writeMembers(os); + Util.currentProtocolEncoding.ice_writeMembers(os); + os.writeByte(Protocol.closeConnectionMsg); os.writeByte(_compressionSupported ? (byte)1 : (byte)0); - os.writeInt(IceInternal.Protocol.headerSize); // Message size. + os.writeInt(Protocol.headerSize); // Message size. - if((sendMessage(new OutgoingMessage(os, false, false)) & - IceInternal.OutgoingAsyncBase.AsyncStatusSent) != 0) + if((sendMessage(new OutgoingMessage(os, false, false)) & OutgoingAsyncBase.AsyncStatusSent) != 0) { setState(StateClosingPending); @@ -1980,17 +1977,17 @@ namespace Ice if(!_endpoint.datagram()) { OutputStream os = new OutputStream(_instance, Util.currentProtocolEncoding); - os.writeBlob(IceInternal.Protocol.magic); - Ice.Util.currentProtocol.ice_writeMembers(os); - Ice.Util.currentProtocolEncoding.ice_writeMembers(os); - os.writeByte(IceInternal.Protocol.validateConnectionMsg); - os.writeByte((byte)0); - os.writeInt(IceInternal.Protocol.headerSize); // Message size. + os.writeBlob(Protocol.magic); + Util.currentProtocol.ice_writeMembers(os); + Util.currentProtocolEncoding.ice_writeMembers(os); + os.writeByte(Protocol.validateConnectionMsg); + os.writeByte(0); + os.writeInt(Protocol.headerSize); // Message size. try { sendMessage(new OutgoingMessage(os, false, false)); } - catch(Ice.LocalException ex) + catch(LocalException ex) { setState(StateClosed, ex); Debug.Assert(_exception != null); @@ -2001,7 +1998,7 @@ namespace Ice private bool initialize(int operation) { int s = _transceiver.initialize(_readStream.getBuffer(), _writeStream.getBuffer(), ref _hasMoreData); - if(s != IceInternal.SocketOperation.None) + if(s != SocketOperation.None) { scheduleTimeout(s); _threadPool.update(this, operation, s); @@ -2026,13 +2023,13 @@ namespace Ice { if(_writeStream.size() == 0) { - _writeStream.writeBlob(IceInternal.Protocol.magic); - Ice.Util.currentProtocol.ice_writeMembers(_writeStream); - Ice.Util.currentProtocolEncoding.ice_writeMembers(_writeStream); - _writeStream.writeByte(IceInternal.Protocol.validateConnectionMsg); - _writeStream.writeByte((byte)0); // Compression status (always zero for validate connection). - _writeStream.writeInt(IceInternal.Protocol.headerSize); // Message size. - IceInternal.TraceUtil.traceSend(_writeStream, _logger, _traceLevels); + _writeStream.writeBlob(Protocol.magic); + Util.currentProtocol.ice_writeMembers(_writeStream); + Util.currentProtocolEncoding.ice_writeMembers(_writeStream); + _writeStream.writeByte(Protocol.validateConnectionMsg); + _writeStream.writeByte(0); // Compression status (always zero for validate connection). + _writeStream.writeInt(Protocol.headerSize); // Message size. + TraceUtil.traceSend(_writeStream, _logger, _traceLevels); _writeStream.prepareWrite(); } @@ -2061,7 +2058,7 @@ namespace Ice { if(_readStream.size() == 0) { - _readStream.resize(IceInternal.Protocol.headerSize); + _readStream.resize(Protocol.headerSize); _readStream.pos(0); } @@ -2086,11 +2083,11 @@ namespace Ice observerFinishRead(_readStream.getBuffer()); } - Debug.Assert(_readStream.pos() == IceInternal.Protocol.headerSize); + Debug.Assert(_readStream.pos() == Protocol.headerSize); _readStream.pos(0); byte[] m = _readStream.readBlob(4); - if(m[0] != IceInternal.Protocol.magic[0] || m[1] != IceInternal.Protocol.magic[1] || - m[2] != IceInternal.Protocol.magic[2] || m[3] != IceInternal.Protocol.magic[3]) + if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] || + m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) { BadMagicException ex = new BadMagicException(); ex.badMagic = m; @@ -2099,24 +2096,24 @@ namespace Ice ProtocolVersion pv = new ProtocolVersion(); pv.ice_readMembers(_readStream); - IceInternal.Protocol.checkSupportedProtocol(pv); + Protocol.checkSupportedProtocol(pv); EncodingVersion ev = new EncodingVersion(); ev.ice_readMembers(_readStream); - IceInternal.Protocol.checkSupportedProtocolEncoding(ev); + Protocol.checkSupportedProtocolEncoding(ev); byte messageType = _readStream.readByte(); - if(messageType != IceInternal.Protocol.validateConnectionMsg) + if(messageType != Protocol.validateConnectionMsg) { throw new ConnectionNotValidatedException(); } _readStream.readByte(); // Ignore compression status for validate connection. int size = _readStream.readInt(); - if(size != IceInternal.Protocol.headerSize) + if(size != Protocol.headerSize) { throw new IllegalMessageSizeException(); } - IceInternal.TraceUtil.traceRecv(_readStream, _logger, _traceLevels); + TraceUtil.traceRecv(_readStream, _logger, _traceLevels); _validated = true; } @@ -2125,7 +2122,7 @@ namespace Ice _writeStream.resize(0); _writeStream.pos(0); - _readStream.resize(IceInternal.Protocol.headerSize); + _readStream.resize(Protocol.headerSize); _readStream.pos(0); _readHeader = true; @@ -2161,14 +2158,14 @@ namespace Ice if(_sendStreams.Count == 0) { - return IceInternal.SocketOperation.None; + return SocketOperation.None; } else if(_state == StateClosingPending && _writeStream.pos() == 0) { // Message wasn't sent, empty the _writeStream, we're not going to send more data. OutgoingMessage message = _sendStreams.First.Value; _writeStream.swap(message.stream); - return IceInternal.SocketOperation.None; + return SocketOperation.None; } Debug.Assert(!_writeStream.isEmpty() && _writeStream.pos() == _writeStream.size()); @@ -2208,7 +2205,7 @@ namespace Ice // if(_state >= StateClosingPending) { - return IceInternal.SocketOperation.None; + return SocketOperation.None; } // @@ -2222,7 +2219,7 @@ namespace Ice message.stream.prepareWrite(); message.prepared = true; - IceInternal.TraceUtil.traceSend(stream, _logger, _traceLevels); + TraceUtil.traceSend(stream, _logger, _traceLevels); _writeStream.swap(message.stream); // @@ -2260,11 +2257,11 @@ namespace Ice } } } - catch(Ice.LocalException ex) + catch(LocalException ex) { setState(StateClosed, ex); } - return IceInternal.SocketOperation.None; + return SocketOperation.None; } private int sendMessage(OutgoingMessage message) @@ -2275,7 +2272,7 @@ namespace Ice { message.adopt(); _sendStreams.AddLast(message); - return IceInternal.OutgoingAsyncBase.AsyncStatusQueued; + return OutgoingAsyncBase.AsyncStatusQueued; } // @@ -2292,7 +2289,7 @@ namespace Ice message.stream.prepareWrite(); message.prepared = true; - IceInternal.TraceUtil.traceSend(stream, _logger, _traceLevels); + TraceUtil.traceSend(stream, _logger, _traceLevels); // // Send the message without blocking. @@ -2309,15 +2306,15 @@ namespace Ice observerFinishWrite(message.stream.getBuffer()); } - int status = IceInternal.OutgoingAsyncBase.AsyncStatusSent; + int status = OutgoingAsyncBase.AsyncStatusSent; if(message.sent()) { - status = status | IceInternal.OutgoingAsyncBase.AsyncStatusInvokeSentCallback; + status = status | OutgoingAsyncBase.AsyncStatusInvokeSentCallback; } if(_acmLastActivity > -1) { - _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + _acmLastActivity = Time.currentMonotonicTimeMillis(); } return status; } @@ -2328,7 +2325,7 @@ namespace Ice _sendStreams.AddLast(message); scheduleTimeout(op); _threadPool.register(this, op); - return IceInternal.OutgoingAsyncBase.AsyncStatusQueued; + return OutgoingAsyncBase.AsyncStatusQueued; } private OutputStream doCompress(OutputStream uncompressed, bool compress) @@ -2340,9 +2337,8 @@ namespace Ice // // Do compression. // - IceInternal.Buffer cbuf = IceInternal.BZip2.compress(uncompressed.getBuffer(), - IceInternal.Protocol.headerSize, - _compressionLevel); + IceInternal.Buffer cbuf = BZip2.compress(uncompressed.getBuffer(), Protocol.headerSize, + _compressionLevel); if(cbuf != null) { OutputStream cstream = @@ -2352,7 +2348,7 @@ namespace Ice // Set compression status. // cstream.pos(9); - cstream.writeByte((byte)2); + cstream.writeByte(2); // // Write the size of the compressed stream into the header. @@ -2365,7 +2361,7 @@ namespace Ice // uncompressed stream -- we need this to trace requests correctly. // uncompressed.pos(9); - uncompressed.writeByte((byte)2); + uncompressed.writeByte(2); uncompressed.writeInt(cstream.size()); return cstream; @@ -2404,7 +2400,7 @@ namespace Ice info.stream = new InputStream(_instance, Util.currentProtocolEncoding); _readStream.swap(info.stream); - _readStream.resize(IceInternal.Protocol.headerSize); + _readStream.resize(Protocol.headerSize); _readStream.pos(0); _readHeader = true; @@ -2426,13 +2422,12 @@ namespace Ice info.stream.pos(8); byte messageType = info.stream.readByte(); info.compress = info.stream.readByte(); - if(info.compress == (byte)2) + if(info.compress == 2) { if(_compressionSupported) { - IceInternal.Buffer ubuf = IceInternal.BZip2.uncompress(info.stream.getBuffer(), - IceInternal.Protocol.headerSize, - _messageSizeMax); + IceInternal.Buffer ubuf = BZip2.uncompress(info.stream.getBuffer(), Protocol.headerSize, + _messageSizeMax); info.stream = new InputStream(info.stream.instance(), info.stream.getEncoding(), ubuf, true); } else @@ -2442,13 +2437,13 @@ namespace Ice throw ex; } } - info.stream.pos(IceInternal.Protocol.headerSize); + info.stream.pos(Protocol.headerSize); switch(messageType) { - case IceInternal.Protocol.closeConnectionMsg: + case Protocol.closeConnectionMsg: { - IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); + TraceUtil.traceRecv(info.stream, _logger, _traceLevels); if(_endpoint.datagram()) { if(_warn) @@ -2473,17 +2468,17 @@ namespace Ice break; } - case IceInternal.Protocol.requestMsg: + case Protocol.requestMsg: { if(_state >= StateClosing) { - IceInternal.TraceUtil.trace("received request during closing\n" + - "(ignored by server, client will retry)", info.stream, _logger, - _traceLevels); + TraceUtil.trace("received request during closing\n" + + "(ignored by server, client will retry)", info.stream, _logger, + _traceLevels); } else { - IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); + TraceUtil.traceRecv(info.stream, _logger, _traceLevels); info.requestId = info.stream.readInt(); info.invokeNum = 1; info.servantManager = _servantManager; @@ -2493,17 +2488,17 @@ namespace Ice break; } - case IceInternal.Protocol.requestBatchMsg: + case Protocol.requestBatchMsg: { if(_state >= StateClosing) { - IceInternal.TraceUtil.trace("received batch request during closing\n" + - "(ignored by server, client will retry)", info.stream, _logger, - _traceLevels); + TraceUtil.trace("received batch request during closing\n" + + "(ignored by server, client will retry)", info.stream, _logger, + _traceLevels); } else { - IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); + TraceUtil.traceRecv(info.stream, _logger, _traceLevels); info.invokeNum = info.stream.readInt(); if(info.invokeNum < 0) { @@ -2519,7 +2514,7 @@ namespace Ice case Protocol.replyMsg: { - IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); + TraceUtil.traceRecv(info.stream, _logger, _traceLevels); info.requestId = info.stream.readInt(); if(_asyncRequests.TryGetValue(info.requestId, out info.outAsync)) { @@ -2550,9 +2545,9 @@ namespace Ice break; } - case IceInternal.Protocol.validateConnectionMsg: + case Protocol.validateConnectionMsg: { - IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); + TraceUtil.traceRecv(info.stream, _logger, _traceLevels); if(_heartbeatCallback != null) { info.heartbeatCallback = _heartbeatCallback; @@ -2563,8 +2558,8 @@ namespace Ice default: { - IceInternal.TraceUtil.trace("received unknown message\n(invalid, closing connection)", - info.stream, _logger, _traceLevels); + TraceUtil.trace("received unknown message\n(invalid, closing connection)", + info.stream, _logger, _traceLevels); throw new UnknownMessageException(); } } @@ -2584,18 +2579,18 @@ namespace Ice } } - return _state == StateHolding ? IceInternal.SocketOperation.None : IceInternal.SocketOperation.Read; + return _state == StateHolding ? SocketOperation.None : SocketOperation.Read; } private void invokeAll(InputStream stream, int invokeNum, int requestId, byte compress, - IceInternal.ServantManager servantManager, ObjectAdapter adapter) + ServantManager servantManager, ObjectAdapter adapter) { // // Note: In contrast to other private or protected methods, this // operation must be called *without* the mutex locked. // - IceInternal.Incoming inc = null; + Incoming inc = null; try { while(invokeNum > 0) @@ -2639,7 +2634,7 @@ namespace Ice int timeout; if(_state < StateActive) { - IceInternal.DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); + DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); if(defaultsAndOverrides.overrideConnectTimeout) { timeout = defaultsAndOverrides.overrideConnectTimeoutValue; @@ -2653,13 +2648,13 @@ namespace Ice { if(_readHeader) // No timeout for reading the header. { - status &= ~IceInternal.SocketOperation.Read; + status &= ~SocketOperation.Read; } timeout = _endpoint.timeout(); } else { - IceInternal.DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); + DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); if(defaultsAndOverrides.overrideCloseTimeout) { timeout = defaultsAndOverrides.overrideCloseTimeoutValue; @@ -2675,7 +2670,7 @@ namespace Ice return; } - if((status & IceInternal.SocketOperation.Read) != 0) + if((status & SocketOperation.Read) != 0) { if(_readTimeoutScheduled) { @@ -2684,7 +2679,7 @@ namespace Ice _timer.schedule(_readTimeout, timeout); _readTimeoutScheduled = true; } - if((status & (IceInternal.SocketOperation.Write | IceInternal.SocketOperation.Connect)) != 0) + if((status & (SocketOperation.Write | SocketOperation.Connect)) != 0) { if(_writeTimeoutScheduled) { @@ -2697,12 +2692,12 @@ namespace Ice private void unscheduleTimeout(int status) { - if((status & IceInternal.SocketOperation.Read) != 0 && _readTimeoutScheduled) + if((status & SocketOperation.Read) != 0 && _readTimeoutScheduled) { _timer.cancel(_readTimeout); _readTimeoutScheduled = false; } - if((status & (IceInternal.SocketOperation.Write | IceInternal.SocketOperation.Connect)) != 0 && + if((status & (SocketOperation.Write | SocketOperation.Connect)) != 0 && _writeTimeoutScheduled) { _timer.cancel(_writeTimeout); @@ -2721,7 +2716,7 @@ namespace Ice { _info = _transceiver.getInfo(); } - catch(Ice.LocalException) + catch(LocalException) { _info = new ConnectionInfo(); } @@ -2800,9 +2795,9 @@ namespace Ice _writeStreamPos = -1; } - private IceInternal.Incoming getIncoming(ObjectAdapter adapter, bool response, byte compress, int requestId) + private Incoming getIncoming(ObjectAdapter adapter, bool response, byte compress, int requestId) { - IceInternal.Incoming inc = null; + Incoming inc = null; if(_cacheBuffers) { @@ -2810,7 +2805,7 @@ namespace Ice { if(_incomingCache == null) { - inc = new IceInternal.Incoming(_instance, this, this, adapter, response, compress, requestId); + inc = new Incoming(_instance, this, this, adapter, response, compress, requestId); } else { @@ -2823,13 +2818,13 @@ namespace Ice } else { - inc = new IceInternal.Incoming(_instance, this, this, adapter, response, compress, requestId); + inc = new Incoming(_instance, this, this, adapter, response, compress, requestId); } return inc; } - internal void reclaimIncoming(IceInternal.Incoming inc) + internal void reclaimIncoming(Incoming inc) { if(_cacheBuffers && inc.reclaim()) { @@ -2895,11 +2890,10 @@ namespace Ice { this.stream = stream; this.compress = compress; - this._adopt = adopt; + _adopt = adopt; } - internal OutgoingMessage(IceInternal.OutgoingAsyncBase outAsync, OutputStream stream, - bool compress, int requestId) + internal OutgoingMessage(OutgoingAsyncBase outAsync, OutputStream stream, bool compress, int requestId) { this.outAsync = outAsync; this.stream = stream; @@ -2947,8 +2941,8 @@ namespace Ice stream = null; } - internal Ice.OutputStream stream; - internal IceInternal.OutgoingAsyncBase outAsync; + internal OutputStream stream; + internal OutgoingAsyncBase outAsync; internal bool compress; internal int requestId; internal bool _adopt; @@ -2959,25 +2953,25 @@ namespace Ice } private Communicator _communicator; - private IceInternal.Instance _instance; - private IceInternal.ACMMonitor _monitor; - private IceInternal.Transceiver _transceiver; + private Instance _instance; + private ACMMonitor _monitor; + private Transceiver _transceiver; private string _desc; private string _type; - private IceInternal.Connector _connector; - private IceInternal.EndpointI _endpoint; + private Connector _connector; + private EndpointI _endpoint; private ObjectAdapter _adapter; - private IceInternal.ServantManager _servantManager; + private ServantManager _servantManager; private Logger _logger; - private IceInternal.TraceLevels _traceLevels; + private TraceLevels _traceLevels; private IceInternal.ThreadPool _threadPool; private IceInternal.Timer _timer; - private IceInternal.TimerTask _writeTimeout; + private TimerTask _writeTimeout; private bool _writeTimeoutScheduled; - private IceInternal.TimerTask _readTimeout; + private TimerTask _readTimeout; private bool _readTimeoutScheduled; private StartCallback _startCallback = null; @@ -2991,13 +2985,12 @@ namespace Ice private int _nextRequestId; - private Dictionary<int, IceInternal.OutgoingAsyncBase> _asyncRequests = - new Dictionary<int, IceInternal.OutgoingAsyncBase>(); + private Dictionary<int, OutgoingAsyncBase> _asyncRequests = new Dictionary<int, OutgoingAsyncBase>(); private LocalException _exception; private readonly int _messageSizeMax; - private IceInternal.BatchRequestQueue _batchRequestQueue; + private BatchRequestQueue _batchRequestQueue; private LinkedList<OutgoingMessage> _sendStreams = new LinkedList<OutgoingMessage>(); @@ -3016,17 +3009,17 @@ namespace Ice private bool _initialized = false; private bool _validated = false; - private IceInternal.Incoming _incomingCache; + private Incoming _incomingCache; private object _incomingCacheMutex = new object(); private static bool _compressionSupported; private bool _cacheBuffers; - private Ice.ConnectionInfo _info; + private ConnectionInfo _info; - private Ice.CloseCallback _closeCallback; - private Ice.HeartbeatCallback _heartbeatCallback; + private CloseCallback _closeCallback; + private HeartbeatCallback _heartbeatCallback; private static ConnectionState[] connectionStateMap = new ConnectionState[] { ConnectionState.ConnectionStateValidating, // StateNotInitialized diff --git a/csharp/src/Ice/ConnectionRequestHandler.cs b/csharp/src/Ice/ConnectionRequestHandler.cs index 40e13fe7691..298022a578b 100644 --- a/csharp/src/Ice/ConnectionRequestHandler.cs +++ b/csharp/src/Ice/ConnectionRequestHandler.cs @@ -7,11 +7,6 @@ // // ********************************************************************** -using System; -using System.Diagnostics; -using System.Collections.Generic; -using Ice.Instrumentation; - namespace IceInternal { public class ConnectionRequestHandler : RequestHandler diff --git a/csharp/src/Ice/Connector.cs b/csharp/src/Ice/Connector.cs index 057dfe6230f..bc9dc6e0b26 100644 --- a/csharp/src/Ice/Connector.cs +++ b/csharp/src/Ice/Connector.cs @@ -9,10 +9,6 @@ namespace IceInternal { - - using System; - using System.Net.Sockets; - public interface Connector { // diff --git a/csharp/src/Ice/DefaultsAndOverrides.cs b/csharp/src/Ice/DefaultsAndOverrides.cs index 779ba08d2bf..40e845c1a29 100644 --- a/csharp/src/Ice/DefaultsAndOverrides.cs +++ b/csharp/src/Ice/DefaultsAndOverrides.cs @@ -13,7 +13,6 @@ using System.Text; namespace IceInternal { - public sealed class DefaultsAndOverrides { internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) diff --git a/csharp/src/Ice/DispatchInterceptor.cs b/csharp/src/Ice/DispatchInterceptor.cs index 9cf3347f606..b73ab7f9219 100644 --- a/csharp/src/Ice/DispatchInterceptor.cs +++ b/csharp/src/Ice/DispatchInterceptor.cs @@ -7,8 +7,6 @@ // // ********************************************************************** -using System.Diagnostics; - namespace Ice { /// <summary> @@ -19,7 +17,7 @@ namespace Ice /// A dispatch interceptor is useful particularly to automatically retry requests /// that have failed due to a recoverable error condition. /// </summary> - public abstract class DispatchInterceptor : Ice.ObjectImpl + public abstract class DispatchInterceptor : ObjectImpl { /// <summary> /// Called by the Ice run time to dispatch an incoming request. The implementation @@ -27,10 +25,10 @@ namespace Ice /// </summary> /// <param name="request">The details of the incoming request.</param> /// <returns>The task if dispatched asynchronously, null otherwise.</returns> - public abstract System.Threading.Tasks.Task<Ice.OutputStream> + public abstract System.Threading.Tasks.Task<OutputStream> dispatch(Request request); - public override System.Threading.Tasks.Task<Ice.OutputStream> + public override System.Threading.Tasks.Task<OutputStream> iceDispatch(IceInternal.Incoming inc, Current current) { return dispatch(inc); diff --git a/csharp/src/Ice/EndpointFactoryManager.cs b/csharp/src/Ice/EndpointFactoryManager.cs index 5cf22c23ceb..814b3686372 100644 --- a/csharp/src/Ice/EndpointFactoryManager.cs +++ b/csharp/src/Ice/EndpointFactoryManager.cs @@ -9,10 +9,8 @@ namespace IceInternal { - using System.Collections.Generic; using System.Diagnostics; - using System.Text.RegularExpressions; public sealed class EndpointFactoryManager { @@ -28,7 +26,7 @@ namespace IceInternal { for(int i = 0; i < _factories.Count; i++) { - EndpointFactory f = (EndpointFactory)_factories[i]; + EndpointFactory f = _factories[i]; if(f.type() == factory.type()) { Debug.Assert(false); @@ -44,7 +42,7 @@ namespace IceInternal { for(int i = 0; i < _factories.Count; i++) { - EndpointFactory f = (EndpointFactory)_factories[i]; + EndpointFactory f = _factories[i]; if(f.type() == type) { return f; diff --git a/csharp/src/Ice/EndpointHostResolver.cs b/csharp/src/Ice/EndpointHostResolver.cs index f1d4316ac8e..af8f2e50ce2 100644 --- a/csharp/src/Ice/EndpointHostResolver.cs +++ b/csharp/src/Ice/EndpointHostResolver.cs @@ -23,16 +23,8 @@ namespace IceInternal _preferIPv6 = instance.preferIPv6(); _thread = new HelperThread(this); updateObserver(); - if(instance.initializationData().properties.getProperty("Ice.ThreadPriority").Length > 0) - { - ThreadPriority priority = IceInternal.Util.stringToThreadPriority( - instance.initializationData().properties.getProperty("Ice.ThreadPriority")); - _thread.Start(priority); - } - else - { - _thread.Start(ThreadPriority.Normal); - } + _thread.Start(Util.stringToThreadPriority( + instance.initializationData().properties.getProperty("Ice.ThreadPriority"))); } public void resolve(string host, int port, Ice.EndpointSelectionType selType, IPEndpointI endpoint, @@ -83,7 +75,7 @@ namespace IceInternal } _queue.AddLast(entry); - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); } } @@ -93,7 +85,7 @@ namespace IceInternal { Debug.Assert(!_destroyed); _destroyed = true; - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); } } @@ -116,7 +108,7 @@ namespace IceInternal { while(!_destroyed && _queue.Count == 0) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } if(_destroyed) diff --git a/csharp/src/Ice/EndpointI.cs b/csharp/src/Ice/EndpointI.cs index ca009e6fba7..1c70bb9e7a0 100644 --- a/csharp/src/Ice/EndpointI.cs +++ b/csharp/src/Ice/EndpointI.cs @@ -12,7 +12,6 @@ namespace IceInternal using System.Collections.Generic; using System.Diagnostics; - using System.Net; using System; public interface EndpointI_connectors @@ -21,7 +20,7 @@ namespace IceInternal void exception(Ice.LocalException ex); } - public abstract class EndpointI : Ice.Endpoint, System.IComparable<EndpointI> + public abstract class EndpointI : Ice.Endpoint, IComparable<EndpointI> { public override string ToString() { diff --git a/csharp/src/Ice/EventHandler.cs b/csharp/src/Ice/EventHandler.cs index 69ac3fae25f..d9aea752773 100644 --- a/csharp/src/Ice/EventHandler.cs +++ b/csharp/src/Ice/EventHandler.cs @@ -10,8 +10,6 @@ namespace IceInternal { -using System; - public abstract class EventHandler { // diff --git a/csharp/src/Ice/Exception.cs b/csharp/src/Ice/Exception.cs index b5720c1b798..b55ea6b32d2 100644 --- a/csharp/src/Ice/Exception.cs +++ b/csharp/src/Ice/Exception.cs @@ -228,7 +228,7 @@ namespace Ice namespace IceInternal { - public class RetryException : System.Exception + public class RetryException : Exception { public RetryException(Ice.LocalException ex) { diff --git a/csharp/src/Ice/HttpParser.cs b/csharp/src/Ice/HttpParser.cs index 008ad3d6ca1..401169563f2 100644 --- a/csharp/src/Ice/HttpParser.cs +++ b/csharp/src/Ice/HttpParser.cs @@ -54,7 +54,7 @@ namespace IceInternal Response }; - internal int isCompleteMessage(IceInternal.ByteBuffer buf, int begin, int end) + internal int isCompleteMessage(ByteBuffer buf, int begin, int end) { byte[] raw = buf.rawBytes(); int p = begin; @@ -99,7 +99,7 @@ namespace IceInternal return -1; } - internal bool parse(IceInternal.ByteBuffer buf, int begin, int end) + internal bool parse(ByteBuffer buf, int begin, int end) { byte[] raw = buf.rawBytes(); int p = begin; @@ -543,7 +543,7 @@ namespace IceInternal _versionMinor = 0; } _versionMinor *= 10; - _versionMinor += (int)(c - '0'); + _versionMinor += (c - '0'); break; } case State.Response: @@ -601,7 +601,7 @@ namespace IceInternal _status = 0; } _status *= 10; - _status += (int)(c - '0'); + _status += (c - '0'); break; } case State.ResponseReasonStart: diff --git a/csharp/src/Ice/IPEndpointI.cs b/csharp/src/Ice/IPEndpointI.cs index 874bdc5f069..706cefc7441 100644 --- a/csharp/src/Ice/IPEndpointI.cs +++ b/csharp/src/Ice/IPEndpointI.cs @@ -11,7 +11,6 @@ namespace IceInternal { using System.Collections.Generic; - using System.Diagnostics; using System.Globalization; using System.Net; using System; @@ -326,9 +325,9 @@ namespace IceInternal try { - port_ = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + port_ = int.Parse(argument, CultureInfo.InvariantCulture); } - catch(System.FormatException ex) + catch(FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint " + endpoint; diff --git a/csharp/src/Ice/ImplicitContextI.cs b/csharp/src/Ice/ImplicitContextI.cs index 75372babf47..fa342c04601 100644 --- a/csharp/src/Ice/ImplicitContextI.cs +++ b/csharp/src/Ice/ImplicitContextI.cs @@ -9,7 +9,6 @@ namespace Ice { - using System.Collections; using System.Collections.Generic; using System.Threading; @@ -34,8 +33,7 @@ namespace Ice } else { - throw new Ice.InitializationException( - "'" + kind + "' is not a valid value for Ice.ImplicitContext"); + throw new InitializationException("'" + kind + "' is not a valid value for Ice.ImplicitContext"); } } @@ -210,7 +208,7 @@ namespace Ice { if(_map.ContainsKey(currentThread)) { - threadContext = (Dictionary<string, string>)_map[currentThread]; + threadContext = _map[currentThread]; } } diff --git a/csharp/src/Ice/Incoming.cs b/csharp/src/Ice/Incoming.cs index 8041c89625e..19529f878ff 100644 --- a/csharp/src/Ice/Incoming.cs +++ b/csharp/src/Ice/Incoming.cs @@ -12,7 +12,7 @@ namespace Ice public interface MarshaledResult { - Ice.OutputStream getOutputStream(Ice.Current current); + OutputStream getOutputStream(Current current); }; } @@ -130,7 +130,7 @@ namespace IceInternal } _current.operation = _is.readString(); - _current.mode = (Ice.OperationMode)(int)_is.readByte(); + _current.mode = (Ice.OperationMode)_is.readByte(); _current.ctx = new Dictionary<string, string>(); int sz = _is.readSize(); while(sz-- > 0) @@ -178,7 +178,7 @@ namespace IceInternal { _servant = _locator.locate(_current, out _cookie); } - catch(System.Exception ex) + catch(Exception ex) { skipReadParams(); // Required for batch requests. handleException(ex, false); @@ -201,7 +201,7 @@ namespace IceInternal throw new Ice.ObjectNotExistException(_current.id, _current.facet, _current.operation); } } - catch(System.Exception ex) + catch(Exception ex) { skipReadParams(); // Required for batch requests handleException(ex, false); @@ -240,7 +240,7 @@ namespace IceInternal } } } - catch(System.Exception ex) + catch(Exception ex) { completed(ex, false); } @@ -282,7 +282,7 @@ namespace IceInternal var os = startWriteParams(); write(os, result); endWriteParams(os); - return Task.FromResult<Ice.OutputStream>(os); + return Task.FromResult(os); }, TaskContinuationOptions.ExecuteSynchronously).Unwrap(); } } @@ -299,7 +299,7 @@ namespace IceInternal return task.ContinueWith((Task t) => { t.GetAwaiter().GetResult(); - return Task.FromResult<Ice.OutputStream>(writeEmptyParams()); + return Task.FromResult(writeEmptyParams()); }, TaskContinuationOptions.ExecuteSynchronously).Unwrap(); } } @@ -315,12 +315,12 @@ namespace IceInternal { return task.ContinueWith((Task<T> t) => { - return Task.FromResult<Ice.OutputStream>(t.GetAwaiter().GetResult().getOutputStream(_current)); + return Task.FromResult(t.GetAwaiter().GetResult().getOutputStream(_current)); }, TaskContinuationOptions.ExecuteSynchronously).Unwrap(); } } - public void completed(System.Exception exc, bool amd) + public void completed(Exception exc, bool amd) { try { @@ -331,7 +331,7 @@ namespace IceInternal { _locator.finished(_current, _servant, _cookie); } - catch(System.Exception ex) + catch(Exception ex) { handleException(ex, amd); return; @@ -433,7 +433,7 @@ namespace IceInternal static public Ice.OutputStream createResponseOutputStream(Ice.Current current) { var os = new Ice.OutputStream(current.adapter.getCommunicator(), Ice.Util.currentProtocolEncoding); - os.writeBlob(IceInternal.Protocol.replyHdr); + os.writeBlob(Protocol.replyHdr); os.writeInt(current.requestId); os.writeByte(ReplyStatus.replyOK); return os; @@ -447,7 +447,7 @@ namespace IceInternal } var os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - os.writeBlob(IceInternal.Protocol.replyHdr); + os.writeBlob(Protocol.replyHdr); os.writeInt(_current.requestId); os.writeByte(ReplyStatus.replyOK); os.startEncapsulation(_current.encoding, _format); @@ -467,7 +467,7 @@ namespace IceInternal if(_response) { var os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - os.writeBlob(IceInternal.Protocol.replyHdr); + os.writeBlob(Protocol.replyHdr); os.writeInt(_current.requestId); os.writeByte(ReplyStatus.replyOK); os.writeEmptyEncapsulation(_current.encoding); @@ -489,7 +489,7 @@ namespace IceInternal if(_response) { var os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - os.writeBlob(IceInternal.Protocol.replyHdr); + os.writeBlob(Protocol.replyHdr); os.writeInt(_current.requestId); os.writeByte(ok ? ReplyStatus.replyOK : ReplyStatus.replyUserException); if(v == null || v.Length == 0) @@ -508,7 +508,7 @@ namespace IceInternal } } - private void warning(System.Exception ex) + private void warning(Exception ex) { Debug.Assert(_instance != null); @@ -541,7 +541,7 @@ namespace IceInternal } } - private void handleException(System.Exception exc, bool amd) + private void handleException(Exception exc, bool amd) { Debug.Assert(_responseHandler != null); @@ -587,7 +587,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); if(ex is Ice.ObjectNotExistException) { @@ -648,7 +648,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); _os.writeByte(ReplyStatus.replyUnknownLocalException); _os.writeString(ex.unknown); @@ -678,7 +678,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); _os.writeByte(ReplyStatus.replyUnknownUserException); _os.writeString(ex.unknown); @@ -709,7 +709,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); _os.writeByte(ReplyStatus.replyUnknownException); _os.writeString(ex.unknown); @@ -734,7 +734,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); _os.writeByte(ReplyStatus.replyUserException); _os.startEncapsulation(_current.encoding, _format); @@ -766,7 +766,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); _os.writeByte(ReplyStatus.replyUnknownLocalException); _os.writeString(ex.ice_id() + "\n" + ex.StackTrace); @@ -781,7 +781,7 @@ namespace IceInternal _responseHandler.sendNoResponse(); } } - catch(System.Exception ex) + catch(Exception ex) { if(_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) { @@ -796,7 +796,7 @@ namespace IceInternal if(_response) { _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); - _os.writeBlob(IceInternal.Protocol.replyHdr); + _os.writeBlob(Protocol.replyHdr); _os.writeInt(_current.requestId); _os.writeByte(ReplyStatus.replyUnknownException); _os.writeString(ex.ToString()); @@ -824,7 +824,7 @@ namespace IceInternal private Ice.Current _current; private Ice.Object _servant; private Ice.ServantLocator _locator; - private System.Object _cookie; + private object _cookie; private Ice.Instrumentation.DispatchObserver _observer; private ResponseHandler _responseHandler; diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs index 5607c7e9e6c..da24b91693f 100644 --- a/csharp/src/Ice/Instance.cs +++ b/csharp/src/Ice/Instance.cs @@ -741,14 +741,14 @@ namespace IceInternal throw fe; } outStream.AutoFlush = true; - System.Console.Out.Close(); - System.Console.SetOut(outStream); + Console.Out.Close(); + Console.SetOut(outStream); } if(stdErr.Length > 0) { if(stdErr.Equals(stdOut)) { - System.Console.SetError(outStream); + Console.SetError(outStream); } else { @@ -764,8 +764,8 @@ namespace IceInternal throw fe; } errStream.AutoFlush = true; - System.Console.Error.Close(); - System.Console.SetError(errStream); + Console.Error.Close(); + Console.SetError(errStream); } } @@ -786,16 +786,14 @@ namespace IceInternal // // Ice.ConsoleListener is enabled by default. // - bool console = - _initData.properties.getPropertyAsIntWithDefault("Ice.ConsoleListener", 1) > 0; + bool console = _initData.properties.getPropertyAsIntWithDefault("Ice.ConsoleListener", 1) > 0; _initData.logger = new Ice.TraceLoggerI(_initData.properties.getProperty("Ice.ProgramName"), console); } if(Ice.Util.getProcessLogger() is Ice.LoggerI) { - _initData.logger = - new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName")); + _initData.logger = new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName")); } else { @@ -1055,18 +1053,10 @@ namespace IceInternal // try { - if(initializationData().properties.getProperty("Ice.ThreadPriority").Length > 0) - { - ThreadPriority priority = IceInternal.Util.stringToThreadPriority( - initializationData().properties.getProperty("Ice.ThreadPriority")); - _timer = new Timer(this, priority); - } - else - { - _timer = new Timer(this); - } + _timer = new Timer(this, Util.stringToThreadPriority( + initializationData().properties.getProperty("Ice.ThreadPriority"))); } - catch(System.Exception ex) + catch(Exception ex) { string s = "cannot create thread for timer:\n" + ex; _initData.logger.error(s); @@ -1077,7 +1067,7 @@ namespace IceInternal { _endpointHostResolver = new EndpointHostResolver(this); } - catch(System.Exception ex) + catch(Exception ex) { string s = "cannot create thread for endpoint host resolver:\n" + ex; _initData.logger.error(s); @@ -1118,7 +1108,7 @@ namespace IceInternal { using(Process p = Process.GetCurrentProcess()) { - System.Console.WriteLine(p.Id); + Console.WriteLine(p.Id); } _printProcessIdDone = true; } @@ -1585,6 +1575,6 @@ namespace IceInternal private static bool _printProcessIdDone = false; private static bool _oneOffDone = false; private Dictionary<string, Ice.ObjectFactory> _objectFactoryMap = new Dictionary<string, Ice.ObjectFactory>(); - private static System.Object _staticLock = new System.Object(); + private static object _staticLock = new object(); } } diff --git a/csharp/src/Ice/InstrumentationI.cs b/csharp/src/Ice/InstrumentationI.cs index 3eca65b7ed6..8cbb58f6d84 100644 --- a/csharp/src/Ice/InstrumentationI.cs +++ b/csharp/src/Ice/InstrumentationI.cs @@ -67,11 +67,11 @@ namespace IceInternal where ObserverImpl : ObserverWithDelegate<S, Observer>, Observer, new() where Observer : Ice.Instrumentation.Observer { - ObserverImpl obsv = base.getObserver<S, ObserverImpl>(mapName, helper); + ObserverImpl obsv = getObserver<S, ObserverImpl>(mapName, helper); if(obsv != null) { obsv.setDelegate(del); - return (Observer)obsv; + return obsv; } return del; } @@ -84,13 +84,13 @@ namespace IceInternal where OImpl : ObserverWithDelegate<T, O>, O, new() where O : Ice.Instrumentation.Observer { - public ObserverFactoryWithDelegate(IceInternal.MetricsAdminI metrics, string name) : base(metrics, name) + public ObserverFactoryWithDelegate(MetricsAdminI metrics, string name) : base(metrics, name) { } public O getObserver(MetricsHelper<T> helper, O del) { - OImpl o = base.getObserver(helper); + OImpl o = getObserver(helper); if(o != null) { o.setDelegate(del); @@ -101,7 +101,7 @@ namespace IceInternal public O getObserver(MetricsHelper<T> helper, object observer, O del) { - OImpl o = base.getObserver(helper, observer); + OImpl o = getObserver(helper, observer); if(o != null) { o.setDelegate(del); @@ -148,13 +148,13 @@ namespace IceInternal r.add("mcastHost", cl.GetMethod("getConnectionInfo"), cli.GetField("mcastAddress")); r.add("mcastPort", cl.GetMethod("getConnectionInfo"), cli.GetField("mcastPort")); - AttrsUtil.addEndpointAttributes<T>(r, cl); + addEndpointAttributes<T>(r, cl); } } class ConnectionHelper : MetricsHelper<ConnectionMetrics> { - class AttributeResolverI : MetricsHelper<ConnectionMetrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -164,7 +164,7 @@ namespace IceInternal add("parent", cl.GetMethod("getParent")); add("id", cl.GetMethod("getId")); add("state", cl.GetMethod("getState")); - AttrsUtil.addConnectionAttributes<ConnectionMetrics>(this, cl); + AttrsUtil.addConnectionAttributes(this, cl); } catch(Exception) { @@ -280,7 +280,7 @@ namespace IceInternal class DispatchHelper : MetricsHelper<DispatchMetrics> { - class AttributeResolverI : MetricsHelper<DispatchMetrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -290,7 +290,7 @@ namespace IceInternal add("parent", cl.GetMethod("getParent")); add("id", cl.GetMethod("getId")); - AttrsUtil.addConnectionAttributes<DispatchMetrics>(this, cl); + AttrsUtil.addConnectionAttributes(this, cl); Type clc = typeof(Ice.Current); add("operation", cl.GetMethod("getCurrent"), clc.GetField("operation")); @@ -406,7 +406,7 @@ namespace IceInternal class InvocationHelper : MetricsHelper<InvocationMetrics> { - class AttributeResolverI : MetricsHelper<InvocationMetrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -555,7 +555,7 @@ namespace IceInternal class ThreadHelper : MetricsHelper<ThreadMetrics> { - class AttributeResolverI : MetricsHelper<ThreadMetrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -605,7 +605,7 @@ namespace IceInternal class EndpointHelper : MetricsHelper<Metrics> { - class AttributeResolverI : MetricsHelper<Metrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -614,7 +614,7 @@ namespace IceInternal Type cl = typeof(EndpointHelper); add("parent", cl.GetMethod("getParent")); add("id", cl.GetMethod("getId")); - AttrsUtil.addEndpointAttributes<Metrics>(this, cl); + AttrsUtil.addEndpointAttributes(this, cl); } catch(Exception) { @@ -670,7 +670,7 @@ namespace IceInternal public class RemoteInvocationHelper : MetricsHelper<RemoteMetrics> { - class AttributeResolverI : MetricsHelper<RemoteMetrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -680,7 +680,7 @@ namespace IceInternal add("parent", cl.GetMethod("getParent")); add("id", cl.GetMethod("getId")); add("requestId", cl.GetMethod("getRequestId")); - AttrsUtil.addConnectionAttributes<RemoteMetrics>(this, cl); + AttrsUtil.addConnectionAttributes(this, cl); } catch(Exception) { @@ -763,7 +763,7 @@ namespace IceInternal public class CollocatedInvocationHelper : MetricsHelper<CollocatedMetrics> { - class AttributeResolverI : MetricsHelper<CollocatedMetrics>.AttributeResolver + class AttributeResolverI : AttributeResolver { public AttributeResolverI() { @@ -1212,12 +1212,12 @@ namespace IceInternal } } - public IceInternal.MetricsAdminI getFacet() + public MetricsAdminI getFacet() { return _metrics; } - readonly private IceInternal.MetricsAdminI _metrics; + readonly private MetricsAdminI _metrics; readonly private Ice.Instrumentation.CommunicatorObserver _delegate; readonly private ObserverFactoryWithDelegate<ConnectionMetrics, ConnectionObserverI, Ice.Instrumentation.ConnectionObserver> _connections; diff --git a/csharp/src/Ice/LocatorInfo.cs b/csharp/src/Ice/LocatorInfo.cs index 50b2c8b6a14..3b5c9bc7422 100644 --- a/csharp/src/Ice/LocatorInfo.cs +++ b/csharp/src/Ice/LocatorInfo.cs @@ -150,7 +150,7 @@ namespace IceInternal while(!_response && _exception == null) { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } } @@ -204,7 +204,7 @@ namespace IceInternal _locatorInfo.finishRequest(_ref, _wellKnownRefs, proxy, false); _response = true; _proxy = proxy; - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } foreach(RequestCallback callback in _callbacks) { @@ -219,7 +219,7 @@ namespace IceInternal { _locatorInfo.finishRequest(_ref, _wellKnownRefs, null, ex is Ice.UserException); _exception = ex; - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } foreach(RequestCallback callback in _callbacks) { @@ -273,7 +273,7 @@ namespace IceInternal try { _locatorInfo.getLocator().begin_findAdapterById(_ref.getAdapterId()).whenCompleted( - this.response, this.exception); + response, exception); } catch(Ice.Exception ex) { @@ -300,7 +300,7 @@ namespace IceInternal public override bool Equals(object obj) { - if(object.ReferenceEquals(this, obj)) + if(ReferenceEquals(this, obj)) { return true; } @@ -784,8 +784,8 @@ namespace IceInternal public override int GetHashCode() { int h = 5381; - IceInternal.HashUtil.hashAdd(ref h, _id); - IceInternal.HashUtil.hashAdd(ref h, _encoding); + HashUtil.hashAdd(ref h, _id); + HashUtil.hashAdd(ref h, _encoding); return h; } @@ -832,7 +832,6 @@ namespace IceInternal // // TODO: reap unused locator info objects? // - lock(this) { LocatorInfo info = null; @@ -881,7 +880,7 @@ namespace IceInternal } } - internal IceInternal.EndpointI[] getAdapterEndpoints(string adapter, int ttl, out bool cached) + internal EndpointI[] getAdapterEndpoints(string adapter, int ttl, out bool cached) { if(ttl == 0) // Locator cache disabled. { @@ -903,7 +902,7 @@ namespace IceInternal } } - internal void addAdapterEndpoints(string adapter, IceInternal.EndpointI[] endpoints) + internal void addAdapterEndpoints(string adapter, EndpointI[] endpoints) { lock(this) { @@ -912,7 +911,7 @@ namespace IceInternal } } - internal IceInternal.EndpointI[] removeAdapterEndpoints(string adapter) + internal EndpointI[] removeAdapterEndpoints(string adapter) { lock(this) { @@ -984,14 +983,14 @@ namespace IceInternal sealed private class EndpointTableEntry { - public EndpointTableEntry(long time, IceInternal.EndpointI[] endpoints) + public EndpointTableEntry(long time, EndpointI[] endpoints) { this.time = time; this.endpoints = endpoints; } public long time; - public IceInternal.EndpointI[] endpoints; + public EndpointI[] endpoints; } sealed private class ReferenceTableEntry diff --git a/csharp/src/Ice/LoggerAdminI.cs b/csharp/src/Ice/LoggerAdminI.cs index 1c421c7c8f9..c8b0208eb76 100644 --- a/csharp/src/Ice/LoggerAdminI.cs +++ b/csharp/src/Ice/LoggerAdminI.cs @@ -10,7 +10,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Threading; namespace IceInternal { diff --git a/csharp/src/Ice/LoggerI.cs b/csharp/src/Ice/LoggerI.cs index 8cdf59ddd98..bab09bd2f9e 100644 --- a/csharp/src/Ice/LoggerI.cs +++ b/csharp/src/Ice/LoggerI.cs @@ -170,7 +170,7 @@ namespace Ice s.Append(System.DateTime.Now.ToString(_time, CultureInfo.CurrentCulture)); s.Append(' '); s.Append(message); - this.WriteLine(s.ToString()); + WriteLine(s.ToString()); } public override void Write(string message) diff --git a/csharp/src/Ice/LoggerPlugin.cs b/csharp/src/Ice/LoggerPlugin.cs index c380debab41..d6fcf0a4720 100644 --- a/csharp/src/Ice/LoggerPlugin.cs +++ b/csharp/src/Ice/LoggerPlugin.cs @@ -14,7 +14,7 @@ namespace Ice /// instantiate a LoggerPlugin with a custom logger and /// return the instance from their PluginFactory implementation. /// </summary> - public class LoggerPlugin : Ice.Plugin + public class LoggerPlugin : Plugin { /// <summary> /// Installs a custom logger for a communicator. diff --git a/csharp/src/Ice/MetricsAdminI.cs b/csharp/src/Ice/MetricsAdminI.cs index e298680e487..30b6b29d14f 100644 --- a/csharp/src/Ice/MetricsAdminI.cs +++ b/csharp/src/Ice/MetricsAdminI.cs @@ -248,7 +248,7 @@ namespace IceInternal if(groupBy.Length > 0) { string v = ""; - bool attribute = Char.IsLetter(groupBy[0]) || Char.IsDigit(groupBy[0]); + bool attribute = char.IsLetter(groupBy[0]) || char.IsDigit(groupBy[0]); if(!attribute) { _groupByAttributes.Add(""); @@ -256,7 +256,7 @@ namespace IceInternal foreach(char p in groupBy) { - bool isAlphaNum = Char.IsLetter(p) || Char.IsDigit(p) || p == '.'; + bool isAlphaNum = char.IsLetter(p) || char.IsDigit(p) || p == '.'; if(attribute && !isAlphaNum) { _groupByAttributes.Add(v); @@ -713,7 +713,7 @@ namespace IceInternal class MetricsMapFactory<T> : IMetricsMapFactory where T : IceMX.Metrics, new() { - public MetricsMapFactory(System.Action updater) + public MetricsMapFactory(Action updater) { _updater = updater; } @@ -735,7 +735,7 @@ namespace IceInternal _subMaps.Add(subMap, new SubMapFactory<S>(field)); } - readonly private System.Action _updater; + readonly private Action _updater; readonly private Dictionary<string, ISubMapFactory> _subMaps = new Dictionary<string, ISubMapFactory>(); } @@ -859,7 +859,7 @@ namespace IceInternal lock(this) { MetricsViewI view = getMetricsView(viewName); - timestamp = IceInternal.Time.currentMonotonicTimeMillis(); + timestamp = Time.currentMonotonicTimeMillis(); if(view != null) { return view.getMetrics(); @@ -895,7 +895,7 @@ namespace IceInternal } } - public void registerMap<T>(string map, System.Action updater) + public void registerMap<T>(string map, Action updater) where T : IceMX.Metrics, new() { bool updated; diff --git a/csharp/src/Ice/MetricsObserverI.cs b/csharp/src/Ice/MetricsObserverI.cs index 0157e163e88..5e5735a6eee 100644 --- a/csharp/src/Ice/MetricsObserverI.cs +++ b/csharp/src/Ice/MetricsObserverI.cs @@ -56,7 +56,7 @@ namespace IceMX { return field.GetValue(obj); } - catch(ArgumentException ex) + catch(ArgumentException) { if(obj is Ice.EndpointInfo) { @@ -68,7 +68,7 @@ namespace IceMX } else { - throw ex; + throw; } } } @@ -430,7 +430,7 @@ namespace IceMX public void update() { - System.Action updater; + Action updater; lock(this) { _maps.Clear(); @@ -448,7 +448,7 @@ namespace IceMX } } - public void setUpdater(System.Action updater) + public void setUpdater(Action updater) { lock(this) { @@ -456,10 +456,10 @@ namespace IceMX } } - private readonly IceInternal.MetricsAdminI _metrics; + private readonly MetricsAdminI _metrics; private readonly string _name; private List<MetricsMap<T>> _maps = new List<MetricsMap<T>>(); private volatile bool _enabled; - private System.Action _updater; + private Action _updater; } } diff --git a/csharp/src/Ice/Network.cs b/csharp/src/Ice/Network.cs index f7d0790371b..0d068ddebcf 100644 --- a/csharp/src/Ice/Network.cs +++ b/csharp/src/Ice/Network.cs @@ -49,7 +49,7 @@ namespace IceInternal { SocketError error = socketErrorCode(ex); return error == SocketError.NoBufferSpaceAvailable || - error == SocketError.Fault; + error == SocketError.Fault; } public static bool wouldBlock(SocketException ex) @@ -155,7 +155,7 @@ namespace IceInternal return ex.Message.IndexOf("period of time", StringComparison.Ordinal) >= 0; } - public static bool noMoreFds(System.Exception ex) + public static bool noMoreFds(Exception ex) { try { @@ -176,13 +176,13 @@ namespace IceInternal string[] arr = ip.Split(splitChars); try { - int i = System.Int32.Parse(arr[0], CultureInfo.InvariantCulture); + int i = int.Parse(arr[0], CultureInfo.InvariantCulture); if(i >= 223 && i <= 239) { return true; } } - catch(System.FormatException) + catch(FormatException) { return false; } @@ -313,7 +313,7 @@ namespace IceInternal { socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); } - catch(System.Exception ex) + catch(Exception ex) { closeSocketNoThrow(socket); throw new Ice.SocketException(ex); @@ -324,12 +324,12 @@ namespace IceInternal { const int SIO_LOOPBACK_FAST_PATH = (-1744830448); - Byte[] OptionInValue = BitConverter.GetBytes(1); + byte[] OptionInValue = BitConverter.GetBytes(1); try { socket.IOControl(SIO_LOOPBACK_FAST_PATH, OptionInValue, null); } - catch(System.Exception) + catch(Exception) { // Expected on platforms that do not support TCP Loopback Fast Path } @@ -354,7 +354,7 @@ namespace IceInternal { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1); } - catch(System.Exception ex) + catch(Exception ex) { closeSocketNoThrow(socket); throw new Ice.SocketException(ex); @@ -439,9 +439,9 @@ namespace IceInternal { try { - ifaceIndex = System.Int32.Parse(iface, CultureInfo.InvariantCulture); + ifaceIndex = int.Parse(iface, CultureInfo.InvariantCulture); } - catch(System.FormatException ex) + catch(FormatException ex) { closeSocketNoThrow(socket); throw new Ice.SocketException(ex); @@ -450,7 +450,7 @@ namespace IceInternal if(family == AddressFamily.InterNetwork) { - ifaceIndex = (int)IPAddress.HostToNetworkOrder(ifaceIndex); + ifaceIndex = IPAddress.HostToNetworkOrder(ifaceIndex); socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, ifaceIndex); } else @@ -796,7 +796,7 @@ namespace IceInternal e.host = host; throw e; } - catch(System.Exception ex) + catch(Exception ex) { Ice.DNSException e = new Ice.DNSException(ex); e.host = host; @@ -864,7 +864,7 @@ namespace IceInternal e.host = "0.0.0.0"; throw e; } - catch(System.Exception ex) + catch(Exception ex) { Ice.DNSException e = new Ice.DNSException(ex); e.host = "0.0.0.0"; @@ -883,7 +883,7 @@ namespace IceInternal } else if (addr.AddressFamily == AddressFamily.InterNetwork) { - Byte[] bytes = addr.GetAddressBytes(); + byte[] bytes = addr.GetAddressBytes(); return bytes[0] == 169 && bytes[1] == 254; } return false; @@ -971,8 +971,7 @@ namespace IceInternal List<string> hosts = new List<string>(); if(wildcard) { - IPAddress[] addrs = - getLocalAddresses(ipv4Wildcard ? Network.EnableIPv4 : protocol, includeLoopback); + IPAddress[] addrs = getLocalAddresses(ipv4Wildcard ? EnableIPv4 : protocol, includeLoopback); foreach(IPAddress a in addrs) { if(!isLinklocal(a)) @@ -1090,7 +1089,7 @@ namespace IceInternal { try { - return (EndPoint)socket.RemoteEndPoint; + return socket.RemoteEndPoint; } catch(SocketException) { @@ -1115,9 +1114,9 @@ namespace IceInternal // try { - return System.Int32.Parse(iface, CultureInfo.InvariantCulture); + return int.Parse(iface, CultureInfo.InvariantCulture); } - catch(System.FormatException) + catch(FormatException) { } @@ -1186,10 +1185,10 @@ namespace IceInternal getNumericAddress(string sourceAddress) { EndPoint addr = null; - if(!String.IsNullOrEmpty(sourceAddress)) + if(!string.IsNullOrEmpty(sourceAddress)) { - List<EndPoint> addrs = getAddresses(sourceAddress, 0, Network.EnableBoth, - Ice.EndpointSelectionType.Ordered, false, false); + List<EndPoint> addrs = getAddresses(sourceAddress, 0, EnableBoth, Ice.EndpointSelectionType.Ordered, + false, false); if(addrs.Count != 0) { return addrs[0]; diff --git a/csharp/src/Ice/NetworkProxy.cs b/csharp/src/Ice/NetworkProxy.cs index 424dc1a5e67..5eb6972b339 100644 --- a/csharp/src/Ice/NetworkProxy.cs +++ b/csharp/src/Ice/NetworkProxy.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System; using System.Net; using System.Net.Sockets; using System.Diagnostics; diff --git a/csharp/src/Ice/Object.cs b/csharp/src/Ice/Object.cs index a05266369e0..7198f308741 100644 --- a/csharp/src/Ice/Object.cs +++ b/csharp/src/Ice/Object.cs @@ -10,6 +10,7 @@ using System; using System.Threading.Tasks; using System.Diagnostics; +using System.ComponentModel; namespace Ice { @@ -28,7 +29,7 @@ namespace Ice /// <summary> /// the base interface for servants. /// </summary> - public interface Object : System.ICloneable + public interface Object : ICloneable { /// <summary> /// Tests whether this object supports a specific Slice interface. @@ -67,9 +68,9 @@ namespace Ice /// </summary> /// <param name="request">The details of the invocation.</param> /// <returns>The task if dispatched asynchronously, null otherwise.</returns> - Task<Ice.OutputStream> ice_dispatch(Request request); + Task<OutputStream> ice_dispatch(Request request); - Task<Ice.OutputStream> iceDispatch(IceInternal.Incoming inc, Current current); + Task<OutputStream> iceDispatch(IceInternal.Incoming inc, Current current); } /// <summary> @@ -110,7 +111,8 @@ namespace Ice return s.Equals(_ids[0]); } - public static Task<Ice.OutputStream> iceD_ice_isA(Ice.Object obj, IceInternal.Incoming inS, Current current) + [EditorBrowsable(EditorBrowsableState.Never)] + public static Task<OutputStream> iceD_ice_isA(Object obj, IceInternal.Incoming inS, Current current) { InputStream istr = inS.startReadParams(); var id = istr.readString(); @@ -132,7 +134,8 @@ namespace Ice // Nothing to do. } - public static Task<Ice.OutputStream> iceD_ice_ping(Ice.Object obj, IceInternal.Incoming inS, Current current) + [EditorBrowsable(EditorBrowsableState.Never)] + public static Task<OutputStream> iceD_ice_ping(Object obj, IceInternal.Incoming inS, Current current) { inS.readEmptyParams(); obj.ice_ping(current); @@ -150,7 +153,8 @@ namespace Ice return _ids; } - public static Task<Ice.OutputStream> iceD_ice_ids(Ice.Object obj, IceInternal.Incoming inS, Current current) + [EditorBrowsable(EditorBrowsableState.Never)] + public static Task<OutputStream> iceD_ice_ids(Object obj, IceInternal.Incoming inS, Current current) { inS.readEmptyParams(); var ret = obj.ice_ids(current); @@ -171,7 +175,8 @@ namespace Ice return _ids[0]; } - public static Task<Ice.OutputStream> iceD_ice_id(Ice.Object obj, IceInternal.Incoming inS, Current current) + [EditorBrowsable(EditorBrowsableState.Never)] + public static Task<OutputStream> iceD_ice_id(Object obj, IceInternal.Incoming inS, Current current) { inS.readEmptyParams(); var ret = obj.ice_id(current); @@ -202,19 +207,20 @@ namespace Ice /// </summary> /// <param name="request">The details of the invocation.</param> /// <returns>The task if dispatched asynchronously, null otherwise.</returns> - public virtual Task<Ice.OutputStream> ice_dispatch(Request request) + public virtual Task<OutputStream> ice_dispatch(Request request) { var inc = (IceInternal.Incoming)request; inc.startOver(); return iceDispatch(inc, inc.getCurrent()); } - public virtual Task<Ice.OutputStream> iceDispatch(IceInternal.Incoming inc, Current current) + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual Task<OutputStream> iceDispatch(IceInternal.Incoming inc, Current current) { - int pos = System.Array.BinarySearch(_all, current.operation); + int pos = Array.BinarySearch(_all, current.operation); if(pos < 0) { - throw new Ice.OperationNotExistException(current.id, current.facet, current.operation); + throw new OperationNotExistException(current.id, current.facet, current.operation); } switch(pos) @@ -238,21 +244,21 @@ namespace Ice } Debug.Assert(false); - throw new Ice.OperationNotExistException(current.id, current.facet, current.operation); + throw new OperationNotExistException(current.id, current.facet, current.operation); } private static string operationModeToString(OperationMode mode) { - if(mode == Ice.OperationMode.Normal) + if(mode == OperationMode.Normal) { return "::Ice::Normal"; } - if(mode == Ice.OperationMode.Nonmutating) + if(mode == OperationMode.Nonmutating) { return "::Ice::Nonmutating"; } - if(mode == Ice.OperationMode.Idempotent) + if(mode == OperationMode.Idempotent) { return "::Ice::Idempotent"; } @@ -273,7 +279,7 @@ namespace Ice } else { - Ice.MarshalException ex = new Ice.MarshalException(); + MarshalException ex = new MarshalException(); ex.reason = "unexpected operation mode. expected = " + operationModeToString(expected) + " received = " + operationModeToString(received); throw ex; @@ -287,7 +293,7 @@ namespace Ice /// derives a concrete servant class from Blobject that /// implements the Blobject.ice_invoke method. /// </summary> - public abstract class Blobject : Ice.ObjectImpl + public abstract class Blobject : ObjectImpl { /// <summary> /// Dispatch an incoming request. @@ -303,7 +309,8 @@ namespace Ice /// Ice run-time exception, it must throw it directly.</returns> public abstract bool ice_invoke(byte[] inParams, out byte[] outParams, Current current); - public override Task<Ice.OutputStream> iceDispatch(IceInternal.Incoming inS, Current current) + [EditorBrowsable(EditorBrowsableState.Never)] + public override Task<OutputStream> iceDispatch(IceInternal.Incoming inS, Current current) { byte[] inEncaps = inS.readParamEncaps(); byte[] outEncaps; @@ -313,17 +320,18 @@ namespace Ice } } - public abstract class BlobjectAsync : Ice.ObjectImpl + public abstract class BlobjectAsync : ObjectImpl { public abstract Task<Ice.Object_Ice_invokeResult> ice_invokeAsync(byte[] inEncaps, Current current); + [EditorBrowsable(EditorBrowsableState.Never)] public override Task<Ice.OutputStream> iceDispatch(IceInternal.Incoming inS, Current current) { byte[] inEncaps = inS.readParamEncaps(); - return ice_invokeAsync(inEncaps, current).ContinueWith((Task<Ice.Object_Ice_invokeResult> t) => + return ice_invokeAsync(inEncaps, current).ContinueWith((Task<Object_Ice_invokeResult> t) => { var ret = t.GetAwaiter().GetResult(); - return Task.FromResult<Ice.OutputStream>(inS.writeParamEncaps(ret.outEncaps, ret.returnValue)); + return Task.FromResult(inS.writeParamEncaps(ret.outEncaps, ret.returnValue)); }).Unwrap(); } } diff --git a/csharp/src/Ice/ObjectAdapterFactory.cs b/csharp/src/Ice/ObjectAdapterFactory.cs index 88c49c3c042..17ccfa91b1c 100644 --- a/csharp/src/Ice/ObjectAdapterFactory.cs +++ b/csharp/src/Ice/ObjectAdapterFactory.cs @@ -9,10 +9,7 @@ namespace IceInternal { - - using System.Collections; using System.Collections.Generic; - using System.Diagnostics; public sealed class ObjectAdapterFactory { diff --git a/csharp/src/Ice/ObjectAdapterI.cs b/csharp/src/Ice/ObjectAdapterI.cs index da1cb5df9ea..26523708c67 100644 --- a/csharp/src/Ice/ObjectAdapterI.cs +++ b/csharp/src/Ice/ObjectAdapterI.cs @@ -10,7 +10,6 @@ namespace Ice { using System; - using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Text; @@ -73,11 +72,11 @@ namespace Ice try { - Ice.Identity dummy = new Ice.Identity(); + Identity dummy = new Identity(); dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } - catch(Ice.LocalException) + catch(LocalException) { // // If we couldn't update the locator registry, we let the @@ -183,7 +182,7 @@ namespace Ice { updateLocatorRegistry(_locatorInfo, null); } - catch(Ice.LocalException) + catch(LocalException) { // // We can't throw exceptions in deactivate so we ignore @@ -327,12 +326,12 @@ namespace Ice } } - public ObjectPrx add(Ice.Object obj, Identity ident) + public ObjectPrx add(Object obj, Identity ident) { return addFacet(obj, ident, ""); } - public ObjectPrx addFacet(Ice.Object obj, Identity ident, string facet) + public ObjectPrx addFacet(Object obj, Identity ident, string facet) { lock(this) { @@ -354,12 +353,12 @@ namespace Ice } } - public ObjectPrx addWithUUID(Ice.Object obj) + public ObjectPrx addWithUUID(Object obj) { return addFacetWithUUID(obj, ""); } - public ObjectPrx addFacetWithUUID(Ice.Object obj, string facet) + public ObjectPrx addFacetWithUUID(Object obj, string facet) { Identity ident = new Identity(); ident.category = ""; @@ -380,12 +379,12 @@ namespace Ice } } - public Ice.Object remove(Identity ident) + public Object remove(Identity ident) { return removeFacet(ident, ""); } - public Ice.Object removeFacet(Identity ident, string facet) + public Object removeFacet(Identity ident, string facet) { lock(this) { @@ -396,7 +395,7 @@ namespace Ice } } - public Dictionary<string, Ice.Object> removeAllFacets(Identity ident) + public Dictionary<string, Object> removeAllFacets(Identity ident) { lock(this) { @@ -407,7 +406,7 @@ namespace Ice } } - public Ice.Object removeDefaultServant(string category) + public Object removeDefaultServant(string category) { lock(this) { @@ -417,12 +416,12 @@ namespace Ice } } - public Ice.Object find(Identity ident) + public Object find(Identity ident) { return findFacet(ident, ""); } - public Ice.Object findFacet(Identity ident, string facet) + public Object findFacet(Identity ident, string facet) { lock(this) { @@ -433,7 +432,7 @@ namespace Ice } } - public Dictionary<string, Ice.Object> findAllFacets(Identity ident) + public Dictionary<string, Object> findAllFacets(Identity ident) { lock(this) { @@ -444,7 +443,7 @@ namespace Ice } } - public Ice.Object findByProxy(ObjectPrx proxy) + public Object findByProxy(ObjectPrx proxy) { lock(this) { @@ -455,7 +454,7 @@ namespace Ice } } - public Ice.Object findDefaultServant(string category) + public Object findDefaultServant(string category) { lock(this) { @@ -572,11 +571,11 @@ namespace Ice try { - Ice.Identity dummy = new Ice.Identity(); + Identity dummy = new Identity(); dummy.name = "dummy"; updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); } - catch(Ice.LocalException) + catch(LocalException) { lock(this) { @@ -924,9 +923,9 @@ namespace Ice // if(_routerInfo.getAdapter() != null) { - Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); + AlreadyRegisteredException ex = new AlreadyRegisteredException(); ex.kindOfObject = "object adapter with router"; - ex.id = Ice.Util.identityToString(router.ice_getIdentity(), _instance.toStringMode()); + ex.id = Util.identityToString(router.ice_getIdentity(), _instance.toStringMode()); throw ex; } @@ -1098,7 +1097,7 @@ namespace Ice } } - private static void checkServant(Ice.Object servant) + private static void checkServant(Object servant) { if(servant == null) { @@ -1125,7 +1124,7 @@ namespace Ice end = beg; while(true) { - end = endpts.IndexOf((System.Char) ':', end); + end = endpts.IndexOf(':', end); if(end == -1) { end = endpts.Length; @@ -1137,14 +1136,14 @@ namespace Ice int quote = beg; while(true) { - quote = endpts.IndexOf((System.Char) '\"', quote); + quote = endpts.IndexOf('\"', quote); if(quote == -1 || end < quote) { break; } else { - quote = endpts.IndexOf((System.Char) '\"', ++quote); + quote = endpts.IndexOf('\"', ++quote); if(quote == -1) { break; @@ -1175,7 +1174,7 @@ namespace Ice EndpointI endp = _instance.endpointFactoryManager().create(s, oaEndpoints); if(endp == null) { - Ice.EndpointParseException e2 = new Ice.EndpointParseException(); + EndpointParseException e2 = new EndpointParseException(); e2.str = "invalid object adapter endpoint `" + s + "'"; throw e2; } @@ -1260,7 +1259,7 @@ namespace Ice { if(_instance.traceLevels().location >= 1) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the object adapter is not known to the locator registry"); _instance.initializationData().logger.trace(_instance.traceLevels().locationCat, s.ToString()); @@ -1275,7 +1274,7 @@ namespace Ice { if(_instance.traceLevels().location >= 1) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the replica group `" + _replicaGroupId + "' is not known to the locator registry"); _instance.initializationData().logger.trace(_instance.traceLevels().locationCat, s.ToString()); @@ -1290,7 +1289,7 @@ namespace Ice { if(_instance.traceLevels().location >= 1) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append("the object adapter endpoints are already set"); _instance.initializationData().logger.trace(_instance.traceLevels().locationCat, s.ToString()); @@ -1312,7 +1311,7 @@ namespace Ice { if(_instance.traceLevels().location >= 1) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); s.Append(e.ToString()); _instance.initializationData().logger.trace(_instance.traceLevels().locationCat, s.ToString()); @@ -1322,12 +1321,12 @@ namespace Ice if(_instance.traceLevels().location >= 1) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); + StringBuilder s = new StringBuilder(); s.Append("updated object adapter `" + _id + "' endpoints with the locator registry\n"); s.Append("endpoints = "); if(proxy != null) { - Ice.Endpoint[] endpoints = proxy.ice_getEndpoints(); + Endpoint[] endpoints = proxy.ice_getEndpoints(); for(int i = 0; i < endpoints.Length; i++) { s.Append(endpoints[i].ToString()); @@ -1388,7 +1387,7 @@ namespace Ice // Do not create unknown properties list if Ice prefix, ie Ice, Glacier2, etc // bool addUnknown = true; - String prefix = _name + "."; + string prefix = _name + "."; for(int i = 0; PropertyNames.clPropNames[i] != null; ++i) { if(prefix.StartsWith(PropertyNames.clPropNames[i] + ".", StringComparison.Ordinal)) @@ -1401,7 +1400,7 @@ namespace Ice bool noProps = true; Dictionary<string, string> props = _instance.initializationData().properties.getPropertiesForPrefix(prefix); - foreach(String prop in props.Keys) + foreach(string prop in props.Keys) { bool valid = false; for(int i = 0; i < _suffixes.Length; ++i) diff --git a/csharp/src/Ice/OpaqueEndpointI.cs b/csharp/src/Ice/OpaqueEndpointI.cs index a8749d4ec17..d0cf54e83aa 100644 --- a/csharp/src/Ice/OpaqueEndpointI.cs +++ b/csharp/src/Ice/OpaqueEndpointI.cs @@ -9,8 +9,6 @@ namespace IceInternal { - - using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Diagnostics; @@ -68,7 +66,7 @@ namespace IceInternal // public override string ice_toString_() { - string val = IceUtilInternal.Base64.encode(_rawBytes); + string val = System.Convert.ToBase64String(_rawBytes); return "opaque -t " + _type + " -e " + Ice.Util.encodingVersionToString(_rawEncoding) + " -v " + val; } @@ -259,7 +257,7 @@ namespace IceInternal s += " -e " + Ice.Util.encodingVersionToString(_rawEncoding); if(_rawBytes.Length > 0) { - s += " -v " + IceUtilInternal.Base64.encode(_rawBytes); + s += " -v " + System.Convert.ToBase64String(_rawBytes); } return s; } @@ -377,16 +375,16 @@ namespace IceInternal throw new Ice.EndpointParseException("no argument provided for -v option in endpoint " + endpoint); } - for(int j = 0; j < argument.Length; ++j) + + try + { + _rawBytes = System.Convert.FromBase64String(argument); + } + catch(System.FormatException ex) { - if(!IceUtilInternal.Base64.isBase64(argument[j])) - { - throw new Ice.EndpointParseException("invalid base64 character `" + argument[j] + - "' (ordinal " + ((int)argument[j]) + - ") in endpoint " + endpoint); - } + throw new Ice.EndpointParseException("Invalid Base64 input in endpoint " + endpoint, ex); } - _rawBytes = IceUtilInternal.Base64.decode(argument); + return true; } @@ -419,9 +417,9 @@ namespace IceInternal private void calcHashValue() { int h = 5381; - IceInternal.HashUtil.hashAdd(ref h, _type); - IceInternal.HashUtil.hashAdd(ref h, _rawEncoding); - IceInternal.HashUtil.hashAdd(ref h, _rawBytes); + HashUtil.hashAdd(ref h, _type); + HashUtil.hashAdd(ref h, _rawEncoding); + HashUtil.hashAdd(ref h, _rawBytes); _hashCode = h; } diff --git a/csharp/src/Ice/Optional.cs b/csharp/src/Ice/Optional.cs index 0aaa95ee32f..574f1137076 100644 --- a/csharp/src/Ice/Optional.cs +++ b/csharp/src/Ice/Optional.cs @@ -106,7 +106,7 @@ namespace Ice { if(!_isSet) { - throw new System.InvalidOperationException(); + throw new InvalidOperationException(); } return _value; } @@ -126,7 +126,7 @@ namespace Ice public override bool Equals(object other) { - if(object.ReferenceEquals(this, other)) + if(ReferenceEquals(this, other)) { return true; } @@ -218,7 +218,7 @@ namespace Ice // However, when v is null, the optional might be cleared, which // is not the result we want. // - this.value = new Optional<T>((T)v); + value = new Optional<T>((T)v); } else { diff --git a/csharp/src/Ice/Options.cs b/csharp/src/Ice/Options.cs index d8fb7a9958a..08fd29ed127 100644 --- a/csharp/src/Ice/Options.cs +++ b/csharp/src/Ice/Options.cs @@ -401,7 +401,7 @@ namespace IceUtilInternal } } - return (string[])vec.ToArray(); + return vec.ToArray(); } } } diff --git a/csharp/src/Ice/OutgoingAsync.cs b/csharp/src/Ice/OutgoingAsync.cs index 04c6069f7e9..db0e76d2bc7 100644 --- a/csharp/src/Ice/OutgoingAsync.cs +++ b/csharp/src/Ice/OutgoingAsync.cs @@ -159,7 +159,7 @@ namespace IceInternal } } - public virtual void cancelable(IceInternal.CancellationHandler handler) + public virtual void cancelable(CancellationHandler handler) { lock(this) { diff --git a/csharp/src/Ice/OutputStream.cs b/csharp/src/Ice/OutputStream.cs index 2dc2521c443..9b4130fe52a 100644 --- a/csharp/src/Ice/OutputStream.cs +++ b/csharp/src/Ice/OutputStream.cs @@ -455,7 +455,7 @@ namespace Ice if(v > 254) { expand(5); - _buf.b.put((byte)255); + _buf.b.put(255); _buf.b.putInt(v); } else @@ -1903,7 +1903,7 @@ namespace Ice /// </summary> /// <param name="tag">The optional tag.</param> /// <param name="v">The optional string sequence to write to the stream.</param> - public void writeStringSeq(int tag, Optional<String[]> v) + public void writeStringSeq(int tag, Optional<string[]> v) { if(v.HasValue) { @@ -2490,7 +2490,7 @@ namespace Ice _current.sliceFlagsPos = _stream.pos(); - _current.sliceFlags = (byte)0; + _current.sliceFlags = 0; if(_encaps.format == FormatType.SlicedFormat) { // @@ -2503,7 +2503,7 @@ namespace Ice _current.sliceFlags |= Protocol.FLAG_IS_LAST_SLICE; // This is the last slice. } - _stream.writeByte((byte)0); // Placeholder for the slice flags + _stream.writeByte(0); // Placeholder for the slice flags // // For instance slices, encode the flag and the type ID either as a @@ -2562,7 +2562,7 @@ namespace Ice // if((_current.sliceFlags & Protocol.FLAG_HAS_OPTIONAL_MEMBERS) != 0) { - _stream.writeByte((byte)Protocol.OPTIONAL_END_MARKER); + _stream.writeByte(Protocol.OPTIONAL_END_MARKER); } // @@ -2712,7 +2712,7 @@ namespace Ice previous.next = this; } this.previous = previous; - this.next = null; + next = null; } // Instance attributes diff --git a/csharp/src/Ice/PluginManagerI.cs b/csharp/src/Ice/PluginManagerI.cs index 54bf2b2e4b7..ee2a4117064 100644 --- a/csharp/src/Ice/PluginManagerI.cs +++ b/csharp/src/Ice/PluginManagerI.cs @@ -168,8 +168,8 @@ namespace Ice } catch(System.Exception ex) { - Ice.Util.getProcessLogger().warning("unexpected exception raised by plug-in `" + - p.name + "' destruction:\n" + ex.ToString()); + Util.getProcessLogger().warning("unexpected exception raised by plug-in `" + + p.name + "' destruction:\n" + ex.ToString()); } } } @@ -433,13 +433,13 @@ namespace Ice throw e; } } - catch(System.InvalidCastException ex) + catch(InvalidCastException ex) { PluginInitializationException e = new PluginInitializationException(ex); e.reason = err + "InvalidCastException to Ice.PluginFactory"; throw e; } - catch(System.UnauthorizedAccessException ex) + catch(UnauthorizedAccessException ex) { PluginInitializationException e = new PluginInitializationException(ex); e.reason = err + "UnauthorizedAccessException: " + ex.ToString(); diff --git a/csharp/src/Ice/PropertiesAdminI.cs b/csharp/src/Ice/PropertiesAdminI.cs index 0dbd4e5bc1f..d8cafda5007 100644 --- a/csharp/src/Ice/PropertiesAdminI.cs +++ b/csharp/src/Ice/PropertiesAdminI.cs @@ -9,7 +9,6 @@ using System; using System.Collections.Generic; -using System.Threading.Tasks; namespace Ice { @@ -31,7 +30,7 @@ namespace IceInternal { sealed class PropertiesAdminI : Ice.PropertiesAdminDisp_, Ice.NativePropertiesAdmin { - internal PropertiesAdminI(IceInternal.Instance instance) + internal PropertiesAdminI(Instance instance) { _properties = instance.initializationData().properties; _logger = instance.initializationData().logger; diff --git a/csharp/src/Ice/PropertiesI.cs b/csharp/src/Ice/PropertiesI.cs index be5a5e9be32..5e8ac519ea6 100644 --- a/csharp/src/Ice/PropertiesI.cs +++ b/csharp/src/Ice/PropertiesI.cs @@ -84,12 +84,12 @@ namespace Ice pv.used = true; try { - return System.Int32.Parse(pv.val, CultureInfo.InvariantCulture); + return int.Parse(pv.val, CultureInfo.InvariantCulture); } - catch(System.FormatException) + catch(FormatException) { - Ice.Util.getProcessLogger().warning("numeric property " + key + - " set to non-numeric value, defaulting to " + val); + Util.getProcessLogger().warning("numeric property " + key + + " set to non-numeric value, defaulting to " + val); return val; } } @@ -120,8 +120,8 @@ namespace Ice string[] result = IceUtilInternal.StringUtil.splitString(pv.val, ", \t\r\n"); if(result == null) { - Ice.Util.getProcessLogger().warning("mismatched quotes in property " + key - + "'s value, returning default value"); + Util.getProcessLogger().warning("mismatched quotes in property " + key + + "'s value, returning default value"); return val; } else @@ -142,7 +142,7 @@ namespace Ice { if(prefix.Length == 0 || s.StartsWith(prefix, StringComparison.Ordinal)) { - PropertyValue pv = (PropertyValue)_properties[s]; + PropertyValue pv = _properties[s]; pv.used = true; result[s] = pv.val; } @@ -162,13 +162,13 @@ namespace Ice } if(key == null || key.Length == 0) { - throw new Ice.InitializationException("Attempt to set property with empty key"); + throw new InitializationException("Attempt to set property with empty key"); } // // Check if the property is legal. // - Logger logger = Ice.Util.getProcessLogger(); + Logger logger = Util.getProcessLogger(); int dotPos = key.IndexOf('.'); if(dotPos != -1) { @@ -343,7 +343,7 @@ namespace Ice } catch(System.IO.IOException ex) { - Ice.FileException fe = new Ice.FileException(ex); + FileException fe = new FileException(ex); fe.path = file; throw fe; } @@ -420,7 +420,7 @@ namespace Ice } else { - _properties["Ice.ProgramName"] = new PropertyValue(System.AppDomain.CurrentDomain.FriendlyName, true); + _properties["Ice.ProgramName"] = new PropertyValue(AppDomain.CurrentDomain.FriendlyName, true); } bool loadConfigFiles = false; @@ -438,10 +438,10 @@ namespace Ice loadConfigFiles = true; string[] arr = new string[args.Length - 1]; - System.Array.Copy(args, 0, arr, 0, i); + Array.Copy(args, 0, arr, 0, i); if(i < args.Length - 1) { - System.Array.Copy(args, i + 1, arr, i, args.Length - i - 1); + Array.Copy(args, i + 1, arr, i, args.Length - i - 1); } args = arr; } @@ -639,7 +639,7 @@ namespace Ice if((state == ParseStateKey && key.Length != 0) || (state == ParseStateValue && key.Length == 0)) { - Ice.Util.getProcessLogger().warning("invalid config file entry: \"" + line + "\""); + Util.getProcessLogger().warning("invalid config file entry: \"" + line + "\""); return; } else if(key.Length == 0) @@ -655,7 +655,7 @@ namespace Ice string val = getProperty("Ice.Config"); if(val.Length == 0 || val.Equals("1")) { - string s = System.Environment.GetEnvironmentVariable("ICE_CONFIG"); + string s = Environment.GetEnvironmentVariable("ICE_CONFIG"); if(s != null && s.Length != 0) { val = s; diff --git a/csharp/src/Ice/Protocol.cs b/csharp/src/Ice/Protocol.cs index 8db65a45542..70cde8614fd 100644 --- a/csharp/src/Ice/Protocol.cs +++ b/csharp/src/Ice/Protocol.cs @@ -28,8 +28,7 @@ namespace IceInternal // // The magic number at the front of each message // - internal static readonly byte[] magic - = new byte[] { (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50 }; // 'I', 'c', 'e', 'P' + internal static readonly byte[] magic = new byte[] { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P' // // The current Ice protocol and encoding version @@ -44,13 +43,13 @@ namespace IceInternal public const byte OPTIONAL_END_MARKER = 0xFF; - public const byte FLAG_HAS_TYPE_ID_STRING = (byte)(1<<0); - public const byte FLAG_HAS_TYPE_ID_INDEX = (byte)(1<<1); - public const byte FLAG_HAS_TYPE_ID_COMPACT = (byte)(1<<1 | 1<<0); - public const byte FLAG_HAS_OPTIONAL_MEMBERS = (byte)(1<<2); - public const byte FLAG_HAS_INDIRECTION_TABLE = (byte)(1<<3); - public const byte FLAG_HAS_SLICE_SIZE = (byte)(1<<4); - public const byte FLAG_IS_LAST_SLICE = (byte)(1<<5); + public const byte FLAG_HAS_TYPE_ID_STRING = (1<<0); + public const byte FLAG_HAS_TYPE_ID_INDEX = (1<<1); + public const byte FLAG_HAS_TYPE_ID_COMPACT = (1<<1 | 1<<0); + public const byte FLAG_HAS_OPTIONAL_MEMBERS = (1<<2); + public const byte FLAG_HAS_INDIRECTION_TABLE = (1<<3); + public const byte FLAG_HAS_SLICE_SIZE = (1<<4); + public const byte FLAG_IS_LAST_SLICE = (1<<5); // // The Ice protocol message types @@ -63,37 +62,34 @@ namespace IceInternal internal static readonly byte[] requestHdr = new byte[] { - IceInternal.Protocol.magic[0], IceInternal.Protocol.magic[1], IceInternal.Protocol.magic[2], - IceInternal.Protocol.magic[3], - IceInternal.Protocol.protocolMajor, IceInternal.Protocol.protocolMinor, - IceInternal.Protocol.protocolEncodingMajor, IceInternal.Protocol.protocolEncodingMinor, - IceInternal.Protocol.requestMsg, - (byte)0, // Compression status. - (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). - (byte)0, (byte)0, (byte)0, (byte)0 // Request ID (placeholder). + magic[0], magic[1], magic[2], magic[3], + protocolMajor, protocolMinor, + protocolEncodingMajor, protocolEncodingMinor, + requestMsg, + 0, // Compression status. + 0, 0, 0, 0, // Message size (placeholder). + 0, 0, 0, 0 // Request ID (placeholder). }; internal static readonly byte[] requestBatchHdr = new byte[] { - IceInternal.Protocol.magic[0], IceInternal.Protocol.magic[1], IceInternal.Protocol.magic[2], - IceInternal.Protocol.magic[3], - IceInternal.Protocol.protocolMajor, IceInternal.Protocol.protocolMinor, - IceInternal.Protocol.protocolEncodingMajor, IceInternal.Protocol.protocolEncodingMinor, - IceInternal.Protocol.requestBatchMsg, - (byte)0, // Compression status. - (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). - (byte)0, (byte)0, (byte)0, (byte)0 // Number of requests in batch (placeholder). + magic[0], magic[1], magic[2], magic[3], + protocolMajor, protocolMinor, + protocolEncodingMajor, protocolEncodingMinor, + requestBatchMsg, + 0, // Compression status. + 0, 0, 0, 0, // Message size (placeholder). + 0, 0, 0, 0 // Number of requests in batch (placeholder). }; internal static readonly byte[] replyHdr = new byte[] { - IceInternal.Protocol.magic[0], IceInternal.Protocol.magic[1], IceInternal.Protocol.magic[2], - IceInternal.Protocol.magic[3], - IceInternal.Protocol.protocolMajor, IceInternal.Protocol.protocolMinor, - IceInternal.Protocol.protocolEncodingMajor, IceInternal.Protocol.protocolEncodingMinor, - IceInternal.Protocol.replyMsg, - (byte)0, // Compression status. - (byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder). + magic[0], magic[1], magic[2], magic[3], + protocolMajor, protocolMinor, + protocolEncodingMajor, protocolEncodingMinor, + replyMsg, + 0, // Compression status. + 0, 0, 0, 0 // Message size (placeholder). }; internal static void diff --git a/csharp/src/Ice/ProtocolPluginFacade.cs b/csharp/src/Ice/ProtocolPluginFacade.cs index cde21ecb7b1..8f88ac6dad5 100644 --- a/csharp/src/Ice/ProtocolPluginFacade.cs +++ b/csharp/src/Ice/ProtocolPluginFacade.cs @@ -38,7 +38,7 @@ namespace IceInternal public ProtocolPluginFacadeI(Ice.Communicator communicator) { _communicator = communicator; - _instance = IceInternal.Util.getInstance(communicator); + _instance = Util.getInstance(communicator); } // diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index 78ec0f9ecbe..4bdf1f466c2 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -13,6 +13,7 @@ using System.Diagnostics; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; +using System.ComponentModel; using IceUtilInternal; using IceInternal; @@ -767,6 +768,7 @@ namespace Ice /// Write a proxy to the output stream. /// </summary> /// <param name="os">Output stream object to write the proxy.</param> + [EditorBrowsable(EditorBrowsableState.Never)] void iceWrite(OutputStream os); } @@ -2399,17 +2401,20 @@ namespace Ice return !Equals(lhs, rhs); } + [EditorBrowsable(EditorBrowsableState.Never)] public void iceWrite(OutputStream os) { _reference.getIdentity().ice_writeMembers(os); _reference.streamWrite(os); } + [EditorBrowsable(EditorBrowsableState.Never)] public Reference iceReference() { return _reference; } + [EditorBrowsable(EditorBrowsableState.Never)] public void iceCopyFrom(ObjectPrx from) { lock(from) @@ -2420,6 +2425,7 @@ namespace Ice } } + [EditorBrowsable(EditorBrowsableState.Never)] public int iceHandleException(Exception ex, RequestHandler handler, OperationMode mode, bool sent, ref int cnt) { @@ -2465,6 +2471,7 @@ namespace Ice } } + [EditorBrowsable(EditorBrowsableState.Never)] public void iceCheckAsyncTwowayOnly(string name) { // @@ -2478,6 +2485,7 @@ namespace Ice } } + [EditorBrowsable(EditorBrowsableState.Never)] public RequestHandler iceGetRequestHandler() { if(_reference.getCacheConnection()) @@ -2493,6 +2501,7 @@ namespace Ice return _reference.getRequestHandler(this); } + [EditorBrowsable(EditorBrowsableState.Never)] public BatchRequestQueue iceGetBatchRequestQueue() { @@ -2506,6 +2515,7 @@ namespace Ice } } + [EditorBrowsable(EditorBrowsableState.Never)] public RequestHandler iceSetRequestHandler(RequestHandler handler) { @@ -2523,6 +2533,7 @@ namespace Ice return handler; } + [EditorBrowsable(EditorBrowsableState.Never)] public void iceUpdateRequestHandler(RequestHandler previous, RequestHandler handler) { if(_reference.getCacheConnection() && previous != null) @@ -2728,6 +2739,12 @@ namespace Ice } } + /// <summary> + /// Only for internal use by OutgoingAsync + /// </summary> + /// <param name="iss"></param> + /// <param name="os"></param> + [EditorBrowsable(EditorBrowsableState.Never)] public void cacheMessageBuffers(InputStream iss, OutputStream os) { @@ -2748,6 +2765,7 @@ namespace Ice /// Only for internal use by ProxyFactory /// </summary> /// <param name="ref"></param> + [EditorBrowsable(EditorBrowsableState.Never)] public void setup(Reference @ref) { // diff --git a/csharp/src/Ice/ProxyFactory.cs b/csharp/src/Ice/ProxyFactory.cs index 012a26b0afe..178d073150b 100644 --- a/csharp/src/Ice/ProxyFactory.cs +++ b/csharp/src/Ice/ProxyFactory.cs @@ -247,7 +247,7 @@ namespace IceInternal try { - v = System.Int32.Parse(arr[i], CultureInfo.InvariantCulture); + v = int.Parse(arr[i], CultureInfo.InvariantCulture); } catch(System.FormatException) { diff --git a/csharp/src/Ice/ProxyIdentityKey.cs b/csharp/src/Ice/ProxyIdentityKey.cs index 0766b3c2297..60e46cd3737 100644 --- a/csharp/src/Ice/ProxyIdentityKey.cs +++ b/csharp/src/Ice/ProxyIdentityKey.cs @@ -27,7 +27,7 @@ namespace Ice public int GetHashCode(object obj) { int h = 5381; - IceInternal.HashUtil.hashAdd(ref h, ((Ice.ObjectPrx)obj).ice_getIdentity()); + IceInternal.HashUtil.hashAdd(ref h, ((ObjectPrx)obj).ice_getIdentity()); return h; } @@ -55,18 +55,18 @@ namespace Ice /// 0, otherwise.</returns> public int Compare(object obj1, object obj2) { - Ice.ObjectPrx proxy1 = obj1 as Ice.ObjectPrx; + ObjectPrx proxy1 = obj1 as ObjectPrx; if(obj1 != null && proxy1 == null) { - throw new System.ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj1"); + throw new ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj1"); } - Ice.ObjectPrx proxy2 = obj2 as Ice.ObjectPrx; + ObjectPrx proxy2 = obj2 as ObjectPrx; if(obj2 != null && proxy2 == null) { - throw new System.ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj2"); + throw new ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj2"); } - return Ice.Util.proxyIdentityCompare(proxy1, proxy2); + return Util.proxyIdentityCompare(proxy1, proxy2); } } @@ -84,8 +84,8 @@ namespace Ice /// <returns>The hash value for the proxy based on the identity and facet.</returns> public int GetHashCode(object obj) { - Ice.ObjectPrx o = (Ice.ObjectPrx)obj; - Ice.Identity identity = o.ice_getIdentity(); + ObjectPrx o = (ObjectPrx)obj; + Identity identity = o.ice_getIdentity(); string facet = o.ice_getFacet(); int h = 5381; IceInternal.HashUtil.hashAdd(ref h, identity); @@ -117,18 +117,18 @@ namespace Ice /// 0, otherwise.</returns> public int Compare(object obj1, object obj2) { - Ice.ObjectPrx proxy1 = obj1 as Ice.ObjectPrx; + ObjectPrx proxy1 = obj1 as ObjectPrx; if(obj1 != null && proxy1 == null) { - throw new System.ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj1"); + throw new ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj1"); } - Ice.ObjectPrx proxy2 = obj2 as Ice.ObjectPrx; + ObjectPrx proxy2 = obj2 as ObjectPrx; if(obj2 != null && proxy2 == null) { - throw new System.ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj2"); + throw new ArgumentException("Argument must be derived from Ice.ObjectPrx", "obj2"); } - return Ice.Util.proxyIdentityAndFacetCompare(proxy1, proxy2); + return Util.proxyIdentityAndFacetCompare(proxy1, proxy2); } } diff --git a/csharp/src/Ice/Reference.cs b/csharp/src/Ice/Reference.cs index 6aa49ecac17..7c951193cac 100644 --- a/csharp/src/Ice/Reference.cs +++ b/csharp/src/Ice/Reference.cs @@ -92,7 +92,7 @@ namespace IceInternal public abstract bool getPreferSecure(); public abstract Ice.EndpointSelectionType getEndpointSelection(); public abstract int getLocatorCacheTimeout(); - public abstract String getConnectionId(); + public abstract string getConnectionId(); // // The change* methods (here and in derived classes) create @@ -218,19 +218,19 @@ namespace IceInternal return hashValue_; } int h = 5381; - IceInternal.HashUtil.hashAdd(ref h, _mode); - IceInternal.HashUtil.hashAdd(ref h, secure_); - IceInternal.HashUtil.hashAdd(ref h, _identity); - IceInternal.HashUtil.hashAdd(ref h, _context); - IceInternal.HashUtil.hashAdd(ref h, _facet); - IceInternal.HashUtil.hashAdd(ref h, overrideCompress_); + HashUtil.hashAdd(ref h, _mode); + HashUtil.hashAdd(ref h, secure_); + HashUtil.hashAdd(ref h, _identity); + HashUtil.hashAdd(ref h, _context); + HashUtil.hashAdd(ref h, _facet); + HashUtil.hashAdd(ref h, overrideCompress_); if(overrideCompress_) { - IceInternal.HashUtil.hashAdd(ref h, compress_); + HashUtil.hashAdd(ref h, compress_); } - IceInternal.HashUtil.hashAdd(ref h, _protocol); - IceInternal.HashUtil.hashAdd(ref h, _encoding); - IceInternal.HashUtil.hashAdd(ref h, _invocationTimeout); + HashUtil.hashAdd(ref h, _protocol); + HashUtil.hashAdd(ref h, _encoding); + HashUtil.hashAdd(ref h, _invocationTimeout); hashValue_ = h; hashInitialized_ = true; return hashValue_; @@ -459,7 +459,7 @@ namespace IceInternal return true; } - public Object Clone() + public object Clone() { // // A member-wise copy is safe because the members are immutable. @@ -519,7 +519,7 @@ namespace IceInternal compress_ = false; } - protected static System.Random rand_ = new System.Random(unchecked((int)System.DateTime.Now.Ticks)); + protected static Random rand_ = new Random(unchecked((int)DateTime.Now.Ticks)); } public class FixedReference : Reference @@ -528,7 +528,7 @@ namespace IceInternal Ice.Communicator communicator, Ice.Identity identity, string facet, - Reference.Mode mode, + Mode mode, bool secure, Ice.EncodingVersion encoding, Ice.ConnectionI connection) @@ -671,9 +671,9 @@ namespace IceInternal { switch(getMode()) { - case Reference.Mode.ModeTwoway: - case Reference.Mode.ModeOneway: - case Reference.Mode.ModeBatchOneway: + case Mode.ModeTwoway: + case Mode.ModeOneway: + case Mode.ModeBatchOneway: { if(_fixedConnection.endpoint().datagram()) { @@ -682,8 +682,8 @@ namespace IceInternal break; } - case Reference.Mode.ModeDatagram: - case Reference.Mode.ModeBatchDatagram: + case Mode.ModeDatagram: + case Mode.ModeBatchDatagram: { if(!_fixedConnection.endpoint().datagram()) { @@ -728,9 +728,7 @@ namespace IceInternal compress = _fixedConnection.endpoint().compress(); } - return ((Ice.ObjectPrxHelperBase)proxy).iceSetRequestHandler(new ConnectionRequestHandler(this, - _fixedConnection, - compress)); + return proxy.iceSetRequestHandler(new ConnectionRequestHandler(this, _fixedConnection, compress)); } public override BatchRequestQueue getBatchRequestQueue() @@ -740,7 +738,7 @@ namespace IceInternal public override bool Equals(object obj) { - if(object.ReferenceEquals(this, obj)) + if(ReferenceEquals(this, obj)) { return true; } @@ -852,7 +850,7 @@ namespace IceInternal public override Reference changeEndpoints(EndpointI[] newEndpoints) { - if(Array.Equals(newEndpoints, _endpoints)) + if(Equals(newEndpoints, _endpoints)) { return this; } @@ -1090,7 +1088,7 @@ namespace IceInternal if(_routerInfo != null) { Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)_routerInfo.getRouter(); - Dictionary<String, String> routerProperties = h.iceReference().toProperty(prefix + ".Router"); + Dictionary<string, string> routerProperties = h.iceReference().toProperty(prefix + ".Router"); foreach(KeyValuePair<string, string> entry in routerProperties) { properties[entry.Key] = entry.Value; @@ -1100,7 +1098,7 @@ namespace IceInternal if(_locatorInfo != null) { Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)_locatorInfo.getLocator(); - Dictionary<String, String> locatorProperties = h.iceReference().toProperty(prefix + ".Locator"); + Dictionary<string, string> locatorProperties = h.iceReference().toProperty(prefix + ".Locator"); foreach(KeyValuePair<string, string> entry in locatorProperties) { properties[entry.Key] = entry.Value; @@ -1120,7 +1118,7 @@ namespace IceInternal if(!hashInitialized_) { int h = base.GetHashCode(); // Initializes hashValue_. - IceInternal.HashUtil.hashAdd(ref h, _adapterId); + HashUtil.hashAdd(ref h, _adapterId); hashValue_ = h; } return hashValue_; @@ -1129,7 +1127,7 @@ namespace IceInternal public override bool Equals(object obj) { - if(Object.ReferenceEquals(this, obj)) + if(ReferenceEquals(this, obj)) { return true; } @@ -1196,7 +1194,6 @@ namespace IceInternal return true; } - private sealed class RouterEndpointsCallback : RouterInfo.GetClientEndpointsCallback { internal RouterEndpointsCallback(RoutableReference ir, GetConnectionCallback cb) @@ -1353,7 +1350,7 @@ namespace IceInternal Ice.Communicator communicator, Ice.Identity identity, string facet, - Reference.Mode mode, + Mode mode, bool secure, Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, @@ -1420,7 +1417,7 @@ namespace IceInternal // for(int i = 0; i < allEndpoints.Length; i++) { - if(!(allEndpoints[i] is IceInternal.OpaqueEndpointI)) + if(!(allEndpoints[i] is OpaqueEndpointI)) { endpoints.Add(allEndpoints[i]); } @@ -1431,9 +1428,9 @@ namespace IceInternal // switch(getMode()) { - case Reference.Mode.ModeTwoway: - case Reference.Mode.ModeOneway: - case Reference.Mode.ModeBatchOneway: + case Mode.ModeTwoway: + case Mode.ModeOneway: + case Mode.ModeBatchOneway: { // // Filter out datagram endpoints. @@ -1450,8 +1447,8 @@ namespace IceInternal break; } - case Reference.Mode.ModeDatagram: - case Reference.Mode.ModeBatchDatagram: + case Mode.ModeDatagram: + case Mode.ModeBatchDatagram: { // // Filter out non-datagram endpoints. @@ -1623,14 +1620,14 @@ namespace IceInternal } } - private class EndpointComparator : IComparer<IceInternal.EndpointI> + private class EndpointComparator : IComparer<EndpointI> { public EndpointComparator(bool preferSecure) { _preferSecure = preferSecure; } - public int Compare(IceInternal.EndpointI le, IceInternal.EndpointI re) + public int Compare(EndpointI le, EndpointI re) { bool ls = le.secure(); bool rs = re.secure(); diff --git a/csharp/src/Ice/ReferenceFactory.cs b/csharp/src/Ice/ReferenceFactory.cs index b7716a1914a..f583c6d08d2 100644 --- a/csharp/src/Ice/ReferenceFactory.cs +++ b/csharp/src/Ice/ReferenceFactory.cs @@ -262,7 +262,7 @@ namespace IceInternal { facet = IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.Length, ""); } - catch(System.ArgumentException argEx) + catch(ArgumentException argEx) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid facet in `" + s + "': " + argEx.Message; @@ -421,14 +421,14 @@ namespace IceInternal int quote = beg; while(true) { - quote = s.IndexOf((System.Char) '\"', quote); + quote = s.IndexOf('\"', quote); if(quote == -1 || end < quote) { break; } else { - quote = s.IndexOf((System.Char) '\"', ++quote); + quote = s.IndexOf('\"', ++quote); if(quote == -1) { break; @@ -476,7 +476,7 @@ namespace IceInternal for(int idx = 0; idx < sz; ++idx) { msg.Append(" `"); - msg.Append((string)unknownEndpoints[idx]); + msg.Append(unknownEndpoints[idx]); msg.Append("'"); } _instance.initializationData().logger.warning(msg.ToString()); @@ -530,7 +530,7 @@ namespace IceInternal { adapter = IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length, ""); } - catch(System.ArgumentException argEx) + catch(ArgumentException argEx) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid adapter id in `" + s + "': " + argEx.Message; @@ -580,7 +580,7 @@ namespace IceInternal facet = ""; } - int mode = (int)s.readByte(); + int mode = s.readByte(); if(mode < 0 || mode > (int)Reference.Mode.ModeLast) { throw new Ice.ProxyUnmarshalException(); @@ -682,14 +682,14 @@ namespace IceInternal }; private void - checkForUnknownProperties(String prefix) + checkForUnknownProperties(string prefix) { // // Do not warn about unknown properties if Ice prefix, ie Ice, Glacier2, etc // - for(int i = 0; IceInternal.PropertyNames.clPropNames[i] != null; ++i) + for(int i = 0; PropertyNames.clPropNames[i] != null; ++i) { - if(prefix.StartsWith(IceInternal.PropertyNames.clPropNames[i] + ".", StringComparison.Ordinal)) + if(prefix.StartsWith(PropertyNames.clPropNames[i] + ".", StringComparison.Ordinal)) { return; } @@ -698,7 +698,7 @@ namespace IceInternal List<string> unknownProps = new List<string>(); Dictionary<string, string> props = _instance.initializationData().properties.getPropertiesForPrefix(prefix + "."); - foreach(String prop in props.Keys) + foreach(string prop in props.Keys) { bool valid = false; for(int i = 0; i < _suffixes.Length; ++i) diff --git a/csharp/src/Ice/RouterInfo.cs b/csharp/src/Ice/RouterInfo.cs index 87f786ff0f2..51b99ec7250 100644 --- a/csharp/src/Ice/RouterInfo.cs +++ b/csharp/src/Ice/RouterInfo.cs @@ -44,9 +44,9 @@ namespace IceInternal } } - public override bool Equals(System.Object obj) + public override bool Equals(object obj) { - if(object.ReferenceEquals(this, obj)) + if(ReferenceEquals(this, obj)) { return true; } diff --git a/csharp/src/Ice/StreamSocket.cs b/csharp/src/Ice/StreamSocket.cs index cae0fdbd0a3..97aac5bb781 100644 --- a/csharp/src/Ice/StreamSocket.cs +++ b/csharp/src/Ice/StreamSocket.cs @@ -35,7 +35,7 @@ namespace IceInternal _state = StateConnected; try { - _desc = IceInternal.Network.fdToString(_fd); + _desc = Network.fdToString(_fd); } catch(Exception) { @@ -111,12 +111,12 @@ namespace IceInternal public int getSendPacketSize(int length) { - return _maxSendPacketSize > 0 ? System.Math.Min(length, _maxSendPacketSize) : length; + return _maxSendPacketSize > 0 ? Math.Min(length, _maxSendPacketSize) : length; } public int getRecvPacketSize(int length) { - return _maxRecvPacketSize > 0 ? System.Math.Min(length, _maxRecvPacketSize) : length; + return _maxRecvPacketSize > 0 ? Math.Min(length, _maxRecvPacketSize) : length; } public void setBufferSize(int rcvSize, int sndSize) @@ -474,8 +474,8 @@ namespace IceInternal // connection timeout could easily be triggered when // receiging/sending large messages. // - _maxSendPacketSize = System.Math.Max(512, Network.getSendBufferSize(_fd)); - _maxRecvPacketSize = System.Math.Max(512, Network.getRecvBufferSize(_fd)); + _maxSendPacketSize = Math.Max(512, Network.getSendBufferSize(_fd)); + _maxRecvPacketSize = Math.Max(512, Network.getRecvBufferSize(_fd)); } private int toState(int operation) @@ -492,7 +492,7 @@ namespace IceInternal } private readonly ProtocolInstance _instance; - private readonly IceInternal.NetworkProxy _proxy; + private readonly NetworkProxy _proxy; private readonly EndPoint _addr; private readonly EndPoint _sourceAddr; diff --git a/csharp/src/Ice/StreamWrapper.cs b/csharp/src/Ice/StreamWrapper.cs index 9f3196204dc..c832726aa06 100644 --- a/csharp/src/Ice/StreamWrapper.cs +++ b/csharp/src/Ice/StreamWrapper.cs @@ -34,7 +34,7 @@ namespace IceInternal // as a single byte, followed by the contents of the _bytes buffer. // - public class OutputStreamWrapper : System.IO.Stream, System.IDisposable + public class OutputStreamWrapper : Stream, System.IDisposable { public OutputStreamWrapper(Ice.OutputStream s) { @@ -233,7 +233,7 @@ namespace IceInternal private long _length; } - public class InputStreamWrapper : System.IO.Stream, System.IDisposable + public class InputStreamWrapper : Stream, System.IDisposable { public InputStreamWrapper(int size, Ice.InputStream s) { diff --git a/csharp/src/Ice/StringUtil.cs b/csharp/src/Ice/StringUtil.cs index d2e90bd9a52..e5669c2ed2c 100644 --- a/csharp/src/Ice/StringUtil.cs +++ b/csharp/src/Ice/StringUtil.cs @@ -67,7 +67,7 @@ namespace IceUtilInternal for(int i = start; i < len; i++) { char ch = str[i]; - if(match.IndexOf((char) ch) == -1) + if(match.IndexOf(ch) == -1) { return i; } @@ -249,13 +249,13 @@ namespace IceUtilInternal for(int i = 0; i < s.Length; i++) { char c = s[i]; - if(toStringMode == Ice.ToStringMode.Unicode || !System.Char.IsSurrogate(c)) + if(toStringMode == Ice.ToStringMode.Unicode || !char.IsSurrogate(c)) { encodeChar(c, result, special, toStringMode); } else { - Debug.Assert(toStringMode == Ice.ToStringMode.ASCII && System.Char.IsSurrogate(c)); + Debug.Assert(toStringMode == Ice.ToStringMode.ASCII && char.IsSurrogate(c)); if(i + 1 == s.Length) { throw new System.ArgumentException("High surrogate without low surrogate"); @@ -263,7 +263,7 @@ namespace IceUtilInternal else { i++; - int codePoint = System.Char.ConvertToUtf32(c, s[i]); + int codePoint = char.ConvertToUtf32(c, s[i]); // append \Unnnnnnnn result.Append("\\U"); string hex = System.Convert.ToString(codePoint, 16); @@ -424,7 +424,7 @@ namespace IceUtilInternal } else { - result.Append(System.Char.ConvertFromUtf32(codePoint)); + result.Append(char.ConvertFromUtf32(codePoint)); } break; } @@ -520,7 +520,7 @@ namespace IceUtilInternal } default: { - if(System.String.IsNullOrEmpty(special) || special.IndexOf(c) == -1) + if(string.IsNullOrEmpty(special) || special.IndexOf(c) == -1) { result.Append('\\'); // not in special, so we keep the backslash } @@ -720,14 +720,13 @@ namespace IceUtilInternal return true; } - private class OrdinalStringComparerImpl : System.Collections.Generic.IComparer<string> + private class OrdinalStringComparerImpl : IComparer<string> { public int Compare(string l, string r) { return string.CompareOrdinal(l, r); } } - public static System.Collections.Generic.IComparer<string> OrdinalStringComparer = - new OrdinalStringComparerImpl(); + public static IComparer<string> OrdinalStringComparer = new OrdinalStringComparerImpl(); } } diff --git a/csharp/src/Ice/SysLoggerI.cs b/csharp/src/Ice/SysLoggerI.cs deleted file mode 100644 index f4b5650659c..00000000000 --- a/csharp/src/Ice/SysLoggerI.cs +++ /dev/null @@ -1,232 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -using System.Net.Sockets; - -namespace Ice -{ - - public sealed class SysLoggerI : Logger - { - public SysLoggerI(string prefix, string facilityString) - { - int facility; - if(facilityString.Equals("LOG_KERN")) - { - facility = LOG_KERN; - } - else if(facilityString.Equals("LOG_USER")) - { - facility = LOG_USER; - } - else if(facilityString.Equals("LOG_MAIL")) - { - facility = LOG_MAIL; - } - else if(facilityString.Equals("LOG_DAEMON")) - { - facility = LOG_DAEMON; - } - else if(facilityString.Equals("LOG_AUTH")) - { - facility = LOG_AUTH; - } - else if(facilityString.Equals("LOG_SYSLOG")) - { - facility = LOG_SYSLOG; - } - else if(facilityString.Equals("LOG_LPR")) - { - facility = LOG_LPR; - } - else if(facilityString.Equals("LOG_NEWS")) - { - facility = LOG_NEWS; - } - else if(facilityString.Equals("LOG_UUCP")) - { - facility = LOG_UUCP; - } - else if(facilityString.Equals("LOG_CRON")) - { - facility = LOG_CRON; - } - else if(facilityString.Equals("LOG_AUTHPRIV")) - { - facility = LOG_AUTHPRIV; - } - else if(facilityString.Equals("LOG_FTP")) - { - facility = LOG_FTP; - } - else if(facilityString.Equals("LOG_LOCAL0")) - { - facility = LOG_LOCAL0; - } - else if(facilityString.Equals("LOG_LOCAL1")) - { - facility = LOG_LOCAL1; - } - else if(facilityString.Equals("LOG_LOCAL2")) - { - facility = LOG_LOCAL2; - } - else if(facilityString.Equals("LOG_LOCAL3")) - { - facility = LOG_LOCAL3; - } - else if(facilityString.Equals("LOG_LOCAL4")) - { - facility = LOG_LOCAL4; - } - else if(facilityString.Equals("LOG_LOCAL5")) - { - facility = LOG_LOCAL5; - } - else if(facilityString.Equals("LOG_LOCAL6")) - { - facility = LOG_LOCAL6; - } - else if(facilityString.Equals("LOG_LOCAL7")) - { - facility = LOG_LOCAL7; - } - else - { - throw new Ice.InitializationException("Invalid value for Ice.SyslogFacility: " + facilityString); - } - initialize(prefix, facility); - } - - private SysLoggerI(string prefix, int facility) - { - initialize(prefix, facility); - } - - private void initialize(string prefix, int facility) - { - _prefix = prefix; - _facility = facility; - - // - // Open a datagram socket to communicate with the localhost - // syslog daemon. - // - try - { - _host = ((System.Net.IPEndPoint)IceInternal.Network.getAddressForServer( - System.Net.Dns.GetHostName(), _port, IceInternal.Network.EnableBoth, false)).Address; - _socket = new UdpClient(); - _socket.Connect(_host, _port); - } - catch(System.Exception ex) - { - throw new Ice.DNSException(ex); - } - } - - public void print(string message) - { - log(LOG_INFO, message); - } - - public void trace(string category, string message) - { - log(LOG_INFO, category + ": " + message); - } - - public void warning(string message) - { - log(LOG_WARNING, message); - } - - public void error(string message) - { - log(LOG_ERR, message); - } - - public string getPrefix() - { - return _prefix; - } - - public Logger cloneWithPrefix(string prefix) - { - return new SysLoggerI(prefix, _facility); - } - - private void log(int severity, string message) - { - try - { - // - // Create a syslog message as defined by the RFC 3164: - // <PRI>HEADER MSG. PRI is the priority and is calculated - // from the facility and the severity. We don't specify - // the HEADER. MSG contains the identifier followed by a - // colon character and the message. - // - - int priority = (_facility << 3) | severity; - - string msg = '<' + priority + '>' + _prefix + ": " + message; - - byte[] buf = new byte[msg.Length]; - for(int i = 0; i < msg.Length; i++) - { - buf[i] = (byte)msg[i]; - } - _socket.Send(buf, buf.Length); - } - catch(System.IO.IOException ex) - { - Ice.SocketException se = new Ice.SocketException(ex); - throw se; - } - } - - private string _prefix; - private int _facility; - private UdpClient _socket; - private System.Net.IPAddress _host; - private static int _port = 514; - - // - // Syslog facilities (as defined in syslog.h) - // - private const int LOG_KERN = 0; - private const int LOG_USER = 1; - private const int LOG_MAIL = 2; - private const int LOG_DAEMON = 3; - private const int LOG_AUTH = 4; - private const int LOG_SYSLOG = 5; - private const int LOG_LPR = 6; - private const int LOG_NEWS = 7; - private const int LOG_UUCP = 8; - private const int LOG_CRON = 9; - private const int LOG_AUTHPRIV = 10; - private const int LOG_FTP = 11; - private const int LOG_LOCAL0 = 16; - private const int LOG_LOCAL1 = 17; - private const int LOG_LOCAL2 = 18; - private const int LOG_LOCAL3 = 19; - private const int LOG_LOCAL4 = 20; - private const int LOG_LOCAL5 = 21; - private const int LOG_LOCAL6 = 22; - private const int LOG_LOCAL7 = 23; - - // - // Syslog priorities (as defined in syslog.h) - // - private const int LOG_ERR = 3; - private const int LOG_WARNING = 4; - private const int LOG_INFO = 6; - } - -} diff --git a/csharp/src/Ice/TcpAcceptor.cs b/csharp/src/Ice/TcpAcceptor.cs index f8f3e3c8dca..543c8a677a7 100644 --- a/csharp/src/Ice/TcpAcceptor.cs +++ b/csharp/src/Ice/TcpAcceptor.cs @@ -136,7 +136,7 @@ namespace IceInternal Network.setBlock(_fd, false); Network.setTcpBufSize(_fd, _instance); } - catch(System.Exception) + catch(Exception) { _fd = null; throw; @@ -147,7 +147,7 @@ namespace IceInternal private ProtocolInstance _instance; private Socket _fd; private Socket _acceptFd; - private System.Exception _acceptError; + private Exception _acceptError; private int _backlog; private IPEndPoint _addr; private IAsyncResult _result; diff --git a/csharp/src/Ice/TcpConnector.cs b/csharp/src/Ice/TcpConnector.cs index a4ca495c2a2..454cb3e1f41 100644 --- a/csharp/src/Ice/TcpConnector.cs +++ b/csharp/src/Ice/TcpConnector.cs @@ -37,13 +37,13 @@ namespace IceInternal _connectionId = connectionId; _hashCode = 5381; - IceInternal.HashUtil.hashAdd(ref _hashCode, _addr); + HashUtil.hashAdd(ref _hashCode, _addr); if(_sourceAddr != null) { - IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr); + HashUtil.hashAdd(ref _hashCode, _sourceAddr); } - IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout); - IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId); + HashUtil.hashAdd(ref _hashCode, _timeout); + HashUtil.hashAdd(ref _hashCode, _connectionId); } public override bool Equals(object obj) diff --git a/csharp/src/Ice/TcpEndpointI.cs b/csharp/src/Ice/TcpEndpointI.cs index 579ab230366..bc9579bf465 100644 --- a/csharp/src/Ice/TcpEndpointI.cs +++ b/csharp/src/Ice/TcpEndpointI.cs @@ -196,8 +196,8 @@ namespace IceInternal public override void hashInit(ref int h) { base.hashInit(ref h); - IceInternal.HashUtil.hashAdd(ref h, _timeout); - IceInternal.HashUtil.hashAdd(ref h, _compress); + HashUtil.hashAdd(ref h, _timeout); + HashUtil.hashAdd(ref h, _compress); } public override void fillEndpointInfo(Ice.IPEndpointInfo info) @@ -232,7 +232,7 @@ namespace IceInternal { try { - _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + _timeout = int.Parse(argument, CultureInfo.InvariantCulture); if(_timeout < 1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); diff --git a/csharp/src/Ice/ThreadHookPlugin.cs b/csharp/src/Ice/ThreadHookPlugin.cs index a828b1b224f..77dfbbfbb62 100644 --- a/csharp/src/Ice/ThreadHookPlugin.cs +++ b/csharp/src/Ice/ThreadHookPlugin.cs @@ -15,7 +15,7 @@ namespace Ice /// thread notification hook and return the instance from their /// PluginFactory implementation. /// </summary> - public class ThreadHookPlugin : Ice.Plugin + public class ThreadHookPlugin : Plugin { /// <summary> /// Installs a custom logger for a communicator. diff --git a/csharp/src/Ice/ThreadPool.cs b/csharp/src/Ice/ThreadPool.cs index 450b656d98e..b5e51d7d554 100644 --- a/csharp/src/Ice/ThreadPool.cs +++ b/csharp/src/Ice/ThreadPool.cs @@ -39,7 +39,7 @@ namespace IceInternal // the call on the UI thread which will then use its own synchronization // context to execute continuations). // - var ctx = SynchronizationContext.Current as ThreadPoolSynchronizationContext; + var ctx = Current as ThreadPoolSynchronizationContext; if(ctx != this) { _threadPool.dispatch(() => { d(state); }, null, false); @@ -236,13 +236,10 @@ namespace IceInternal stackSize = 0; } _stackSize = stackSize; - _hasPriority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0; - _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority")); - if(!_hasPriority) - { - _hasPriority = properties.getProperty("Ice.ThreadPriority").Length > 0; - _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority")); - } + + _priority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0 ? + Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority")) : + Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority")); if(_instance.traceLevels().threadPool >= 1) { @@ -259,14 +256,7 @@ namespace IceInternal for(int i = 0; i < _size; ++i) { WorkerThread thread = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++); - if(_hasPriority) - { - thread.start(_priority); - } - else - { - thread.start(ThreadPriority.Normal); - } + thread.start(_priority); _threads.Add(thread); } } @@ -290,7 +280,7 @@ namespace IceInternal return; } _destroyed = true; - System.Threading.Monitor.PulseAll(this); + Monitor.PulseAll(this); } } @@ -444,14 +434,7 @@ namespace IceInternal try { WorkerThread t = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++); - if(_hasPriority) - { - t.start(_priority); - } - else - { - t.start(ThreadPriority.Normal); - } + t.start(_priority); _threads.Add(t); } catch(System.Exception ex) @@ -525,7 +508,7 @@ namespace IceInternal if(_threadIdleTime > 0) { - if(!System.Threading.Monitor.Wait(this, _threadIdleTime * 1000) && _workItems.Count == 0) // If timeout + if(!Monitor.Wait(this, _threadIdleTime * 1000) && _workItems.Count == 0) // If timeout { if(_destroyed) { @@ -557,7 +540,7 @@ namespace IceInternal else { Debug.Assert(_serverIdleTime > 0 && _inUse == 0 && _threads.Count == 1); - if(!System.Threading.Monitor.Wait(this, _serverIdleTime * 1000) && + if(!Monitor.Wait(this, _serverIdleTime * 1000) && _workItems.Count == 0) { if(!_destroyed) @@ -579,7 +562,7 @@ namespace IceInternal } else { - System.Threading.Monitor.Wait(this); + Monitor.Wait(this); } } @@ -880,7 +863,6 @@ namespace IceInternal private readonly int _sizeWarn; // If _inUse reaches _sizeWarn, a "low on threads" warning will be printed. private readonly bool _serialize; // True if requests need to be serialized over the connection. private readonly ThreadPriority _priority; - private readonly bool _hasPriority = false; private readonly int _serverIdleTime; private readonly int _threadIdleTime; private readonly int _stackSize; diff --git a/csharp/src/Ice/Timer.cs b/csharp/src/Ice/Timer.cs index 266faf90a19..859747fca85 100644 --- a/csharp/src/Ice/Timer.cs +++ b/csharp/src/Ice/Timer.cs @@ -36,7 +36,7 @@ namespace IceInternal } _instance = null; - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); _tokens.Clear(); _tasks.Clear(); @@ -68,7 +68,7 @@ namespace IceInternal if(token.scheduledTime < _wakeUpTime) { - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); } } } @@ -96,7 +96,7 @@ namespace IceInternal if(token.scheduledTime < _wakeUpTime) { - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); } } } @@ -124,17 +124,12 @@ namespace IceInternal // // Only for use by Instance. // - internal Timer(IceInternal.Instance instance, ThreadPriority priority) + internal Timer(Instance instance, ThreadPriority priority = ThreadPriority.Normal) { init(instance, priority, true); } - - internal Timer(IceInternal.Instance instance) - { - init(instance, ThreadPriority.Normal, false); - } - internal void init(IceInternal.Instance instance, ThreadPriority priority, bool hasPriority) + internal void init(Instance instance, ThreadPriority priority, bool hasPriority) { _instance = instance; @@ -201,8 +196,8 @@ namespace IceInternal if(_tokens.Count == 0) { - _wakeUpTime = System.Int64.MaxValue; - System.Threading.Monitor.Wait(this); + _wakeUpTime = long.MaxValue; + Monitor.Wait(this); } if(_instance == null) @@ -234,7 +229,7 @@ namespace IceInternal } _wakeUpTime = first.scheduledTime; - System.Threading.Monitor.Wait(this, (int)(first.scheduledTime - now)); + Monitor.Wait(this, (int)(first.scheduledTime - now)); } if(_instance == null) @@ -322,7 +317,7 @@ namespace IceInternal public override bool Equals(object o) { - if(object.ReferenceEquals(this, o)) + if(ReferenceEquals(this, o)) { return true; } @@ -333,8 +328,8 @@ namespace IceInternal public override int GetHashCode() { int h = 5381; - IceInternal.HashUtil.hashAdd(ref h, id); - IceInternal.HashUtil.hashAdd(ref h, scheduledTime); + HashUtil.hashAdd(ref h, id); + HashUtil.hashAdd(ref h, scheduledTime); return h; } @@ -347,7 +342,7 @@ namespace IceInternal private IDictionary<Token, object> _tokens = new SortedDictionary<Token, object>(); private IDictionary<TimerTask, Token> _tasks = new Dictionary<TimerTask, Token>(); private Instance _instance; - private long _wakeUpTime = System.Int64.MaxValue; + private long _wakeUpTime = long.MaxValue; private int _tokenId = 0; private Thread _thread; diff --git a/csharp/src/Ice/TraceUtil.cs b/csharp/src/Ice/TraceUtil.cs index 54e2783a187..37d883f7ef3 100644 --- a/csharp/src/Ice/TraceUtil.cs +++ b/csharp/src/Ice/TraceUtil.cs @@ -91,7 +91,7 @@ namespace IceInternal internal static void traceSlicing(string kind, string typeId, string slicingCat, Ice.Logger logger) { - lock(typeof(IceInternal.TraceUtil)) + lock(typeof(TraceUtil)) { if(slicingIds.Add(typeId)) { @@ -126,7 +126,7 @@ namespace IceInternal { if(j < data.Length) { - int n = (int)data[j]; + int n = data[j]; if(n < 0) { n += 256; @@ -157,7 +157,7 @@ namespace IceInternal for(int j = i; j < data.Length && j - i < inc; j++) { // TODO: this needs fixing - if(data[j] >= (byte)32 && data[j] < (byte)127) + if(data[j] >= 32 && data[j] < 127) { System.Console.Out.Write((char) data[j]); } @@ -175,7 +175,6 @@ namespace IceInternal { try { - Ice.ToStringMode toStringMode = Ice.ToStringMode.Unicode; if(str.instance() != null) { @@ -422,19 +421,19 @@ namespace IceInternal s.Write("\ncompression status = " + (int)compress + ' '); switch(compress) { - case (byte)0: + case 0: { s.Write("(not compressed; do not compress response, if any)"); break; } - case (byte)1: + case 1: { s.Write("(not compressed; compress response, if any)"); break; } - case (byte)2: + case 2: { s.Write("(compressed; compress response, if any)"); break; diff --git a/csharp/src/Ice/UdpConnector.cs b/csharp/src/Ice/UdpConnector.cs index b9aea3b0a58..c404472d44c 100644 --- a/csharp/src/Ice/UdpConnector.cs +++ b/csharp/src/Ice/UdpConnector.cs @@ -37,14 +37,14 @@ namespace IceInternal _connectionId = connectionId; _hashCode = 5381; - IceInternal.HashUtil.hashAdd(ref _hashCode, _addr); + HashUtil.hashAdd(ref _hashCode, _addr); if(sourceAddr != null) { - IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr); + HashUtil.hashAdd(ref _hashCode, _sourceAddr); } - IceInternal.HashUtil.hashAdd(ref _hashCode, _mcastInterface); - IceInternal.HashUtil.hashAdd(ref _hashCode, _mcastTtl); - IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId); + HashUtil.hashAdd(ref _hashCode, _mcastInterface); + HashUtil.hashAdd(ref _hashCode, _mcastTtl); + HashUtil.hashAdd(ref _hashCode, _connectionId); } public override bool Equals(object obj) diff --git a/csharp/src/Ice/UdpEndpointI.cs b/csharp/src/Ice/UdpEndpointI.cs index 7180de35718..2e3418eaa9d 100644 --- a/csharp/src/Ice/UdpEndpointI.cs +++ b/csharp/src/Ice/UdpEndpointI.cs @@ -269,10 +269,10 @@ namespace IceInternal public override void hashInit(ref int h) { base.hashInit(ref h); - IceInternal.HashUtil.hashAdd(ref h, _mcastInterface); - IceInternal.HashUtil.hashAdd(ref h, _mcastTtl); - IceInternal.HashUtil.hashAdd(ref h, _connect); - IceInternal.HashUtil.hashAdd(ref h, _compress); + HashUtil.hashAdd(ref h, _mcastInterface); + HashUtil.hashAdd(ref h, _mcastTtl); + HashUtil.hashAdd(ref h, _connect); + HashUtil.hashAdd(ref h, _compress); } public override void fillEndpointInfo(Ice.IPEndpointInfo info) @@ -352,9 +352,9 @@ namespace IceInternal try { - _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); + _mcastTtl = int.Parse(argument, CultureInfo.InvariantCulture); } - catch(System.FormatException ex) + catch(FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint " + endpoint; diff --git a/csharp/src/Ice/UdpTransceiver.cs b/csharp/src/Ice/UdpTransceiver.cs index 3d2d3d427d0..d456b792a74 100644 --- a/csharp/src/Ice/UdpTransceiver.cs +++ b/csharp/src/Ice/UdpTransceiver.cs @@ -152,7 +152,7 @@ namespace IceInternal Debug.Assert(_fd != null && _state >= StateConnected); // The caller is supposed to check the send size before by calling checkSendSize - Debug.Assert(System.Math.Min(_maxPacketSize, _sndSize - _udpOverhead) >= buf.size()); + Debug.Assert(Math.Min(_maxPacketSize, _sndSize - _udpOverhead) >= buf.size()); int ret = 0; while(true) @@ -194,7 +194,7 @@ namespace IceInternal throw new Ice.SocketException(ex); } } - catch(System.Exception e) + catch(Exception e) { throw new Ice.SyscallException(e); } @@ -216,7 +216,7 @@ namespace IceInternal Debug.Assert(buf.b.position() == 0); Debug.Assert(_fd != null); - int packetSize = System.Math.Min(_maxPacketSize, _rcvSize - _udpOverhead); + int packetSize = Math.Min(_maxPacketSize, _rcvSize - _udpOverhead); buf.resize(packetSize, true); buf.b.position(0); @@ -280,7 +280,7 @@ namespace IceInternal throw new Ice.SocketException(e); } } - catch(System.Exception e) + catch(Exception e) { throw new Ice.SyscallException(e); } @@ -319,7 +319,7 @@ namespace IceInternal { Debug.Assert(buf.b.position() == 0); - int packetSize = System.Math.Min(_maxPacketSize, _rcvSize - _udpOverhead); + int packetSize = Math.Min(_maxPacketSize, _rcvSize - _udpOverhead); buf.resize(packetSize, true); buf.b.position(0); @@ -456,7 +456,7 @@ namespace IceInternal Debug.Assert(_fd != null); // The caller is supposed to check the send size before by calling checkSendSize - Debug.Assert(System.Math.Min(_maxPacketSize, _sndSize - _udpOverhead) >= buf.size()); + Debug.Assert(Math.Min(_maxPacketSize, _sndSize - _udpOverhead) >= buf.size()); Debug.Assert(buf.b.position() == 0); @@ -605,7 +605,7 @@ namespace IceInternal // The maximum packetSize is either the maximum allowable UDP packet size, or // the UDP send buffer size (which ever is smaller). // - int packetSize = System.Math.Min(_maxPacketSize, _sndSize - _udpOverhead); + int packetSize = Math.Min(_maxPacketSize, _sndSize - _udpOverhead); if(packetSize < buf.size()) { throw new Ice.DatagramLimitException(); @@ -657,7 +657,7 @@ namespace IceInternal if(intfs.Count != 0) { s.Append("\nlocal interfaces = "); - s.Append(String.Join(", ", intfs.ToArray())); + s.Append(string.Join(", ", intfs.ToArray())); } return s.ToString(); } @@ -794,7 +794,7 @@ namespace IceInternal // // Check for sanity. // - if(sizeRequested < (_udpOverhead + IceInternal.Protocol.headerSize)) + if(sizeRequested < (_udpOverhead + Protocol.headerSize)) { _instance.logger().warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " + dfltSize); diff --git a/csharp/src/Ice/Util.cs b/csharp/src/Ice/Util.cs index 336ef131289..42305dda09a 100644 --- a/csharp/src/Ice/Util.cs +++ b/csharp/src/Ice/Util.cs @@ -10,7 +10,6 @@ using System; using System.Threading; using System.Collections; -using System.Text; using System.Globalization; namespace Ice @@ -60,7 +59,7 @@ namespace Ice /// <summary> /// Creates and returns a copy of this object. /// </summary> - public System.Object Clone() + public object Clone() { // // A member-wise copy is safe because the members are immutable. @@ -81,7 +80,7 @@ namespace Ice /// <summary> /// The communicator observer used by the Ice run-time. /// </summary> - public Ice.Instrumentation.CommunicatorObserver observer; + public Instrumentation.CommunicatorObserver observer; /// <summary> /// The thread hook for the communicator. @@ -277,7 +276,7 @@ namespace Ice { ident.name = IceUtilInternal.StringUtil.unescapeString(s, 0, s.Length, "/"); } - catch(System.ArgumentException e) + catch(ArgumentException e) { IdentityParseException ex = new IdentityParseException(); ex.str = "invalid identity name `" + s + "': " + e.Message; @@ -290,7 +289,7 @@ namespace Ice { ident.category = IceUtilInternal.StringUtil.unescapeString(s, 0, slash, "/"); } - catch(System.ArgumentException e) + catch(ArgumentException e) { IdentityParseException ex = new IdentityParseException(); ex.str = "invalid category in identity `" + s + "': " + e.Message; @@ -302,7 +301,7 @@ namespace Ice { ident.name = IceUtilInternal.StringUtil.unescapeString(s, slash + 1, s.Length, "/"); } - catch(System.ArgumentException e) + catch(ArgumentException e) { IdentityParseException ex = new IdentityParseException(); ex.str = "invalid name in identity `" + s + "': " + e.Message; @@ -451,7 +450,7 @@ namespace Ice { if(_processLogger == null) { - _processLogger = new ConsoleLoggerI(System.AppDomain.CurrentDomain.FriendlyName); + _processLogger = new ConsoleLoggerI(AppDomain.CurrentDomain.FriendlyName); } return _processLogger; } @@ -496,11 +495,11 @@ namespace Ice /// </summary> /// <param name="version">The string to convert.</param> /// <returns>The converted protocol version.</returns> - public static Ice.ProtocolVersion stringToProtocolVersion(string version) + public static ProtocolVersion stringToProtocolVersion(string version) { byte major, minor; stringToMajorMinor(version, out major, out minor); - return new Ice.ProtocolVersion(major, minor); + return new ProtocolVersion(major, minor); } /// <summary> @@ -508,11 +507,11 @@ namespace Ice /// </summary> /// <param name="version">The string to convert.</param> /// <returns>The converted object identity.</returns> - public static Ice.EncodingVersion stringToEncodingVersion(string version) + public static EncodingVersion stringToEncodingVersion(string version) { byte major, minor; stringToMajorMinor(version, out major, out minor); - return new Ice.EncodingVersion(major, minor); + return new EncodingVersion(major, minor); } /// <summary> @@ -537,10 +536,10 @@ namespace Ice static private void stringToMajorMinor(string str, out byte major, out byte minor) { - int pos = str.IndexOf((System.Char) '.'); + int pos = str.IndexOf('.'); if(pos == -1) { - throw new Ice.VersionParseException("malformed version value `" + str + "'"); + throw new VersionParseException("malformed version value `" + str + "'"); } string majStr = str.Substring(0, (pos) - (0)); @@ -549,30 +548,26 @@ namespace Ice int minVersion; try { - majVersion = System.Int32.Parse(majStr, CultureInfo.InvariantCulture); - minVersion = System.Int32.Parse(minStr, CultureInfo.InvariantCulture); + majVersion = int.Parse(majStr, CultureInfo.InvariantCulture); + minVersion = int.Parse(minStr, CultureInfo.InvariantCulture); } - catch(System.FormatException) + catch(FormatException) { - throw new Ice.VersionParseException("invalid version value `" + str + "'"); + throw new VersionParseException("invalid version value `" + str + "'"); } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { - throw new Ice.VersionParseException("range error in version `" + str + "'"); + throw new VersionParseException("range error in version `" + str + "'"); } major = (byte)majVersion; minor = (byte)minVersion; } - static private String majorMinorToString(byte major, byte minor) + static private string majorMinorToString(byte major, byte minor) { - StringBuilder str = new StringBuilder(); - str.Append(major < 0 ? (int)major + 255 : (int)major); - str.Append("."); - str.Append(minor < 0 ? (int)minor + 255 : (int)minor); - return str.ToString(); + return string.Format("{0}.{1}", major, minor); } public static readonly ProtocolVersion currentProtocol = @@ -690,9 +685,9 @@ namespace IceInternal return new ProtocolPluginFacadeI(communicator); } - public static System.Threading.ThreadPriority stringToThreadPriority(string s) + public static ThreadPriority stringToThreadPriority(string s) { - if(String.IsNullOrEmpty(s)) + if(string.IsNullOrEmpty(s)) { return ThreadPriority.Normal; } diff --git a/csharp/src/Ice/Value.cs b/csharp/src/Ice/Value.cs index b3c9924811e..6eb5ad1acef 100644 --- a/csharp/src/Ice/Value.cs +++ b/csharp/src/Ice/Value.cs @@ -8,6 +8,7 @@ // ********************************************************************** using System; +using System.ComponentModel; namespace Ice { @@ -50,6 +51,7 @@ namespace Ice { } + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void iceWrite(OutputStream ostr) { ostr.startValue(null); @@ -57,6 +59,7 @@ namespace Ice ostr.endValue(); } + [EditorBrowsable(EditorBrowsableState.Never)] public virtual void iceRead(InputStream istr) { istr.startValue(); @@ -64,10 +67,12 @@ namespace Ice istr.endValue(false); } + [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void iceWriteImpl(OutputStream ostr) { } + [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void iceReadImpl(InputStream istr) { } @@ -95,12 +100,14 @@ namespace Ice return _id; } + [EditorBrowsable(EditorBrowsableState.Never)] protected override void iceWriteImpl(OutputStream ostr) { ostr.startSlice(ice_id(), -1, true); ostr.endSlice(); } + [EditorBrowsable(EditorBrowsableState.Never)] protected override void iceReadImpl(InputStream istr) { istr.startSlice(); diff --git a/csharp/src/Ice/WSConnector.cs b/csharp/src/Ice/WSConnector.cs index 5b1479d47cb..79a095be76d 100644 --- a/csharp/src/Ice/WSConnector.cs +++ b/csharp/src/Ice/WSConnector.cs @@ -66,7 +66,7 @@ namespace IceInternal } private ProtocolInstance _instance; - private IceInternal.Connector _delegate; + private Connector _delegate; private string _host; private string _resource; } diff --git a/csharp/src/Ice/WSTransceiver.cs b/csharp/src/Ice/WSTransceiver.cs index 7945d22d684..31c6155c59f 100644 --- a/csharp/src/Ice/WSTransceiver.cs +++ b/csharp/src/Ice/WSTransceiver.cs @@ -11,7 +11,6 @@ namespace IceInternal { using System; using System.Diagnostics; - using System.Collections.Generic; using System.Net.Sockets; using System.Security.Cryptography; using System.Text; @@ -74,7 +73,7 @@ namespace IceInternal // byte[] key = new byte[16]; _rand.NextBytes(key); - _key = IceUtilInternal.Base64.encode(key); + _key = System.Convert.ToBase64String(key); @out.Append(_key + "\r\n\r\n"); // EOM byte[] bytes = _utf8.GetBytes(@out.ToString()); @@ -829,7 +828,7 @@ namespace IceInternal throw new WebSocketException("missing value for WebSocket key"); } - byte[] decodedKey = IceUtilInternal.Base64.decode(key); + byte[] decodedKey = Convert.FromBase64String(key); if(decodedKey.Length != 16) { throw new WebSocketException("invalid value `" + key + "' for WebSocket key"); @@ -865,7 +864,7 @@ namespace IceInternal @out.Append("Sec-WebSocket-Accept: "); string input = key + _wsUUID; byte[] hash = SHA1.Create().ComputeHash(_utf8.GetBytes(input)); - @out.Append(IceUtilInternal.Base64.encode(hash) + "\r\n" + "\r\n"); // EOM + @out.Append(Convert.ToBase64String(hash) + "\r\n" + "\r\n"); // EOM byte[] bytes = _utf8.GetBytes(@out.ToString()); Debug.Assert(bytes.Length == @out.Length); @@ -967,7 +966,7 @@ namespace IceInternal string input = _key + _wsUUID; byte[] hash = SHA1.Create().ComputeHash(_utf8.GetBytes(input)); - if(!val.Equals(IceUtilInternal.Base64.encode(hash))) + if(!val.Equals(Convert.ToBase64String(hash))) { throw new WebSocketException("invalid value `" + val + "' for Sec-WebSocket-Accept"); } @@ -1581,7 +1580,7 @@ namespace IceInternal // // Use an extra 16 bits to encode the payload length. // - _writeBuffer.b.put((byte)126); + _writeBuffer.b.put(126); _writeBuffer.b.putShort((short)payloadLength); } else if(payloadLength > 65535) @@ -1589,7 +1588,7 @@ namespace IceInternal // // Use an extra 64 bits to encode the payload length. // - _writeBuffer.b.put((byte)127); + _writeBuffer.b.put(127); _writeBuffer.b.putLong(payloadLength); } @@ -1698,6 +1697,6 @@ namespace IceInternal private const string _iceProtocol = "ice.zeroc.com"; private const string _wsUUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - private static System.Text.UTF8Encoding _utf8 = new System.Text.UTF8Encoding(false, true); + private static UTF8Encoding _utf8 = new UTF8Encoding(false, true); } } diff --git a/csharp/src/Ice/msbuild/ice.csproj b/csharp/src/Ice/msbuild/ice.csproj index 91990f84bc0..ed21534e3fc 100644 --- a/csharp/src/Ice/msbuild/ice.csproj +++ b/csharp/src/Ice/msbuild/ice.csproj @@ -45,9 +45,6 @@ <Compile Include="..\AsyncResult.cs"> <Link>AsyncResult.cs</Link> </Compile> - <Compile Include="..\Base64.cs"> - <Link>Base64.cs</Link> - </Compile> <Compile Include="..\BatchRequestInterceptor.cs"> <Link>BatchRequestInterceptor.cs</Link> </Compile> @@ -279,9 +276,6 @@ <Compile Include="..\StringUtil.cs"> <Link>StringUtil.cs</Link> </Compile> - <Compile Include="..\SysLoggerI.cs"> - <Link>SysLoggerI.cs</Link> - </Compile> <Compile Include="..\TcpAcceptor.cs"> <Link>TcpAcceptor.cs</Link> </Compile> diff --git a/csharp/src/IceBox/Server.cs b/csharp/src/IceBox/Server.cs index 4ed957c7396..6773c4a869a 100644 --- a/csharp/src/IceBox/Server.cs +++ b/csharp/src/IceBox/Server.cs @@ -28,13 +28,13 @@ public class Server public override int run(string[] args) { - List<String> argSeq = new List<String>(args); - const String prefix = "IceBox.Service."; + List<string> argSeq = new List<string>(args); + const string prefix = "IceBox.Service."; Ice.Properties properties = communicator().getProperties(); Dictionary<string, string> services = properties.getPropertiesForPrefix(prefix); foreach(KeyValuePair<string, string> pair in services) { - String name = pair.Key.Substring(prefix.Length); + string name = pair.Key.Substring(prefix.Length); for(int i = 0; i < argSeq.Count; ++i) { if(argSeq[i].StartsWith("--" + name, StringComparison.CurrentCulture)) @@ -45,7 +45,7 @@ public class Server } } - foreach(String s in argSeq) + foreach(string s in argSeq) { if(s.Equals("-h") || s.Equals("--help")) { diff --git a/csharp/src/IceBox/ServiceManagerI.cs b/csharp/src/IceBox/ServiceManagerI.cs index 34cf7a953d5..17757974413 100644 --- a/csharp/src/IceBox/ServiceManagerI.cs +++ b/csharp/src/IceBox/ServiceManagerI.cs @@ -210,7 +210,6 @@ class ServiceManagerI : ServiceManagerDisp_ // // Null observers and duplicate registrations are ignored // - lock(this) { if(observer != null) @@ -520,7 +519,7 @@ class ServiceManagerI : ServiceManagerDisp_ } } } - catch(System.Exception ex) + catch(Exception ex) { FailureException e = new FailureException(ex); e.reason = err + "unable to load assembly: " + assemblyName; @@ -530,12 +529,12 @@ class ServiceManagerI : ServiceManagerDisp_ // // Instantiate the class. // - System.Type c = null; + Type c = null; try { c = serviceAssembly.GetType(className, true); } - catch(System.Exception ex) + catch(Exception ex) { FailureException e = new FailureException(ex); e.reason = err + "GetType failed for '" + className + "'"; @@ -640,11 +639,11 @@ class ServiceManagerI : ServiceManagerDisp_ { try { - Object[] parameters = new Object[1]; + object[] parameters = new object[1]; parameters[0] = _communicator; info.service = (Service)ci.Invoke(parameters); } - catch(System.MethodAccessException ex) + catch(MethodAccessException ex) { FailureException e = new FailureException(ex); e.reason = err + "unable to access service constructor " + className + "(Ice.Communicator)"; @@ -666,7 +665,7 @@ class ServiceManagerI : ServiceManagerDisp_ throw e; } } - catch(System.UnauthorizedAccessException ex) + catch(UnauthorizedAccessException ex) { FailureException e = new FailureException(ex); e.reason = err + "unauthorized access to default service constructor for " + className; @@ -678,7 +677,7 @@ class ServiceManagerI : ServiceManagerDisp_ { throw; } - catch(System.InvalidCastException ex) + catch(InvalidCastException ex) { FailureException e = new FailureException(ex); e.reason = err + "service does not implement IceBox.Service"; @@ -686,7 +685,7 @@ class ServiceManagerI : ServiceManagerDisp_ } catch(System.Reflection.TargetInvocationException ex) { - if(ex.InnerException is IceBox.FailureException) + if(ex.InnerException is FailureException) { throw ex.InnerException; } @@ -697,7 +696,7 @@ class ServiceManagerI : ServiceManagerDisp_ throw e; } } - catch(System.Exception ex) + catch(Exception ex) { FailureException e = new FailureException(ex); e.reason = err + "exception in service constructor " + className; @@ -713,7 +712,7 @@ class ServiceManagerI : ServiceManagerDisp_ { throw; } - catch(System.Exception ex) + catch(Exception ex) { FailureException e = new FailureException(ex); e.reason = "exception while starting service " + service; @@ -723,7 +722,7 @@ class ServiceManagerI : ServiceManagerDisp_ info.status = ServiceStatus.Started; _services.Add(info); } - catch(System.Exception) + catch(Exception) { if(info.communicator != null) { @@ -763,7 +762,7 @@ class ServiceManagerI : ServiceManagerDisp_ info.service.stop(); stoppedServices.Add(info.name); } - catch(System.Exception e) + catch(Exception e) { _logger.warning("IceBox.ServiceManager: exception while stopping service " + info.name + ":\n" + e.ToString()); @@ -784,7 +783,7 @@ class ServiceManagerI : ServiceManagerDisp_ { _sharedCommunicator.destroy(); } - catch(System.Exception e) + catch(Exception e) { _logger.warning("ServiceManager: exception while destroying shared communicator:\n" + e.ToString()); } @@ -796,7 +795,7 @@ class ServiceManagerI : ServiceManagerDisp_ } } - private void servicesStarted(List<String> services, Dictionary<ServiceObserverPrx, bool>.KeyCollection observers) + private void servicesStarted(List<string> services, Dictionary<ServiceObserverPrx, bool>.KeyCollection observers) { // // Must be called with 'this' unlocked @@ -849,7 +848,7 @@ class ServiceManagerI : ServiceManagerDisp_ } } - private void observerRemoved(ServiceObserverPrx observer, System.Exception ex) + private void observerRemoved(ServiceObserverPrx observer, Exception ex) { if(_traceServiceObserver >= 1) { @@ -938,7 +937,7 @@ class ServiceManagerI : ServiceManagerDisp_ public string[] args; } - private Ice.Properties createServiceProperties(String service) + private Ice.Properties createServiceProperties(string service) { Ice.Properties properties; Ice.Properties communicatorProperties = _communicator.getProperties(); @@ -956,7 +955,7 @@ class ServiceManagerI : ServiceManagerDisp_ properties = Ice.Util.createProperties(); } - String programName = communicatorProperties.getProperty("Ice.ProgramName"); + string programName = communicatorProperties.getProperty("Ice.ProgramName"); if(programName.Length == 0) { properties.setProperty("Ice.ProgramName", service); @@ -984,7 +983,7 @@ class ServiceManagerI : ServiceManagerDisp_ // the communicator for its own reasons. // } - catch(System.Exception e) + catch(Exception e) { _logger.warning("ServiceManager: exception while shutting down communicator for service " + service + "\n" + e.ToString()); @@ -996,7 +995,7 @@ class ServiceManagerI : ServiceManagerDisp_ { communicator.destroy(); } - catch(System.Exception e) + catch(Exception e) { _logger.warning("ServiceManager: exception while destroying communicator for service " + service + "\n" + e.ToString()); @@ -1024,7 +1023,7 @@ class ServiceManagerI : ServiceManagerDisp_ if(facetNames.Count > 0) { // TODO: need String.Join with escape! - properties.setProperty("Ice.Admin.Facets", String.Join(" ", facetNames.ToArray())); + properties.setProperty("Ice.Admin.Facets", string.Join(" ", facetNames.ToArray())); } return true; } diff --git a/csharp/src/IceDiscovery/LocatorI.cs b/csharp/src/IceDiscovery/LocatorI.cs index 5875bc39d8d..f1b6c2a0eea 100644 --- a/csharp/src/IceDiscovery/LocatorI.cs +++ b/csharp/src/IceDiscovery/LocatorI.cs @@ -9,7 +9,6 @@ namespace IceDiscovery { - using System; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/csharp/src/IceDiscovery/PluginI.cs b/csharp/src/IceDiscovery/PluginI.cs index 740256af9fd..6f856f33b4b 100644 --- a/csharp/src/IceDiscovery/PluginI.cs +++ b/csharp/src/IceDiscovery/PluginI.cs @@ -11,7 +11,6 @@ namespace IceDiscovery { using System; using System.Text; - using System.Collections.Generic; public sealed class PluginFactory : Ice.PluginFactory { diff --git a/csharp/src/IceSSL/AcceptorI.cs b/csharp/src/IceSSL/AcceptorI.cs index f0f50b84b45..99f04373206 100644 --- a/csharp/src/IceSSL/AcceptorI.cs +++ b/csharp/src/IceSSL/AcceptorI.cs @@ -9,10 +9,6 @@ namespace IceSSL { - using System; - using System.Collections.Generic; - using System.Diagnostics; - class AcceptorI : IceInternal.Acceptor { public void close() diff --git a/csharp/src/IceSSL/EndpointI.cs b/csharp/src/IceSSL/EndpointI.cs index 438ece37433..067d3a0860a 100644 --- a/csharp/src/IceSSL/EndpointI.cs +++ b/csharp/src/IceSSL/EndpointI.cs @@ -9,11 +9,7 @@ namespace IceSSL { - using System; - using System.Diagnostics; using System.Collections.Generic; - using System.Net; - using System.Globalization; sealed class EndpointI : IceInternal.EndpointI { @@ -28,7 +24,7 @@ namespace IceSSL _delegate.streamWriteImpl(os); } - private sealed class InfoI : IceSSL.EndpointInfo + private sealed class InfoI : EndpointInfo { public InfoI(EndpointI e) { diff --git a/csharp/src/IceSSL/Instance.cs b/csharp/src/IceSSL/Instance.cs index b115e682db8..323ab0b716d 100644 --- a/csharp/src/IceSSL/Instance.cs +++ b/csharp/src/IceSSL/Instance.cs @@ -9,16 +9,8 @@ namespace IceSSL { - using System; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Security; using System.Security.Authentication; - using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; - using System.Text; - using System.Globalization; internal class Instance : IceInternal.ProtocolInstance { diff --git a/csharp/src/IceSSL/RFC2253.cs b/csharp/src/IceSSL/RFC2253.cs index 1ff869cfe15..5a32988b5f6 100644 --- a/csharp/src/IceSSL/RFC2253.cs +++ b/csharp/src/IceSSL/RFC2253.cs @@ -13,7 +13,6 @@ namespace IceSSL { using System; - using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Text; @@ -276,11 +275,11 @@ namespace IceSSL // // First the OID case. // - if(Char.IsDigit(data[pos]) || + if(char.IsDigit(data[pos]) || (data.Length - pos >= 4 && (data.Substring(pos, 4).Equals("oid.") || data.Substring(pos, 4).Equals("OID.")))) { - if(!Char.IsDigit(data[pos])) + if(!char.IsDigit(data[pos])) { result += data.Substring(pos, 4); pos += 4; @@ -289,7 +288,7 @@ namespace IceSSL while(true) { // 1*DIGIT - while(pos < data.Length && Char.IsDigit(data[pos])) + while(pos < data.Length && char.IsDigit(data[pos])) { result += data[pos]; ++pos; @@ -300,7 +299,7 @@ namespace IceSSL result += data[pos]; ++pos; // 1*DIGIT must follow "." - if(pos < data.Length && !Char.IsDigit(data[pos])) + if(pos < data.Length && !char.IsDigit(data[pos])) { throw new ParseException("invalid attribute type (expected end of data)"); } @@ -311,7 +310,7 @@ namespace IceSSL } } } - else if(Char.IsUpper(data[pos]) || Char.IsLower(data[pos])) + else if(char.IsUpper(data[pos]) || char.IsLower(data[pos])) { // // The grammar is wrong in this case. It should be ALPHA @@ -322,9 +321,9 @@ namespace IceSSL ++pos; // 1* KEYCHAR while(pos < data.Length && - (Char.IsDigit(data[pos]) || - Char.IsUpper(data[pos]) || - Char.IsLower(data[pos]) || + (char.IsDigit(data[pos]) || + char.IsUpper(data[pos]) || + char.IsLower(data[pos]) || data[pos] == '-')) { result += data[pos]; diff --git a/csharp/src/IceSSL/SSLEngine.cs b/csharp/src/IceSSL/SSLEngine.cs index d5a4df95649..7f9d8bdf24e 100644 --- a/csharp/src/IceSSL/SSLEngine.cs +++ b/csharp/src/IceSSL/SSLEngine.cs @@ -10,7 +10,6 @@ namespace IceSSL { using System; - using System.Collections; using System.Collections.Generic; using System.IO; using System.Security; @@ -31,15 +30,6 @@ namespace IceSSL _securityTraceCategory = "Security"; _initialized = false; _trustManager = new TrustManager(_communicator); - _tls12Support = false; - try - { - Enum.Parse(typeof(System.Security.Authentication.SslProtocols), "Tls12"); - _tls12Support = true; - } - catch(Exception) - { - } } internal void initialize() @@ -81,9 +71,7 @@ namespace IceSSL // TLS1.1 and TLS1.2 to avoid security issues with SSLv3 // _protocols = parseProtocols( - properties.getPropertyAsListWithDefault(prefix + "Protocols", - _tls12Support ? new string[]{"TLS1_0", "TLS1_1", "TLS1_2"} : - new string[]{"TLS1_0", "TLS1_1"})); + properties.getPropertyAsListWithDefault(prefix + "Protocols", new string[]{"TLS1_0", "TLS1_1", "TLS1_2"})); // // CheckCertName determines whether we compare the name in a peer's // certificate against its hostname. @@ -1138,6 +1126,5 @@ namespace IceSSL private CertificateVerifier _verifier; private PasswordCallback _passwordCallback; private TrustManager _trustManager; - private bool _tls12Support; } } diff --git a/csharp/src/IceSSL/TransceiverI.cs b/csharp/src/IceSSL/TransceiverI.cs index 5ec9afccf8a..4ae6ee2cd0f 100644 --- a/csharp/src/IceSSL/TransceiverI.cs +++ b/csharp/src/IceSSL/TransceiverI.cs @@ -13,7 +13,6 @@ namespace IceSSL using System.Diagnostics; using System.Collections.Generic; using System.IO; - using System.Net; using System.Net.Security; using System.Net.Sockets; using System.Security.Authentication; @@ -48,8 +47,8 @@ namespace IceSSL // connection timeout could easily be triggered when // receiging/sending large messages. // - _maxSendPacketSize = System.Math.Max(512, IceInternal.Network.getSendBufferSize(fd())); - _maxRecvPacketSize = System.Math.Max(512, IceInternal.Network.getRecvBufferSize(fd())); + _maxSendPacketSize = Math.Max(512, IceInternal.Network.getSendBufferSize(fd())); + _maxRecvPacketSize = Math.Max(512, IceInternal.Network.getRecvBufferSize(fd())); if(_sslStream == null) { @@ -742,12 +741,12 @@ namespace IceSSL private int getSendPacketSize(int length) { - return _maxSendPacketSize > 0 ? System.Math.Min(length, _maxSendPacketSize) : length; + return _maxSendPacketSize > 0 ? Math.Min(length, _maxSendPacketSize) : length; } public int getRecvPacketSize(int length) { - return _maxRecvPacketSize > 0 ? System.Math.Min(length, _maxRecvPacketSize) : length; + return _maxRecvPacketSize > 0 ? Math.Min(length, _maxRecvPacketSize) : length; } private Instance _instance; diff --git a/csharp/src/IceSSL/TrustManager.cs b/csharp/src/IceSSL/TrustManager.cs index d9f53b058c5..887e9926cbd 100644 --- a/csharp/src/IceSSL/TrustManager.cs +++ b/csharp/src/IceSSL/TrustManager.cs @@ -9,7 +9,6 @@ namespace IceSSL { - using System; using System.Collections.Generic; using System.Diagnostics; using System.Security.Cryptography.X509Certificates; diff --git a/csharp/src/IceSSL/Util.cs b/csharp/src/IceSSL/Util.cs index 1b617dff0a0..ffb47cda1db 100644 --- a/csharp/src/IceSSL/Util.cs +++ b/csharp/src/IceSSL/Util.cs @@ -25,7 +25,7 @@ namespace IceSSL /// supply a certificate. The peer's certificate (if any) is the /// first one in the chain. /// </summary> - public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts; + public X509Certificate2[] nativeCerts; } public sealed class Util |