From ec1f5dc317182582ebff843c9e8a4d5277405469 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 6 Jan 2019 21:50:43 +0100 Subject: Mayor code cleanup Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment. --- Jellyfin.Server/SocketSharp/RequestMono.cs | 8 ++++---- Jellyfin.Server/SocketSharp/SharpWebSocket.cs | 4 ++-- Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs | 3 ++- Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'Jellyfin.Server/SocketSharp') diff --git a/Jellyfin.Server/SocketSharp/RequestMono.cs b/Jellyfin.Server/SocketSharp/RequestMono.cs index 31f2894977..13904be56c 100644 --- a/Jellyfin.Server/SocketSharp/RequestMono.cs +++ b/Jellyfin.Server/SocketSharp/RequestMono.cs @@ -138,7 +138,7 @@ namespace Jellyfin.SocketSharp if (v.Length > 20) v = v.Substring(0, 16) + "...\""; - string msg = String.Format("A potentially dangerous Request.{0} value was " + + string msg = string.Format("A potentially dangerous Request.{0} value was " + "detected from the client ({1}={2}).", name, key, v); throw new Exception(msg); @@ -328,13 +328,13 @@ namespace Jellyfin.SocketSharp public override int Read(byte[] buffer, int dest_offset, int count) { if (buffer == null) - throw new ArgumentNullException("buffer"); + throw new ArgumentNullException(nameof(buffer)); if (dest_offset < 0) - throw new ArgumentOutOfRangeException("dest_offset", "< 0"); + throw new ArgumentOutOfRangeException(nameof(dest_offset), "< 0"); if (count < 0) - throw new ArgumentOutOfRangeException("count", "< 0"); + throw new ArgumentOutOfRangeException(nameof(count), "< 0"); int len = buffer.Length; if (dest_offset > len) diff --git a/Jellyfin.Server/SocketSharp/SharpWebSocket.cs b/Jellyfin.Server/SocketSharp/SharpWebSocket.cs index 77de50267c..7101f83d90 100644 --- a/Jellyfin.Server/SocketSharp/SharpWebSocket.cs +++ b/Jellyfin.Server/SocketSharp/SharpWebSocket.cs @@ -29,12 +29,12 @@ namespace Jellyfin.SocketSharp { if (socket == null) { - throw new ArgumentNullException("socket"); + throw new ArgumentNullException(nameof(socket)); } if (logger == null) { - throw new ArgumentNullException("logger"); + throw new ArgumentNullException(nameof(logger)); } _logger = logger; diff --git a/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs b/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs index c360a8fcea..468c4c5cab 100644 --- a/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs +++ b/Jellyfin.Server/SocketSharp/WebSocketSharpListener.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using System.Threading; @@ -202,6 +202,7 @@ namespace Jellyfin.SocketSharp } catch (ObjectDisposedException) { + //TODO Investigate and properly fix. } catch (Exception ex) { diff --git a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs index 7c9dc8f88c..149842bd42 100644 --- a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs +++ b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs @@ -82,7 +82,7 @@ namespace Jellyfin.SocketSharp { get { - return String.IsNullOrEmpty(request.Headers["X-Forwarded-For"]) ? null : request.Headers["X-Forwarded-For"]; + return string.IsNullOrEmpty(request.Headers["X-Forwarded-For"]) ? null : request.Headers["X-Forwarded-For"]; } } @@ -106,7 +106,7 @@ namespace Jellyfin.SocketSharp { get { - return String.IsNullOrEmpty(request.Headers["X-Real-IP"]) ? null : request.Headers["X-Real-IP"]; + return string.IsNullOrEmpty(request.Headers["X-Real-IP"]) ? null : request.Headers["X-Real-IP"]; } } -- cgit v1.2.3