diff options
| author | Erwin de Haan <EraYaN@users.noreply.github.com> | 2019-01-06 21:50:43 +0100 |
|---|---|---|
| committer | Erwin de Haan <EraYaN@users.noreply.github.com> | 2019-01-10 20:38:53 +0100 |
| commit | ec1f5dc317182582ebff843c9e8a4d5277405469 (patch) | |
| tree | 6514de336cc9aa94becb3fbd767285dfa61d0b1b /SocketHttpListener/Ext.cs | |
| parent | 3d867c2c46cec39b669bb8647efef677f32b8a8d (diff) | |
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.
Diffstat (limited to 'SocketHttpListener/Ext.cs')
| -rw-r--r-- | SocketHttpListener/Ext.cs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/SocketHttpListener/Ext.cs b/SocketHttpListener/Ext.cs index 125775180..4404235ba 100644 --- a/SocketHttpListener/Ext.cs +++ b/SocketHttpListener/Ext.cs @@ -149,7 +149,7 @@ namespace SocketHttpListener internal static string CheckIfValidControlData(this byte[] data, string paramName) { return data.Length > 125 - ? String.Format("'{0}' length must be less.", paramName) + ? string.Format("'{0}' length must be less.", paramName) : null; } @@ -222,7 +222,7 @@ namespace SocketHttpListener internal static bool EqualsWith(this int value, char c, Action<int> action) { if (value < 0 || value > 255) - throw new ArgumentOutOfRangeException("value"); + throw new ArgumentOutOfRangeException(nameof(value)); action(value); return value == c - 0; @@ -248,7 +248,7 @@ namespace SocketHttpListener ? "WebSocket server got an internal error." : code == CloseStatusCode.TlsHandshakeFailure ? "An error has occurred while handshaking." - : String.Empty; + : string.Empty; } internal static string GetNameInternal(this string nameAndValue, string separator) @@ -329,7 +329,7 @@ namespace SocketHttpListener { return value.IsToken() ? value - : String.Format("\"{0}\"", value.Replace("\"", "\\\"")); + : string.Format("\"{0}\"", value.Replace("\"", "\\\"")); } internal static byte[] ReadBytes(this Stream stream, int length) @@ -484,13 +484,13 @@ namespace SocketHttpListener this CompressionMethod method, params string[] parameters) { if (method == CompressionMethod.None) - return String.Empty; + return string.Empty; - var m = String.Format("permessage-{0}", method.ToString().ToLower()); + var m = string.Format("permessage-{0}", method.ToString().ToLower()); if (parameters == null || parameters.Length == 0) return m; - return String.Format("{0}; {1}", m, parameters.ToString("; ")); + return string.Format("{0}; {1}", m, parameters.ToString("; ")); } internal static List<TSource> ToList<TSource>(this IEnumerable<TSource> source) @@ -715,7 +715,7 @@ namespace SocketHttpListener case 507: return "Insufficient Storage"; } - return String.Empty; + return string.Empty; } /// <summary> @@ -855,7 +855,7 @@ namespace SocketHttpListener public static byte[] ToHostOrder(this byte[] src, ByteOrder srcOrder) { if (src == null) - throw new ArgumentNullException("src"); + throw new ArgumentNullException(nameof(src)); return src.Length > 1 && !srcOrder.IsHostOrder() ? src.Reverse() @@ -886,14 +886,14 @@ namespace SocketHttpListener public static string ToString<T>(this T[] array, string separator) { if (array == null) - throw new ArgumentNullException("array"); + throw new ArgumentNullException(nameof(array)); var len = array.Length; if (len == 0) - return String.Empty; + return string.Empty; if (separator == null) - separator = String.Empty; + separator = string.Empty; var buff = new StringBuilder(64); (len - 1).Times(i => buff.AppendFormat("{0}{1}", array[i].ToString(), separator)); |
