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 /RSSDP/HttpParserBase.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 'RSSDP/HttpParserBase.cs')
| -rw-r--r-- | RSSDP/HttpParserBase.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/RSSDP/HttpParserBase.cs b/RSSDP/HttpParserBase.cs index e841feab3..000d6db26 100644 --- a/RSSDP/HttpParserBase.cs +++ b/RSSDP/HttpParserBase.cs @@ -42,9 +42,9 @@ namespace Rssdp.Infrastructure [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Honestly, it's fine. MemoryStream doesn't mind.")] protected virtual void Parse(T message, System.Net.Http.Headers.HttpHeaders headers, string data) { - if (data == null) throw new ArgumentNullException("data"); - if (data.Length == 0) throw new ArgumentException("data cannot be an empty string.", "data"); - if (!LineTerminators.Any(data.Contains)) throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", "data"); + if (data == null) throw new ArgumentNullException(nameof(data)); + if (data.Length == 0) throw new ArgumentException("data cannot be an empty string.", nameof(data)); + if (!LineTerminators.Any(data.Contains)) throw new ArgumentException("data is not a valid request, it does not contain any CRLF/LF terminators.", nameof(data)); using (var retVal = new ByteArrayContent(EmptyByteArray)) { @@ -77,10 +77,10 @@ namespace Rssdp.Infrastructure /// <returns>A <see cref="Version"/> object containing the parsed version data.</returns> protected Version ParseHttpVersion(string versionData) { - if (versionData == null) throw new ArgumentNullException("versionData"); + if (versionData == null) throw new ArgumentNullException(nameof(versionData)); var versionSeparatorIndex = versionData.IndexOf('/'); - if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length) throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", "versionData"); + if (versionSeparatorIndex <= 0 || versionSeparatorIndex == versionData.Length) throw new ArgumentException("request header line is invalid. Http Version not supplied or incorrect format.", nameof(versionData)); return Version.Parse(versionData.Substring(versionSeparatorIndex + 1)); } |
