You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2018/04/01 10:42:11 UTC

[2/3] thrift git commit: THRIFT-4535: XML docs; code cleanup (tabs->spaces; String->string) Client: C# Patch: Christian Weiss

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Server/TThreadPoolServer.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Server/TThreadPoolServer.cs b/lib/csharp/src/Server/TThreadPoolServer.cs
index ec283da..a494ce7 100644
--- a/lib/csharp/src/Server/TThreadPoolServer.cs
+++ b/lib/csharp/src/Server/TThreadPoolServer.cs
@@ -28,268 +28,268 @@ using Thrift.Transport;
 
 namespace Thrift.Server
 {
-  /// <summary>
-  /// Server that uses C# built-in ThreadPool to spawn threads when handling requests
-  /// </summary>
-  public class TThreadPoolServer : TServer
-  {
-    private const int DEFAULT_MIN_THREADS = -1;  // use .NET ThreadPool defaults
-    private const int DEFAULT_MAX_THREADS = -1;  // use .NET ThreadPool defaults
-    private volatile bool stop = false;
-
-    public struct Configuration
-    {
-      public int MinWorkerThreads;
-      public int MaxWorkerThreads;
-      public int MinIOThreads;
-      public int MaxIOThreads;
-
-      public Configuration(int min = DEFAULT_MIN_THREADS, int max = DEFAULT_MAX_THREADS)
-      {
-        MinWorkerThreads = min;
-        MaxWorkerThreads = max;
-        MinIOThreads = min;
-        MaxIOThreads = max;
-      }
-
-      public Configuration(int minWork, int maxWork, int minIO, int maxIO)
-      {
-        MinWorkerThreads = minWork;
-        MaxWorkerThreads = maxWork;
-        MinIOThreads = minIO;
-        MaxIOThreads = maxIO;
-      }
-    }
-
-    public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport)
-        : this(new TSingletonProcessorFactory(processor), serverTransport,
-         new TTransportFactory(), new TTransportFactory(),
-         new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
-         new Configuration(), DefaultLogDelegate)
-    {
-    }
-
-    public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate)
-        : this(new TSingletonProcessorFactory(processor), serverTransport,
-         new TTransportFactory(), new TTransportFactory(),
-         new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
-         new Configuration(), logDelegate)
+    /// <summary>
+    /// Server that uses C# built-in ThreadPool to spawn threads when handling requests.
+    /// </summary>
+    public class TThreadPoolServer : TServer
     {
-    }
+        private const int DEFAULT_MIN_THREADS = -1;  // use .NET ThreadPool defaults
+        private const int DEFAULT_MAX_THREADS = -1;  // use .NET ThreadPool defaults
+        private volatile bool stop = false;
 
-    public TThreadPoolServer(TProcessor processor,
-     TServerTransport serverTransport,
-     TTransportFactory transportFactory,
-     TProtocolFactory protocolFactory)
-        : this(new TSingletonProcessorFactory(processor), serverTransport,
-           transportFactory, transportFactory,
-           protocolFactory, protocolFactory,
-           new Configuration(), DefaultLogDelegate)
-    {
-    }
+        public struct Configuration
+        {
+            public int MinWorkerThreads;
+            public int MaxWorkerThreads;
+            public int MinIOThreads;
+            public int MaxIOThreads;
 
-    public TThreadPoolServer(TProcessorFactory processorFactory,
-                 TServerTransport serverTransport,
-                 TTransportFactory transportFactory,
-                 TProtocolFactory protocolFactory)
-        : this(processorFactory, serverTransport,
-         transportFactory, transportFactory,
-         protocolFactory, protocolFactory,
-         new Configuration(), DefaultLogDelegate)
-    {
-    }
+            public Configuration(int min = DEFAULT_MIN_THREADS, int max = DEFAULT_MAX_THREADS)
+            {
+                MinWorkerThreads = min;
+                MaxWorkerThreads = max;
+                MinIOThreads = min;
+                MaxIOThreads = max;
+            }
 
-    public TThreadPoolServer(TProcessorFactory processorFactory,
-                 TServerTransport serverTransport,
-                 TTransportFactory inputTransportFactory,
-                 TTransportFactory outputTransportFactory,
-                 TProtocolFactory inputProtocolFactory,
-                 TProtocolFactory outputProtocolFactory,
-                 int minThreadPoolThreads, int maxThreadPoolThreads, LogDelegate logDel)
-        : this(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
-         inputProtocolFactory, outputProtocolFactory,
-         new Configuration(minThreadPoolThreads, maxThreadPoolThreads),
-         logDel)
-    {
-    }
+            public Configuration(int minWork, int maxWork, int minIO, int maxIO)
+            {
+                MinWorkerThreads = minWork;
+                MaxWorkerThreads = maxWork;
+                MinIOThreads = minIO;
+                MaxIOThreads = maxIO;
+            }
+        }
 
-    public TThreadPoolServer(TProcessorFactory processorFactory,
-                 TServerTransport serverTransport,
-                 TTransportFactory inputTransportFactory,
-                 TTransportFactory outputTransportFactory,
-                 TProtocolFactory inputProtocolFactory,
-                 TProtocolFactory outputProtocolFactory,
-                 Configuration threadConfig,
-                 LogDelegate logDel)
-        : base(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
-        inputProtocolFactory, outputProtocolFactory, logDel)
-    {
-      lock (typeof(TThreadPoolServer))
-      {
-        if ((threadConfig.MaxWorkerThreads > 0) || (threadConfig.MaxIOThreads > 0))
+        public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport)
+            : this(new TSingletonProcessorFactory(processor), serverTransport,
+             new TTransportFactory(), new TTransportFactory(),
+             new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
+             new Configuration(), DefaultLogDelegate)
         {
-          int work, comm;
-          ThreadPool.GetMaxThreads(out work, out comm);
-          if (threadConfig.MaxWorkerThreads > 0)
-            work = threadConfig.MaxWorkerThreads;
-          if (threadConfig.MaxIOThreads > 0)
-            comm = threadConfig.MaxIOThreads;
-          if (!ThreadPool.SetMaxThreads(work, comm))
-            throw new Exception("Error: could not SetMaxThreads in ThreadPool");
         }
 
-        if ((threadConfig.MinWorkerThreads > 0) || (threadConfig.MinIOThreads > 0))
+        public TThreadPoolServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate)
+            : this(new TSingletonProcessorFactory(processor), serverTransport,
+             new TTransportFactory(), new TTransportFactory(),
+             new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
+             new Configuration(), logDelegate)
         {
-          int work, comm;
-          ThreadPool.GetMinThreads(out work, out comm);
-          if (threadConfig.MinWorkerThreads > 0)
-            work = threadConfig.MinWorkerThreads;
-          if (threadConfig.MinIOThreads > 0)
-            comm = threadConfig.MinIOThreads;
-          if (!ThreadPool.SetMinThreads(work, comm))
-            throw new Exception("Error: could not SetMinThreads in ThreadPool");
         }
-      }
-    }
 
-
-    /// <summary>
-    /// Use new ThreadPool thread for each new client connection
-    /// </summary>
-    public override void Serve()
-    {
-      try
-      {
-        serverTransport.Listen();
-      }
-      catch (TTransportException ttx)
-      {
-        logDelegate("Error, could not listen on ServerTransport: " + ttx);
-        return;
-      }
-
-      //Fire the preServe server event when server is up but before any client connections
-      if (serverEventHandler != null)
-        serverEventHandler.preServe();
-
-      while (!stop)
-      {
-        int failureCount = 0;
-        try
+        public TThreadPoolServer(TProcessor processor,
+         TServerTransport serverTransport,
+         TTransportFactory transportFactory,
+         TProtocolFactory protocolFactory)
+            : this(new TSingletonProcessorFactory(processor), serverTransport,
+               transportFactory, transportFactory,
+               protocolFactory, protocolFactory,
+               new Configuration(), DefaultLogDelegate)
         {
-          TTransport client = serverTransport.Accept();
-          ThreadPool.QueueUserWorkItem(this.Execute, client);
         }
-        catch (TTransportException ttx)
-        {
-          if (!stop || ttx.Type != TTransportException.ExceptionType.Interrupted)
-          {
-            ++failureCount;
-            logDelegate(ttx.ToString());
-          }
 
+        public TThreadPoolServer(TProcessorFactory processorFactory,
+                     TServerTransport serverTransport,
+                     TTransportFactory transportFactory,
+                     TProtocolFactory protocolFactory)
+            : this(processorFactory, serverTransport,
+             transportFactory, transportFactory,
+             protocolFactory, protocolFactory,
+             new Configuration(), DefaultLogDelegate)
+        {
         }
-      }
 
-      if (stop)
-      {
-        try
+        public TThreadPoolServer(TProcessorFactory processorFactory,
+                     TServerTransport serverTransport,
+                     TTransportFactory inputTransportFactory,
+                     TTransportFactory outputTransportFactory,
+                     TProtocolFactory inputProtocolFactory,
+                     TProtocolFactory outputProtocolFactory,
+                     int minThreadPoolThreads, int maxThreadPoolThreads, LogDelegate logDel)
+            : this(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
+             inputProtocolFactory, outputProtocolFactory,
+             new Configuration(minThreadPoolThreads, maxThreadPoolThreads),
+             logDel)
         {
-          serverTransport.Close();
         }
-        catch (TTransportException ttx)
+
+        public TThreadPoolServer(TProcessorFactory processorFactory,
+                     TServerTransport serverTransport,
+                     TTransportFactory inputTransportFactory,
+                     TTransportFactory outputTransportFactory,
+                     TProtocolFactory inputProtocolFactory,
+                     TProtocolFactory outputProtocolFactory,
+                     Configuration threadConfig,
+                     LogDelegate logDel)
+            : base(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
+            inputProtocolFactory, outputProtocolFactory, logDel)
         {
-          logDelegate("TServerTransport failed on close: " + ttx.Message);
+            lock (typeof(TThreadPoolServer))
+            {
+                if ((threadConfig.MaxWorkerThreads > 0) || (threadConfig.MaxIOThreads > 0))
+                {
+                    int work, comm;
+                    ThreadPool.GetMaxThreads(out work, out comm);
+                    if (threadConfig.MaxWorkerThreads > 0)
+                        work = threadConfig.MaxWorkerThreads;
+                    if (threadConfig.MaxIOThreads > 0)
+                        comm = threadConfig.MaxIOThreads;
+                    if (!ThreadPool.SetMaxThreads(work, comm))
+                        throw new Exception("Error: could not SetMaxThreads in ThreadPool");
+                }
+
+                if ((threadConfig.MinWorkerThreads > 0) || (threadConfig.MinIOThreads > 0))
+                {
+                    int work, comm;
+                    ThreadPool.GetMinThreads(out work, out comm);
+                    if (threadConfig.MinWorkerThreads > 0)
+                        work = threadConfig.MinWorkerThreads;
+                    if (threadConfig.MinIOThreads > 0)
+                        comm = threadConfig.MinIOThreads;
+                    if (!ThreadPool.SetMinThreads(work, comm))
+                        throw new Exception("Error: could not SetMinThreads in ThreadPool");
+                }
+            }
         }
-        stop = false;
-      }
-    }
 
-    /// <summary>
-    /// Loops on processing a client forever
-    /// threadContext will be a TTransport instance
-    /// </summary>
-    /// <param name="threadContext"></param>
-    private void Execute(Object threadContext)
-    {
-      using( TTransport client = (TTransport)threadContext)
-      {
-        TProcessor processor = processorFactory.GetProcessor(client, this);
-        TTransport inputTransport = null;
-        TTransport outputTransport = null;
-        TProtocol inputProtocol = null;
-        TProtocol outputProtocol = null;
-        Object connectionContext = null;
-        try
+
+        /// <summary>
+        /// Use new ThreadPool thread for each new client connection.
+        /// </summary>
+        public override void Serve()
         {
-          try
-          {
-            inputTransport = inputTransportFactory.GetTransport(client);
-            outputTransport = outputTransportFactory.GetTransport(client);
-            inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
-            outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
-                   
-            //Recover event handler (if any) and fire createContext server event when a client connects
+            try
+            {
+                serverTransport.Listen();
+            }
+            catch (TTransportException ttx)
+            {
+                logDelegate("Error, could not listen on ServerTransport: " + ttx);
+                return;
+            }
+
+            //Fire the preServe server event when server is up but before any client connections
             if (serverEventHandler != null)
-              connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol);
-  
-            //Process client requests until client disconnects
+                serverEventHandler.preServe();
+
             while (!stop)
             {
-              if (!inputTransport.Peek())
-                break;
-  
-              //Fire processContext server event
-              //N.B. This is the pattern implemented in C++ and the event fires provisionally.
-              //That is to say it may be many minutes between the event firing and the client request
-              //actually arriving or the client may hang up without ever makeing a request.
-              if (serverEventHandler != null)
-                serverEventHandler.processContext(connectionContext, inputTransport);
-              //Process client request (blocks until transport is readable)
-              if (!processor.Process(inputProtocol, outputProtocol))
-                break;
+                int failureCount = 0;
+                try
+                {
+                    TTransport client = serverTransport.Accept();
+                    ThreadPool.QueueUserWorkItem(this.Execute, client);
+                }
+                catch (TTransportException ttx)
+                {
+                    if (!stop || ttx.Type != TTransportException.ExceptionType.Interrupted)
+                    {
+                        ++failureCount;
+                        logDelegate(ttx.ToString());
+                    }
+
+                }
             }
-          }
-          catch (TTransportException)
-          {
-            //Usually a client disconnect, expected
-          }
-          catch (Exception x)
-          {
-            //Unexpected
-            logDelegate("Error: " + x);
-          }
-  
-          //Fire deleteContext server event after client disconnects
-          if (serverEventHandler != null)
-            serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
-  
-        } 
-        finally
+
+            if (stop)
+            {
+                try
+                {
+                    serverTransport.Close();
+                }
+                catch (TTransportException ttx)
+                {
+                    logDelegate("TServerTransport failed on close: " + ttx.Message);
+                }
+                stop = false;
+            }
+        }
+
+        /// <summary>
+        /// Loops on processing a client forever
+        /// threadContext will be a TTransport instance
+        /// </summary>
+        /// <param name="threadContext"></param>
+        private void Execute(object threadContext)
         {
-          //Close transports
-          if (inputTransport != null)
-            inputTransport.Close();
-          if (outputTransport != null)
-            outputTransport.Close();
-		
-          // disposable stuff should be disposed
-          if( inputProtocol != null)
-            inputProtocol.Dispose();
-          if( outputProtocol != null)
-            outputProtocol.Dispose();
-          if( inputTransport != null)
-            inputTransport.Dispose();
-          if( outputTransport != null)
-            outputTransport.Dispose();
+            using (TTransport client = (TTransport)threadContext)
+            {
+                TProcessor processor = processorFactory.GetProcessor(client, this);
+                TTransport inputTransport = null;
+                TTransport outputTransport = null;
+                TProtocol inputProtocol = null;
+                TProtocol outputProtocol = null;
+                object connectionContext = null;
+                try
+                {
+                    try
+                    {
+                        inputTransport = inputTransportFactory.GetTransport(client);
+                        outputTransport = outputTransportFactory.GetTransport(client);
+                        inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
+                        outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
+
+                        //Recover event handler (if any) and fire createContext server event when a client connects
+                        if (serverEventHandler != null)
+                            connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol);
+
+                        //Process client requests until client disconnects
+                        while (!stop)
+                        {
+                            if (!inputTransport.Peek())
+                                break;
+
+                            //Fire processContext server event
+                            //N.B. This is the pattern implemented in C++ and the event fires provisionally.
+                            //That is to say it may be many minutes between the event firing and the client request
+                            //actually arriving or the client may hang up without ever makeing a request.
+                            if (serverEventHandler != null)
+                                serverEventHandler.processContext(connectionContext, inputTransport);
+                            //Process client request (blocks until transport is readable)
+                            if (!processor.Process(inputProtocol, outputProtocol))
+                                break;
+                        }
+                    }
+                    catch (TTransportException)
+                    {
+                        //Usually a client disconnect, expected
+                    }
+                    catch (Exception x)
+                    {
+                        //Unexpected
+                        logDelegate("Error: " + x);
+                    }
+
+                    //Fire deleteContext server event after client disconnects
+                    if (serverEventHandler != null)
+                        serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
+
+                }
+                finally
+                {
+                    //Close transports
+                    if (inputTransport != null)
+                        inputTransport.Close();
+                    if (outputTransport != null)
+                        outputTransport.Close();
+
+                    // disposable stuff should be disposed
+                    if (inputProtocol != null)
+                        inputProtocol.Dispose();
+                    if (outputProtocol != null)
+                        outputProtocol.Dispose();
+                    if (inputTransport != null)
+                        inputTransport.Dispose();
+                    if (outputTransport != null)
+                        outputTransport.Dispose();
+                }
+            }
         }
-      }
-    }
 
-    public override void Stop()
-    {
-      stop = true;
-      serverTransport.Close();
+        public override void Stop()
+        {
+            stop = true;
+            serverTransport.Close();
+        }
     }
-  }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Server/TThreadedServer.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Server/TThreadedServer.cs b/lib/csharp/src/Server/TThreadedServer.cs
index 3a1734a..cc051a3 100644
--- a/lib/csharp/src/Server/TThreadedServer.cs
+++ b/lib/csharp/src/Server/TThreadedServer.cs
@@ -26,258 +26,257 @@ using Thrift.Transport;
 
 namespace Thrift.Server
 {
-  /// <summary>
-  /// Server that uses C# threads (as opposed to the ThreadPool) when handling requests
-  /// </summary>
-  public class TThreadedServer : TServer
-  {
-    private const int DEFAULT_MAX_THREADS = 100;
-    private volatile bool stop = false;
-    private readonly int maxThreads;
-
-    private Queue<TTransport> clientQueue;
-    private THashSet<Thread> clientThreads;
-    private object clientLock;
-    private Thread workerThread;
-
-    public int ClientThreadsCount  {
-        get { return clientThreads.Count; }
-    }
-
-    public TThreadedServer(TProcessor processor, TServerTransport serverTransport)
-        : this(new TSingletonProcessorFactory(processor), serverTransport,
-         new TTransportFactory(), new TTransportFactory(),
-         new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
-         DEFAULT_MAX_THREADS, DefaultLogDelegate)
-    {
-    }
-
-    public TThreadedServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate)
-        : this(new TSingletonProcessorFactory(processor), serverTransport,
-         new TTransportFactory(), new TTransportFactory(),
-         new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
-         DEFAULT_MAX_THREADS, logDelegate)
-    {
-    }
-
-
-    public TThreadedServer(TProcessor processor,
-                 TServerTransport serverTransport,
-                 TTransportFactory transportFactory,
-                 TProtocolFactory protocolFactory)
-        : this(new TSingletonProcessorFactory(processor), serverTransport,
-         transportFactory, transportFactory,
-         protocolFactory, protocolFactory,
-         DEFAULT_MAX_THREADS, DefaultLogDelegate)
-    {
-    }
-
-    public TThreadedServer(TProcessorFactory processorFactory,
-           TServerTransport serverTransport,
-           TTransportFactory transportFactory,
-           TProtocolFactory protocolFactory)
-        : this(processorFactory, serverTransport,
-         transportFactory, transportFactory,
-         protocolFactory, protocolFactory,
-         DEFAULT_MAX_THREADS, DefaultLogDelegate)
-    {
-    }
-    public TThreadedServer(TProcessorFactory processorFactory,
-                 TServerTransport serverTransport,
-                 TTransportFactory inputTransportFactory,
-                 TTransportFactory outputTransportFactory,
-                 TProtocolFactory inputProtocolFactory,
-                 TProtocolFactory outputProtocolFactory,
-                 int maxThreads, LogDelegate logDel)
-      : base(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
-          inputProtocolFactory, outputProtocolFactory, logDel)
-    {
-      this.maxThreads = maxThreads;
-      clientQueue = new Queue<TTransport>();
-      clientLock = new object();
-      clientThreads = new THashSet<Thread>();
-    }
-
     /// <summary>
-    /// Use new Thread for each new client connection. block until numConnections < maxThreads
+    /// Server that uses C# threads (as opposed to the ThreadPool) when handling requests.
     /// </summary>
-    public override void Serve()
+    public class TThreadedServer : TServer
     {
-      try
-      {
-        //start worker thread
-        workerThread = new Thread(new ThreadStart(Execute));
-        workerThread.Start();
-        serverTransport.Listen();
-      }
-      catch (TTransportException ttx)
-      {
-        logDelegate("Error, could not listen on ServerTransport: " + ttx);
-        return;
-      }
+        private const int DEFAULT_MAX_THREADS = 100;
+        private volatile bool stop = false;
+        private readonly int maxThreads;
+
+        private Queue<TTransport> clientQueue;
+        private THashSet<Thread> clientThreads;
+        private object clientLock;
+        private Thread workerThread;
 
-      //Fire the preServe server event when server is up but before any client connections
-      if (serverEventHandler != null)
-        serverEventHandler.preServe();
+        public int ClientThreadsCount
+        {
+            get { return clientThreads.Count; }
+        }
 
-      while (!stop)
-      {
-        int failureCount = 0;
-        try
+        public TThreadedServer(TProcessor processor, TServerTransport serverTransport)
+            : this(new TSingletonProcessorFactory(processor), serverTransport,
+             new TTransportFactory(), new TTransportFactory(),
+             new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
+             DEFAULT_MAX_THREADS, DefaultLogDelegate)
         {
-          TTransport client = serverTransport.Accept();
-          lock (clientLock)
-          {
-            clientQueue.Enqueue(client);
-            Monitor.Pulse(clientLock);
-          }
         }
-        catch (TTransportException ttx)
+
+        public TThreadedServer(TProcessor processor, TServerTransport serverTransport, LogDelegate logDelegate)
+            : this(new TSingletonProcessorFactory(processor), serverTransport,
+             new TTransportFactory(), new TTransportFactory(),
+             new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(),
+             DEFAULT_MAX_THREADS, logDelegate)
         {
-          if (!stop || ttx.Type != TTransportException.ExceptionType.Interrupted)
-          {
-            ++failureCount;
-            logDelegate(ttx.ToString());
-          }
+        }
 
+
+        public TThreadedServer(TProcessor processor,
+                     TServerTransport serverTransport,
+                     TTransportFactory transportFactory,
+                     TProtocolFactory protocolFactory)
+            : this(new TSingletonProcessorFactory(processor), serverTransport,
+             transportFactory, transportFactory,
+             protocolFactory, protocolFactory,
+             DEFAULT_MAX_THREADS, DefaultLogDelegate)
+        {
         }
-      }
 
-      if (stop)
-      {
-        try
+        public TThreadedServer(TProcessorFactory processorFactory,
+               TServerTransport serverTransport,
+               TTransportFactory transportFactory,
+               TProtocolFactory protocolFactory)
+            : this(processorFactory, serverTransport,
+             transportFactory, transportFactory,
+             protocolFactory, protocolFactory,
+             DEFAULT_MAX_THREADS, DefaultLogDelegate)
         {
-          serverTransport.Close();
         }
-        catch (TTransportException ttx)
+        public TThreadedServer(TProcessorFactory processorFactory,
+                     TServerTransport serverTransport,
+                     TTransportFactory inputTransportFactory,
+                     TTransportFactory outputTransportFactory,
+                     TProtocolFactory inputProtocolFactory,
+                     TProtocolFactory outputProtocolFactory,
+                     int maxThreads, LogDelegate logDel)
+          : base(processorFactory, serverTransport, inputTransportFactory, outputTransportFactory,
+              inputProtocolFactory, outputProtocolFactory, logDel)
         {
-          logDelegate("TServeTransport failed on close: " + ttx.Message);
+            this.maxThreads = maxThreads;
+            clientQueue = new Queue<TTransport>();
+            clientLock = new object();
+            clientThreads = new THashSet<Thread>();
         }
-        stop = false;
-      }
-    }
 
-    /// <summary>
-    /// Loops on processing a client forever
-    /// threadContext will be a TTransport instance
-    /// </summary>
-    /// <param name="threadContext"></param>
-    private void Execute()
-    {
-      while (!stop)
-      {
-        TTransport client;
-        Thread t;
-        lock (clientLock)
+        /// <summary>
+        /// Use new Thread for each new client connection. block until numConnections &lt; maxThreads.
+        /// </summary>
+        public override void Serve()
         {
-          //don't dequeue if too many connections
-          while (clientThreads.Count >= maxThreads)
-          {
-            Monitor.Wait(clientLock);
-          }
+            try
+            {
+                //start worker thread
+                workerThread = new Thread(new ThreadStart(Execute));
+                workerThread.Start();
+                serverTransport.Listen();
+            }
+            catch (TTransportException ttx)
+            {
+                logDelegate("Error, could not listen on ServerTransport: " + ttx);
+                return;
+            }
+
+            //Fire the preServe server event when server is up but before any client connections
+            if (serverEventHandler != null)
+                serverEventHandler.preServe();
 
-          while (clientQueue.Count == 0)
-          {
-            Monitor.Wait(clientLock);
-          }
+            while (!stop)
+            {
+                int failureCount = 0;
+                try
+                {
+                    TTransport client = serverTransport.Accept();
+                    lock (clientLock)
+                    {
+                        clientQueue.Enqueue(client);
+                        Monitor.Pulse(clientLock);
+                    }
+                }
+                catch (TTransportException ttx)
+                {
+                    if (!stop || ttx.Type != TTransportException.ExceptionType.Interrupted)
+                    {
+                        ++failureCount;
+                        logDelegate(ttx.ToString());
+                    }
+
+                }
+            }
 
-          client = clientQueue.Dequeue();
-          t = new Thread(new ParameterizedThreadStart(ClientWorker));
-          clientThreads.Add(t);
+            if (stop)
+            {
+                try
+                {
+                    serverTransport.Close();
+                }
+                catch (TTransportException ttx)
+                {
+                    logDelegate("TServeTransport failed on close: " + ttx.Message);
+                }
+                stop = false;
+            }
         }
-        //start processing requests from client on new thread
-        t.Start(client);
-      }
-    }
 
-    private void ClientWorker(Object context)
-    {
-      using( TTransport client = (TTransport)context)
-      { 
-        TProcessor processor = processorFactory.GetProcessor(client);
-        TTransport inputTransport = null;
-        TTransport outputTransport = null;
-        TProtocol inputProtocol = null;
-        TProtocol outputProtocol = null;
-        Object connectionContext = null;
-        try
+        /// <summary>
+        /// Loops on processing a client forever
+        /// </summary>
+        private void Execute()
         {
-          try
-          {
-            inputTransport = inputTransportFactory.GetTransport(client);
-            outputTransport = outputTransportFactory.GetTransport(client);
-            inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
-            outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
-  
-            //Recover event handler (if any) and fire createContext server event when a client connects
-            if (serverEventHandler != null)
-              connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol);
-  
-            //Process client requests until client disconnects
             while (!stop)
             {
-              if (!inputTransport.Peek())
-                break;
-  
-              //Fire processContext server event
-              //N.B. This is the pattern implemented in C++ and the event fires provisionally.
-              //That is to say it may be many minutes between the event firing and the client request
-              //actually arriving or the client may hang up without ever makeing a request.
-              if (serverEventHandler != null)
-                serverEventHandler.processContext(connectionContext, inputTransport);
-              //Process client request (blocks until transport is readable)
-              if (!processor.Process(inputProtocol, outputProtocol))
-                break;
+                TTransport client;
+                Thread t;
+                lock (clientLock)
+                {
+                    //don't dequeue if too many connections
+                    while (clientThreads.Count >= maxThreads)
+                    {
+                        Monitor.Wait(clientLock);
+                    }
+
+                    while (clientQueue.Count == 0)
+                    {
+                        Monitor.Wait(clientLock);
+                    }
+
+                    client = clientQueue.Dequeue();
+                    t = new Thread(new ParameterizedThreadStart(ClientWorker));
+                    clientThreads.Add(t);
+                }
+                //start processing requests from client on new thread
+                t.Start(client);
             }
-          }
-          catch (TTransportException)
-          {
-            //Usually a client disconnect, expected
-          }
-          catch (Exception x)
-          {
-            //Unexpected
-            logDelegate("Error: " + x);
-          }
-  
-          //Fire deleteContext server event after client disconnects
-          if (serverEventHandler != null)
-            serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
-  
-          lock (clientLock)
-          {
-            clientThreads.Remove(Thread.CurrentThread);
-            Monitor.Pulse(clientLock);
-          }
+        }
 
-        } 
-        finally
+        private void ClientWorker(object context)
         {
-          //Close transports
-          if (inputTransport != null)
-            inputTransport.Close();
-          if (outputTransport != null)
-            outputTransport.Close();
-		
-          // disposable stuff should be disposed
-          if (inputProtocol != null)
-            inputProtocol.Dispose();
-          if (outputProtocol != null)
-            outputProtocol.Dispose();
+            using (TTransport client = (TTransport)context)
+            {
+                TProcessor processor = processorFactory.GetProcessor(client);
+                TTransport inputTransport = null;
+                TTransport outputTransport = null;
+                TProtocol inputProtocol = null;
+                TProtocol outputProtocol = null;
+                object connectionContext = null;
+                try
+                {
+                    try
+                    {
+                        inputTransport = inputTransportFactory.GetTransport(client);
+                        outputTransport = outputTransportFactory.GetTransport(client);
+                        inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
+                        outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
+
+                        //Recover event handler (if any) and fire createContext server event when a client connects
+                        if (serverEventHandler != null)
+                            connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol);
+
+                        //Process client requests until client disconnects
+                        while (!stop)
+                        {
+                            if (!inputTransport.Peek())
+                                break;
+
+                            //Fire processContext server event
+                            //N.B. This is the pattern implemented in C++ and the event fires provisionally.
+                            //That is to say it may be many minutes between the event firing and the client request
+                            //actually arriving or the client may hang up without ever makeing a request.
+                            if (serverEventHandler != null)
+                                serverEventHandler.processContext(connectionContext, inputTransport);
+                            //Process client request (blocks until transport is readable)
+                            if (!processor.Process(inputProtocol, outputProtocol))
+                                break;
+                        }
+                    }
+                    catch (TTransportException)
+                    {
+                        //Usually a client disconnect, expected
+                    }
+                    catch (Exception x)
+                    {
+                        //Unexpected
+                        logDelegate("Error: " + x);
+                    }
+
+                    //Fire deleteContext server event after client disconnects
+                    if (serverEventHandler != null)
+                        serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
+
+                    lock (clientLock)
+                    {
+                        clientThreads.Remove(Thread.CurrentThread);
+                        Monitor.Pulse(clientLock);
+                    }
+
+                }
+                finally
+                {
+                    //Close transports
+                    if (inputTransport != null)
+                        inputTransport.Close();
+                    if (outputTransport != null)
+                        outputTransport.Close();
+
+                    // disposable stuff should be disposed
+                    if (inputProtocol != null)
+                        inputProtocol.Dispose();
+                    if (outputProtocol != null)
+                        outputProtocol.Dispose();
+                }
+            }
         }
-      }
-    }
 
-    public override void Stop()
-    {
-      stop = true;
-      serverTransport.Close();
-      //clean up all the threads myself
-      workerThread.Abort();
-      foreach (Thread t in clientThreads)
-      {
-        t.Abort();
-      }
+        public override void Stop()
+        {
+            stop = true;
+            serverTransport.Close();
+            //clean up all the threads myself
+            workerThread.Abort();
+            foreach (Thread t in clientThreads)
+            {
+                t.Abort();
+            }
+        }
     }
-  }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/TApplicationException.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/TApplicationException.cs b/lib/csharp/src/TApplicationException.cs
index 409aa4d..0c5b08b 100644
--- a/lib/csharp/src/TApplicationException.cs
+++ b/lib/csharp/src/TApplicationException.cs
@@ -103,7 +103,7 @@ namespace Thrift
 
             oprot.WriteStructBegin(struc);
 
-            if (!String.IsNullOrEmpty(Message))
+            if (!string.IsNullOrEmpty(Message))
             {
                 field.Name = "message";
                 field.Type = TType.String;

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/TException.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/TException.cs b/lib/csharp/src/TException.cs
index 65509ec..35193c5 100644
--- a/lib/csharp/src/TException.cs
+++ b/lib/csharp/src/TException.cs
@@ -31,7 +31,7 @@ namespace Thrift
         {
         }
 
-        public TException( string message)
+        public TException(string message)
             : base(message)
         {
         }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/TPrototypeProcessorFactory.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/TPrototypeProcessorFactory.cs b/lib/csharp/src/TPrototypeProcessorFactory.cs
index 6f56d33..0b47261 100644
--- a/lib/csharp/src/TPrototypeProcessorFactory.cs
+++ b/lib/csharp/src/TPrototypeProcessorFactory.cs
@@ -42,7 +42,7 @@ namespace Thrift
 
         public TProcessor GetProcessor(TTransport trans, TServer server = null)
         {
-            H handler = (H) Activator.CreateInstance(typeof(H), handlerArgs);
+            H handler = (H)Activator.CreateInstance(typeof(H), handlerArgs);
 
             TControllingHandler handlerServerRef = handler as TControllingHandler;
             if (handlerServerRef != null)

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/TSingletonProcessorFactory.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/TSingletonProcessorFactory.cs b/lib/csharp/src/TSingletonProcessorFactory.cs
index 40dc44c..ed2897b 100644
--- a/lib/csharp/src/TSingletonProcessorFactory.cs
+++ b/lib/csharp/src/TSingletonProcessorFactory.cs
@@ -17,7 +17,7 @@
  * under the License.
  */
 
- using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TBufferedTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index c969419..9efeeb7 100644
--- a/lib/csharp/src/Transport/TBufferedTransport.cs
+++ b/lib/csharp/src/Transport/TBufferedTransport.cs
@@ -154,11 +154,11 @@ namespace Thrift.Transport
             {
                 if (disposing)
                 {
-                    if(inputBuffer != null)
+                    if (inputBuffer != null)
                         inputBuffer.Dispose();
-                    if(outputBuffer != null)
+                    if (outputBuffer != null)
                         outputBuffer.Dispose();
-                    if(transport != null)
+                    if (transport != null)
                         transport.Dispose();
                 }
             }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TFramedTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TFramedTransport.cs b/lib/csharp/src/Transport/TFramedTransport.cs
index 0af8b1f..3436cc6 100644
--- a/lib/csharp/src/Transport/TFramedTransport.cs
+++ b/lib/csharp/src/Transport/TFramedTransport.cs
@@ -116,8 +116,8 @@ namespace Thrift.Transport
             byte[] buf = writeBuffer.GetBuffer();
             int len = (int)writeBuffer.Length;
             int data_len = len - HeaderSize;
-            if ( data_len < 0 )
-                throw new System.InvalidOperationException (); // logic error actually
+            if (data_len < 0)
+                throw new System.InvalidOperationException(); // logic error actually
 
             // Inject message header into the reserved buffer space
             EncodeFrameSize(data_len, buf);
@@ -130,7 +130,7 @@ namespace Thrift.Transport
             transport.Flush();
         }
 
-        private void InitWriteBuffer ()
+        private void InitWriteBuffer()
         {
             // Reserve space for message header to be put right before sending it out
             writeBuffer.SetLength(HeaderSize);
@@ -150,7 +150,7 @@ namespace Thrift.Transport
             return
                 ((buf[0] & 0xff) << 24) |
                 ((buf[1] & 0xff) << 16) |
-                ((buf[2] & 0xff) <<  8) |
+                ((buf[2] & 0xff) << 8) |
                 ((buf[3] & 0xff));
         }
 
@@ -171,11 +171,11 @@ namespace Thrift.Transport
             {
                 if (disposing)
                 {
-                    if(readBuffer != null)
+                    if (readBuffer != null)
                         readBuffer.Dispose();
-                    if(writeBuffer != null)
+                    if (writeBuffer != null)
                         writeBuffer.Dispose();
-                    if(transport != null)
+                    if (transport != null)
                         transport.Dispose();
                 }
             }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/THttpClient.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/THttpClient.cs b/lib/csharp/src/Transport/THttpClient.cs
index f678d1e..06ed6bc 100644
--- a/lib/csharp/src/Transport/THttpClient.cs
+++ b/lib/csharp/src/Transport/THttpClient.cs
@@ -30,7 +30,6 @@ using System.IO.Compression;
 
 namespace Thrift.Transport
 {
-
     public class THttpClient : TTransport, IDisposable
     {
         private readonly Uri uri;
@@ -43,7 +42,7 @@ namespace Thrift.Transport
 
         private int readTimeout = 30000;
 
-        private IDictionary<String, String> customHeaders = new Dictionary<string, string>();
+        private IDictionary<string, string> customHeaders = new Dictionary<string, string>();
 
 #if !SILVERLIGHT
         private IWebProxy proxy = WebRequest.DefaultWebProxy;
@@ -64,7 +63,7 @@ namespace Thrift.Transport
         {
             set
             {
-               connectTimeout = value;
+                connectTimeout = value;
             }
         }
 
@@ -76,7 +75,7 @@ namespace Thrift.Transport
             }
         }
 
-        public IDictionary<String, String> CustomHeaders
+        public IDictionary<string, string> CustomHeaders
         {
             get
             {
@@ -325,7 +324,7 @@ namespace Thrift.Transport
         {
             try
             {
-                var flushAsyncResult = (FlushAsyncResult) asyncResult;
+                var flushAsyncResult = (FlushAsyncResult)asyncResult;
 
                 if (!flushAsyncResult.IsCompleted)
                 {
@@ -338,7 +337,8 @@ namespace Thrift.Transport
                 {
                     throw flushAsyncResult.AsyncException;
                 }
-            } finally
+            }
+            finally
             {
                 outputStream = new MemoryStream();
             }
@@ -387,9 +387,9 @@ namespace Thrift.Transport
             private volatile Boolean _isCompleted;
             private ManualResetEvent _evt;
             private readonly AsyncCallback _cbMethod;
-            private readonly Object _state;
+            private readonly object _state;
 
-            public FlushAsyncResult(AsyncCallback cbMethod, Object state)
+            public FlushAsyncResult(AsyncCallback cbMethod, object state)
             {
                 _cbMethod = cbMethod;
                 _state = state;
@@ -415,7 +415,7 @@ namespace Thrift.Transport
             {
                 get { return _isCompleted; }
             }
-            private readonly Object _locker = new Object();
+            private readonly object _locker = new object();
             private ManualResetEvent GetEvtHandle()
             {
                 lock (_locker)
@@ -452,7 +452,7 @@ namespace Thrift.Transport
             }
         }
 
-#region " IDisposable Support "
+        #region " IDisposable Support "
         private bool _IsDisposed;
 
         // IDisposable
@@ -470,6 +470,6 @@ namespace Thrift.Transport
             }
             _IsDisposed = true;
         }
-#endregion
+        #endregion
     }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TMemoryBuffer.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TMemoryBuffer.cs b/lib/csharp/src/Transport/TMemoryBuffer.cs
index d8ff9dc..303d083 100644
--- a/lib/csharp/src/Transport/TMemoryBuffer.cs
+++ b/lib/csharp/src/Transport/TMemoryBuffer.cs
@@ -22,45 +22,56 @@ using System.IO;
 using System.Reflection;
 using Thrift.Protocol;
 
-namespace Thrift.Transport {
-    public class TMemoryBuffer : TTransport {
+namespace Thrift.Transport
+{
+    public class TMemoryBuffer : TTransport
+    {
 
         private readonly MemoryStream byteStream;
 
-        public TMemoryBuffer() {
+        public TMemoryBuffer()
+        {
             byteStream = new MemoryStream();
         }
 
-        public TMemoryBuffer(byte[] buf) {
+        public TMemoryBuffer(byte[] buf)
+        {
             byteStream = new MemoryStream(buf);
         }
 
-        public override void Open() {
+        public override void Open()
+        {
             /** do nothing **/
         }
 
-        public override void Close() {
+        public override void Close()
+        {
             /** do nothing **/
         }
 
-        public override int Read(byte[] buf, int off, int len) {
+        public override int Read(byte[] buf, int off, int len)
+        {
             return byteStream.Read(buf, off, len);
         }
 
-        public override void Write(byte[] buf, int off, int len) {
+        public override void Write(byte[] buf, int off, int len)
+        {
             byteStream.Write(buf, off, len);
         }
 
-        public byte[] GetBuffer() {
+        public byte[] GetBuffer()
+        {
             return byteStream.ToArray();
         }
 
 
-        public override bool IsOpen {
+        public override bool IsOpen
+        {
             get { return true; }
         }
 
-        public static byte[] Serialize(TAbstractBase s) {
+        public static byte[] Serialize(TAbstractBase s)
+        {
             var t = new TMemoryBuffer();
             var p = new TBinaryProtocol(t);
 
@@ -69,26 +80,33 @@ namespace Thrift.Transport {
             return t.GetBuffer();
         }
 
-        public static T DeSerialize<T>(byte[] buf) where T : TAbstractBase {
+        public static T DeSerialize<T>(byte[] buf) where T : TAbstractBase
+        {
             var trans = new TMemoryBuffer(buf);
             var p = new TBinaryProtocol(trans);
-            if (typeof (TBase).IsAssignableFrom(typeof (T))) {
-                var method = typeof (T).GetMethod("Read", BindingFlags.Instance | BindingFlags.Public);
+            if (typeof(TBase).IsAssignableFrom(typeof(T)))
+            {
+                var method = typeof(T).GetMethod("Read", BindingFlags.Instance | BindingFlags.Public);
                 var t = Activator.CreateInstance<T>();
-                method.Invoke(t, new object[] {p});
+                method.Invoke(t, new object[] { p });
                 return t;
-             } else {
-                   var method = typeof (T).GetMethod("Read", BindingFlags.Static | BindingFlags.Public);
-                return (T) method.Invoke(null, new object[] {p});
+            }
+            else
+            {
+                var method = typeof(T).GetMethod("Read", BindingFlags.Static | BindingFlags.Public);
+                return (T)method.Invoke(null, new object[] { p });
             }
         }
 
         private bool _IsDisposed;
 
         // IDisposable
-        protected override void Dispose(bool disposing) {
-            if (!_IsDisposed) {
-                if (disposing) {
+        protected override void Dispose(bool disposing)
+        {
+            if (!_IsDisposed)
+            {
+                if (disposing)
+                {
                     if (byteStream != null)
                         byteStream.Dispose();
                 }
@@ -96,4 +114,4 @@ namespace Thrift.Transport {
             _IsDisposed = true;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TNamedPipeClientTransport.cs b/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
index ea2e862..49a50aa 100644
--- a/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
+++ b/lib/csharp/src/Transport/TNamedPipeClientTransport.cs
@@ -108,4 +108,4 @@ namespace Thrift.Transport
             client.Dispose();
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TServerSocket.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TServerSocket.cs b/lib/csharp/src/Transport/TServerSocket.cs
index e29a87e..40e47dc 100644
--- a/lib/csharp/src/Transport/TServerSocket.cs
+++ b/lib/csharp/src/Transport/TServerSocket.cs
@@ -27,150 +27,150 @@ using System.Net.Sockets;
 
 namespace Thrift.Transport
 {
-	public class TServerSocket : TServerTransport
-	{
-        /**
-        * Underlying server with socket
-        */
-		private TcpListener server = null;
+    public class TServerSocket : TServerTransport
+    {
+        /// <summary>
+        /// Underlying server with socket.
+        /// </summary>
+        private TcpListener server = null;
 
-		/**
-		 * Port to listen on
-		 */
-		private int port = 0;
+        /// <summary>
+        /// Port to listen on.
+        /// </summary>
+        private int port = 0;
 
-		/**
-		 * Timeout for client sockets from accept
-		 */
-		private int clientTimeout = 0;
+        /// <summary>
+        /// Timeout for client sockets from accept.
+        /// </summary>
+        private int clientTimeout = 0;
 
-		/**
-		 * Whether or not to wrap new TSocket connections in buffers
-		 */
-		private bool useBufferedSockets = false;
+        /// <summary>
+        /// Whether or not to wrap new TSocket connections in buffers.
+        /// </summary>
+        private bool useBufferedSockets = false;
 
-		/**
-		 * Creates a server socket from underlying socket object
-		 */
-		public TServerSocket(TcpListener listener)
-            :this(listener, 0)
-		{
-		}
+        /// <summary>
+        /// Creates a server socket from underlying socket object.
+        /// </summary>
+        public TServerSocket(TcpListener listener)
+            : this(listener, 0)
+        {
+        }
 
-		/**
-		 * Creates a server socket from underlying socket object
-		 */
-		public TServerSocket(TcpListener listener, int clientTimeout)
-		{
-			this.server = listener;
-			this.clientTimeout = clientTimeout;
-		}
+        /// <summary>
+        /// Creates a server socket from underlying socket object.
+        /// </summary>
+        public TServerSocket(TcpListener listener, int clientTimeout)
+        {
+            this.server = listener;
+            this.clientTimeout = clientTimeout;
+        }
 
-		/**
-		 * Creates just a port listening server socket
-		 */
-		public TServerSocket(int port)
-			: this(port, 0)
-		{
-		}
+        /// <summary>
+        /// Creates just a port listening server socket.
+        /// </summary>
+        public TServerSocket(int port)
+            : this(port, 0)
+        {
+        }
 
-		/**
-		 * Creates just a port listening server socket
-		 */
-		public TServerSocket(int port, int clientTimeout)
-            :this(port, clientTimeout, false)
-		{
-		}
+        /// <summary>
+        /// Creates just a port listening server socket.
+        /// </summary>
+        public TServerSocket(int port, int clientTimeout)
+            : this(port, clientTimeout, false)
+        {
+        }
 
-		public TServerSocket(int port, int clientTimeout, bool useBufferedSockets)
-		{
-			this.port = port;
-			this.clientTimeout = clientTimeout;
-			this.useBufferedSockets = useBufferedSockets;
-			try
-			{
-				// Make server socket
-				this.server = TSocketVersionizer.CreateTcpListener(this.port);
-				this.server.Server.NoDelay = true;
-			}
-			catch (Exception)
-			{
-				server = null;
-				throw new TTransportException("Could not create ServerSocket on port " + this.port + ".");
-			}
-		}
+        public TServerSocket(int port, int clientTimeout, bool useBufferedSockets)
+        {
+            this.port = port;
+            this.clientTimeout = clientTimeout;
+            this.useBufferedSockets = useBufferedSockets;
+            try
+            {
+                // Make server socket
+                this.server = TSocketVersionizer.CreateTcpListener(this.port);
+                this.server.Server.NoDelay = true;
+            }
+            catch (Exception)
+            {
+                server = null;
+                throw new TTransportException("Could not create ServerSocket on port " + this.port + ".");
+            }
+        }
 
-		public override void Listen()
-		{
-			// Make sure not to block on accept
-			if (server != null)
-			{
-				try
-				{
-					server.Start();
-				}
-				catch (SocketException sx)
-				{
-					throw new TTransportException("Could not accept on listening socket: " + sx.Message);
-				}
-			}
-		}
+        public override void Listen()
+        {
+            // Make sure not to block on accept
+            if (server != null)
+            {
+                try
+                {
+                    server.Start();
+                }
+                catch (SocketException sx)
+                {
+                    throw new TTransportException("Could not accept on listening socket: " + sx.Message);
+                }
+            }
+        }
 
-		protected override TTransport AcceptImpl()
-		{
-			if (server == null)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
-			}
-			try
-			{
-				TSocket result2 = null;
-				TcpClient result = server.AcceptTcpClient();
-				try
-				{
-					result2 = new TSocket(result);
-					result2.Timeout = clientTimeout;
-					if (useBufferedSockets)
-					{
-						TBufferedTransport result3 = new TBufferedTransport(result2);
-						return result3;
-					}
-					else
-					{
-						return result2;
-					}
-				}
-				catch (System.Exception)
-				{
-					// If a TSocket was successfully created, then let
-					// it do proper cleanup of the TcpClient object.
-					if (result2 != null)
-						result2.Dispose();
-					else //  Otherwise, clean it up ourselves.
-						((IDisposable)result).Dispose();
-					throw;
-				}
-			}
-			catch (Exception ex)
-			{
-				throw new TTransportException(ex.ToString());
-			}
-		}
+        protected override TTransport AcceptImpl()
+        {
+            if (server == null)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
+            }
+            try
+            {
+                TSocket result2 = null;
+                TcpClient result = server.AcceptTcpClient();
+                try
+                {
+                    result2 = new TSocket(result);
+                    result2.Timeout = clientTimeout;
+                    if (useBufferedSockets)
+                    {
+                        TBufferedTransport result3 = new TBufferedTransport(result2);
+                        return result3;
+                    }
+                    else
+                    {
+                        return result2;
+                    }
+                }
+                catch (System.Exception)
+                {
+                    // If a TSocket was successfully created, then let
+                    // it do proper cleanup of the TcpClient object.
+                    if (result2 != null)
+                        result2.Dispose();
+                    else //  Otherwise, clean it up ourselves.
+                        ((IDisposable)result).Dispose();
+                    throw;
+                }
+            }
+            catch (Exception ex)
+            {
+                throw new TTransportException(ex.ToString());
+            }
+        }
 
-		public override void Close()
-		{
-			if (server != null)
-			{
-				try
-				{
-					server.Stop();
-				}
-				catch (Exception ex)
-				{
-					throw new TTransportException("WARNING: Could not close server socket: " + ex);
-				}
-				server = null;
-			}
-		}
-	}
+        public override void Close()
+        {
+            if (server != null)
+            {
+                try
+                {
+                    server.Stop();
+                }
+                catch (Exception ex)
+                {
+                    throw new TTransportException("WARNING: Could not close server socket: " + ex);
+                }
+                server = null;
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TServerTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TServerTransport.cs b/lib/csharp/src/Transport/TServerTransport.cs
index 05d7d0f..e63880b 100644
--- a/lib/csharp/src/Transport/TServerTransport.cs
+++ b/lib/csharp/src/Transport/TServerTransport.cs
@@ -34,10 +34,11 @@ namespace Thrift.Transport
         public TTransport Accept()
         {
             TTransport transport = AcceptImpl();
-            if (transport == null) {
-              throw new TTransportException("accept() may not return NULL");
+            if (transport == null)
+            {
+                throw new TTransportException("accept() may not return NULL");
             }
             return transport;
-         }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TSilverlightSocket.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TSilverlightSocket.cs b/lib/csharp/src/Transport/TSilverlightSocket.cs
index cbd3baa..40469ab 100644
--- a/lib/csharp/src/Transport/TSilverlightSocket.cs
+++ b/lib/csharp/src/Transport/TSilverlightSocket.cs
@@ -112,7 +112,7 @@ namespace Thrift.Transport
                 throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
             }
 
-            if (String.IsNullOrEmpty(host))
+            if (string.IsNullOrEmpty(host))
             {
                 throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
             }
@@ -282,9 +282,9 @@ namespace Thrift.Transport
             private volatile Boolean _isCompleted;
             private ManualResetEvent _evt;
             private readonly AsyncCallback _cbMethod;
-            private readonly Object _state;
+            private readonly object _state;
 
-            public FlushAsyncResult(AsyncCallback cbMethod, Object state)
+            public FlushAsyncResult(AsyncCallback cbMethod, object state)
             {
                 _cbMethod = cbMethod;
                 _state = state;
@@ -314,7 +314,7 @@ namespace Thrift.Transport
                 get { return _isCompleted; }
             }
 
-            private readonly Object _locker = new Object();
+            private readonly object _locker = new object();
 
             private ManualResetEvent GetEvtHandle()
             {
@@ -362,7 +362,7 @@ namespace Thrift.Transport
             }
         }
 
-        #region " IDisposable Support "
+#region " IDisposable Support "
         private bool _IsDisposed;
 
         // IDisposable
@@ -385,7 +385,7 @@ namespace Thrift.Transport
             }
             _IsDisposed = true;
         }
-        #endregion
+#endregion
     }
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TSocket.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TSocket.cs b/lib/csharp/src/Transport/TSocket.cs
index 7501e30..d8fa335 100644
--- a/lib/csharp/src/Transport/TSocket.cs
+++ b/lib/csharp/src/Transport/TSocket.cs
@@ -26,216 +26,220 @@ using System.Net.Sockets;
 
 namespace Thrift.Transport
 {
-	public class TSocket : TStreamTransport
-	{
-		private TcpClient client = null;
-		private string host = null;
-		private int port = 0;
-		private int timeout = 0;
-
-		public TSocket(TcpClient client)
-		{
-			this.client = client;
-
-			if (IsOpen)
-			{
-				inputStream = client.GetStream();
-				outputStream = client.GetStream();
-			}
-		}
-
-		public TSocket(string host, int port)
-			: this(host, port, 0)
-		{
-		}
-
-		public TSocket(string host, int port, int timeout)
-		{
-			this.host = host;
-			this.port = port;
-			this.timeout = timeout;
-
-			InitSocket();
-		}
-
-		private void InitSocket()
-		{
-			this.client = TSocketVersionizer.CreateTcpClient();
-			this.client.ReceiveTimeout = client.SendTimeout = timeout;
-			this.client.Client.NoDelay = true;
-		}
-
-		public int Timeout
-		{
-			set
-			{
-				client.ReceiveTimeout = client.SendTimeout = timeout = value;
-			}
-		}
-
-		public TcpClient TcpClient
-		{
-			get
-			{
-				return client;
-			}
-		}
-
-		public string Host
-		{
-			get
-			{
-				return host;
-			}
-		}
-
-		public int Port
-		{
-			get
-			{
-				return port;
-			}
-		}
-
-		public override bool IsOpen
-		{
-			get
-			{
-				if (client == null)
-				{
-					return false;
-				}
-
-				return client.Connected;
-			}
-		}
-
-		public override void Open()
-		{
-			if (IsOpen)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
-			}
-
-			if (String.IsNullOrEmpty(host))
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
-			}
-
-			if (port <= 0)
-			{
-				throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open without port");
-			}
-
-			if (client == null)
-			{
-				InitSocket();
-			}
-
-            if( timeout == 0)            // no timeout -> infinite
-			{
-				client.Connect(host, port);
-			}
-			else                        // we have a timeout -> use it
-			{
-				ConnectHelper hlp = new ConnectHelper(client);
-				IAsyncResult asyncres = client.BeginConnect(host, port, new AsyncCallback(ConnectCallback), hlp);
-				bool bConnected = asyncres.AsyncWaitHandle.WaitOne(timeout) && client.Connected;
-				if (!bConnected)
-				{
-					lock (hlp.Mutex)
-					{
-                        if( hlp.CallbackDone)
-						{
-							asyncres.AsyncWaitHandle.Close();
-							client.Close();
-						}
-						else
-						{
-							hlp.DoCleanup = true;
-							client = null;
-						}
-					}
-					throw new TTransportException(TTransportException.ExceptionType.TimedOut, "Connect timed out");
-				}
-			}
-
-			inputStream = client.GetStream();
-			outputStream = client.GetStream();
-		}
-
-
-		static void ConnectCallback(IAsyncResult asyncres)
-		{
-			ConnectHelper hlp = asyncres.AsyncState as ConnectHelper;
-			lock (hlp.Mutex)
-			{
-				hlp.CallbackDone = true;
-
-				try
-				{
-                    if( hlp.Client.Client != null)
-						hlp.Client.EndConnect(asyncres);
-				}
-				catch (Exception)
-				{
-					// catch that away
-				}
-
-				if (hlp.DoCleanup)
-				{
-                    try {
-						asyncres.AsyncWaitHandle.Close();
-                    } catch (Exception) {}
-
-                    try {
-						if (hlp.Client is IDisposable)
-							((IDisposable)hlp.Client).Dispose();
-                    } catch (Exception) {}
-					hlp.Client = null;
-				}
-			}
-		}
-
-		private class ConnectHelper
-		{
-			public object Mutex = new object();
-			public bool DoCleanup = false;
-			public bool CallbackDone = false;
-			public TcpClient Client;
-			public ConnectHelper(TcpClient client)
-			{
-				Client = client;
-			}
-		}
-
-		public override void Close()
-		{
-			base.Close();
-			if (client != null)
-			{
-				client.Close();
-				client = null;
-			}
-		}
-
-		#region " IDisposable Support "
-		private bool _IsDisposed;
-
-		// IDisposable
-		protected override void Dispose(bool disposing)
-		{
-			if (!_IsDisposed)
-			{
-				if (disposing)
-				{
-					if (client != null)
-						((IDisposable)client).Dispose();
-					base.Dispose(disposing);
-				}
-			}
-			_IsDisposed = true;
-		}
-		#endregion
-	}
+    public class TSocket : TStreamTransport
+    {
+        private TcpClient client = null;
+        private string host = null;
+        private int port = 0;
+        private int timeout = 0;
+
+        public TSocket(TcpClient client)
+        {
+            this.client = client;
+
+            if (IsOpen)
+            {
+                inputStream = client.GetStream();
+                outputStream = client.GetStream();
+            }
+        }
+
+        public TSocket(string host, int port)
+            : this(host, port, 0)
+        {
+        }
+
+        public TSocket(string host, int port, int timeout)
+        {
+            this.host = host;
+            this.port = port;
+            this.timeout = timeout;
+
+            InitSocket();
+        }
+
+        private void InitSocket()
+        {
+            this.client = TSocketVersionizer.CreateTcpClient();
+            this.client.ReceiveTimeout = client.SendTimeout = timeout;
+            this.client.Client.NoDelay = true;
+        }
+
+        public int Timeout
+        {
+            set
+            {
+                client.ReceiveTimeout = client.SendTimeout = timeout = value;
+            }
+        }
+
+        public TcpClient TcpClient
+        {
+            get
+            {
+                return client;
+            }
+        }
+
+        public string Host
+        {
+            get
+            {
+                return host;
+            }
+        }
+
+        public int Port
+        {
+            get
+            {
+                return port;
+            }
+        }
+
+        public override bool IsOpen
+        {
+            get
+            {
+                if (client == null)
+                {
+                    return false;
+                }
+
+                return client.Connected;
+            }
+        }
+
+        public override void Open()
+        {
+            if (IsOpen)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
+            }
+
+            if (string.IsNullOrEmpty(host))
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
+            }
+
+            if (port <= 0)
+            {
+                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open without port");
+            }
+
+            if (client == null)
+            {
+                InitSocket();
+            }
+
+            if (timeout == 0)            // no timeout -> infinite
+            {
+                client.Connect(host, port);
+            }
+            else                        // we have a timeout -> use it
+            {
+                ConnectHelper hlp = new ConnectHelper(client);
+                IAsyncResult asyncres = client.BeginConnect(host, port, new AsyncCallback(ConnectCallback), hlp);
+                bool bConnected = asyncres.AsyncWaitHandle.WaitOne(timeout) && client.Connected;
+                if (!bConnected)
+                {
+                    lock (hlp.Mutex)
+                    {
+                        if (hlp.CallbackDone)
+                        {
+                            asyncres.AsyncWaitHandle.Close();
+                            client.Close();
+                        }
+                        else
+                        {
+                            hlp.DoCleanup = true;
+                            client = null;
+                        }
+                    }
+                    throw new TTransportException(TTransportException.ExceptionType.TimedOut, "Connect timed out");
+                }
+            }
+
+            inputStream = client.GetStream();
+            outputStream = client.GetStream();
+        }
+
+
+        static void ConnectCallback(IAsyncResult asyncres)
+        {
+            ConnectHelper hlp = asyncres.AsyncState as ConnectHelper;
+            lock (hlp.Mutex)
+            {
+                hlp.CallbackDone = true;
+
+                try
+                {
+                    if (hlp.Client.Client != null)
+                        hlp.Client.EndConnect(asyncres);
+                }
+                catch (Exception)
+                {
+                    // catch that away
+                }
+
+                if (hlp.DoCleanup)
+                {
+                    try
+                    {
+                        asyncres.AsyncWaitHandle.Close();
+                    }
+                    catch (Exception) { }
+
+                    try
+                    {
+                        if (hlp.Client is IDisposable)
+                            ((IDisposable)hlp.Client).Dispose();
+                    }
+                    catch (Exception) { }
+                    hlp.Client = null;
+                }
+            }
+        }
+
+        private class ConnectHelper
+        {
+            public object Mutex = new object();
+            public bool DoCleanup = false;
+            public bool CallbackDone = false;
+            public TcpClient Client;
+            public ConnectHelper(TcpClient client)
+            {
+                Client = client;
+            }
+        }
+
+        public override void Close()
+        {
+            base.Close();
+            if (client != null)
+            {
+                client.Close();
+                client = null;
+            }
+        }
+
+        #region " IDisposable Support "
+        private bool _IsDisposed;
+
+        // IDisposable
+        protected override void Dispose(bool disposing)
+        {
+            if (!_IsDisposed)
+            {
+                if (disposing)
+                {
+                    if (client != null)
+                        ((IDisposable)client).Dispose();
+                    base.Dispose(disposing);
+                }
+            }
+            _IsDisposed = true;
+        }
+        #endregion
+    }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TSocketVersionizer.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TSocketVersionizer.cs b/lib/csharp/src/Transport/TSocketVersionizer.cs
index 904e519..bf4c0e4 100644
--- a/lib/csharp/src/Transport/TSocketVersionizer.cs
+++ b/lib/csharp/src/Transport/TSocketVersionizer.cs
@@ -1,4 +1,27 @@
-using System;
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Net.Sockets;
@@ -10,46 +33,46 @@ using System.Threading.Tasks;
 
 namespace Thrift.Transport
 {
-	/**
-	* PropertyInfo for the DualMode property of the System.Net.Sockets.Socket class. Used to determine if the sockets are capable of
-	* automatic IPv4 and IPv6 handling. If DualMode is present the sockets automatically handle IPv4 and IPv6 connections.
-	* If the DualMode is not available the system configuration determines whether IPv4 or IPv6 is used.
-	*/
-	internal static class TSocketVersionizer
-	{
-		/*
-		* Creates a TcpClient according to the capabilitites of the used framework
-		*/
-		internal static TcpClient CreateTcpClient()
-		{
-			TcpClient client = null;
+    /// <summary>
+    /// PropertyInfo for the DualMode property of the System.Net.Sockets.Socket class. Used to determine if the sockets are capable of
+    /// automatic IPv4 and IPv6 handling. If DualMode is present the sockets automatically handle IPv4 and IPv6 connections.
+    /// If the DualMode is not available the system configuration determines whether IPv4 or IPv6 is used.
+    /// </summary>
+    internal static class TSocketVersionizer
+    {
+        /// <summary>
+        /// Creates a TcpClient according to the capabilitites of the used framework
+        /// </summary>
+        internal static TcpClient CreateTcpClient()
+        {
+            TcpClient client = null;
 
 #if NET45
-			client = new TcpClient(AddressFamily.InterNetworkV6);
-			client.Client.DualMode = true;
+            client = new TcpClient(AddressFamily.InterNetworkV6);
+            client.Client.DualMode = true;
 #else
             client = new TcpClient(AddressFamily.InterNetwork);
 #endif
 
-			return client;
-		}
+            return client;
+        }
 
-		/*
-		* Creates a TcpListener according to the capabilitites of the used framework
-		*/
-		internal static TcpListener CreateTcpListener(Int32 port)
-		{
-			TcpListener listener = null;
+        /// <summary>
+        /// Creates a TcpListener according to the capabilitites of the used framework.
+        /// </summary>
+        internal static TcpListener CreateTcpListener(Int32 port)
+        {
+            TcpListener listener = null;
 
 #if NET45
-			listener = new TcpListener(System.Net.IPAddress.IPv6Any, port);
-			listener.Server.DualMode = true;
+            listener = new TcpListener(System.Net.IPAddress.IPv6Any, port);
+            listener.Server.DualMode = true;
 #else
 
-			listener = new TcpListener(System.Net.IPAddress.Any, port);
+            listener = new TcpListener(System.Net.IPAddress.Any, port);
 #endif
 
             return listener;
-		}
-	}
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TStreamTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TStreamTransport.cs b/lib/csharp/src/Transport/TStreamTransport.cs
index 468743c..304599f 100644
--- a/lib/csharp/src/Transport/TStreamTransport.cs
+++ b/lib/csharp/src/Transport/TStreamTransport.cs
@@ -105,24 +105,24 @@ namespace Thrift.Transport
         }
 
 
-    #region " IDisposable Support "
-    private bool _IsDisposed;
+        #region " IDisposable Support "
+        private bool _IsDisposed;
 
-    // IDisposable
-    protected override void Dispose(bool disposing)
-    {
-      if (!_IsDisposed)
-      {
-        if (disposing)
+        // IDisposable
+        protected override void Dispose(bool disposing)
         {
-          if (InputStream != null)
-            InputStream.Dispose();
-          if (OutputStream != null)
-            OutputStream.Dispose();
+            if (!_IsDisposed)
+            {
+                if (disposing)
+                {
+                    if (InputStream != null)
+                        InputStream.Dispose();
+                    if (OutputStream != null)
+                        OutputStream.Dispose();
+                }
+            }
+            _IsDisposed = true;
         }
-      }
-      _IsDisposed = true;
+        #endregion
     }
-    #endregion
-  }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TTLSServerSocket.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TTLSServerSocket.cs b/lib/csharp/src/Transport/TTLSServerSocket.cs
index 24222b7..aa8ff7c 100644
--- a/lib/csharp/src/Transport/TTLSServerSocket.cs
+++ b/lib/csharp/src/Transport/TTLSServerSocket.cs
@@ -76,7 +76,7 @@ namespace Thrift.Transport
         /// <param name="port">The port where the server runs.</param>
         /// <param name="certificate">The certificate object.</param>
         public TTLSServerSocket(int port, X509Certificate2 certificate)
-            : this(port,  0, certificate)
+            : this(port, 0, certificate)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TTLSSocket.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TTLSSocket.cs b/lib/csharp/src/Transport/TTLSSocket.cs
index 27be0f4..fd019c3 100644
--- a/lib/csharp/src/Transport/TTLSSocket.cs
+++ b/lib/csharp/src/Transport/TTLSSocket.cs
@@ -263,7 +263,7 @@ namespace Thrift.Transport
         /// <param name="sender">The sender-object.</param>
         /// <param name="certificate">The used certificate.</param>
         /// <param name="chain">The certificate chain.</param>
-        /// <param name="sslPolicyErrors">An enum, which lists all the errors from the .NET certificate check.</param>
+        /// <param name="sslValidationErrors">An enum, which lists all the errors from the .NET certificate check.</param>
         /// <returns></returns>
         private bool DefaultCertificateValidator(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslValidationErrors)
         {
@@ -280,7 +280,7 @@ namespace Thrift.Transport
                 throw new TTransportException(TTransportException.ExceptionType.AlreadyOpen, "Socket already connected");
             }
 
-            if (String.IsNullOrEmpty(host))
+            if (string.IsNullOrEmpty(host))
             {
                 throw new TTransportException(TTransportException.ExceptionType.NotOpen, "Cannot open null host");
             }
@@ -307,7 +307,7 @@ namespace Thrift.Transport
         {
             RemoteCertificateValidationCallback validator = this.certValidator ?? DefaultCertificateValidator;
 
-            if( this.localCertificateSelectionCallback != null)
+            if (this.localCertificateSelectionCallback != null)
             {
                 this.secureStream = new SslStream(
                     this.client.GetStream(),
@@ -335,7 +335,7 @@ namespace Thrift.Transport
                 else
                 {
                     // Client authentication
-                    X509CertificateCollection certs = certificate != null ?  new X509CertificateCollection { certificate } : new X509CertificateCollection();
+                    X509CertificateCollection certs = certificate != null ? new X509CertificateCollection { certificate } : new X509CertificateCollection();
                     this.secureStream.AuthenticateAsClient(host, certs, sslProtocols, true);
                 }
             }

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TTransport.cs b/lib/csharp/src/Transport/TTransport.cs
index 6fb1077..5e4ac22 100644
--- a/lib/csharp/src/Transport/TTransport.cs
+++ b/lib/csharp/src/Transport/TTransport.cs
@@ -53,7 +53,7 @@ namespace Thrift.Transport
                 if (bytes == 0)
                     return false;
             }
-            catch( IOException)
+            catch (IOException)
             {
                 return false;
             }
@@ -108,7 +108,7 @@ namespace Thrift.Transport
 
         public virtual void Write(byte[] buf)
         {
-            Write (buf, 0, buf.Length);
+            Write(buf, 0, buf.Length);
         }
 
         public abstract void Write(byte[] buf, int off, int len);

http://git-wip-us.apache.org/repos/asf/thrift/blob/8fb719ef/lib/csharp/src/Transport/TTransportFactory.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TTransportFactory.cs b/lib/csharp/src/Transport/TTransportFactory.cs
index fa10033..47a0c62 100644
--- a/lib/csharp/src/Transport/TTransportFactory.cs
+++ b/lib/csharp/src/Transport/TTransportFactory.cs
@@ -26,7 +26,7 @@ using System;
 namespace Thrift.Transport
 {
     /// <summary>
-    /// From Mark Slee & Aditya Agarwal of Facebook:
+    /// From Mark Slee &amp; Aditya Agarwal of Facebook:
     /// Factory class used to create wrapped instance of Transports.
     /// This is used primarily in servers, which get Transports from
     /// a ServerTransport and then may want to mutate them (i.e. create