diff options
author | Jose <jose@zeroc.com> | 2016-05-11 16:51:13 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-05-11 16:51:13 +0200 |
commit | 20ead35bcd15c258b00da6b1a16d26107f8dea8b (patch) | |
tree | 0aa99a82b9d56383c76c372fc1050dfd5493b4e9 /csharp/src | |
parent | Fixed make install issue (diff) | |
download | ice-20ead35bcd15c258b00da6b1a16d26107f8dea8b.tar.bz2 ice-20ead35bcd15c258b00da6b1a16d26107f8dea8b.tar.xz ice-20ead35bcd15c258b00da6b1a16d26107f8dea8b.zip |
CSharp mapping cleanup
- Remove code support for old ussuported frameworks (SILVERLIGHT, COMPACT, MONO)
- Remove code support for deprecated collection mappings clr:collection
Diffstat (limited to 'csharp/src')
69 files changed, 72 insertions, 2272 deletions
diff --git a/csharp/src/Glacier2/Application.cs b/csharp/src/Glacier2/Application.cs index 6b91325a181..dd7caf4f806 100644 --- a/csharp/src/Glacier2/Application.cs +++ b/csharp/src/Glacier2/Application.cs @@ -9,10 +9,6 @@ using System; using System.Diagnostics; -using System.Collections.Generic; -using System.Threading; - -#if !SILVERLIGHT namespace Glacier2 { @@ -32,7 +28,7 @@ public abstract class Application : Ice.Application /// <summary> /// This exception is raised if the session should be restarted. /// </summary> - public class RestartSessionException : System.Exception + public class RestartSessionException : Exception { } @@ -454,4 +450,3 @@ public abstract class Application : Ice.Application } } -#endif diff --git a/csharp/src/Ice/Application.cs b/csharp/src/Ice/Application.cs index 791d5670851..b41ba4e8996 100644 --- a/csharp/src/Ice/Application.cs +++ b/csharp/src/Ice/Application.cs @@ -7,8 +7,6 @@ // // ********************************************************************** -#if !SILVERLIGHT - namespace Ice { using System; @@ -20,7 +18,6 @@ namespace Ice internal static class NativeMethods { -#if !COMPACT && !UNITY // // Technically it's not necessary to wrap DllImport in conditional compilation because // the binding occurs at run time and it will never be executed on Mono. However, it @@ -30,7 +27,6 @@ namespace Ice [return: MarshalAsAttribute(UnmanagedType.Bool)] internal static extern bool SetConsoleCtrlHandler(CtrlCEventHandler eh, [MarshalAsAttribute(UnmanagedType.Bool)]bool add); -#endif } /// <summary> @@ -224,9 +220,6 @@ namespace Ice _application = this; int status; -#if COMPACT || UNITY - status = doMain(args, initData); -#else if(signalPolicy__ == SignalPolicy.HandleSignals) { if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows) @@ -248,7 +241,6 @@ namespace Ice { status = doMain(args, initData); } -#endif return status; } @@ -749,7 +741,6 @@ namespace Ice private delegate void SignalHandler(int sig); private static readonly SignalHandler _handler = new SignalHandler(signalHandler); -#if !COMPACT && !UNITY private Signals _signals; private interface Signals @@ -928,9 +919,7 @@ namespace Ice #endif private SignalHandler _handler; } -#endif } delegate bool CtrlCEventHandler(int sig); } -#endif diff --git a/csharp/src/Ice/AssemblyUtil.cs b/csharp/src/Ice/AssemblyUtil.cs index 454fde42b1b..9eb8805235a 100644 --- a/csharp/src/Ice/AssemblyUtil.cs +++ b/csharp/src/Ice/AssemblyUtil.cs @@ -13,9 +13,7 @@ namespace IceInternal using System; using System.Collections; using System.Collections.Generic; - using System.Diagnostics; using System.Reflection; - using System.Threading; public sealed class AssemblyUtil { @@ -53,34 +51,8 @@ namespace IceInternal runtimeRevision_ = v.Revision; v = System.Environment.OSVersion.Version; - xp_ = v.Major == 5 && v.Minor == 1; // Are we running on XP? osx_ = false; -#if COMPACT || SILVERLIGHT - // - // Populate the _iceAssemblies list with the fully-qualified names - // of the standard Ice assemblies. The fully-qualified name looks - // like this: - // - // Ice, Version=X.Y.Z.0, Culture=neutral, PublicKeyToken=... - // - string name = Assembly.GetExecutingAssembly().FullName; - _iceAssemblies.Add(name); - int pos = name.IndexOf(','); - if(pos >= 0 && pos < name.Length - 1) - { - // - // Strip off the leading assembly name and use the remainder of the - // string to compose the names of the other standard assemblies. - // - string suffix = name.Substring(pos + 1); - _iceAssemblies.Add("Glacier2," + suffix); - _iceAssemblies.Add("IceBox," + suffix); - _iceAssemblies.Add("IceGrid," + suffix); - _iceAssemblies.Add("IcePatch2," + suffix); - _iceAssemblies.Add("IceStorm," + suffix); - } -#elif !UNITY if (platform_ == Platform.NonWindows) { try @@ -107,7 +79,6 @@ namespace IceInternal { } } -#endif } public static Type findType(Instance instance, string csharpId) @@ -119,33 +90,7 @@ namespace IceInternal { return t; } -#if COMPACT || SILVERLIGHT - string[] assemblies = instance.factoryAssemblies(); - for(int i = 0; i < assemblies.Length; ++i) - { - string s = csharpId + "," + assemblies[i]; - if((t = Type.GetType(s)) != null) - { - _typeTable[csharpId] = t; - return t; - } - } - // - // As a last resort, look for the type in the standard Ice assemblies. - // This avoids the need for a program to set a property such as: - // - // Ice.FactoryAssemblies=Ice - // - foreach(string a in _iceAssemblies) - { - string s = csharpId + "," + a; - if((t = Type.GetType(s)) != null) - { - _typeTable[csharpId] = t; - return t; - } - } -#else + loadAssemblies(); // Lazy initialization foreach (Assembly a in _loadedAssemblies.Values) { @@ -155,12 +100,10 @@ namespace IceInternal return t; } } -#endif } return null; } -#if !COMPACT && !SILVERLIGHT public static Type[] findTypesWithPrefix(string prefix) { LinkedList<Type> l = new LinkedList<Type>(); @@ -188,7 +131,6 @@ namespace IceInternal } return result; } -#endif public static object createInstance(Type t) { @@ -202,7 +144,6 @@ namespace IceInternal } } -#if !COMPACT && !SILVERLIGHT // // Make sure that all assemblies that are referenced by this process // are actually loaded. This is necessary so we can use reflection @@ -264,9 +205,6 @@ namespace IceInternal } private static Hashtable _loadedAssemblies = new Hashtable(); // <string, Assembly> pairs. -#else - private static List<string> _iceAssemblies = new List<string>(); -#endif private static Dictionary<string, Type> _typeTable = new Dictionary<string, Type>(); // <type name, Type> pairs. private static object _mutex = new object(); @@ -281,7 +219,6 @@ namespace IceInternal public readonly static int runtimeRevision_; public readonly static Platform platform_; - public readonly static bool xp_; public readonly static bool osx_; } diff --git a/csharp/src/Ice/AsyncIOThread.cs b/csharp/src/Ice/AsyncIOThread.cs index 9aa8bec52c3..0d9db92604f 100644 --- a/csharp/src/Ice/AsyncIOThread.cs +++ b/csharp/src/Ice/AsyncIOThread.cs @@ -9,10 +9,8 @@ namespace IceInternal { - using System; using System.Collections.Generic; using System.Diagnostics; - using System.Net; using System.Threading; public class AsyncIOThread @@ -23,7 +21,6 @@ namespace IceInternal _thread = new HelperThread(this); updateObserver(); -#if !SILVERLIGHT if(instance.initializationData().properties.getProperty("Ice.ThreadPriority").Length > 0) { ThreadPriority priority = IceInternal.Util.stringToThreadPriority( @@ -34,9 +31,6 @@ namespace IceInternal { _thread.Start(ThreadPriority.Normal); } -#else - _thread.Start(); -#endif } public void @@ -178,18 +172,11 @@ namespace IceInternal return _name; } -#if !SILVERLIGHT public void Start(ThreadPriority priority) -#else - public void Start() -#endif { _thread = new Thread(new ThreadStart(Run)); _thread.IsBackground = true; _thread.Name = _name; -#if !SILVERLIGHT - _thread.Priority = priority; -#endif _thread.Start(); } diff --git a/csharp/src/Ice/AsyncResult.cs b/csharp/src/Ice/AsyncResult.cs index 42e8f78608d..5fad90abb05 100644 --- a/csharp/src/Ice/AsyncResult.cs +++ b/csharp/src/Ice/AsyncResult.cs @@ -205,11 +205,7 @@ namespace IceInternal { if(_waitHandle == null) { -#if SILVERLIGHT - _waitHandle = new ManualResetEvent(false); -#else _waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); -#endif } if((state_ & StateDone) != 0) { diff --git a/csharp/src/Ice/BZip2.cs b/csharp/src/Ice/BZip2.cs index ffa26f967b0..79e8020663d 100644 --- a/csharp/src/Ice/BZip2.cs +++ b/csharp/src/Ice/BZip2.cs @@ -12,13 +12,9 @@ namespace IceInternal using System; using System.Diagnostics; -#if !COMPACT && !SILVERLIGHT using System.Runtime.InteropServices; - using System.Runtime.Serialization; - using System.Runtime.Serialization.Formatters.Binary; -#endif -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED internal static class NativeMethods { [DllImport("bzip2.dll")] @@ -47,7 +43,7 @@ namespace IceInternal { static BZip2() { -#if MANAGED || COMPACT || SILVERLIGHT +#if MANAGED // // Protocol compression is not supported when using managed code. // @@ -94,7 +90,7 @@ namespace IceInternal #endif } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED static string getBZ2Error(int error) { string rc; @@ -165,7 +161,7 @@ namespace IceInternal { Debug.Assert(supported()); -#if MANAGED || COMPACT || SILVERLIGHT +#if MANAGED return null; #else // @@ -227,7 +223,7 @@ namespace IceInternal { Debug.Assert(supported()); -#if MANAGED || COMPACT || SILVERLIGHT +#if MANAGED return null; #else buf.b.position(headerSize); diff --git a/csharp/src/Ice/ByteBuffer.cs b/csharp/src/Ice/ByteBuffer.cs index 8112a6149bc..0dd59e20ed4 100644 --- a/csharp/src/Ice/ByteBuffer.cs +++ b/csharp/src/Ice/ByteBuffer.cs @@ -323,7 +323,7 @@ namespace IceInternal return v; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public short getShort(int pos) @@ -331,7 +331,7 @@ namespace IceInternal checkUnderflow(pos, 2); if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[pos]) { _valBytes.shortVal = *((short*)p); @@ -370,7 +370,7 @@ namespace IceInternal _position += len; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public ByteBuffer putShort(short val) @@ -379,7 +379,7 @@ namespace IceInternal _valBytes.shortVal = val; if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { *((short*)p) = _valBytes.shortVal; @@ -420,7 +420,7 @@ namespace IceInternal return this; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public int getInt() @@ -428,7 +428,7 @@ namespace IceInternal checkUnderflow(4); if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { _valBytes.intVal = *((int*)p); @@ -481,7 +481,7 @@ namespace IceInternal return this; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public ByteBuffer putInt(int pos, int val) @@ -497,7 +497,7 @@ namespace IceInternal _valBytes.intVal = val; if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[pos]) { *((int*)p) = _valBytes.intVal; @@ -550,7 +550,7 @@ namespace IceInternal return v; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public long getLong(int pos) @@ -558,7 +558,7 @@ namespace IceInternal checkUnderflow(pos, 8); if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[pos]) { _valBytes.longVal = *((long*)p); @@ -615,7 +615,7 @@ namespace IceInternal _position += len; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public ByteBuffer putLong(long val) @@ -624,7 +624,7 @@ namespace IceInternal _valBytes.longVal = val; if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { *((long*)p) = _valBytes.longVal; @@ -683,7 +683,7 @@ namespace IceInternal return this; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public float getFloat() @@ -691,7 +691,7 @@ namespace IceInternal checkUnderflow(4); if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { _valBytes.floatVal = *((float*)p); @@ -737,7 +737,7 @@ namespace IceInternal _position += len; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public ByteBuffer putFloat(float val) @@ -746,7 +746,7 @@ namespace IceInternal _valBytes.floatVal = val; if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { *((float*)p) = _valBytes.floatVal; @@ -793,7 +793,7 @@ namespace IceInternal return this; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public double getDouble() @@ -801,7 +801,7 @@ namespace IceInternal checkUnderflow(8); if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { _valBytes.doubleVal = *((double*)p); @@ -859,7 +859,7 @@ namespace IceInternal _position += len; } -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED unsafe #endif public ByteBuffer putDouble(double val) @@ -868,7 +868,7 @@ namespace IceInternal _valBytes.doubleVal = val; if(NO._o == _order) { -#if !MANAGED && !COMPACT && !SILVERLIGHT +#if !MANAGED fixed(byte* p = &_bytes[_position]) { *((double*)p) = _valBytes.doubleVal; @@ -989,11 +989,7 @@ namespace IceInternal private static void throwOutOfRange(string param, object value, string message) { -#if COMPACT || SILVERLIGHT - throw new ArgumentOutOfRangeException(param, message); -#else throw new ArgumentOutOfRangeException(param, value, message); -#endif } } } diff --git a/csharp/src/Ice/CollectionBase.cs b/csharp/src/Ice/CollectionBase.cs deleted file mode 100644 index df1ae7b1038..00000000000 --- a/csharp/src/Ice/CollectionBase.cs +++ /dev/null @@ -1,450 +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; -using System.Collections.Generic; - -namespace IceInternal -{ -#if !SILVERLIGHT - [Serializable] -#endif - public abstract class CollectionBase<T> : System.Collections.IList - { - protected List<T> list_; - - public CollectionBase() - { - list_ = new List<T>(); - } - - public CollectionBase(int capacity) - { - list_ = new List<T>(capacity); - } - - public CollectionBase(T[] a) - { - if(a == null) - { - throw new ArgumentNullException("a", "Cannot construct collection from null array"); - } - - list_ = new List<T>(a.Length); - list_.AddRange(a); - } - - public CollectionBase(IEnumerable<T> l) - { - if(l == null) - { - throw new ArgumentNullException("l", "Cannot construct collection from null collection"); - } - - list_ = new List<T>(); - list_.AddRange(l); - } - - public static implicit operator List<T>(CollectionBase<T> l) - { - return l.list_; - } - - - public void CopyTo(T[] a__) - { - list_.CopyTo(a__); - } - - public void CopyTo(T[] a__, int i__) - { - list_.CopyTo(a__, i__); - } - - public void CopyTo(int i__, T[] a__, int ai__, int _c_) - { - list_.CopyTo(i__, a__, ai__, _c_); - } - - public T[] ToArray() - { - return list_.ToArray(); - } - - public virtual void TrimToSize() - { - list_.TrimExcess(); - } - - public virtual void Sort() - { - list_.Sort(); - } - - public virtual void Sort(System.Collections.IComparer comparer) - { - list_.Sort(new Comparer(comparer)); - } - - public virtual void Sort(int index, int count, System.Collections.IComparer comparer) - { - list_.Sort(index, count, new Comparer(comparer)); - } - - public virtual void Reverse() - { - list_.Reverse(); - } - - public virtual void Reverse(int index, int count) - { - list_.Reverse(index, count); - } - - public virtual int BinarySearch(T value) - { - return list_.BinarySearch(value); - } - - public virtual int BinarySearch(T value, System.Collections.IComparer comparer) - { - return list_.BinarySearch(value, new Comparer(comparer)); - } - - public virtual int BinarySearch(int index, int count, T value, System.Collections.IComparer comparer) - { - return list_.BinarySearch(index, count, value, new Comparer(comparer)); - } - - public virtual void InsertRange(int index, CollectionBase<T> c) - { - list_.InsertRange(index, c.list_); - } - - public virtual void InsertRange(int index, T[] c) - { - list_.InsertRange(index, c); - } - - public virtual void RemoveRange(int index, int count) - { - list_.RemoveRange(index, count); - } - - public virtual void SetRange(int index, CollectionBase<T> c) - { - if(c == null) - { - throw new ArgumentNullException("c", "Collection must not be null for SetRange()"); - } - if(index < 0 || index + c.Count > list_.Count) - { - throw new ArgumentOutOfRangeException("index", "Index out of range"); - } - for(int i = index; i < list_.Count; ++i) - { - list_[i] = c[i - index]; - } - } - - public virtual void SetRange(int index, T[] c) - { - if(c == null) - { - throw new ArgumentNullException("c", "Collection must not be null for SetRange()"); - } - if(index < 0 || index + c.Length > list_.Count) - { - throw new ArgumentOutOfRangeException("index", "Index out of range"); - } - for(int i = index; i < list_.Count; ++i) - { - list_[i] = c[i - index]; - } - } - - public virtual int LastIndexOf(T value) - { - return list_.LastIndexOf(value); - } - - public virtual int LastIndexOf(T value, int startIndex) - { - return list_.LastIndexOf(value, startIndex); - } - - public virtual int LastIndexOf(T value, int startIndex, int count) - { - return list_.LastIndexOf(value, startIndex, count); - } - - public void AddRange(CollectionBase<T> s__) - { - list_.AddRange(s__.list_); - } - - public void AddRange(T[] a__) - { - list_.AddRange(a__); - } - - public int Capacity - { - get - { - return list_.Capacity; - } - - set - { - list_.Capacity = value; - } - } - - public int Count - { - get - { - return list_.Count; - } - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return list_.GetEnumerator(); - } - - public IEnumerator<T> GetEnumerator() - { - return list_.GetEnumerator(); - } - - public void RemoveAt(int index) - { - list_.RemoveAt(index); - } - - public int Add(T value) - { - list_.Add(value); - return list_.Count - 1; - } - - public void Clear() - { - list_.Clear(); - } - - public bool IsFixedSize - { - get - { - return false; - } - } - - public bool IsReadOnly - { - get - { - return false; - } - } - - public int IndexOf(T value) - { - return list_.IndexOf(value); - } - - public void Insert(int index, T value) - { - list_.Insert(index, value); - } - - public void Remove(T value) - { - list_.Remove(value); - } - - public bool Contains(T value) - { - return list_.Contains(value); - } - - public bool IsSynchronized - { - get - { - return false; - } - } - - public object SyncRoot - { - get - { - return this; - } - } - - public T this[int index] - { - get - { - return list_[index]; - } - set - { - list_[index] = value; - } - } - - public override int GetHashCode() - { - int h = 5381; - for(int i = 0; i < Count; ++i) - { - T v__ = list_[i]; - IceInternal.HashUtil.hashAdd(ref h, v__); - } - return h; - } - - public override bool Equals(object other) - { - if(object.ReferenceEquals(this, other)) - { - return true; - } - try - { - CollectionBase<T> c = (CollectionBase<T>)other; - if(list_.Count != c.list_.Count) - { - return false; - } - if(list_.Count == 0) - { - return true; - } - for(int i = 0; i < list_.Count; ++i) - { - if(!Equals(list_[i], c.list_[i])) - { - return false; - } - } - } - catch(System.Exception) - { - return false; - } - - return true; - } - - public static bool operator==(CollectionBase<T> lhs__, CollectionBase<T> rhs__) - { - return Equals(lhs__, rhs__); - } - - public static bool operator!=(CollectionBase<T> lhs__, CollectionBase<T> rhs__) - { - return !Equals(lhs__, rhs__); - } - - private class Comparer : IComparer<T> - { - private System.Collections.IComparer _c; - - public Comparer(System.Collections.IComparer c) - { - _c = c; - } - - public virtual int Compare(T l, T r) - { - return _c.Compare(l, r); - } - } - - public int Add(object o) - { - checkType(o); - return Add((T)o); - } - - public bool Contains(object o) - { - checkType(o); - return Contains((T)o); - } - - public int IndexOf(object o) - { - checkType(o); - return IndexOf((T)o); - } - - public void Insert(int i, object o) - { - checkType(o); - Insert(i, (T)o); - } - - public void Remove(object o) - { - checkType(o); - Remove((T)o); - } - - object System.Collections.IList.this[int index] - { - get - { - return this[index]; - } - set - { - checkType(value); - this[index] = (T)value; - } - } - - public void CopyTo(Array a, int index) - { - Type t = a.GetType().GetElementType(); - if(!t.IsAssignableFrom(typeof(T))) - { - throw new ArgumentException("a__", "Cannot assign " + typeof(T).ToString() + " to array of " - + t.ToString()); - } - CopyTo((T[])a, index); - } - - private void checkType(object o) - { - - if(o != null && !(o is T)) - { - throw new ArgumentException("Cannot use an object of type " + o.GetType().ToString() - + " with a collection of " + typeof(T).ToString()); - } - } - } - -} - -namespace Ice -{ - [Obsolete("This class is deprecated.")] - public abstract class CollectionBase<T> : IceInternal.CollectionBase<T> - { - } -} diff --git a/csharp/src/Ice/CollocatedRequestHandler.cs b/csharp/src/Ice/CollocatedRequestHandler.cs index b08e8626b9b..9e8ce8b777d 100644 --- a/csharp/src/Ice/CollocatedRequestHandler.cs +++ b/csharp/src/Ice/CollocatedRequestHandler.cs @@ -191,10 +191,10 @@ namespace IceInternal _sendAsyncRequests.Add(outAsync, requestId); } } - catch(System.Exception ex) + catch(System.Exception) { _adapter.decDirectCount(); - throw ex; + throw; } outAsync.attachCollocatedObserver(_adapter, requestId); diff --git a/csharp/src/Ice/ConnectionFactory.cs b/csharp/src/Ice/ConnectionFactory.cs index 8c56a2fbab3..d68b7e808c1 100644 --- a/csharp/src/Ice/ConnectionFactory.cs +++ b/csharp/src/Ice/ConnectionFactory.cs @@ -11,13 +11,9 @@ namespace IceInternal { using System; - using System.Collections; using System.Collections.Generic; using System.Diagnostics; - using System.Net.Sockets; - using System.Threading; using System.Text; - using IceUtilInternal; public class MultiDictionary<K, V> : Dictionary<K, ICollection<V>> { @@ -28,7 +24,7 @@ namespace IceInternal if(!this.TryGetValue(key, out list)) { list = new List<V>(); - this.Add(key, list); + Add(key, list); } list.Add(value); } @@ -40,7 +36,7 @@ namespace IceInternal list.Remove(value); if(list.Count == 0) { - this.Remove(key); + Remove(key); } } } @@ -148,7 +144,6 @@ namespace IceInternal } } - public void create(EndpointI[] endpts, bool hasMore, Ice.EndpointSelectionType selType, CreateConnectionCallback callback) { @@ -1303,9 +1298,7 @@ namespace IceInternal } finally { -#if !COMPACT && !SILVERLIGHT System.Environment.FailFast(s); -#endif } return false; } @@ -1329,9 +1322,7 @@ namespace IceInternal } finally { -#if !COMPACT && !SILVERLIGHT System.Environment.FailFast(s); -#endif } return false; } @@ -1409,9 +1400,7 @@ namespace IceInternal } finally { -#if !COMPACT && !SILVERLIGHT System.Environment.FailFast(s); -#endif } } @@ -1725,13 +1714,13 @@ namespace IceInternal _adapter.getThreadPool().unregister(this, SocketOperation.Read); } } - catch(SystemException ex) + catch(SystemException) { if(_acceptor != null) { _acceptor.close(); } - throw ex; + throw; } } diff --git a/csharp/src/Ice/DefaultsAndOverrides.cs b/csharp/src/Ice/DefaultsAndOverrides.cs index 573e0b673ec..bdf1084fd6e 100644 --- a/csharp/src/Ice/DefaultsAndOverrides.cs +++ b/csharp/src/Ice/DefaultsAndOverrides.cs @@ -107,10 +107,6 @@ namespace IceInternal overrideCloseTimeoutValue = -1; } -#if COMPACT - overrideCompress = false; - overrideCompressValue = false; -#else val = properties.getProperty("Ice.Override.Compress"); if(val.Length > 0) { @@ -128,7 +124,6 @@ namespace IceInternal overrideCompress = !BZip2.supported(); overrideCompressValue = false; } -#endif val = properties.getProperty("Ice.Override.Secure"); if(val.Length > 0) diff --git a/csharp/src/Ice/DictionaryBase.cs b/csharp/src/Ice/DictionaryBase.cs deleted file mode 100644 index 53dbb0a91ac..00000000000 --- a/csharp/src/Ice/DictionaryBase.cs +++ /dev/null @@ -1,355 +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; -using System.Collections.Generic; - -namespace IceInternal -{ -#if !SILVERLIGHT - [Serializable] -#endif - public abstract class DictionaryBase<KT, VT> : System.Collections.IDictionary - { - protected Dictionary<KT, VT> dict_; - - public DictionaryBase() - { - dict_ = new Dictionary<KT, VT>(); - } - - public int Count - { - get - { - return dict_.Count; - } - } - - public void Clear() - { - dict_.Clear(); - } - - public void CopyTo(System.Array a__, int index) - { - if(a__ == null) - { - throw new ArgumentNullException("a__", "Cannot copy to null array"); - } - if(index < 0) - { - throw new ArgumentException("Array index cannot be less than zero", "index"); - } - if(index >= a__.Length) - { - throw new ArgumentException("Array index must less than array length"); - } - if(dict_.Count > a__.Length - index) - { - throw new ArgumentException("Insufficient room in target array beyond index"); - } - if(a__.Rank > 1) - { - throw new ArgumentException("Cannot copy to multidimensional array", "a__"); - } - Type t = a__.GetType().GetElementType(); - if(!t.IsAssignableFrom(typeof(System.Collections.DictionaryEntry))) - { - throw new ArgumentException("Cannot assign DictionaryEntry to target array", "a__"); - } - - IEnumerator<KeyValuePair<KT, VT>> e = dict_.GetEnumerator(); - while(e.MoveNext()) - { - a__.SetValue(new System.Collections.DictionaryEntry(e.Current.Key, e.Current.Value), index++); - } - } - - public override bool Equals(object other) - { - if(object.ReferenceEquals(this, other)) - { - return true; - } - if(other == null) - { - return false; - } - - try - { - DictionaryBase<KT, VT> d2 = (DictionaryBase<KT, VT>)other; - - if(dict_.Count != d2.dict_.Count) - { - return false; - } - if(Count == 0) - { - return true; - } - - // - // Compare both sets of keys. Keys are unique and non-null. - // - Dictionary<KT, VT>.KeyCollection keys1 = dict_.Keys; - Dictionary<KT, VT>.KeyCollection keys2 = d2.dict_.Keys; - KT[] ka1 = new KT[dict_.Count]; - KT[] ka2 = new KT[d2.dict_.Count]; - keys1.CopyTo(ka1, 0); - keys2.CopyTo(ka2, 0); - Array.Sort(ka1); - Array.Sort(ka2); - - for(int i = 0; i < ka1.Length; ++i) - { - if(!Equals(ka1[i], ka2[i])) - { - return false; - } - if(!Equals(dict_[ka1[i]], d2.dict_[ka1[i]])) - { - return false; - } - } - - return true; - } - catch(System.Exception) - { - return false; - } - } - - public static bool operator==(DictionaryBase<KT, VT> lhs__, DictionaryBase<KT, VT> rhs__) - { - return Equals(lhs__, rhs__); - } - - public static bool operator!=(DictionaryBase<KT, VT> lhs__, DictionaryBase<KT, VT> rhs__) - { - return !Equals(lhs__, rhs__); - } - - public override int GetHashCode() - { - int h = 5381; - foreach(KeyValuePair<KT, VT> kvp in dict_) - { - IceInternal.HashUtil.hashAdd(ref h, kvp.Key); - IceInternal.HashUtil.hashAdd(ref h, kvp.Value); - } - return h; - } - - public class CEnumerator : System.Collections.IDictionaryEnumerator - { - public CEnumerator(IEnumerator<KeyValuePair<KT, VT>> e) - { - _e = e; - } - - public bool MoveNext() - { - return _e.MoveNext(); - } - - public object Current - { - get - { - return new System.Collections.DictionaryEntry(_e.Current.Key, _e.Current.Value); - } - } - - public System.Collections.DictionaryEntry Entry - { - get - { - return new System.Collections.DictionaryEntry(_e.Current.Key, _e.Current.Value); - } - } - - public object Key - { - get - { - return _e.Current.Key; - } - } - - public object Value - { - get - { - return _e.Current.Value; - } - } - - public void Reset() - { - _e.Reset(); - } - - private IEnumerator<KeyValuePair<KT, VT>> _e; - } - - public System.Collections.IEnumerator GetEnumerator() - { - return new CEnumerator(dict_.GetEnumerator()); - } - - public bool IsFixedSize - { - get - { - return false; - } - } - - public bool IsReadOnly - { - get - { - return false; - } - } - - public bool IsSynchronized - { - get - { - return false; - } - } - - public object SyncRoot - { - get - { - return this; - } - } - - public VT this[KT key] - { - get - { - return dict_[key]; - } - set - { - dict_[key] = value; - } - } - - public System.Collections.ICollection Keys - { - get - { - return dict_.Keys; - } - } - - public System.Collections.ICollection Values - { - get - { - return dict_.Values; - } - } - - public void Add(KT key, VT value) - { - try - { - dict_.Add(key, value); - } - catch(ArgumentException) - { - // Ignore. - } - } - - public void Remove(KT key) - { - dict_.Remove(key); - } - - public bool Contains(KT key) - { - return dict_.ContainsKey(key); - } - - public void Add(object key, object value) - { - checkKeyType(key); - checkValueType(value); - Add((KT)key, (VT)value); - } - - public void Remove(object key) - { - checkKeyType(key); - Remove((KT)key); - } - - public bool Contains(object key) - { - return dict_.ContainsKey((KT)key); - } - - System.Collections.IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator() - { - return new CEnumerator(dict_.GetEnumerator()); - } - - public object this[object key] - { - get - { - checkKeyType(key); - return dict_[(KT)key]; - } - set - { - checkKeyType(key); - checkValueType(value); - dict_[(KT)key] = (VT)value; - } - } - - private void checkKeyType(object o) - { - if(o != null && !(o is KT)) - { - throw new ArgumentException("Cannot use a key of type " + o.GetType().ToString() - + " for a dictionary with key type " + typeof(KT).ToString()); - } - } - - private void checkValueType(object o) - { - if(o != null && !(o is KT)) - { - throw new ArgumentException("Cannot use a value of type " + o.GetType().ToString() - + " for a dictionary with value type " + typeof(VT).ToString()); - } - } - } -} - -namespace Ice -{ - [Obsolete("This class is deprecated.")] - public abstract class DictionaryBase<KT, VT> : IceInternal.DictionaryBase<KT, VT> - { - } -} diff --git a/csharp/src/Ice/EndpointHostResolver.cs b/csharp/src/Ice/EndpointHostResolver.cs index c925763dfeb..886b5cc484c 100644 --- a/csharp/src/Ice/EndpointHostResolver.cs +++ b/csharp/src/Ice/EndpointHostResolver.cs @@ -7,10 +7,8 @@ // // ********************************************************************** -#if !SILVERLIGHT namespace IceInternal { - using System; using System.Collections.Generic; using System.Diagnostics; using System.Net; @@ -289,4 +287,3 @@ namespace IceInternal private HelperThread _thread; } } -#endif diff --git a/csharp/src/Ice/Exception.cs b/csharp/src/Ice/Exception.cs index 3fcda64934f..e07e9209a9c 100644 --- a/csharp/src/Ice/Exception.cs +++ b/csharp/src/Ice/Exception.cs @@ -7,7 +7,7 @@ // // ********************************************************************** -using System.Diagnostics; +using System; using System.Globalization; using System.Runtime.Serialization; @@ -35,10 +35,8 @@ namespace Ice /// <summary> /// Base class for Ice exceptions. /// </summary> -#if !SILVERLIGHT - [System.Serializable] -#endif - public abstract class Exception : System.Exception, System.ICloneable + [Serializable] + public abstract class Exception : System.Exception, ICloneable { /// <summary> /// Creates and returns a copy of this exception. @@ -61,21 +59,19 @@ namespace Ice /// <param name="ex">The inner exception.</param> public Exception(System.Exception ex) : base("", ex) {} -#if !SILVERLIGHT /// <summary> /// Initializes a new instance of the exception with serialized data. /// </summary> /// <param name="info">Holds the serialized object data about the exception being thrown.</param> /// <param name="context">Contains contextual information about the source or destination.</param> protected Exception(SerializationInfo info, StreamingContext context) : base(info, context) {} -#endif /// <summary> /// ice_name() is deprecated, use ice_id() instead. /// Returns the name of this exception. /// </summary> /// <returns>The name of this exception.</returns> - [System.Obsolete("ice_name() is deprecated, use ice_id() instead.")] + [Obsolete("ice_name() is deprecated, use ice_id() instead.")] public string ice_name() { return ice_id().Substring(2); @@ -132,9 +128,7 @@ namespace Ice /// <summary> /// Base class for local exceptions. /// </summary> -#if !SILVERLIGHT - [System.Serializable] -#endif + [Serializable] public abstract class LocalException : Exception { /// <summary> @@ -149,22 +143,18 @@ namespace Ice /// <param name="ex">The inner exception.</param> public LocalException(System.Exception ex) : base(ex) {} -#if !SILVERLIGHT /// <summary> /// Initializes a new instance of the exception with serialized data. /// </summary> /// <param name="info">Holds the serialized object data about the exception being thrown.</param> /// <param name="context">Contains contextual information about the source or destination.</param> protected LocalException(SerializationInfo info, StreamingContext context) : base(info, context) {} -#endif } /// <summary> /// Base class for Ice run-time exceptions. /// </summary> -#if !SILVERLIGHT - [System.Serializable] -#endif + [Serializable] public abstract class SystemException : Exception { /// <summary> @@ -179,22 +169,18 @@ namespace Ice /// <param name="ex">The inner exception.</param> public SystemException(System.Exception ex) : base(ex) {} -#if !SILVERLIGHT /// <summary> /// Initializes a new instance of the exception with serialized data. /// </summary> /// <param name="info">Holds the serialized object data about the exception being thrown.</param> /// <param name="context">Contains contextual information about the source or destination.</param> protected SystemException(SerializationInfo info, StreamingContext context) : base(info, context) {} -#endif } /// <summary> /// Base class for Slice user exceptions. /// </summary> -#if !SILVERLIGHT - [System.Serializable] -#endif + [Serializable] public abstract class UserException : Exception { /// <summary> @@ -209,14 +195,12 @@ namespace Ice /// <param name="ex">The inner exception.</param> public UserException(System.Exception ex) : base(ex) {} -#if !SILVERLIGHT /// <summary> /// Initializes a new instance of the exception with serialized data. /// </summary> /// <param name="info">Holds the serialized object data about the exception being thrown.</param> /// <param name="context">Contains contextual information about the source or destination.</param> protected UserException(SerializationInfo info, StreamingContext context) : base(info, context) {} -#endif public virtual void write__(OutputStream os__) { diff --git a/csharp/src/Ice/HashSet.cs b/csharp/src/Ice/HashSet.cs deleted file mode 100644 index 07b9743404e..00000000000 --- a/csharp/src/Ice/HashSet.cs +++ /dev/null @@ -1,114 +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. -// -// ********************************************************************** - -#if COMPACT - -// -// System.Collections.Generic.HashSet is not available in the .NET Compact Framework. -// This class is a minimal implementation that provides only the methods required by -// Ice internals. -// -using System; -using System.Collections.Generic; - -namespace IceInternal -{ - public class HashSet<T> : ICollection<T> - { - public HashSet() - { - entries_ = new Dictionary<T, bool>(); - } - - public HashSet(int capacity) - { - entries_ = new Dictionary<T, bool>(capacity); - } - - void ICollection<T>.Add(T item) - { - try - { - entries_.Add(item, false); - } - catch(ArgumentException) - { - // Item already present. - } - } - - public bool Add(T item) - { - try - { - entries_.Add(item, false); - } - catch(ArgumentException) - { - return false; // Item already present. - } - return true; - } - - public void Clear() - { - entries_.Clear(); - } - - public bool Contains(T item) - { - return entries_.ContainsKey(item); - } - - public void CopyTo(T[] a, int idx) - { - entries_.Keys.CopyTo(a, idx); - } - - public void CopyTo(T[] a) - { - entries_.Keys.CopyTo(a, 0); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return entries_.Keys.GetEnumerator(); - } - - public IEnumerator<T> GetEnumerator() - { - return entries_.Keys.GetEnumerator(); - } - - public bool Remove(T item) - { - return entries_.Remove(item); - } - - public int Count - { - get - { - return entries_.Count; - } - } - - public bool IsReadOnly - { - get - { - return false; - } - } - - private Dictionary<T, bool> entries_; - } -} - -#endif diff --git a/csharp/src/Ice/HttpParser.cs b/csharp/src/Ice/HttpParser.cs index e05758686fd..008ad3d6ca1 100644 --- a/csharp/src/Ice/HttpParser.cs +++ b/csharp/src/Ice/HttpParser.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System; using System.Diagnostics; using System.Collections.Generic; using System.Text; diff --git a/csharp/src/Ice/IPEndpointI.cs b/csharp/src/Ice/IPEndpointI.cs index 7cb442a4284..3a0263407bd 100644 --- a/csharp/src/Ice/IPEndpointI.cs +++ b/csharp/src/Ice/IPEndpointI.cs @@ -121,11 +121,7 @@ namespace IceInternal public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback) { -#if SILVERLIGHT - callback.connectors(connectors(selType)); -#else instance_.resolve(host_, port_, selType, this, callback); -#endif } public override List<EndpointI> expand() @@ -167,15 +163,6 @@ namespace IceInternal return connectors; } -#if SILVERLIGHT - public List<Connector> connectors(Ice.EndpointSelectionType selType) - { - return connectors(Network.getAddresses(host_, port_, instance_.protocolSupport(), selType, - instance_.preferIPv6(), false), - instance_.networkProxy()); - } -#endif - public override string options() { // diff --git a/csharp/src/Ice/InputStream.cs b/csharp/src/Ice/InputStream.cs index 121274da87d..b9cb5a50e35 100644 --- a/csharp/src/Ice/InputStream.cs +++ b/csharp/src/Ice/InputStream.cs @@ -11,15 +11,10 @@ namespace Ice { using System; - using System.Collections; using System.Collections.Generic; using System.Diagnostics; - using System.Reflection; -#if !COMPACT && !SILVERLIGHT using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; -#endif - using System.Threading; using Protocol = IceInternal.Protocol; /// <summary> @@ -1094,7 +1089,6 @@ namespace Ice /// <returns>The serializable object.</returns> public object readSerializable() { -#if !COMPACT && !SILVERLIGHT int sz = readAndCheckSeqSize(1); if(sz == 0) { @@ -1110,9 +1104,6 @@ namespace Ice { throw new Ice.MarshalException("cannot deserialize object:", ex); } -#else - throw new Ice.MarshalException("serialization not supported"); -#endif } /// <summary> @@ -3112,7 +3103,7 @@ namespace Ice // Set the reason member to a more helpful message. // ex.reason = "unknown exception type `" + mostDerivedId + "'"; - throw ex; + throw; } } } diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs index a2fe6072a2c..4aef3c883d5 100644 --- a/csharp/src/Ice/Instance.cs +++ b/csharp/src/Ice/Instance.cs @@ -83,13 +83,6 @@ namespace IceInternal return _defaultsAndOverrides; } -#if COMPACT || SILVERLIGHT - public string[] factoryAssemblies() - { - return _factoryAssemblies; - } -#endif - public RouterManager routerManager() { lock(this) @@ -259,7 +252,6 @@ namespace IceInternal } } -#if !SILVERLIGHT public EndpointHostResolver endpointHostResolver() { lock(this) @@ -273,7 +265,7 @@ namespace IceInternal return _endpointHostResolver; } } -#endif + public RetryQueue retryQueue() { @@ -730,7 +722,7 @@ namespace IceInternal { _initData.properties = Ice.Util.createProperties(); } -#if !SILVERLIGHT && !UNITY + lock(_staticLock) { if(!_oneOffDone) @@ -784,11 +776,9 @@ namespace IceInternal _oneOffDone = true; } } -#endif if(_initData.logger == null) { -#if !SILVERLIGHT && !UNITY string logfile = _initData.properties.getProperty("Ice.LogFile"); if(_initData.properties.getPropertyAsInt("Ice.UseSyslog") > 0 && AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows) @@ -811,23 +801,17 @@ namespace IceInternal // // Ice.ConsoleListener is enabled by default. // -# if COMPACT - _initData.logger = - new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName")); -# else bool console = _initData.properties.getPropertyAsIntWithDefault("Ice.ConsoleListener", 1) > 0; _initData.logger = new Ice.TraceLoggerI(_initData.properties.getProperty("Ice.ProgramName"), console); -# endif } -#else + if(Ice.Util.getProcessLogger() is Ice.LoggerI) { _initData.logger = new Ice.ConsoleLoggerI(_initData.properties.getProperty("Ice.ProgramName")); } -#endif else { _initData.logger = Ice.Util.getProcessLogger(); @@ -850,10 +834,6 @@ namespace IceInternal new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM", new ACMConfig(true))); -#if COMPACT || SILVERLIGHT - char[] separators = { ' ', '\t', '\n', '\r' }; - _factoryAssemblies = _initData.properties.getProperty("Ice.FactoryAssemblies").Split(separators); -#endif { const int defaultMessageSizeMax = 1024; int num = @@ -936,10 +916,7 @@ namespace IceInternal ProtocolInstance udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false); _endpointFactoryManager.add(new UdpEndpointFactory(udpInstance)); - -#if !SILVERLIGHT _pluginManager = new Ice.PluginManagerI(communicator); -#endif if(_initData.valueFactoryManager == null) { @@ -965,10 +942,8 @@ namespace IceInternal // Load plug-ins. // Debug.Assert(_serverThreadPool == null); -#if !SILVERLIGHT Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager; pluginManagerImpl.loadPlugins(ref args); -#endif // // Add WS and WSS endpoint factories if TCP/SSL factories are installed. @@ -1077,7 +1052,6 @@ namespace IceInternal // try { -#if !SILVERLIGHT if(initializationData().properties.getProperty("Ice.ThreadPriority").Length > 0) { ThreadPriority priority = IceInternal.Util.stringToThreadPriority( @@ -1088,9 +1062,6 @@ namespace IceInternal { _timer = new Timer(this); } -#else - _timer = new Timer(this); -#endif } catch(System.Exception ex) { @@ -1099,7 +1070,6 @@ namespace IceInternal throw; } -#if !SILVERLIGHT try { _endpointHostResolver = new EndpointHostResolver(this); @@ -1110,7 +1080,6 @@ namespace IceInternal _initData.logger.error(s); throw; } -#endif _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0); // @@ -1140,7 +1109,6 @@ namespace IceInternal // // Show process id if requested (but only once). // -#if !SILVERLIGHT lock(this) { if(!_printProcessIdDone && _initData.properties.getPropertyAsInt("Ice.PrintProcessId") > 0) @@ -1152,7 +1120,6 @@ namespace IceInternal _printProcessIdDone = true; } } -#endif // // Server thread pool initialization is lazy in serverThreadPool(). @@ -1163,12 +1130,11 @@ namespace IceInternal // initialization until after it has interacted directly with the // plug-ins. // -#if !SILVERLIGHT if(_initData.properties.getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0) { pluginManagerImpl.initializePlugins(); } -#endif + // // This must be done last as this call creates the Ice.Admin object adapter // and eventually registers a process proxy with the Ice locator (allowing @@ -1261,12 +1227,10 @@ namespace IceInternal { _asyncIOThread.destroy(); } -#if !SILVERLIGHT if(_endpointHostResolver != null) { _endpointHostResolver.destroy(); } -#endif // // Wait for all the threads to be finished. @@ -1287,12 +1251,10 @@ namespace IceInternal { _asyncIOThread.joinWithThread(); } -#if !SILVERLIGHT if(_endpointHostResolver != null) { _endpointHostResolver.joinWithThread(); } -#endif foreach(Ice.ObjectFactory factory in _objectFactoryMap.Values) { @@ -1350,9 +1312,7 @@ namespace IceInternal _serverThreadPool = null; _clientThreadPool = null; _asyncIOThread = null; -#if !SILVERLIGHT _endpointHostResolver = null; -#endif _timer = null; _referenceFactory = null; @@ -1469,12 +1429,10 @@ namespace IceInternal } Debug.Assert(_objectAdapterFactory != null); _objectAdapterFactory.updateThreadObservers(); -#if !SILVERLIGHT if(_endpointHostResolver != null) { _endpointHostResolver.updateObserver(); } -#endif if(_asyncIOThread != null) { _asyncIOThread.updateObserver(); @@ -1590,9 +1548,6 @@ namespace IceInternal private Ice.InitializationData _initData; // Immutable, not reset by destroy(). private TraceLevels _traceLevels; // Immutable, not reset by destroy(). private DefaultsAndOverrides _defaultsAndOverrides; // Immutable, not reset by destroy(). -#if COMPACT || SILVERLIGHT - private string[] _factoryAssemblies; // Immutable, not reset by destroy(). -#endif private int _messageSizeMax; // Immutable, not reset by destroy(). private int _batchAutoFlushSize; // Immutable, not reset by destroy(). private int _cacheMessageBuffers; // Immutable, not reset by destroy(). @@ -1612,9 +1567,7 @@ namespace IceInternal private ThreadPool _clientThreadPool; private ThreadPool _serverThreadPool; private AsyncIOThread _asyncIOThread; -#if !SILVERLIGHT private EndpointHostResolver _endpointHostResolver; -#endif private Timer _timer; private RetryQueue _retryQueue; private EndpointFactoryManager _endpointFactoryManager; @@ -1625,17 +1578,9 @@ namespace IceInternal private HashSet<string> _adminFacetFilter = new HashSet<string>(); private Ice.Identity _adminIdentity; private Dictionary<short, BufSizeWarnInfo> _setBufSizeWarn = new Dictionary<short, BufSizeWarnInfo>(); - -#if !SILVERLIGHT private static bool _printProcessIdDone = false; -#endif - -#if !SILVERLIGHT && !UNITY private static bool _oneOffDone = false; -#endif - private Dictionary<string, Ice.ObjectFactory> _objectFactoryMap = new Dictionary<string, Ice.ObjectFactory>(); - private static System.Object _staticLock = new System.Object(); } } diff --git a/csharp/src/Ice/LoggerAdminI.cs b/csharp/src/Ice/LoggerAdminI.cs index 9a3733803d5..0b8b872ee09 100644 --- a/csharp/src/Ice/LoggerAdminI.cs +++ b/csharp/src/Ice/LoggerAdminI.cs @@ -86,7 +86,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ catch(Ice.LocalException ex) { deadRemoteLogger(remoteLogger, _logger, ex, "init"); - throw ex; + throw; } } diff --git a/csharp/src/Ice/LoggerI.cs b/csharp/src/Ice/LoggerI.cs index 362c22dad60..8cdf59ddd98 100644 --- a/csharp/src/Ice/LoggerI.cs +++ b/csharp/src/Ice/LoggerI.cs @@ -7,15 +7,11 @@ // // ********************************************************************** -#define TRACE - namespace Ice { using System.Diagnostics; using System.Globalization; -#if !SILVERLIGHT && !UNITY using System.IO; -#endif public abstract class LoggerI : Logger { @@ -120,7 +116,6 @@ namespace Ice } } -#if !SILVERLIGHT && !UNITY public sealed class FileLoggerI : LoggerI { public FileLoggerI(string prefix, string file) : @@ -145,8 +140,6 @@ namespace Ice private TextWriter _writer; } - -# if !COMPACT public class ConsoleListener : TraceListener { public ConsoleListener() @@ -259,6 +252,4 @@ namespace Ice private bool _console; internal static ConsoleListener _consoleListener = new ConsoleListener(); } -# endif -#endif } diff --git a/csharp/src/Ice/MetricsAdminI.cs b/csharp/src/Ice/MetricsAdminI.cs index f949c593f3b..e298680e487 100644 --- a/csharp/src/Ice/MetricsAdminI.cs +++ b/csharp/src/Ice/MetricsAdminI.cs @@ -713,11 +713,7 @@ namespace IceInternal class MetricsMapFactory<T> : IMetricsMapFactory where T : IceMX.Metrics, new() { -#if COMPACT - public MetricsMapFactory(Ice.VoidAction updater) -#else public MetricsMapFactory(System.Action updater) -#endif { _updater = updater; } @@ -739,11 +735,7 @@ namespace IceInternal _subMaps.Add(subMap, new SubMapFactory<S>(field)); } -#if COMPACT - readonly private Ice.VoidAction _updater; -#else readonly private System.Action _updater; -#endif readonly private Dictionary<string, ISubMapFactory> _subMaps = new Dictionary<string, ISubMapFactory>(); } @@ -903,11 +895,7 @@ namespace IceInternal } } -#if COMPACT - public void registerMap<T>(string map, Ice.VoidAction updater) -#else public void registerMap<T>(string map, System.Action updater) -#endif where T : IceMX.Metrics, new() { bool updated; diff --git a/csharp/src/Ice/MetricsObserverI.cs b/csharp/src/Ice/MetricsObserverI.cs index bf7bc261362..ad3f4ad2412 100644 --- a/csharp/src/Ice/MetricsObserverI.cs +++ b/csharp/src/Ice/MetricsObserverI.cs @@ -38,17 +38,13 @@ namespace IceMX } return ""; } - catch(ArgumentOutOfRangeException ex) + catch(ArgumentOutOfRangeException) { - throw ex; + throw; } catch(Exception ex) { -#if COMPACT - throw new ArgumentOutOfRangeException(_name, ex.ToString()); -#else throw new ArgumentOutOfRangeException(_name, ex); -#endif } } @@ -407,11 +403,7 @@ namespace IceMX public void update() { -#if COMPACT - Ice.VoidAction updater; -#else - System.Action updater; -#endif + System.Action updater; lock(this) { _maps.Clear(); @@ -429,11 +421,7 @@ namespace IceMX } } -#if COMPACT - public void setUpdater(Ice.VoidAction updater) -#else public void setUpdater(System.Action updater) -#endif { lock(this) { @@ -445,10 +433,6 @@ namespace IceMX private readonly string _name; private List<MetricsMap<T>> _maps = new List<MetricsMap<T>>(); private volatile bool _enabled; -#if COMPACT - private Ice.VoidAction _updater; -#else private System.Action _updater; -#endif } } diff --git a/csharp/src/Ice/Network.cs b/csharp/src/Ice/Network.cs index 21e4caac666..a91fb166fe0 100644 --- a/csharp/src/Ice/Network.cs +++ b/csharp/src/Ice/Network.cs @@ -10,17 +10,10 @@ namespace IceInternal { using System; - using System.Collections; using System.Collections.Generic; - using System.ComponentModel; - using System.Diagnostics; using System.Net; -#if !COMPACT && !UNITY using System.Net.NetworkInformation; -#endif using System.Net.Sockets; - using System.Runtime.InteropServices; - using System.Threading; using System.Globalization; public sealed class Network @@ -30,71 +23,10 @@ namespace IceInternal public const int EnableIPv6 = 1; public const int EnableBoth = 2; -#if COMPACT - public static SocketError socketErrorCode(SocketException ex) - { - return (SocketError)ex.ErrorCode; - } -#else public static SocketError socketErrorCode(SocketException ex) { return ex.SocketErrorCode; } -#endif - -#if COMPACT - // - // SocketError enumeration isn't available with Silverlight - // - public enum SocketError - { - Interrupted = 10004, // A blocking Socket call was canceled. - //AccessDenied =10013, // An attempt was made to access a Socket in a way that is forbidden by its access permissions. - Fault = 10014, // An invalid pointer address was detected by the underlying socket provider. - InvalidArgument = 10022, // An invalid argument was supplied to a Socket member. - TooManyOpenSockets = 10024, // There are too many open sockets in the underlying socket provider. - WouldBlock = 10035, // An operation on a nonblocking socket cannot be completed immediately. - InProgress = 10036, // A blocking operation is in progress. - //AlreadyInProgress = 10037, // The nonblocking Socket already has an operation in progress. - //NotSocket = 10038, // A Socket operation was attempted on a non-socket. - //DestinationAddressRequired = 10039, // A required address was omitted from an operation on a Socket. - MessageSize = 10040, // The datagram is too long. - //ProtocolType = 10041, // The protocol type is incorrect for this Socket. - //ProtocolOption = 10042, // An unknown, invalid, or unsupported option or level was used with a Socket. - //ProtocolNotSupported = 10043, // The protocol is not implemented or has not been configured. - //SocketNotSupported = 10044, // The support for the specified socket type does not exist in this address family. - //OperationNotSupported = 10045, // The address family is not supported by the protocol family. - //ProtocolFamilyNotSupported = 10046, // The protocol family is not implemented or has not been configured. - //AddressFamilyNotSupported = 10047, // The address family specified is not supported. - //AddressAlreadyInUse = 10048, // Only one use of an address is normally permitted. - //AddressNotAvailable = 10049, // The selected IP address is not valid in this context. - NetworkDown = 10050, // The network is not available. - NetworkUnreachable = 10051, // No route to the remote host exists. - NetworkReset = 10052, // The application tried to set KeepAlive on a connection that has already timed out. - ConnectionAborted = 10053, // The connection was aborted by the .NET Framework or the underlying socket provider. - ConnectionReset = 10054, // The connection was reset by the remote peer. - NoBufferSpaceAvailable = 10055, // No free buffer space is available for a Socket operation. - //IsConnected = 10056, // The Socket is already connected. - NotConnected = 10057, // The application tried to send or receive data, and the Socket is not connected. - Shutdown = 10058, // A request to send or receive data was disallowed because the Socket has already been closed. - TimedOut = 10060, // The connection attempt timed out, or the connected host has failed to respond. - ConnectionRefused = 10061, // The remote host is actively refusing a connection. - //HostDown = 10064, // The operation failed because the remote host is down. - HostUnreachable = 10065, // There is no network route to the specified host. - //ProcessLimit = 10067, // Too many processes are using the underlying socket provider. - //SystemNotReady = 10091, // The network subsystem is unavailable. - //VersionNotSupported = 10092, // The version of the underlying socket provider is out of range. - //NotInitialized = 10093, // The underlying socket provider has not been initialized. - //Disconnecting = 10101, // A graceful shutdown is in progress. - //TypeNotFound = 10109, // The specified class was not found. - //HostNotFound = 11001, // No such host is known. The name is not an official host name or alias. - TryAgain = 11002, // The name of the host could not be resolved. Try again later. - //NoRecovery = 11003, // The error is unrecoverable or the requested database cannot be located. - //NoData = 11004, // The requested name or IP address was not found on the name server. - //IOPending = 997, // The application has initiated an overlapped operation that cannot be completed immediately. - OperationAborted =995 // The overlapped operation was aborted due to the closure of the Socket. - } -#endif public static bool interrupted(SocketException ex) { @@ -166,7 +98,6 @@ namespace IceInternal return connectionLost(ex.InnerException as SocketException); } -#if !UNITY // // In other cases the IOException has no inner exception. We could examine the // exception's message, but that is fragile due to localization issues. We @@ -186,8 +117,6 @@ namespace IceInternal { return true; } -#endif - return false; } @@ -240,11 +169,7 @@ namespace IceInternal public static bool isMulticast(IPEndPoint addr) { -#if COMPACT - string ip = addr.Address.ToString().ToUpper(); -#else string ip = addr.Address.ToString().ToUpperInvariant(); -#endif if(addr.AddressFamily == AddressFamily.InterNetwork) { char[] splitChars = { '.' }; @@ -316,12 +241,8 @@ namespace IceInternal try { setTcpNoDelay(socket); -#if !SILVERLIGHT socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1); -# if !__MonoCS__ setTcpLoopbackFastPath(socket); -# endif -#endif } catch(SocketException ex) { @@ -335,7 +256,6 @@ namespace IceInternal public static Socket createServerSocket(bool udp, AddressFamily family, int protocol) { Socket socket = createSocket(udp, family); -# if !COMPACT && !UNITY && !__MonoCS__ && !SILVERLIGHT && !DOTNET3_5 // // The IPv6Only enumerator was added in .NET 4. // @@ -352,7 +272,6 @@ namespace IceInternal throw new Ice.SocketException(ex); } } -#endif return socket; } @@ -392,11 +311,7 @@ namespace IceInternal { try { -#if SILVERLIGHT - socket.NoDelay = true; -#else socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1); -#endif } catch(System.Exception ex) { @@ -405,7 +320,6 @@ namespace IceInternal } } -#if !SILVERLIGHT public static void setTcpLoopbackFastPath(Socket socket) { const int SIO_LOOPBACK_FAST_PATH = (-1744830448); @@ -446,17 +360,12 @@ namespace IceInternal throw new Ice.SocketException(ex); } } -#endif public static void setSendBufferSize(Socket socket, int sz) { try { -#if SILVERLIGHT - socket.SendBufferSize = sz; -#else socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, sz); -#endif } catch(SocketException ex) { @@ -470,11 +379,7 @@ namespace IceInternal int sz; try { -#if SILVERLIGHT - sz = socket.SendBufferSize; -#else sz = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer); -#endif } catch(SocketException ex) { @@ -488,11 +393,7 @@ namespace IceInternal { try { -#if SILVERLIGHT - socket.ReceiveBufferSize = sz; -#else socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, sz); -#endif } catch(SocketException ex) { @@ -506,11 +407,7 @@ namespace IceInternal int sz = 0; try { -#if SILVERLIGHT - sz = socket.ReceiveBufferSize; -#else sz = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer); -#endif } catch(SocketException ex) { @@ -520,7 +417,6 @@ namespace IceInternal return sz; } -#if !SILVERLIGHT public static void setReuseAddress(Socket socket, bool reuse) { try @@ -577,9 +473,6 @@ namespace IceInternal if(group.AddressFamily == AddressFamily.InterNetwork) { MulticastOption option; -#if COMPACT - option = new MulticastOption(group); -#else if(index == -1) { option = new MulticastOption(group); @@ -589,7 +482,6 @@ namespace IceInternal { option = new MulticastOption(group, index); } -#endif s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, option); } else @@ -612,15 +504,11 @@ namespace IceInternal throw new Ice.SocketException(ex); } } -#endif public static void setMcastTtl(Socket socket, int ttl, AddressFamily family) { try { -#if SILVERLIGHT - socket.Ttl = (short)ttl; -#else if(family == AddressFamily.InterNetwork) { socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, ttl); @@ -629,7 +517,6 @@ namespace IceInternal { socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.MulticastTimeToLive, ttl); } -#endif } catch(SocketException ex) { @@ -638,7 +525,6 @@ namespace IceInternal } } -#if !SILVERLIGHT public static IPEndPoint doBind(Socket socket, EndPoint addr) { try @@ -673,9 +559,7 @@ namespace IceInternal throw new Ice.SocketException(ex); } } -#endif -#if !SILVERLIGHT public static bool doConnect(Socket fd, EndPoint addr, EndPoint sourceAddr) { EndPoint bindAddr = sourceAddr; @@ -835,7 +719,6 @@ namespace IceInternal } } } -#endif public static EndPoint getAddressForServer(string host, int port, int protocol, bool preferIPv6) { @@ -898,29 +781,13 @@ namespace IceInternal } catch(FormatException) { -#if !SILVERLIGHT if(!blocking) { return addresses; } -#endif } -#if SILVERLIGHT - if(protocol != EnableIPv6) - { - addresses.Add(new DnsEndPoint(host, port, AddressFamily.InterNetwork)); - } - if(protocol != EnableIPv4) - { - addresses.Add(new DnsEndPoint(host, port, AddressFamily.InterNetworkV6)); - } -#else -# if COMPACT - foreach(IPAddress a in Dns.GetHostEntry(host).AddressList) -# else foreach(IPAddress a in Dns.GetHostAddresses(host)) -# endif { if((a.AddressFamily == AddressFamily.InterNetwork && protocol != EnableIPv6) || (a.AddressFamily == AddressFamily.InterNetworkV6 && protocol != EnableIPv4)) @@ -928,7 +795,6 @@ namespace IceInternal addresses.Add(new IPEndPoint(a, port)); } } -#endif if(selType == Ice.EndpointSelectionType.Random) { @@ -978,9 +844,6 @@ namespace IceInternal public static IPAddress[] getLocalAddresses(int protocol, bool includeLoopback) { -#if SILVERLIGHT - return new List<IPAddress>().ToArray(); -#else List<IPAddress> addresses; int retry = 5; @@ -988,7 +851,6 @@ namespace IceInternal try { addresses = new List<IPAddress>(); -# if !COMPACT && !UNITY NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); foreach(NetworkInterface ni in nics) { @@ -1006,12 +868,8 @@ namespace IceInternal } } } -# else -# if COMPACT - foreach(IPAddress a in Dns.GetHostEntry(Dns.GetHostName()).AddressList) -# else + foreach(IPAddress a in Dns.GetHostAddresses(Dns.GetHostName())) -# endif { if((a.AddressFamily == AddressFamily.InterNetwork && protocol != EnableIPv6) || (a.AddressFamily == AddressFamily.InterNetworkV6 && protocol != EnableIPv4)) @@ -1022,7 +880,6 @@ namespace IceInternal } } } -# endif } catch(SocketException ex) { @@ -1042,7 +899,6 @@ namespace IceInternal } return addresses.ToArray(); -#endif } public static bool @@ -1153,11 +1009,7 @@ namespace IceInternal getLocalAddresses(ipv4Wildcard ? Network.EnableIPv4 : protocol, includeLoopback); foreach(IPAddress a in addrs) { -#if COMPACT - if(!IPAddress.IsLoopback(a)) -#else if(!isLinklocal(a)) -#endif { hosts.Add(a.ToString()); } @@ -1239,11 +1091,7 @@ namespace IceInternal { if(endpoint == null) { -#if SILVERLIGHT - return "<not available>"; -#else return "<not bound>"; -#endif } return endpointAddressToString(endpoint) + ":" + endpointPort(endpoint); } @@ -1261,8 +1109,6 @@ namespace IceInternal public static EndPoint getLocalAddress(Socket socket) { - // Silverlight socket doesn't exposes a local endpoint -#if !SILVERLIGHT try { return socket.LocalEndPoint; @@ -1271,9 +1117,6 @@ namespace IceInternal { throw new Ice.SocketException(ex); } -#else - return null; -#endif } public static EndPoint @@ -1312,7 +1155,6 @@ namespace IceInternal { } -#if !COMPACT && !SILVERLIGHT && !UNITY NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); try { @@ -1371,7 +1213,6 @@ namespace IceInternal } } } -#endif return -1; } @@ -1418,13 +1259,6 @@ namespace IceInternal { if(endpoint != null) { -#if SILVERLIGHT - if(endpoint is DnsEndPoint) - { - DnsEndPoint dnsEndpoint = (DnsEndPoint)endpoint; - return dnsEndpoint.Host; - } -#endif if(endpoint is IPEndPoint) { IPEndPoint ipEndpoint = (IPEndPoint) endpoint; @@ -1439,13 +1273,6 @@ namespace IceInternal { if(endpoint != null) { -#if SILVERLIGHT - if(endpoint is DnsEndPoint) - { - DnsEndPoint dnsEndpoint = (DnsEndPoint)endpoint; - return dnsEndpoint.Port; - } -#endif if(endpoint is IPEndPoint) { IPEndPoint ipEndpoint = (IPEndPoint) endpoint; diff --git a/csharp/src/Ice/NetworkProxy.cs b/csharp/src/Ice/NetworkProxy.cs index 09cffa914d2..424dc1a5e67 100644 --- a/csharp/src/Ice/NetworkProxy.cs +++ b/csharp/src/Ice/NetworkProxy.cs @@ -39,7 +39,6 @@ namespace IceInternal // void finish(Buffer readBuffer, Buffer writeBuffer); -#if !SILVERLIGHT // // If the proxy host needs to be resolved, this should return // a new NetworkProxy containing the IP address of the proxy. @@ -47,7 +46,7 @@ namespace IceInternal // it's safe if this this method blocks. // NetworkProxy resolveHost(int protocolSupport); -#endif + // // Returns the IP address of the network proxy. This method // must not block. It's only called on a network proxy object @@ -70,12 +69,8 @@ namespace IceInternal { public SOCKSNetworkProxy(string host, int port) { -#if SILVERLIGHT - _address = new DnsEndPoint(host, port, AddressFamily.InterNetwork); -#else _host = host; _port = port; -#endif } private SOCKSNetworkProxy(EndPoint address) @@ -144,7 +139,6 @@ namespace IceInternal } } -#if !SILVERLIGHT public NetworkProxy resolveHost(int protocolSupport) { Debug.Assert(_host != null); @@ -155,7 +149,6 @@ namespace IceInternal false, true)[0]); } -#endif public EndPoint getAddress() { @@ -173,10 +166,8 @@ namespace IceInternal return Network.EnableIPv4; } -#if !SILVERLIGHT private readonly string _host; private readonly int _port; -#endif private readonly EndPoint _address; } @@ -184,14 +175,9 @@ namespace IceInternal { public HTTPNetworkProxy(string host, int port) { -#if SILVERLIGHT - _address = new DnsEndPoint(host, port, AddressFamily.InterNetwork); - _protocolSupport = Network.EnableIPv4; -#else _host = host; _port = port; _protocolSupport = Network.EnableBoth; -#endif } private HTTPNetworkProxy(EndPoint address, int protocolSupport) @@ -209,12 +195,7 @@ namespace IceInternal str.Append(" HTTP/1.1\r\nHost: "); str.Append(addr); str.Append("\r\n\r\n"); - -#if SILVERLIGHT - byte[] b = System.Text.Encoding.UTF8.GetBytes(str.ToString()); -#else byte[] b = System.Text.Encoding.ASCII.GetBytes(str.ToString()); -#endif // // HTTP connect request @@ -271,7 +252,6 @@ namespace IceInternal } } -#if !SILVERLIGHT public NetworkProxy resolveHost(int protocolSupport) { Debug.Assert(_host != null); @@ -283,7 +263,6 @@ namespace IceInternal true)[0], protocolSupport); } -#endif public EndPoint getAddress() { @@ -301,10 +280,8 @@ namespace IceInternal return _protocolSupport; } -#if !SILVERLIGHT private readonly string _host; private readonly int _port; -#endif private readonly EndPoint _address; private readonly int _protocolSupport; } diff --git a/csharp/src/Ice/ObjectAdapterI.cs b/csharp/src/Ice/ObjectAdapterI.cs index df2f40c720d..f6dec965c71 100644 --- a/csharp/src/Ice/ObjectAdapterI.cs +++ b/csharp/src/Ice/ObjectAdapterI.cs @@ -1018,36 +1018,6 @@ namespace Ice } } - /* - ~ObjectAdapterI() - { - if(!_deactivated) - { - string msg = "object adapter `" + getName() + "' has not been deactivated"; - if(!Environment.HasShutdownStarted) - { - instance_.initializationData().logger.warning(msg); - } - else - { - Console.Error.WriteLine(msg); - } - } - else if(!_destroyed) - { - string msg = "object adapter `" + getName() + "' has not been destroyed"; - if(!Environment.HasShutdownStarted) - { - instance_.initializationData().logger.warning(msg); - } - else - { - Console.Error.WriteLine(msg); - } - } - } - */ - private ObjectPrx newProxy(Identity ident, string facet) { if(_id.Length == 0) @@ -1205,25 +1175,6 @@ namespace Ice EndpointI endp = instance_.endpointFactoryManager().create(s, oaEndpoints); if(endp == null) { -#if COMPACT - if(s.StartsWith("ssl", StringComparison.Ordinal) || s.StartsWith("wss", StringComparison.Ordinal)) - { - instance_.initializationData().logger.warning( - "ignoring endpoint `" + s + - "': IceSSL is not supported with the .NET Compact Framework"); - ++end; - continue; - } -#else - if(AssemblyUtil.runtime_ == AssemblyUtil.Runtime.Mono && - (s.StartsWith("ssl", StringComparison.Ordinal) || s.StartsWith("wss", StringComparison.Ordinal))) - { - instance_.initializationData().logger.warning( - "ignoring endpoint `" + s + "': IceSSL is not supported with Mono"); - ++end; - continue; - } -#endif Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid object adapter endpoint `" + s + "'"; throw e2; diff --git a/csharp/src/Ice/Optional.cs b/csharp/src/Ice/Optional.cs index 84802723371..1ea9aad3862 100644 --- a/csharp/src/Ice/Optional.cs +++ b/csharp/src/Ice/Optional.cs @@ -20,12 +20,8 @@ namespace Ice /// <summary> /// Encapsulates an optional value. Instances of this type are immutable. /// </summary> -#if SILVERLIGHT - public struct Optional<T> -#else [Serializable] public struct Optional<T> : ISerializable -#endif { /// <summary> /// Creates an optional value whose state is unset. @@ -54,7 +50,6 @@ namespace Ice _isSet = v._isSet; } -#if !SILVERLIGHT /// <summary> /// Initializes a new instance of the exception with serialized data. /// </summary> @@ -72,7 +67,6 @@ namespace Ice _value = default(T); } } -#endif /// <summary> /// Conversion operator to the underlying type; a cast is required. An exception @@ -175,7 +169,6 @@ namespace Ice } } -#if !SILVERLIGHT /// <summary> /// Serializes an optional value. /// </summary> @@ -189,7 +182,6 @@ namespace Ice info.AddValue("value", _value, typeof(T)); } } -#endif private T _value; private bool _isSet; diff --git a/csharp/src/Ice/Options.cs b/csharp/src/Ice/Options.cs index 0455909611a..d8fb7a9958a 100644 --- a/csharp/src/Ice/Options.cs +++ b/csharp/src/Ice/Options.cs @@ -7,6 +7,7 @@ // // ********************************************************************** +using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -15,7 +16,7 @@ namespace IceUtilInternal { public sealed class Options { - public sealed class BadQuote : System.Exception + public sealed class BadQuote : Exception { public BadQuote(string message) : base(message) { diff --git a/csharp/src/Ice/OutgoingAsync.cs b/csharp/src/Ice/OutgoingAsync.cs index 22c8966020a..0f376ede850 100644 --- a/csharp/src/Ice/OutgoingAsync.cs +++ b/csharp/src/Ice/OutgoingAsync.cs @@ -347,7 +347,7 @@ namespace IceInternal // if(userThread) { - throw ex; + throw; } Ice.AsyncCallback cb = finished(ex); // No retries, we're done if(cb != null) @@ -775,10 +775,10 @@ namespace IceInternal _is.startEncapsulation(); _is.throwException(null); } - catch(Ice.UserException ex) + catch(Ice.UserException) { _is.endEncapsulation(); - throw ex; + throw; } } @@ -868,10 +868,10 @@ namespace IceInternal } Debug.Assert(sentCB == null); } - catch(Ice.LocalException ex) + catch(Ice.LocalException) { doCheck(false); - throw ex; + throw; } } diff --git a/csharp/src/Ice/OutputStream.cs b/csharp/src/Ice/OutputStream.cs index 242f89d3b0a..fa7ae881100 100644 --- a/csharp/src/Ice/OutputStream.cs +++ b/csharp/src/Ice/OutputStream.cs @@ -15,10 +15,8 @@ namespace Ice using System.Collections.Generic; using System.Diagnostics; using System.Reflection; -#if !COMPACT && !SILVERLIGHT using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; -#endif using System.Threading; using Protocol = IceInternal.Protocol; @@ -728,7 +726,6 @@ namespace Ice /// <param name="o">The serializable object to write.</param> public void writeSerializable(object o) { -#if !COMPACT && !SILVERLIGHT if(o == null) { writeSize(0); @@ -745,9 +742,6 @@ namespace Ice { throw new Ice.MarshalException("cannot serialize object:", ex); } -#else - throw new Ice.MarshalException("serialization not supported"); -#endif } /// <summary> diff --git a/csharp/src/Ice/Patcher.cs b/csharp/src/Ice/Patcher.cs index f709d05194f..947602f247d 100644 --- a/csharp/src/Ice/Patcher.cs +++ b/csharp/src/Ice/Patcher.cs @@ -210,42 +210,6 @@ namespace IceInternal private int _index; // The index at which to patch the array. } - public sealed class SequencePatcher<T> - { - public SequencePatcher(string type, IceInternal.CollectionBase<T> seq, int index) - { - _type = type; - _seq = seq; - _index = index; - } - - public void patch(Ice.Object v) - { - if(v != null && !typeof(T).IsAssignableFrom(v.GetType())) - { - IceInternal.Ex.throwUOE(_type, v.ice_id()); - } - - int count = _seq.Count; - if(_index >= count) // Need to grow the sequence. - { - for(int i = count; i < _index; i++) - { - _seq.Add(default(T)); - } - _seq.Add((T)v); - } - else - { - _seq[_index] = (T)v; - } - } - - private string _type; - private IceInternal.CollectionBase<T> _seq; - private int _index; // The index at which to patch the sequence. - } - public sealed class ListPatcher<T> { public ListPatcher(string type, List<T> seq, int index) diff --git a/csharp/src/Ice/PluginManagerI.cs b/csharp/src/Ice/PluginManagerI.cs index 3f0009bbaba..692d18ac8da 100644 --- a/csharp/src/Ice/PluginManagerI.cs +++ b/csharp/src/Ice/PluginManagerI.cs @@ -7,7 +7,6 @@ // // ********************************************************************** -#if !SILVERLIGHT namespace Ice { using System; @@ -57,15 +56,13 @@ namespace Ice { p.plugin.initialize(); } - catch(PluginInitializationException ex) + catch(PluginInitializationException) { - throw ex; + throw; } catch(System.Exception ex) { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = "plugin `" + p.name + "' initialization failed"; - throw e; + throw new PluginInitializationException(String.Format("plugin `{0}' initialization failed", p.name), ex); } initializedPlugins.Add(p.plugin); } @@ -405,37 +402,6 @@ namespace Ice } catch(System.Exception ex) { -#if COMPACT - // - // IceSSL is not supported with the Compact Framework. - // - if(name == "IceSSL") - { - if(!_sslWarnOnce) - { - _communicator.getLogger().warning( - "IceSSL plug-in not loaded: IceSSL is not supported with the .NET Compact Framework"); - _sslWarnOnce = true; - } - return; - } -#else - // - // IceSSL is not yet supported with Mono. We avoid throwing an exception in that case, - // so the same configuration can be used with Mono or Visual C#. - // - if(IceInternal.AssemblyUtil.runtime_ == IceInternal.AssemblyUtil.Runtime.Mono && name == "IceSSL") - { - if(!_sslWarnOnce) - { - _communicator.getLogger().warning( - "IceSSL plug-in not loaded: IceSSL is not supported with Mono"); - _sslWarnOnce = true; - } - return; - } -#endif - PluginInitializationException e = new PluginInitializationException(); e.reason = err + "unable to load assembly: `" + assemblyName + "': " + ex.ToString(); throw e; @@ -494,7 +460,7 @@ namespace Ice catch(PluginInitializationException ex) { ex.reason = err + ex.reason; - throw ex; + throw; } catch(System.Exception ex) { @@ -537,7 +503,5 @@ namespace Ice private Communicator _communicator; private ArrayList _plugins; private bool _initialized; - private static bool _sslWarnOnce = false; } } -#endif diff --git a/csharp/src/Ice/PropertiesI.cs b/csharp/src/Ice/PropertiesI.cs index a7dc668167f..af84ff0c503 100644 --- a/csharp/src/Ice/PropertiesI.cs +++ b/csharp/src/Ice/PropertiesI.cs @@ -313,10 +313,6 @@ namespace Ice public void load(string file) { -#if UNITY - throw new FeatureNotSupportedException("File I/O not supported in UNITY build"); -#else -# if !SILVERLIGHT if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows && (file.StartsWith("HKLM\\", StringComparison.Ordinal))) { @@ -339,7 +335,6 @@ namespace Ice } else { -# endif try { using(System.IO.StreamReader sr = new System.IO.StreamReader(file)) @@ -353,10 +348,7 @@ namespace Ice fe.path = file; throw fe; } -# if !SILVERLIGHT } -# endif -#endif } public Properties ice_clone_() @@ -662,8 +654,6 @@ namespace Ice private void loadConfig() { string val = getProperty("Ice.Config"); - -#if !COMPACT && !SILVERLIGHT if(val.Length == 0 || val.Equals("1")) { string s = System.Environment.GetEnvironmentVariable("ICE_CONFIG"); @@ -672,7 +662,6 @@ namespace Ice val = s; } } -#endif if(val.Length > 0) { diff --git a/csharp/src/Ice/Protocol.cs b/csharp/src/Ice/Protocol.cs index d8144552b0f..8db65a45542 100644 --- a/csharp/src/Ice/Protocol.cs +++ b/csharp/src/Ice/Protocol.cs @@ -9,7 +9,6 @@ namespace IceInternal { - public sealed class Protocol { // diff --git a/csharp/src/Ice/ProtocolInstance.cs b/csharp/src/Ice/ProtocolInstance.cs index 35ef7cc3909..9552e1e3198 100644 --- a/csharp/src/Ice/ProtocolInstance.cs +++ b/csharp/src/Ice/ProtocolInstance.cs @@ -7,11 +7,10 @@ // // ********************************************************************** +using System.Net; + namespace IceInternal { - using System.Net; - using System.Collections.Generic; - public class ProtocolInstance { public ProtocolInstance(Ice.Communicator communicator, short type, string protocol, bool secure) @@ -113,13 +112,11 @@ namespace IceInternal return instance_.messageSizeMax(); } -#if !SILVERLIGHT public void resolve(string host, int port, Ice.EndpointSelectionType type, IPEndpointI endpt, EndpointI_connectors callback) { instance_.endpointHostResolver().resolve(host, port, type, endpt, callback); } -#endif public BufSizeWarnInfo getBufSizeWarn(short type) { diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index 5c509216595..c912662cbdc 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -8,11 +8,9 @@ // ********************************************************************** using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using IceUtilInternal; -using Ice.Instrumentation; namespace Ice { diff --git a/csharp/src/Ice/Reference.cs b/csharp/src/Ice/Reference.cs index 0dd31858f3e..5b827fc0935 100644 --- a/csharp/src/Ice/Reference.cs +++ b/csharp/src/Ice/Reference.cs @@ -8,7 +8,6 @@ // ********************************************************************** using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Text; diff --git a/csharp/src/Ice/ReferenceFactory.cs b/csharp/src/Ice/ReferenceFactory.cs index 1a8aad17952..0bbdbc5a23c 100644 --- a/csharp/src/Ice/ReferenceFactory.cs +++ b/csharp/src/Ice/ReferenceFactory.cs @@ -8,7 +8,6 @@ // ********************************************************************** using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Text; diff --git a/csharp/src/Ice/RequestHandler.cs b/csharp/src/Ice/RequestHandler.cs index bc2359e7255..37471ceec04 100644 --- a/csharp/src/Ice/RequestHandler.cs +++ b/csharp/src/Ice/RequestHandler.cs @@ -7,9 +7,6 @@ // // ********************************************************************** -using System.Collections.Generic; -using Ice.Instrumentation; - namespace IceInternal { public interface CancellationHandler diff --git a/csharp/src/Ice/RequestHandlerFactory.cs b/csharp/src/Ice/RequestHandlerFactory.cs index 25c93d35a41..c30707f2492 100644 --- a/csharp/src/Ice/RequestHandlerFactory.cs +++ b/csharp/src/Ice/RequestHandlerFactory.cs @@ -8,7 +8,6 @@ // ********************************************************************** using System.Collections.Generic; -using System.Diagnostics; namespace IceInternal { diff --git a/csharp/src/Ice/RouterInfo.cs b/csharp/src/Ice/RouterInfo.cs index 7a6d0cddffd..cfb7645d598 100644 --- a/csharp/src/Ice/RouterInfo.cs +++ b/csharp/src/Ice/RouterInfo.cs @@ -9,8 +9,6 @@ namespace IceInternal { - - using System.Collections; using System.Collections.Generic; using System.Diagnostics; diff --git a/csharp/src/Ice/SliceChecksums.cs b/csharp/src/Ice/SliceChecksums.cs index 6b388683481..2f809f1fd02 100644 --- a/csharp/src/Ice/SliceChecksums.cs +++ b/csharp/src/Ice/SliceChecksums.cs @@ -9,7 +9,6 @@ namespace Ice { - using System; using System.Collections; using System.Collections.Generic; @@ -18,8 +17,6 @@ namespace Ice public sealed class SliceChecksums { public static Dictionary<string, string> checksums = new Dictionary<string, string>(); - -#if !COMPACT && !SILVERLIGHT static SliceChecksums() { Type[] types = IceInternal.AssemblyUtil.findTypesWithPrefix("IceInternal.SliceChecksums"); @@ -33,7 +30,6 @@ namespace Ice } } } -#endif } } diff --git a/csharp/src/Ice/StreamSocket.cs b/csharp/src/Ice/StreamSocket.cs index 6801484906d..f5a0663f5c2 100644 --- a/csharp/src/Ice/StreamSocket.cs +++ b/csharp/src/Ice/StreamSocket.cs @@ -7,14 +7,6 @@ // // ********************************************************************** -// -// .NET and Silverlight use the new socket asynchronous APIs whereas -// the compact framework and mono still use the old Begin/End APIs. -// -#if !COMPACT && !__MonoCS__ && !UNITY -#define ICE_SOCKET_ASYNC_API -#endif - namespace IceInternal { using System; @@ -45,20 +37,18 @@ namespace IceInternal { _desc = IceInternal.Network.fdToString(_fd); } - catch(Exception ex) + catch(Exception) { Network.closeSocketNoThrow(_fd); - throw ex; + throw; } init(); } -#if !SILVERLIGHT public void setBlock(bool block) { Network.setBlock(_fd, block); } -#endif public int connect(Buffer readBuffer, Buffer writeBuffer, ref bool moreData) { @@ -69,7 +59,6 @@ namespace IceInternal } else if(_state <= StateConnectPending) { -#if ICE_SOCKET_ASYNC_API if(_writeEventArgs.SocketError != SocketError.Success) { SocketException ex = new SocketException((int)_writeEventArgs.SocketError); @@ -82,10 +71,6 @@ namespace IceInternal throw new Ice.ConnectFailedException(ex); } } -#else - Network.doFinishConnectAsync(_fd, _writeResult); - _writeResult = null; -#endif _desc = Network.fdToString(_fd, _proxy, _addr); _state = _proxy != null ? StateProxyWrite : StateConnected; } @@ -186,25 +171,15 @@ namespace IceInternal public bool startRead(Buffer buf, AsyncCallback callback, object state) { -#if ICE_SOCKET_ASYNC_API Debug.Assert(_fd != null && _readEventArgs != null); -#else - Debug.Assert(_fd != null && _readResult == null); -#endif int packetSize = getRecvPacketSize(buf.b.remaining()); try { _readCallback = callback; -#if ICE_SOCKET_ASYNC_API _readEventArgs.UserToken = state; _readEventArgs.SetBuffer(buf.b.rawBytes(), buf.b.position(), packetSize); return !_fd.ReceiveAsync(_readEventArgs); -#else - _readResult = _fd.BeginReceive(buf.b.rawBytes(), buf.b.position(), packetSize, SocketFlags.None, - readCompleted, state); - return _readResult.CompletedSynchronously; -#endif } catch(SocketException ex) { @@ -220,30 +195,19 @@ namespace IceInternal { if(_fd == null) // Transceiver was closed { -#if !ICE_SOCKET_ASYNC_API - _readResult = null; -#endif return; } -#if ICE_SOCKET_ASYNC_API Debug.Assert(_fd != null && _readEventArgs != null); -#else - Debug.Assert(_fd != null && _readResult != null); -#endif try { -#if ICE_SOCKET_ASYNC_API if(_readEventArgs.SocketError != SocketError.Success) { throw new SocketException((int)_readEventArgs.SocketError); } int ret = _readEventArgs.BytesTransferred; _readEventArgs.SetBuffer(null, 0, 0); -#else - int ret = _fd.EndReceive(_readResult); - _readResult = null; -#endif + if(ret == 0) { throw new Ice.ConnectionLostException(); @@ -273,12 +237,7 @@ namespace IceInternal public bool startWrite(Buffer buf, AsyncCallback callback, object state, out bool completed) { -#if ICE_SOCKET_ASYNC_API Debug.Assert(_fd != null && _writeEventArgs != null); -#else - Debug.Assert(_fd != null && _writeResult == null); -#endif - if(_state == StateConnectPending) { completed = false; @@ -286,14 +245,9 @@ namespace IceInternal try { EndPoint addr = _proxy != null ? _proxy.getAddress() : _addr; -#if ICE_SOCKET_ASYNC_API _writeEventArgs.RemoteEndPoint = addr; _writeEventArgs.UserToken = state; return !_fd.ConnectAsync(_writeEventArgs); -#else - _writeResult = Network.doConnectAsync(_fd, addr, _sourceAddr, callback, state); - return _writeResult.CompletedSynchronously; -#endif } catch(Exception ex) { @@ -305,15 +259,9 @@ namespace IceInternal try { _writeCallback = callback; -#if ICE_SOCKET_ASYNC_API _writeEventArgs.UserToken = state; _writeEventArgs.SetBuffer(buf.b.rawBytes(), buf.b.position(), packetSize); bool completedSynchronously = !_fd.SendAsync(_writeEventArgs); -#else - _writeResult = _fd.BeginSend(buf.b.rawBytes(), buf.b.position(), packetSize, SocketFlags.None, - writeCompleted, state); - bool completedSynchronously = _writeResult.CompletedSynchronously; -#endif completed = packetSize == buf.b.remaining(); return completedSynchronously; } @@ -339,17 +287,10 @@ namespace IceInternal { buf.b.position(buf.b.limit()); // Assume all the data was sent for at-most-once semantics. } -#if !ICE_SOCKET_ASYNC_API - _writeResult = null; -#endif return; } -#if ICE_SOCKET_ASYNC_API Debug.Assert(_fd != null && _writeEventArgs != null); -#else - Debug.Assert(_fd != null && _writeResult != null); -#endif if(_state < StateConnected && _state != StateProxyWrite) { @@ -358,17 +299,12 @@ namespace IceInternal try { -#if ICE_SOCKET_ASYNC_API if(_writeEventArgs.SocketError != SocketError.Success) { throw new SocketException((int)_writeEventArgs.SocketError); } int ret = _writeEventArgs.BytesTransferred; _writeEventArgs.SetBuffer(null, 0, 0); -#else - int ret = _fd.EndSend(_writeResult); - _writeResult = null; -#endif if(ret == 0) { throw new Ice.ConnectionLostException(); @@ -412,11 +348,9 @@ namespace IceInternal public void destroy() { -#if ICE_SOCKET_ASYNC_API Debug.Assert(_readEventArgs != null && _writeEventArgs != null); _readEventArgs.Dispose(); _writeEventArgs.Dispose(); -#endif } public override string ToString() @@ -427,16 +361,6 @@ namespace IceInternal private int read(ByteBuffer buf) { Debug.Assert(_fd != null); - -#if COMPACT || SILVERLIGHT - // - // Silverlight and the Compact .NET Framework don't - // support the use of synchronous socket operations on a - // non-blocking socket. Returning 0 here forces the caller - // to schedule an asynchronous operation. - // - return 0; -#else int read = 0; while(buf.hasRemaining()) { @@ -469,23 +393,12 @@ namespace IceInternal } } return read; -#endif } private int write(ByteBuffer buf) { Debug.Assert(_fd != null); -#if COMPACT || SILVERLIGHT - // - // Silverlight and the Compact .NET Frameworks don't - // support the use of synchronous socket operations on a - // non-blocking socket. Returning 0 here forces the caller - // to schedule an asynchronous operation. - // - return 0; -#else - int packetSize = buf.remaining(); if(AssemblyUtil.platform_ == AssemblyUtil.Platform.Windows) { @@ -529,10 +442,7 @@ namespace IceInternal } } return sent; -#endif } - -#if ICE_SOCKET_ASYNC_API private void ioCompleted(object sender, SocketAsyncEventArgs e) { switch (e.LastOperation) @@ -548,50 +458,17 @@ namespace IceInternal throw new ArgumentException("The last operation completed on the socket was not a receive or send"); } } -#else - private void readCompleted(IAsyncResult result) - { - if(!result.CompletedSynchronously) - { - _readCallback(result.AsyncState); - } - } - - private void writeCompleted(IAsyncResult result) - { - if(!result.CompletedSynchronously) - { - _writeCallback(result.AsyncState); - } - } -#endif private void init() { -#if !SILVERLIGHT Network.setBlock(_fd, false); -#endif Network.setTcpBufSize(_fd, _instance); -#if ICE_SOCKET_ASYNC_API _readEventArgs = new SocketAsyncEventArgs(); _readEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted); _writeEventArgs = new SocketAsyncEventArgs(); _writeEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted); -# if SILVERLIGHT - String policy = _instance.properties().getProperty("Ice.ClientAccessPolicyProtocol"); - if(policy.Equals("Http")) - { - _readEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http; - _writeEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http; - } - else if(!String.IsNullOrEmpty(policy)) - { - _instance.logger().warning("Ignoring invalid Ice.ClientAccessPolicyProtocol value `" + policy + "'"); - } -# endif -#endif // // For timeouts to work properly, we need to receive/send @@ -628,13 +505,8 @@ namespace IceInternal private int _state; private string _desc; -#if ICE_SOCKET_ASYNC_API private SocketAsyncEventArgs _writeEventArgs; private SocketAsyncEventArgs _readEventArgs; -#else - private IAsyncResult _writeResult; - private IAsyncResult _readResult; -#endif AsyncCallback _writeCallback; AsyncCallback _readCallback; diff --git a/csharp/src/Ice/StreamWrapper.cs b/csharp/src/Ice/StreamWrapper.cs index 5bb5d653de6..983182a9ff6 100644 --- a/csharp/src/Ice/StreamWrapper.cs +++ b/csharp/src/Ice/StreamWrapper.cs @@ -10,11 +10,8 @@ namespace IceInternal { - - using System; using System.Diagnostics; using System.IO; - using System.Text; // // Classes to provide a System.IO.Stream interface on top of an Ice stream. diff --git a/csharp/src/Ice/SysLoggerI.cs b/csharp/src/Ice/SysLoggerI.cs index d1524d4b13e..f4b5650659c 100644 --- a/csharp/src/Ice/SysLoggerI.cs +++ b/csharp/src/Ice/SysLoggerI.cs @@ -7,7 +7,6 @@ // // ********************************************************************** -#if !SILVERLIGHT using System.Net.Sockets; namespace Ice @@ -231,4 +230,3 @@ namespace Ice } } -#endif diff --git a/csharp/src/Ice/TcpAcceptor.cs b/csharp/src/Ice/TcpAcceptor.cs index 26733afcbe0..8bddfc491ea 100644 --- a/csharp/src/Ice/TcpAcceptor.cs +++ b/csharp/src/Ice/TcpAcceptor.cs @@ -7,8 +7,6 @@ // // ********************************************************************** -#if !SILVERLIGHT - namespace IceInternal { using System; @@ -136,9 +134,7 @@ namespace IceInternal _addr = (IPEndPoint)Network.getAddressForServer(host, port, protocol, _instance.preferIPv6()); _fd = Network.createServerSocket(false, _addr.AddressFamily, protocol); Network.setBlock(_fd, false); -# if !COMPACT Network.setTcpBufSize(_fd, _instance); -# endif if(AssemblyUtil.platform_ != AssemblyUtil.Platform.Windows) { // @@ -173,4 +169,3 @@ namespace IceInternal private IAsyncResult _result; } } -#endif diff --git a/csharp/src/Ice/TcpConnector.cs b/csharp/src/Ice/TcpConnector.cs index 287b0d97671..a4ca495c2a2 100644 --- a/csharp/src/Ice/TcpConnector.cs +++ b/csharp/src/Ice/TcpConnector.cs @@ -9,10 +9,7 @@ namespace IceInternal { - using System; - using System.Diagnostics; using System.Net; - using System.Net.Sockets; sealed class TcpConnector : Connector { diff --git a/csharp/src/Ice/TcpEndpointI.cs b/csharp/src/Ice/TcpEndpointI.cs index 6541470e53b..bb8c0e18638 100644 --- a/csharp/src/Ice/TcpEndpointI.cs +++ b/csharp/src/Ice/TcpEndpointI.cs @@ -9,10 +9,8 @@ namespace IceInternal { - using System.Diagnostics; using System.Collections.Generic; using System.Net; - using System; using System.Globalization; sealed class TcpEndpointI : IPEndpointI, WSEndpointDelegate @@ -150,20 +148,14 @@ namespace IceInternal public override Acceptor acceptor(string adapterName) { -#if SILVERLIGHT - throw new Ice.FeatureNotSupportedException("server endpoint not supported for `" + ToString() + "'"); -#else return new TcpAcceptor(this, instance_, host_, port_); -#endif } -#if !SILVERLIGHT public TcpEndpointI endpoint(TcpAcceptor acceptor) { return new TcpEndpointI(instance_, host_, acceptor.effectivePort(), sourceAddr_, _timeout, connectionId_, _compress); } -#endif public override string options() { diff --git a/csharp/src/Ice/TcpTransceiver.cs b/csharp/src/Ice/TcpTransceiver.cs index 67e948d764f..42cf3319890 100644 --- a/csharp/src/Ice/TcpTransceiver.cs +++ b/csharp/src/Ice/TcpTransceiver.cs @@ -9,8 +9,6 @@ namespace IceInternal { - using System; - using System.ComponentModel; using System.Diagnostics; using System.Collections.Generic; using System.Net; diff --git a/csharp/src/Ice/ThreadPool.cs b/csharp/src/Ice/ThreadPool.cs index a4abc6c64a0..d42b087f82b 100644 --- a/csharp/src/Ice/ThreadPool.cs +++ b/csharp/src/Ice/ThreadPool.cs @@ -9,8 +9,6 @@ namespace IceInternal { - - using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading; @@ -196,8 +194,6 @@ namespace IceInternal stackSize = 0; } _stackSize = stackSize; - -#if !SILVERLIGHT _hasPriority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0; _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority")); if(!_hasPriority) @@ -205,7 +201,6 @@ namespace IceInternal _hasPriority = properties.getProperty("Ice.ThreadPriority").Length > 0; _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority")); } -#endif if(_instance.traceLevels().threadPool >= 1) { @@ -222,7 +217,6 @@ namespace IceInternal for(int i = 0; i < _size; ++i) { WorkerThread thread = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++); -#if !SILVERLIGHT if(_hasPriority) { thread.start(_priority); @@ -231,9 +225,6 @@ namespace IceInternal { thread.start(ThreadPriority.Normal); } -#else - thread.start(); -#endif _threads.Add(thread); } } @@ -351,11 +342,7 @@ namespace IceInternal } } -#if COMPACT - public void dispatchFromThisThread(Ice.VoidAction call, Ice.Connection con) -#else public void dispatchFromThisThread(System.Action call, Ice.Connection con) -#endif { if(_dispatcher != null) { @@ -378,11 +365,7 @@ namespace IceInternal } } -#if COMPACT - public void dispatch(Ice.VoidAction call, Ice.Connection con) -#else public void dispatch(System.Action call, Ice.Connection con) -#endif { lock(this) { @@ -415,7 +398,6 @@ namespace IceInternal try { WorkerThread t = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++); -#if !SILVERLIGHT if(_hasPriority) { t.start(_priority); @@ -424,9 +406,6 @@ namespace IceInternal { t.start(ThreadPriority.Normal); } -#else - t.start(); -#endif _threads.Add(t); } catch(System.Exception ex) @@ -778,7 +757,6 @@ namespace IceInternal _thread.Join(); } -#if !SILVERLIGHT public void start(ThreadPriority priority) { if(_threadPool._stackSize == 0) @@ -794,15 +772,6 @@ namespace IceInternal _thread.Priority = priority; _thread.Start(); } -#else - public void start() - { - _thread = new Thread(new ThreadStart(Run)); - _thread.IsBackground = true; - _thread.Name = _name; - _thread.Start(); - } -#endif public void Run() { @@ -858,10 +827,8 @@ namespace IceInternal private readonly int _sizeMax; // Maximum number of threads. 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. -#if !SILVERLIGHT private readonly ThreadPriority _priority; private readonly bool _hasPriority = false; -#endif private readonly int _serverIdleTime; private readonly int _threadIdleTime; private readonly int _stackSize; diff --git a/csharp/src/Ice/Time.cs b/csharp/src/Ice/Time.cs index 4b5f57e29d4..7223291991d 100644 --- a/csharp/src/Ice/Time.cs +++ b/csharp/src/Ice/Time.cs @@ -9,7 +9,6 @@ namespace IceInternal { -#if !SILVERLIGHT using System.Diagnostics; public sealed class Time @@ -26,78 +25,4 @@ namespace IceInternal private static Stopwatch _stopwatch = new Stopwatch(); } - -#else - - public class Stopwatch - { - public void Start() - { - if(!_running) - { - _startTick = System.DateTime.Now.Ticks; - _running = true; - } - } - - public void Stop() - { - if(_running) - { - _elapsedTicks += System.DateTime.Now.Ticks - _startTick; - _running = false; - } - - } - - public void Reset() - { - _startTick = 0; - _elapsedTicks = 0; - _running = false; - } - - public long ElapsedTicks - { - get - { - if(!_running) - { - return _elapsedTicks; - } - else - { - return _elapsedTicks + (System.DateTime.Now.Ticks - _startTick); - } - } - } - - public long Frequency - { - get - { - return System.TimeSpan.TicksPerMillisecond * 1000; - } - } - - private long _startTick = 0; - private long _elapsedTicks = 0; - private bool _running = false; - } - - public sealed class Time - { - static Time() - { - _begin = System.DateTime.Now.Ticks; - } - - public static long currentMonotonicTimeMillis() - { - return (System.DateTime.Now.Ticks - _begin) / 10000; - } - - private static long _begin; - } -#endif } diff --git a/csharp/src/Ice/Timer.cs b/csharp/src/Ice/Timer.cs index 497b60975c4..266faf90a19 100644 --- a/csharp/src/Ice/Timer.cs +++ b/csharp/src/Ice/Timer.cs @@ -15,10 +15,8 @@ namespace IceInternal { - using System; using System.Diagnostics; using System.Threading; - using System.Collections; using System.Collections.Generic; public interface TimerTask @@ -61,16 +59,7 @@ namespace IceInternal try { _tasks.Add(task, token); -#if SILVERLIGHT - int index = _tokens.BinarySearch(token); - Debug.Assert(index < 0); - if(index < 0) - { - _tokens.Insert(~index, token); - } -#else _tokens.Add(token, null); -#endif } catch(System.ArgumentException) { @@ -98,16 +87,7 @@ namespace IceInternal try { _tasks.Add(task, token); -#if SILVERLIGHT - int index = _tokens.BinarySearch(token); - Debug.Assert(index < 0); - if(index < 0) - { - _tokens.Insert(~index, token); - } -#else _tokens.Add(token, null); -#endif } catch(System.ArgumentException) { @@ -144,27 +124,17 @@ namespace IceInternal // // Only for use by Instance. // -#if !SILVERLIGHT internal Timer(IceInternal.Instance instance, ThreadPriority priority) { init(instance, priority, true); } -#endif internal Timer(IceInternal.Instance instance) { -#if !SILVERLIGHT init(instance, ThreadPriority.Normal, false); -#else - init(instance); -#endif } -#if !SILVERLIGHT internal void init(IceInternal.Instance instance, ThreadPriority priority, bool hasPriority) -#else - internal void init(IceInternal.Instance instance) -#endif { _instance = instance; @@ -177,12 +147,10 @@ namespace IceInternal _thread = new Thread(new ThreadStart(Run)); _thread.IsBackground = true; _thread.Name = threadName + "Ice.Timer"; -#if !SILVERLIGHT if(hasPriority) { _thread.Priority = priority; } -#endif _thread.Start(); } @@ -220,16 +188,7 @@ namespace IceInternal if(_tasks.ContainsKey(token.task)) { token.scheduledTime = Time.currentMonotonicTimeMillis() + token.delay; -#if SILVERLIGHT - int index = _tokens.BinarySearch(token); - Debug.Assert(index < 0); - if(index < 0) - { - _tokens.Insert(~index, token); - } -#else _tokens.Add(token, null); -#endif } } } @@ -256,11 +215,7 @@ namespace IceInternal long now = Time.currentMonotonicTimeMillis(); Token first = null; -#if SILVERLIGHT - foreach(Token t in _tokens) -#else foreach(Token t in _tokens.Keys) -#endif { first = t; break; @@ -389,13 +344,7 @@ namespace IceInternal public TimerTask task; } -#if COMPACT - private IDictionary<Token, object> _tokens = new SortedList<Token, object>(); -#elif SILVERLIGHT - private List<Token> _tokens = new List<Token>(); -#else private IDictionary<Token, object> _tokens = new SortedDictionary<Token, object>(); -#endif private IDictionary<TimerTask, Token> _tasks = new Dictionary<TimerTask, Token>(); private Instance _instance; private long _wakeUpTime = System.Int64.MaxValue; diff --git a/csharp/src/Ice/TraceLevels.cs b/csharp/src/Ice/TraceLevels.cs index 9d9cce0bb96..185d64151bd 100644 --- a/csharp/src/Ice/TraceLevels.cs +++ b/csharp/src/Ice/TraceLevels.cs @@ -9,7 +9,6 @@ namespace IceInternal { - public sealed class TraceLevels { internal TraceLevels(Ice.Properties properties) diff --git a/csharp/src/Ice/TraceUtil.cs b/csharp/src/Ice/TraceUtil.cs index 1e74629e761..e191dfe7e05 100644 --- a/csharp/src/Ice/TraceUtil.cs +++ b/csharp/src/Ice/TraceUtil.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System.Collections.Generic; using System.Diagnostics; using System.Globalization; diff --git a/csharp/src/Ice/Transceiver.cs b/csharp/src/Ice/Transceiver.cs index f1f4a512b02..70f5260b65e 100644 --- a/csharp/src/Ice/Transceiver.cs +++ b/csharp/src/Ice/Transceiver.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System; using System.Net.Sockets; public interface Transceiver diff --git a/csharp/src/Ice/UdpConnector.cs b/csharp/src/Ice/UdpConnector.cs index 7de5ab2d217..b9aea3b0a58 100644 --- a/csharp/src/Ice/UdpConnector.cs +++ b/csharp/src/Ice/UdpConnector.cs @@ -9,10 +9,7 @@ namespace IceInternal { - using System; - using System.Diagnostics; using System.Net; - using System.Net.Sockets; sealed class UdpConnector : Connector { diff --git a/csharp/src/Ice/UdpTransceiver.cs b/csharp/src/Ice/UdpTransceiver.cs index 612edd6565f..e2ac691bf86 100644 --- a/csharp/src/Ice/UdpTransceiver.cs +++ b/csharp/src/Ice/UdpTransceiver.cs @@ -7,14 +7,6 @@ // // ********************************************************************** -// -// .NET and Silverlight use the new socket asynchronous APIs whereas -// the compact framework and mono still use the old Begin/End APIs. -// -#if !COMPACT && !__MonoCS__ && !UNITY -#define ICE_SOCKET_ASYNC_API -#endif - namespace IceInternal { using System; @@ -37,7 +29,6 @@ namespace IceInternal if(_state == StateNeedConnect) { _state = StateConnectPending; -#if ICE_SOCKET_ASYNC_API && !SILVERLIGHT try { if(_sourceAddr != null) @@ -58,14 +49,10 @@ namespace IceInternal { throw new Ice.ConnectFailedException(ex); } -#else - return SocketOperation.Connect; -#endif } if(_state <= StateConnectPending) { -#if !SILVERLIGHT if(!AssemblyUtil.osx_) { // @@ -82,7 +69,6 @@ namespace IceInternal } } } -#endif _state = StateConnected; } @@ -115,7 +101,6 @@ namespace IceInternal public EndpointI bind() { -#if !SILVERLIGHT if(Network.isMulticast((IPEndPoint)_addr)) { Network.setReuseAddress(_fd, true); @@ -165,7 +150,6 @@ namespace IceInternal } _addr = Network.doBind(_fd, _addr); } -#endif _bound = true; _endpoint = _endpoint.endpoint(this); return _endpoint; @@ -173,10 +157,8 @@ namespace IceInternal public void destroy() { -#if ICE_SOCKET_ASYNC_API _readEventArgs.Dispose(); _writeEventArgs.Dispose(); -#endif } public int write(Buffer buf) @@ -185,20 +167,7 @@ namespace IceInternal { return SocketOperation.None; } -#if COMPACT || SILVERLIGHT -# if !ICE_SOCKET_ASYNC_API - if(_writeResult != null) - { - return SocketOperation.None; - } -# endif - // - // Silverlight and the Compact .NET Framework don't support the use of synchronous socket - // operations on a non-blocking socket. Returning SocketOperation.Write here forces the - // caller to schedule an asynchronous operation. - // - return SocketOperation.Write; -#else + Debug.Assert(buf.b.position() == 0); Debug.Assert(_fd != null && _state >= StateConnected); @@ -255,7 +224,6 @@ namespace IceInternal Debug.Assert(ret == buf.b.limit()); buf.b.position(buf.b.limit()); return SocketOperation.None; -#endif } public int read(Buffer buf, ref bool hasMoreData) @@ -264,14 +232,7 @@ namespace IceInternal { return SocketOperation.None; } -#if COMPACT || SILVERLIGHT - // - // Silverlight and the Compact .NET Framework don't support the use of synchronous socket - // operations on a non-blocking socket. Returning SocketOperation.Read here forces the - // caller to schedule an asynchronous operation. - // - return SocketOperation.Read; -#else + Debug.Assert(buf.b.position() == 0); Debug.Assert(_fd != null); @@ -372,7 +333,6 @@ namespace IceInternal buf.b.position(ret); return SocketOperation.None; -#endif } public bool startRead(Buffer buf, AsyncCallback callback, object state) @@ -388,42 +348,17 @@ namespace IceInternal if(_state == StateConnected) { _readCallback = callback; -#if ICE_SOCKET_ASYNC_API _readEventArgs.UserToken = state; _readEventArgs.SetBuffer(buf.b.rawBytes(), buf.b.position(), packetSize); return !_fd.ReceiveAsync(_readEventArgs); -#else - _readResult = _fd.BeginReceive(buf.b.rawBytes(), 0, buf.b.limit(), SocketFlags.None, - readCompleted, state); - return _readResult.CompletedSynchronously; -#endif } else { Debug.Assert(_incoming); _readCallback = callback; -#if ICE_SOCKET_ASYNC_API _readEventArgs.UserToken = state; _readEventArgs.SetBuffer(buf.b.rawBytes(), 0, buf.b.limit()); return !_fd.ReceiveFromAsync(_readEventArgs); -#else - EndPoint peerAddr = _peerAddr; - if(peerAddr == null) - { - if(_addr.AddressFamily == AddressFamily.InterNetwork) - { - peerAddr = new IPEndPoint(IPAddress.Any, 0); - } - else - { - Debug.Assert(_addr.AddressFamily == AddressFamily.InterNetworkV6); - peerAddr = new IPEndPoint(IPAddress.IPv6Any, 0); - } - } - _readResult = _fd.BeginReceiveFrom(buf.b.rawBytes(), 0, buf.b.limit(), SocketFlags.None, - ref peerAddr, readCompleted, state); - return _readResult.CompletedSynchronously; -#endif } } catch(SocketException ex) @@ -457,7 +392,6 @@ namespace IceInternal int ret; try { -#if ICE_SOCKET_ASYNC_API if(_readEventArgs.SocketError != SocketError.Success) { throw new SocketException((int)_readEventArgs.SocketError); @@ -467,29 +401,6 @@ namespace IceInternal { _peerAddr = _readEventArgs.RemoteEndPoint; } -#else - Debug.Assert(_readResult != null); - if(_state == StateConnected) - { - ret = _fd.EndReceive(_readResult); - } - else - { - EndPoint peerAddr = _peerAddr; - if(_addr.AddressFamily == AddressFamily.InterNetwork) - { - peerAddr = new IPEndPoint(IPAddress.Any, 0); - } - else - { - Debug.Assert(_addr.AddressFamily == AddressFamily.InterNetworkV6); - peerAddr = new IPEndPoint(IPAddress.IPv6Any, 0); - } - ret = _fd.EndReceiveFrom(_readResult, ref peerAddr); - _peerAddr = (IPEndPoint)peerAddr; - } - _readResult = null; -#endif } catch(SocketException ex) { @@ -533,11 +444,7 @@ namespace IceInternal // If we must connect, then we connect to the first peer that // sends us a packet. // -#if ICE_SOCKET_ASYNC_API bool connected = !_fd.ConnectAsync(_readEventArgs); -#else - bool connected = Network.doConnect(_fd, _peerAddr, null); -#endif Debug.Assert(connected); _state = StateConnected; // We're connected now @@ -558,19 +465,12 @@ namespace IceInternal { Debug.Assert(_addr != null); completed = false; -#if ICE_SOCKET_ASYNC_API -# if !SILVERLIGHT if(_sourceAddr != null) { _fd.Bind(_sourceAddr); } -# endif _writeEventArgs.UserToken = state; return !_fd.ConnectAsync(_writeEventArgs); -#else - _writeResult = Network.doConnectAsync(_fd, _addr, _sourceAddr, callback, state); - return _writeResult.CompletedSynchronously; -#endif } Debug.Assert(_fd != null); @@ -587,15 +487,9 @@ namespace IceInternal if(_state == StateConnected) { -#if ICE_SOCKET_ASYNC_API _writeEventArgs.UserToken = state; _writeEventArgs.SetBuffer(buf.b.rawBytes(), 0, buf.b.limit()); completedSynchronously = !_fd.SendAsync(_writeEventArgs); -#else - _writeResult = _fd.BeginSend(buf.b.rawBytes(), 0, buf.b.limit(), SocketFlags.None, - writeCompleted, state); - completedSynchronously = _writeResult.CompletedSynchronously; -#endif } else { @@ -603,16 +497,10 @@ namespace IceInternal { throw new Ice.SocketException(); } -#if ICE_SOCKET_ASYNC_API _writeEventArgs.RemoteEndPoint = _peerAddr; _writeEventArgs.UserToken = state; _writeEventArgs.SetBuffer(buf.b.rawBytes(), 0, buf.b.limit()); completedSynchronously = !_fd.SendToAsync(_writeEventArgs); -#else - _writeResult = _fd.BeginSendTo(buf.b.rawBytes(), 0, buf.b.limit(), SocketFlags.None, _peerAddr, - writeCompleted, state); - completedSynchronously = _writeResult.CompletedSynchronously; -#endif } } catch(SocketException ex) @@ -636,17 +524,12 @@ namespace IceInternal if(_fd == null) { buf.b.position(buf.size()); // Assume all the data was sent for at-most-once semantics. -#if ICE_SOCKET_ASYNC_API _writeEventArgs = null; -#else - _writeResult = null; -#endif return; } if(!_incoming && _state < StateConnected) { -#if ICE_SOCKET_ASYNC_API if(_writeEventArgs.SocketError != SocketError.Success) { SocketException ex = new SocketException((int)_writeEventArgs.SocketError); @@ -659,34 +542,17 @@ namespace IceInternal throw new Ice.ConnectFailedException(ex); } } -#else - Debug.Assert(_writeResult != null); - Network.doFinishConnectAsync(_fd, _writeResult); - _writeResult = null; -#endif return; } int ret; try { -#if ICE_SOCKET_ASYNC_API if(_writeEventArgs.SocketError != SocketError.Success) { throw new SocketException((int)_writeEventArgs.SocketError); } ret = _writeEventArgs.BytesTransferred; -#else - if (_state == StateConnected) - { - ret = _fd.EndSend(_writeResult); - } - else - { - ret = _fd.EndSendTo(_writeResult); - } - _writeResult = null; -#endif } catch(SocketException ex) { @@ -745,13 +611,11 @@ namespace IceInternal info.rcvSize = Network.getRecvBufferSize(_fd); info.sndSize = Network.getSendBufferSize(_fd); -#if !SILVERLIGHT if(_mcastAddr != null) { info.mcastAddress = Network.endpointAddressToString(_mcastAddr); info.mcastPort = Network.endpointPort(_mcastAddr); } -#endif return info; } @@ -798,12 +662,10 @@ namespace IceInternal s = Network.fdToString(_fd); } -#if !SILVERLIGHT if(_mcastAddr != null) { s += "\nmulticast address = " + Network.addrToString(_mcastAddr); } -#endif return s; } @@ -835,7 +697,6 @@ namespace IceInternal _addr = addr; _sourceAddr = sourceAddr; -#if ICE_SOCKET_ASYNC_API _readEventArgs = new SocketAsyncEventArgs(); _readEventArgs.RemoteEndPoint = _addr; _readEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted); @@ -843,19 +704,6 @@ namespace IceInternal _writeEventArgs = new SocketAsyncEventArgs(); _writeEventArgs.RemoteEndPoint = _addr; _writeEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted); -#if SILVERLIGHT - String policy = instance.properties().getProperty("Ice.ClientAccessPolicyProtocol"); - if(policy.Equals("Http")) - { - _readEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http; - _writeEventArgs.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http; - } - else if(!String.IsNullOrEmpty(policy)) - { - _instance.logger().warning("Ignoring invalid Ice.ClientAccessPolicyProtocol value `" + policy + "'"); - } -#endif -#endif _mcastInterface = mcastInterface; _mcastTtl = mcastTtl; @@ -866,7 +714,6 @@ namespace IceInternal { _fd = Network.createSocket(true, _addr.AddressFamily); setBufSize(-1, -1); -#if !SILVERLIGHT Network.setBlock(_fd, false); if(Network.isMulticast((IPEndPoint)_addr)) { @@ -888,7 +735,6 @@ namespace IceInternal } } } -#endif } catch(Ice.LocalException) { @@ -914,7 +760,6 @@ namespace IceInternal { _addr = Network.getAddressForServer(host, port, instance.protocolSupport(), instance.preferIPv6()); -#if ICE_SOCKET_ASYNC_API _readEventArgs = new SocketAsyncEventArgs(); _readEventArgs.RemoteEndPoint = _addr; _readEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted); @@ -922,17 +767,13 @@ namespace IceInternal _writeEventArgs = new SocketAsyncEventArgs(); _writeEventArgs.RemoteEndPoint = _addr; _writeEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(ioCompleted); -#endif _fd = Network.createServerSocket(true, _addr.AddressFamily, instance.protocolSupport()); setBufSize(-1, -1); -#if !SILVERLIGHT Network.setBlock(_fd, false); -#endif } catch(Ice.LocalException) { -#if ICE_SOCKET_ASYNC_API if(_readEventArgs != null) { _readEventArgs.Dispose(); @@ -941,7 +782,6 @@ namespace IceInternal { _writeEventArgs.Dispose(); } -#endif _fd = null; throw; } @@ -1042,15 +882,12 @@ namespace IceInternal } } -#if ICE_SOCKET_ASYNC_API internal void ioCompleted(object sender, SocketAsyncEventArgs e) { switch (e.LastOperation) { case SocketAsyncOperation.Receive: -#if !SILVERLIGHT case SocketAsyncOperation.ReceiveFrom: -#endif _readCallback(e.UserToken); break; case SocketAsyncOperation.Send: @@ -1061,23 +898,6 @@ namespace IceInternal throw new ArgumentException("The last operation completed on the socket was not a receive or send"); } } -#else - internal void readCompleted(IAsyncResult result) - { - if(!result.CompletedSynchronously) - { - _readCallback(result.AsyncState); - } - } - - internal void writeCompleted(IAsyncResult result) - { - if(!result.CompletedSynchronously) - { - _writeCallback(result.AsyncState); - } - } -#endif private UdpEndpointI _endpoint; private ProtocolInstance _instance; @@ -1088,9 +908,7 @@ namespace IceInternal private Socket _fd; private EndPoint _addr; private EndPoint _sourceAddr; -#if !SILVERLIGHT private IPEndPoint _mcastAddr = null; -#endif private EndPoint _peerAddr = null; private string _mcastInterface = null; private int _mcastTtl = -1; @@ -1098,13 +916,8 @@ namespace IceInternal private int _port = 0; private bool _bound = false; -#if ICE_SOCKET_ASYNC_API private SocketAsyncEventArgs _writeEventArgs; private SocketAsyncEventArgs _readEventArgs; -#else - private IAsyncResult _writeResult; - private IAsyncResult _readResult; -#endif AsyncCallback _writeCallback; AsyncCallback _readCallback; diff --git a/csharp/src/Ice/UserExceptionFactory.cs b/csharp/src/Ice/UserExceptionFactory.cs deleted file mode 100644 index 05df87217cb..00000000000 --- a/csharp/src/Ice/UserExceptionFactory.cs +++ /dev/null @@ -1,19 +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 IceInternal -{ - - public interface UserExceptionFactory - { - void createAndThrow(string typeId); - void destroy(); - } - -} diff --git a/csharp/src/Ice/Util.cs b/csharp/src/Ice/Util.cs index 2221b360565..5c286fd2712 100644 --- a/csharp/src/Ice/Util.cs +++ b/csharp/src/Ice/Util.cs @@ -37,22 +37,11 @@ namespace Ice void stop(); } -#if COMPACT - /// <summary> - /// A delegate for an action taking no parameters. - /// </summary> - public delegate void VoidAction(); -#endif - /// <summary> /// A delegate for the dispatcher. The dispatcher is called by the Ice /// runtime to dispatch servant calls and AMI callbacks. /// </summary> -#if COMPACT - public delegate void Dispatcher(VoidAction call, Connection con); -#else public delegate void Dispatcher(System.Action call, Connection con); -#endif /// <summary> /// Applications that make use of compact type IDs to conserve space @@ -700,7 +689,6 @@ namespace IceInternal return new ProtocolPluginFacadeI(communicator); } -#if !SILVERLIGHT public static System.Threading.ThreadPriority stringToThreadPriority(string s) { if(String.IsNullOrEmpty(s)) @@ -733,16 +721,5 @@ namespace IceInternal } return ThreadPriority.Normal; } -#endif - } -} - -#if SILVERLIGHT -namespace System -{ - public interface ICloneable - { - Object Clone(); } } -#endif diff --git a/csharp/src/Ice/ValueWriter.cs b/csharp/src/Ice/ValueWriter.cs index 8adb2142726..9973e8a51d4 100644 --- a/csharp/src/Ice/ValueWriter.cs +++ b/csharp/src/Ice/ValueWriter.cs @@ -9,7 +9,6 @@ namespace IceInternal { - using System.Collections; using System.Collections.Generic; using System.Diagnostics; diff --git a/csharp/src/Ice/WSAcceptor.cs b/csharp/src/Ice/WSAcceptor.cs index 2fade1c081a..5b0709b3ccf 100644 --- a/csharp/src/Ice/WSAcceptor.cs +++ b/csharp/src/Ice/WSAcceptor.cs @@ -9,8 +9,6 @@ namespace IceInternal { - using System.Diagnostics; - class WSAcceptor : Acceptor { public void close() diff --git a/csharp/src/Ice/WSEndpoint.cs b/csharp/src/Ice/WSEndpoint.cs index be0e2d9dbb7..affc7d0bdfd 100644 --- a/csharp/src/Ice/WSEndpoint.cs +++ b/csharp/src/Ice/WSEndpoint.cs @@ -12,7 +12,6 @@ namespace IceInternal using System; using System.Diagnostics; using System.Collections.Generic; - using System.Globalization; // // Delegate interface implemented by TcpEndpoint or IceSSL.EndpointI or any endpoint that WS can diff --git a/csharp/src/Ice/WSTransceiver.cs b/csharp/src/Ice/WSTransceiver.cs index 4c83b0148cb..761cb164264 100644 --- a/csharp/src/Ice/WSTransceiver.cs +++ b/csharp/src/Ice/WSTransceiver.cs @@ -875,12 +875,7 @@ namespace IceInternal // @out.Append("Sec-WebSocket-Accept: "); string input = key + _wsUUID; -#if SILVERLIGHT - SHA1Managed sha1 = new SHA1Managed(); - byte[] hash = sha1.ComputeHash(_utf8.GetBytes(input)); -#else byte[] hash = SHA1.Create().ComputeHash(_utf8.GetBytes(input)); -#endif @out.Append(IceUtilInternal.Base64.encode(hash) + "\r\n" + "\r\n"); // EOM byte[] bytes = _utf8.GetBytes(@out.ToString()); @@ -982,12 +977,7 @@ namespace IceInternal } string input = _key + _wsUUID; -#if SILVERLIGHT - SHA1Managed sha1 = new SHA1Managed(); - byte[] hash = sha1.ComputeHash(_utf8.GetBytes(input)); -#else byte[] hash = SHA1.Create().ComputeHash(_utf8.GetBytes(input)); -#endif if(!val.Equals(IceUtilInternal.Base64.encode(hash))) { throw new WebSocketException("invalid value `" + val + "' for Sec-WebSocket-Accept"); diff --git a/csharp/src/Ice/msbuild/ice.csproj b/csharp/src/Ice/msbuild/ice.csproj index 4ca19c3b67d..467b0c7c1ed 100644 --- a/csharp/src/Ice/msbuild/ice.csproj +++ b/csharp/src/Ice/msbuild/ice.csproj @@ -63,9 +63,6 @@ <Compile Include="..\BZip2.cs"> <Link>BZip2.cs</Link> </Compile> - <Compile Include="..\CollectionBase.cs"> - <Link>CollectionBase.cs</Link> - </Compile> <Compile Include="..\Collections.cs"> <Link>Collections.cs</Link> </Compile> @@ -96,9 +93,6 @@ <Compile Include="..\DefaultsAndOverrides.cs"> <Link>DefaultsAndOverrides.cs</Link> </Compile> - <Compile Include="..\DictionaryBase.cs"> - <Link>DictionaryBase.cs</Link> - </Compile> <Compile Include="..\DispatchInterceptor.cs"> <Link>DispatchInterceptor.cs</Link> </Compile> @@ -123,9 +117,6 @@ <Compile Include="..\FormatType.cs"> <Link>FormatType.cs</Link> </Compile> - <Compile Include="..\HashSet.cs"> - <Link>HashSet.cs</Link> - </Compile> <Compile Include="..\HttpParser.cs"> <Link>HttpParser.cs</Link> </Compile> @@ -342,9 +333,6 @@ <Compile Include="..\UnknownSlicedObject.cs"> <Link>UnknownSlicedObject.cs</Link> </Compile> - <Compile Include="..\UserExceptionFactory.cs"> - <Link>UserExceptionFactory.cs</Link> - </Compile> <Compile Include="..\Util.cs"> <Link>Util.cs</Link> </Compile> @@ -368,40 +356,27 @@ </Compile> <Compile Include="generated\BuiltinSequences.cs" /> <Compile Include="generated\Communicator.cs" /> - <Compile Include="generated\CommunicatorF.cs" /> <Compile Include="generated\Connection.cs" /> - <Compile Include="generated\ConnectionF.cs" /> <Compile Include="generated\Current.cs" /> <Compile Include="generated\Endpoint.cs" /> - <Compile Include="generated\EndpointF.cs" /> <Compile Include="generated\EndpointTypes.cs" /> <Compile Include="generated\FacetMap.cs" /> <Compile Include="generated\Identity.cs" /> <Compile Include="generated\ImplicitContext.cs" /> - <Compile Include="generated\ImplicitContextF.cs" /> <Compile Include="generated\Instrumentation.cs" /> - <Compile Include="generated\InstrumentationF.cs" /> <Compile Include="generated\LocalException.cs" /> <Compile Include="generated\Locator.cs" /> - <Compile Include="generated\LocatorF.cs" /> <Compile Include="generated\Logger.cs" /> - <Compile Include="generated\LoggerF.cs" /> <Compile Include="generated\Metrics.cs" /> <Compile Include="generated\ObjectAdapter.cs" /> - <Compile Include="generated\ObjectAdapterF.cs" /> <Compile Include="generated\ObjectFactory.cs" /> <Compile Include="generated\Plugin.cs" /> - <Compile Include="generated\PluginF.cs" /> <Compile Include="generated\Process.cs" /> - <Compile Include="generated\ProcessF.cs" /> <Compile Include="generated\Properties.cs" /> <Compile Include="generated\PropertiesAdmin.cs" /> - <Compile Include="generated\PropertiesF.cs" /> <Compile Include="generated\RemoteLogger.cs" /> <Compile Include="generated\Router.cs" /> - <Compile Include="generated\RouterF.cs" /> <Compile Include="generated\ServantLocator.cs" /> - <Compile Include="generated\ServantLocatorF.cs" /> <Compile Include="generated\SliceChecksumDict.cs" /> <Compile Include="generated\ValueFactory.cs" /> <Compile Include="generated\Version.cs" /> @@ -413,24 +388,15 @@ <None Include="..\..\..\..\slice\Ice\Communicator.ice"> <Link>Communicator.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\CommunicatorF.ice"> - <Link>CommunicatorF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Connection.ice"> <Link>Connection.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\ConnectionF.ice"> - <Link>ConnectionF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Current.ice"> <Link>Current.ice</Link> </None> <None Include="..\..\..\..\slice\Ice\Endpoint.ice"> <Link>Endpoint.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\EndpointF.ice"> - <Link>EndpointF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\EndpointTypes.ice"> <Link>EndpointTypes.ice</Link> </None> @@ -443,78 +409,48 @@ <None Include="..\..\..\..\slice\Ice\ImplicitContext.ice"> <Link>ImplicitContext.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\ImplicitContextF.ice"> - <Link>ImplicitContextF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Instrumentation.ice"> <Link>Instrumentation.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\InstrumentationF.ice"> - <Link>InstrumentationF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\LocalException.ice"> <Link>LocalException.ice</Link> </None> <None Include="..\..\..\..\slice\Ice\Locator.ice"> <Link>Locator.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\LocatorF.ice"> - <Link>LocatorF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Logger.ice"> <Link>Logger.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\LoggerF.ice"> - <Link>LoggerF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Metrics.ice"> <Link>Metrics.ice</Link> </None> <None Include="..\..\..\..\slice\Ice\ObjectAdapter.ice"> <Link>ObjectAdapter.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\ObjectAdapterF.ice"> - <Link>ObjectAdapterF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\ObjectFactory.ice"> <Link>ObjectFactory.ice</Link> </None> <None Include="..\..\..\..\slice\Ice\Plugin.ice"> <Link>Plugin.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\PluginF.ice"> - <Link>PluginF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Process.ice"> <Link>Process.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\ProcessF.ice"> - <Link>ProcessF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\Properties.ice"> <Link>Properties.ice</Link> </None> <None Include="..\..\..\..\slice\Ice\PropertiesAdmin.ice"> <Link>PropertiesAdmin.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\PropertiesF.ice"> - <Link>PropertiesF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\RemoteLogger.ice"> <Link>RemoteLogger.ice</Link> </None> <None Include="..\..\..\..\slice\Ice\Router.ice"> <Link>Router.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\RouterF.ice"> - <Link>RouterF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\ServantLocator.ice"> <Link>ServantLocator.ice</Link> </None> - <None Include="..\..\..\..\slice\Ice\ServantLocatorF.ice"> - <Link>ServantLocatorF.ice</Link> - </None> <None Include="..\..\..\..\slice\Ice\SliceChecksumDict.ice"> <Link>SliceChecksumDict.ice</Link> </None> diff --git a/csharp/src/IceBox/ServiceManagerI.cs b/csharp/src/IceBox/ServiceManagerI.cs index 30c6ae3a269..badb590bcce 100644 --- a/csharp/src/IceBox/ServiceManagerI.cs +++ b/csharp/src/IceBox/ServiceManagerI.cs @@ -725,14 +725,14 @@ class ServiceManagerI : ServiceManagerDisp_ info.status = ServiceStatus.Started; _services.Add(info); } - catch(System.Exception ex) + catch(System.Exception) { if(info.communicator != null) { destroyServiceCommunicator(service, info.communicator); } - throw ex; + throw; } } diff --git a/csharp/src/IceSSL/RFC2253.cs b/csharp/src/IceSSL/RFC2253.cs index c535cd5b34b..1ff869cfe15 100644 --- a/csharp/src/IceSSL/RFC2253.cs +++ b/csharp/src/IceSSL/RFC2253.cs @@ -20,7 +20,7 @@ namespace IceSSL class RFC2253 { - internal class ParseException : System.Exception + internal class ParseException : Exception { internal ParseException() { diff --git a/csharp/src/IceSSL/SSLEngine.cs b/csharp/src/IceSSL/SSLEngine.cs index db1a3dfc32c..bd8f527b8e4 100644 --- a/csharp/src/IceSSL/SSLEngine.cs +++ b/csharp/src/IceSSL/SSLEngine.cs @@ -31,8 +31,6 @@ namespace IceSSL _securityTraceCategory = "Security"; _initialized = false; _trustManager = new TrustManager(_communicator); - -#if !UNITY _tls12Support = false; try { @@ -42,7 +40,6 @@ namespace IceSSL catch(Exception) { } -#endif } internal void initialize() @@ -78,8 +75,6 @@ namespace IceSSL storeLocation = StoreLocation.CurrentUser; } _useMachineContext = certStoreLocation == "LocalMachine"; - -#if !UNITY X509KeyStorageFlags keyStorageFlags; if(_useMachineContext) { @@ -130,7 +125,6 @@ namespace IceSSL importCertificate(name, val, keyStorageFlags); } } -#endif // // Protocols selects which protocols to enable, by default we only enable TLS1.0 @@ -138,12 +132,8 @@ namespace IceSSL // _protocols = parseProtocols( properties.getPropertyAsListWithDefault(prefix + "Protocols", -#if UNITY - new string[]{"TLS1_0"})); -#else _tls12Support ? new string[]{"TLS1_0", "TLS1_1", "TLS1_2"} : new string[]{"TLS1_0", "TLS1_1"})); -#endif // // CheckCertName determines whether we compare the name in a peer's // certificate against its hostname. @@ -162,7 +152,6 @@ namespace IceSSL // _checkCRL = properties.getPropertyAsIntWithDefault(prefix + "CheckCRL", 0); -#if !UNITY // // Check for a certificate verifier. // @@ -433,8 +422,6 @@ namespace IceSSL } } } -#endif - _initialized = true; } @@ -540,12 +527,10 @@ namespace IceSSL s.Append("\nencrypted = " + (stream.IsEncrypted ? "yes" : "no")); s.Append("\nsigned = " + (stream.IsSigned ? "yes" : "no")); s.Append("\nmutually authenticated = " + (stream.IsMutuallyAuthenticated ? "yes" : "no")); -#if !UNITY s.Append("\nhash algorithm = " + stream.HashAlgorithm + "/" + stream.HashStrength); s.Append("\ncipher algorithm = " + stream.CipherAlgorithm + "/" + stream.CipherStrength); s.Append("\nkey exchange algorithm = " + stream.KeyExchangeAlgorithm + "/" + stream.KeyExchangeStrength); s.Append("\nprotocol = " + stream.SslProtocol); -#endif _logger.trace(_securityTraceCategory, s.ToString()); } @@ -888,7 +873,6 @@ namespace IceSSL return false; } -#if !UNITY private void importCertificate(string propName, string propValue, X509KeyStorageFlags keyStorageFlags) { // @@ -990,7 +974,6 @@ namespace IceSSL store.Close(); } } -#endif // // Split strings using a delimiter. Quotes are supported. @@ -1121,7 +1104,6 @@ namespace IceSSL return result; } -#if !UNITY private static X509Certificate2Collection findCertificates(string prop, StoreLocation storeLocation, string name, string value) { @@ -1323,7 +1305,6 @@ namespace IceSSL } return result; } -#endif private static bool decodeASN1Length(byte[] data, int start, out int len, out int next) { @@ -1377,8 +1358,6 @@ namespace IceSSL private CertificateVerifier _verifier; private PasswordCallback _passwordCallback; private TrustManager _trustManager; -#if !UNITY private bool _tls12Support; -#endif } } diff --git a/csharp/src/IceSSL/TransceiverI.cs b/csharp/src/IceSSL/TransceiverI.cs index c94f659c376..171211fb3b5 100644 --- a/csharp/src/IceSSL/TransceiverI.cs +++ b/csharp/src/IceSSL/TransceiverI.cs @@ -10,7 +10,6 @@ namespace IceSSL { using System; - using System.ComponentModel; using System.Diagnostics; using System.Collections.Generic; using System.IO; @@ -19,7 +18,6 @@ namespace IceSSL using System.Net.Sockets; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; - using System.Threading; using System.Text; sealed class TransceiverI : IceInternal.Transceiver, IceInternal.WSTransceiverDelegate @@ -364,12 +362,10 @@ namespace IceSSL X509Certificate2Collection caCerts = _instance.engine().caCerts(); if(caCerts != null) { -#if !UNITY // // We need to set this flag to be able to use a certificate authority from the extra store. // _chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; -#endif foreach(X509Certificate2 cert in caCerts) { _chain.ChainPolicy.ExtraStore.Add(cert); @@ -396,9 +392,6 @@ namespace IceSSL } if(_sslStream != null) { -#if UNITY - info.cipher = ""; -#else info.cipher = _sslStream.CipherAlgorithm.ToString(); if(_chain.ChainElements != null && _chain.ChainElements.Count > 0) { @@ -408,10 +401,8 @@ namespace IceSSL nativeCerts[i] = _chain.ChainElements[i].Certificate; } } -#endif List<string> certs = new List<string>(); -#if !UNITY if(nativeCerts != null) { foreach(X509Certificate2 cert in nativeCerts) @@ -423,7 +414,6 @@ namespace IceSSL certs.Add(s.ToString()); } } -#endif info.certs = certs.ToArray(); info.verified = _verified; } @@ -451,9 +441,6 @@ namespace IceSSL } else { -#if UNITY - throw new Ice.FeatureNotSupportedException("ssl server socket"); -#else // // Server authentication. // @@ -472,7 +459,6 @@ namespace IceSSL _instance.checkCRL() > 0, writeCompleted, state); -#endif } } catch(IOException ex) @@ -487,14 +473,12 @@ namespace IceSSL } throw new Ice.SocketException(ex); } -#if !UNITY catch(AuthenticationException ex) { Ice.SecurityException e = new Ice.SecurityException(ex); e.reason = ex.Message; throw e; } -#endif catch(Exception ex) { throw new Ice.SyscallException(ex); @@ -531,14 +515,12 @@ namespace IceSSL } throw new Ice.SocketException(ex); } -#if !UNITY catch(AuthenticationException ex) { Ice.SecurityException e = new Ice.SecurityException(ex); e.reason = ex.Message; throw e; } -#endif catch(Exception ex) { throw new Ice.SyscallException(ex); @@ -580,7 +562,6 @@ namespace IceSSL private bool validationCallback(object sender, X509Certificate certificate, X509Chain chainEngine, SslPolicyErrors policyErrors) { -#if !UNITY string message = ""; int errors = (int)policyErrors; if(certificate != null) @@ -758,7 +739,6 @@ namespace IceSSL _instance.logger().trace(_instance.securityTraceCategory(), "SSL certificate validation status:" + message); } -#endif return true; } diff --git a/csharp/src/IceSSL/TrustManager.cs b/csharp/src/IceSSL/TrustManager.cs index 4d31702dbb1..b9cba557a25 100644 --- a/csharp/src/IceSSL/TrustManager.cs +++ b/csharp/src/IceSSL/TrustManager.cs @@ -130,9 +130,6 @@ namespace IceSSL // if(info.nativeCerts != null && info.nativeCerts.Length > 0) { -#if UNITY - throw new Ice.FeatureNotSupportedException("certificate subjectName not available"); -#else X500DistinguishedName subjectDN = info.nativeCerts[0].SubjectName; string subjectName = subjectDN.Name; Debug.Assert(subjectName != null); @@ -218,7 +215,6 @@ namespace IceSSL // At this point we accept the connection if there are no explicit accept rules. // return accept.Count == 0; -#endif } return false; |