From e8e28c21a173ea0232db4e212647eaee3d67889e Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Thu, 30 Dec 2021 10:44:50 +0100 Subject: [PATCH] Use NuGet "Stef.Validation" (#707) * Use NuGet "Stef.Validation" * nuget * . --- .../WireMock.Net.Console.NET5.csproj | 2 +- .../WireMock.Net.Console.NETCoreApp.csproj | 2 +- .../WireMock.Net.Console.NETCoreApp2.csproj | 2 +- .../WireMock.Net.Console.NETCoreApp3.csproj | 2 +- ...WireMock.Net.Console.Net452.Classic.csproj | 4 +- .../packages.config | 2 +- ...WireMock.Net.Console.Net461.Classic.csproj | 4 +- .../packages.config | 2 +- ...WireMock.Net.Console.Net472.Classic.csproj | 4 +- .../packages.config | 2 +- .../WireMock.Net.Service.csproj | 4 +- examples/WireMock.Net.Service/packages.config | 2 +- .../WireMock.Net.StandAlone.NETCoreApp.csproj | 2 +- .../WireMock.Net.StandAlone.Net452.csproj | 4 +- .../packages.config | 2 +- .../Matchers/CSharpCodeMatcher.cs | 4 +- .../WireMock.Net.OpenApiParser.csproj | 2 +- src/WireMock.Net.StandAlone/StandAloneApp.cs | 8 +- .../Handlers/LocalFileSystemHandler.cs | 34 +++--- .../Http/ByteArrayContentHelper.cs | 4 +- .../Http/HttpRequestMessageHelper.cs | 6 +- src/WireMock.Net/Http/StringContentHelper.cs | 4 +- src/WireMock.Net/Http/WebhookSender.cs | 10 +- src/WireMock.Net/Matchers/ExactMatcher.cs | 4 +- .../Matchers/ExactObjectMatcher.cs | 6 +- src/WireMock.Net/Matchers/JSONPathMatcher.cs | 4 +- src/WireMock.Net/Matchers/JmesPathMatcher.cs | 4 +- src/WireMock.Net/Matchers/JsonMatcher.cs | 4 +- src/WireMock.Net/Matchers/LinqMatcher.cs | 4 +- src/WireMock.Net/Matchers/RegexMatcher.cs | 4 +- .../Request/RequestMessageBodyMatcher.cs | 12 +- .../Request/RequestMessageClientIPMatcher.cs | 6 +- .../Request/RequestMessageCompositeMatcher.cs | 4 +- .../Request/RequestMessageCookieMatcher.cs | 14 +-- .../Request/RequestMessageHeaderMatcher.cs | 14 +-- .../Request/RequestMessageMethodMatcher.cs | 4 +- .../Request/RequestMessageParamMatcher.cs | 6 +- .../Request/RequestMessagePathMatcher.cs | 6 +- .../Request/RequestMessageUrlMatcher.cs | 6 +- .../Matchers/SimMetricsMatcher.cs | 4 +- src/WireMock.Net/Matchers/XPathMatcher.cs | 4 +- src/WireMock.Net/Models/UrlDetails.cs | 6 +- src/WireMock.Net/Owin/AspNetCoreSelfHost.cs | 6 +- .../Owin/GlobalExceptionMiddleware.cs | 10 +- .../Owin/Mappers/OwinResponseMapper.cs | 4 +- src/WireMock.Net/Owin/MappingMatcher.cs | 4 +- src/WireMock.Net/Owin/OwinSelfHost.cs | 6 +- src/WireMock.Net/Owin/WireMockMiddleware.cs | 18 +-- src/WireMock.Net/Proxy/ProxyHelper.cs | 10 +- .../RegularExpressions/RegexExtended.cs | 4 +- .../RequestBuilders/Request.UsingMethods.cs | 4 +- .../RequestBuilders/Request.WithBody.cs | 12 +- .../RequestBuilders/Request.WithCookies.cs | 24 ++-- .../RequestBuilders/Request.WithHeaders.cs | 24 ++-- .../RequestBuilders/Request.WithParam.cs | 10 +- src/WireMock.Net/RequestBuilders/Request.cs | 20 ++-- src/WireMock.Net/RequestMessage.cs | 8 +- .../ResponseBuilders/Response.WithCallback.cs | 10 +- .../ResponseBuilders/Response.WithProxy.cs | 6 +- src/WireMock.Net/ResponseBuilders/Response.cs | 32 ++--- src/WireMock.Net/ResponseMessage.cs | 4 +- .../Serialization/MappingToFileSaver.cs | 4 +- .../Server/RespondWithAProvider.cs | 6 +- .../Server/WireMockServer.Admin.cs | 10 +- .../WireMockServer.ImportWireMockOrg.cs | 4 +- src/WireMock.Net/Server/WireMockServer.cs | 18 +-- .../Settings/WireMockServerSettingsParser.cs | 4 +- .../Scriban/ScribanContextFactory.cs | 6 +- src/WireMock.Net/Util/BodyParser.cs | 4 +- src/WireMock.Net/Util/DictionaryExtensions.cs | 4 +- .../Util/EnhancedFileSystemWatcher.cs | 14 +-- src/WireMock.Net/Util/FileHelper.cs | 6 +- src/WireMock.Net/Util/UrlUtils.cs | 4 +- src/WireMock.Net/Validation/Check.cs | 113 ------------------ src/WireMock.Net/Validation/CoreStrings.cs | 41 ------- .../Validation/ValidatedNotNullAttribute.cs | 4 +- src/WireMock.Net/WireMock.Net.csproj | 2 +- 77 files changed, 267 insertions(+), 421 deletions(-) delete mode 100644 src/WireMock.Net/Validation/Check.cs delete mode 100644 src/WireMock.Net/Validation/CoreStrings.cs diff --git a/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj b/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj index e49a3c86..c29d2ac3 100644 --- a/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj +++ b/examples/WireMock.Net.Console.NET5/WireMock.Net.Console.NET5.csproj @@ -28,7 +28,7 @@ - + diff --git a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj index a3fbb4a4..70439a56 100644 --- a/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp/WireMock.Net.Console.NETCoreApp.csproj @@ -25,7 +25,7 @@ - + diff --git a/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj b/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj index 6ec928e4..901ec8b7 100644 --- a/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp2/WireMock.Net.Console.NETCoreApp2.csproj @@ -37,7 +37,7 @@ - + diff --git a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj index 78e8dd12..1757b09b 100644 --- a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj +++ b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj @@ -34,7 +34,7 @@ - + diff --git a/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj b/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj index 70d40b5b..f7877fdb 100644 --- a/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj +++ b/examples/WireMock.Net.Console.Net452.Classic/WireMock.Net.Console.Net452.Classic.csproj @@ -48,8 +48,8 @@ ..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll - - ..\..\packages\log4net.2.0.12\lib\net45\log4net.dll + + ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll diff --git a/examples/WireMock.Net.Console.Net452.Classic/packages.config b/examples/WireMock.Net.Console.Net452.Classic/packages.config index 5aef79f8..cea3a614 100644 --- a/examples/WireMock.Net.Console.Net452.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net452.Classic/packages.config @@ -4,7 +4,7 @@ - + diff --git a/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj b/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj index 312a39e7..b29e4207 100644 --- a/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj +++ b/examples/WireMock.Net.Console.Net461.Classic/WireMock.Net.Console.Net461.Classic.csproj @@ -47,8 +47,8 @@ ..\..\packages\Handlebars.Net.Helpers.Core.2.1.1-preview-01\lib\net452\HandlebarsDotNet.Helpers.Core.dll - - ..\..\packages\log4net.2.0.12\lib\net45\log4net.dll + + ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll ..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll diff --git a/examples/WireMock.Net.Console.Net461.Classic/packages.config b/examples/WireMock.Net.Console.Net461.Classic/packages.config index eeff0304..4dda0468 100644 --- a/examples/WireMock.Net.Console.Net461.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net461.Classic/packages.config @@ -4,7 +4,7 @@ - + diff --git a/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj b/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj index b6aa7714..32fee8c9 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj +++ b/examples/WireMock.Net.Console.Net472.Classic/WireMock.Net.Console.Net472.Classic.csproj @@ -57,8 +57,8 @@ ..\..\packages\JmesPath.Net.1.0.125\lib\net45\JmesPath.Net.dll - - ..\..\packages\log4net.2.0.12\lib\net45\log4net.dll + + ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll ..\..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll diff --git a/examples/WireMock.Net.Console.Net472.Classic/packages.config b/examples/WireMock.Net.Console.Net472.Classic/packages.config index 027752fe..f325bc7a 100644 --- a/examples/WireMock.Net.Console.Net472.Classic/packages.config +++ b/examples/WireMock.Net.Console.Net472.Classic/packages.config @@ -6,7 +6,7 @@ - + diff --git a/examples/WireMock.Net.Service/WireMock.Net.Service.csproj b/examples/WireMock.Net.Service/WireMock.Net.Service.csproj index 48f876f0..1bcfe937 100644 --- a/examples/WireMock.Net.Service/WireMock.Net.Service.csproj +++ b/examples/WireMock.Net.Service/WireMock.Net.Service.csproj @@ -32,8 +32,8 @@ 4 - - ..\..\packages\log4net.2.0.12\lib\net45\log4net.dll + + ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll ..\..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll diff --git a/examples/WireMock.Net.Service/packages.config b/examples/WireMock.Net.Service/packages.config index d2bc1dfc..0f8af02d 100644 --- a/examples/WireMock.Net.Service/packages.config +++ b/examples/WireMock.Net.Service/packages.config @@ -1,6 +1,6 @@  - + diff --git a/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj b/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj index 8775a91f..14aafc3d 100644 --- a/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj +++ b/examples/WireMock.Net.StandAlone.NETCoreApp/WireMock.Net.StandAlone.NETCoreApp.csproj @@ -7,7 +7,7 @@ - + diff --git a/examples/WireMock.Net.StandAlone.Net452/WireMock.Net.StandAlone.Net452.csproj b/examples/WireMock.Net.StandAlone.Net452/WireMock.Net.StandAlone.Net452.csproj index 790e218c..8467c689 100644 --- a/examples/WireMock.Net.StandAlone.Net452/WireMock.Net.StandAlone.Net452.csproj +++ b/examples/WireMock.Net.StandAlone.Net452/WireMock.Net.StandAlone.Net452.csproj @@ -39,8 +39,8 @@ WireMock.Net.StandAlone.Net452.Program - - ..\..\packages\log4net.2.0.12\lib\net45\log4net.dll + + ..\..\packages\log4net.2.0.13\lib\net45\log4net.dll ..\..\packages\Microsoft.Owin.Host.HttpListener.4.0.0\lib\net451\Microsoft.Owin.Host.HttpListener.dll diff --git a/examples/WireMock.Net.StandAlone.Net452/packages.config b/examples/WireMock.Net.StandAlone.Net452/packages.config index da1f375a..15fbcb6c 100644 --- a/examples/WireMock.Net.StandAlone.Net452/packages.config +++ b/examples/WireMock.Net.StandAlone.Net452/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs index a92f3771..5fd1c600 100644 --- a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs +++ b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json.Linq; using WireMock.Exceptions; using WireMock.Extensions; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -53,7 +53,7 @@ namespace WireMock.Matchers /// The patterns. public CSharpCodeMatcher(MatchBehaviour matchBehaviour, [NotNull] params AnyOf[] patterns) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); MatchBehaviour = matchBehaviour; ThrowException = false; diff --git a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj index 46560c31..c9452908 100644 --- a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj +++ b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/WireMock.Net.StandAlone/StandAloneApp.cs b/src/WireMock.Net.StandAlone/StandAloneApp.cs index f86f4943..73a5b4d6 100644 --- a/src/WireMock.Net.StandAlone/StandAloneApp.cs +++ b/src/WireMock.Net.StandAlone/StandAloneApp.cs @@ -4,7 +4,7 @@ using JetBrains.Annotations; using WireMock.Logging; using WireMock.Server; using WireMock.Settings; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Net.StandAlone { @@ -22,7 +22,7 @@ namespace WireMock.Net.StandAlone [PublicAPI] public static WireMockServer Start([NotNull] IWireMockServerSettings settings) { - Check.NotNull(settings, nameof(settings)); + Guard.NotNull(settings, nameof(settings)); var server = WireMockServer.Start(settings); @@ -40,7 +40,7 @@ namespace WireMock.Net.StandAlone [PublicAPI] public static WireMockServer Start([NotNull] string[] args, [CanBeNull] IWireMockLogger logger = null) { - Check.NotNull(args, nameof(args)); + Guard.NotNull(args, nameof(args)); if (WireMockServerSettingsParser.TryParseArguments(args, out var settings, logger)) { @@ -62,7 +62,7 @@ namespace WireMock.Net.StandAlone [PublicAPI] public static bool TryStart([NotNull] string[] args, out WireMockServer server, [CanBeNull] IWireMockLogger logger = null) { - Check.NotNull(args, nameof(args)); + Guard.NotNull(args, nameof(args)); if (WireMockServerSettingsParser.TryParseArguments(args, out var settings, logger)) { diff --git a/src/WireMock.Net/Handlers/LocalFileSystemHandler.cs b/src/WireMock.Net/Handlers/LocalFileSystemHandler.cs index 1ce7ef3c..e96b4779 100644 --- a/src/WireMock.Net/Handlers/LocalFileSystemHandler.cs +++ b/src/WireMock.Net/Handlers/LocalFileSystemHandler.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Handlers { @@ -34,7 +34,7 @@ namespace WireMock.Handlers /// public virtual bool FolderExists(string path) { - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path, nameof(path)); return Directory.Exists(path); } @@ -42,7 +42,7 @@ namespace WireMock.Handlers /// public virtual void CreateFolder(string path) { - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path, nameof(path)); Directory.CreateDirectory(path); } @@ -50,7 +50,7 @@ namespace WireMock.Handlers /// public virtual IEnumerable EnumerateFiles(string path, bool includeSubdirectories) { - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path, nameof(path)); return includeSubdirectories ? Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) : Directory.EnumerateFiles(path); } @@ -64,7 +64,7 @@ namespace WireMock.Handlers /// public virtual string ReadMappingFile(string path) { - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path, nameof(path)); return File.ReadAllText(path); } @@ -72,8 +72,8 @@ namespace WireMock.Handlers /// public virtual void WriteMappingFile(string path, string text) { - Check.NotNullOrEmpty(path, nameof(path)); - Check.NotNull(text, nameof(text)); + Guard.NotNullOrEmpty(path, nameof(path)); + Guard.NotNull(text, nameof(text)); File.WriteAllText(path, text); } @@ -81,7 +81,7 @@ namespace WireMock.Handlers /// public virtual byte[] ReadResponseBodyAsFile(string path) { - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path, nameof(path)); path = PathUtils.CleanPath(path); // If the file exists at the given path relative to the MappingsFolder, then return that. // Else the path will just be as-is. @@ -91,7 +91,7 @@ namespace WireMock.Handlers /// public virtual string ReadResponseBodyAsString(string path) { - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(path, nameof(path)); path = PathUtils.CleanPath(path); // In case the path is a filename, the path will be adjusted to the MappingFolder. // Else the path will just be as-is. @@ -101,7 +101,7 @@ namespace WireMock.Handlers /// public virtual bool FileExists(string filename) { - Check.NotNullOrEmpty(filename, nameof(filename)); + Guard.NotNullOrEmpty(filename, nameof(filename)); return File.Exists(AdjustPathForMappingFolder(filename)); } @@ -109,8 +109,8 @@ namespace WireMock.Handlers /// public virtual void WriteFile(string filename, byte[] bytes) { - Check.NotNullOrEmpty(filename, nameof(filename)); - Check.NotNull(bytes, nameof(bytes)); + Guard.NotNullOrEmpty(filename, nameof(filename)); + Guard.NotNull(bytes, nameof(bytes)); File.WriteAllBytes(AdjustPathForMappingFolder(filename), bytes); } @@ -118,7 +118,7 @@ namespace WireMock.Handlers /// public virtual void DeleteFile(string filename) { - Check.NotNullOrEmpty(filename, nameof(filename)); + Guard.NotNullOrEmpty(filename, nameof(filename)); File.Delete(AdjustPathForMappingFolder(filename)); } @@ -126,7 +126,7 @@ namespace WireMock.Handlers /// public virtual byte[] ReadFile(string filename) { - Check.NotNullOrEmpty(filename, nameof(filename)); + Guard.NotNullOrEmpty(filename, nameof(filename)); return File.ReadAllBytes(AdjustPathForMappingFolder(filename)); } @@ -134,7 +134,7 @@ namespace WireMock.Handlers /// public virtual string ReadFileAsString(string filename) { - return File.ReadAllText(AdjustPathForMappingFolder(Check.NotNullOrEmpty(filename, nameof(filename)))); + return File.ReadAllText(AdjustPathForMappingFolder(Guard.NotNullOrEmpty(filename, nameof(filename)))); } /// @@ -146,8 +146,8 @@ namespace WireMock.Handlers /// public virtual void WriteUnmatchedRequest(string filename, string text) { - Check.NotNullOrEmpty(filename, nameof(filename)); - Check.NotNull(text, nameof(text)); + Guard.NotNullOrEmpty(filename, nameof(filename)); + Guard.NotNull(text, nameof(text)); var folder = GetUnmatchedRequestsFolder(); if (!FolderExists(folder)) diff --git a/src/WireMock.Net/Http/ByteArrayContentHelper.cs b/src/WireMock.Net/Http/ByteArrayContentHelper.cs index 44d15bde..14dcc5ec 100644 --- a/src/WireMock.Net/Http/ByteArrayContentHelper.cs +++ b/src/WireMock.Net/Http/ByteArrayContentHelper.cs @@ -1,7 +1,7 @@ using System.Net.Http; using System.Net.Http.Headers; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Http { @@ -15,7 +15,7 @@ namespace WireMock.Http /// ByteArrayContent internal static ByteArrayContent Create([NotNull] byte[] content, [CanBeNull] MediaTypeHeaderValue contentType) { - Check.NotNull(content, nameof(content)); + Guard.NotNull(content, nameof(content)); var byteContent = new ByteArrayContent(content); if (contentType != null) diff --git a/src/WireMock.Net/Http/HttpRequestMessageHelper.cs b/src/WireMock.Net/Http/HttpRequestMessageHelper.cs index b437e6da..6404002b 100644 --- a/src/WireMock.Net/Http/HttpRequestMessageHelper.cs +++ b/src/WireMock.Net/Http/HttpRequestMessageHelper.cs @@ -6,7 +6,7 @@ using System.Net.Http.Headers; using JetBrains.Annotations; using Newtonsoft.Json; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Http { @@ -14,8 +14,8 @@ namespace WireMock.Http { internal static HttpRequestMessage Create([NotNull] RequestMessage requestMessage, [NotNull] string url) { - Check.NotNull(requestMessage, nameof(requestMessage)); - Check.NotNullOrEmpty(url, nameof(url)); + Guard.NotNull(requestMessage, nameof(requestMessage)); + Guard.NotNullOrEmpty(url, nameof(url)); var httpRequestMessage = new HttpRequestMessage(new HttpMethod(requestMessage.Method), url); diff --git a/src/WireMock.Net/Http/StringContentHelper.cs b/src/WireMock.Net/Http/StringContentHelper.cs index f71b55e4..671ca593 100644 --- a/src/WireMock.Net/Http/StringContentHelper.cs +++ b/src/WireMock.Net/Http/StringContentHelper.cs @@ -1,7 +1,7 @@ using System.Net.Http; using System.Net.Http.Headers; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Http { @@ -15,7 +15,7 @@ namespace WireMock.Http /// StringContent internal static StringContent Create([NotNull] string content, [CanBeNull] MediaTypeHeaderValue contentType) { - Check.NotNull(content, nameof(content)); + Guard.NotNull(content, nameof(content)); var stringContent = new StringContent(content); stringContent.Headers.ContentType = contentType; diff --git a/src/WireMock.Net/Http/WebhookSender.cs b/src/WireMock.Net/Http/WebhookSender.cs index bcd06598..fc827bf4 100644 --- a/src/WireMock.Net/Http/WebhookSender.cs +++ b/src/WireMock.Net/Http/WebhookSender.cs @@ -11,7 +11,7 @@ using WireMock.Transformers.Handlebars; using WireMock.Transformers.Scriban; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Http { @@ -28,10 +28,10 @@ namespace WireMock.Http public Task SendAsync([NotNull] HttpClient client, [NotNull] IWebhookRequest request, [NotNull] RequestMessage originalRequestMessage, [NotNull] ResponseMessage originalResponseMessage) { - Check.NotNull(client, nameof(client)); - Check.NotNull(request, nameof(request)); - Check.NotNull(originalRequestMessage, nameof(originalRequestMessage)); - Check.NotNull(originalResponseMessage, nameof(originalResponseMessage)); + Guard.NotNull(client, nameof(client)); + Guard.NotNull(request, nameof(request)); + Guard.NotNull(originalRequestMessage, nameof(originalRequestMessage)); + Guard.NotNull(originalResponseMessage, nameof(originalResponseMessage)); IBodyData bodyData; IDictionary> headers; diff --git a/src/WireMock.Net/Matchers/ExactMatcher.cs b/src/WireMock.Net/Matchers/ExactMatcher.cs index 4568544e..e9f301e7 100644 --- a/src/WireMock.Net/Matchers/ExactMatcher.cs +++ b/src/WireMock.Net/Matchers/ExactMatcher.cs @@ -3,7 +3,7 @@ using AnyOfTypes; using JetBrains.Annotations; using WireMock.Extensions; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -37,7 +37,7 @@ namespace WireMock.Matchers /// The values. public ExactMatcher(MatchBehaviour matchBehaviour, bool throwException = false, [NotNull] params AnyOf[] values) { - Check.NotNull(values, nameof(values)); + Guard.NotNull(values, nameof(values)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Matchers/ExactObjectMatcher.cs b/src/WireMock.Net/Matchers/ExactObjectMatcher.cs index ce8af29f..fe116668 100644 --- a/src/WireMock.Net/Matchers/ExactObjectMatcher.cs +++ b/src/WireMock.Net/Matchers/ExactObjectMatcher.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; using System.Linq; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -41,7 +41,7 @@ namespace WireMock.Matchers /// The value. public ExactObjectMatcher(MatchBehaviour matchBehaviour, [NotNull] object value) { - Check.NotNull(value, nameof(value)); + Guard.NotNull(value, nameof(value)); ValueAsObject = value; MatchBehaviour = matchBehaviour; @@ -63,7 +63,7 @@ namespace WireMock.Matchers /// The value. public ExactObjectMatcher(MatchBehaviour matchBehaviour, [NotNull] byte[] value, bool throwException = false) { - Check.NotNull(value, nameof(value)); + Guard.NotNull(value, nameof(value)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Matchers/JSONPathMatcher.cs b/src/WireMock.Net/Matchers/JSONPathMatcher.cs index 4f95d5b9..ba951d52 100644 --- a/src/WireMock.Net/Matchers/JSONPathMatcher.cs +++ b/src/WireMock.Net/Matchers/JSONPathMatcher.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using WireMock.Extensions; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -48,7 +48,7 @@ namespace WireMock.Matchers /// The patterns. public JsonPathMatcher(MatchBehaviour matchBehaviour, bool throwException = false, [NotNull] params AnyOf[] patterns) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Matchers/JmesPathMatcher.cs b/src/WireMock.Net/Matchers/JmesPathMatcher.cs index 368d42b4..41e8117a 100644 --- a/src/WireMock.Net/Matchers/JmesPathMatcher.cs +++ b/src/WireMock.Net/Matchers/JmesPathMatcher.cs @@ -5,7 +5,7 @@ using Newtonsoft.Json; using System.Linq; using WireMock.Extensions; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -55,7 +55,7 @@ namespace WireMock.Matchers /// The patterns. public JmesPathMatcher(MatchBehaviour matchBehaviour, bool throwException = false, [NotNull] params AnyOf[] patterns) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Matchers/JsonMatcher.cs b/src/WireMock.Net/Matchers/JsonMatcher.cs index e37d7fbc..e3d6eed9 100644 --- a/src/WireMock.Net/Matchers/JsonMatcher.cs +++ b/src/WireMock.Net/Matchers/JsonMatcher.cs @@ -5,7 +5,7 @@ using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -61,7 +61,7 @@ namespace WireMock.Matchers /// Throw an exception when the internal matching fails because of invalid input. public JsonMatcher(MatchBehaviour matchBehaviour, [NotNull] object value, bool ignoreCase = false, bool throwException = false) { - Check.NotNull(value, nameof(value)); + Guard.NotNull(value, nameof(value)); MatchBehaviour = matchBehaviour; IgnoreCase = ignoreCase; diff --git a/src/WireMock.Net/Matchers/LinqMatcher.cs b/src/WireMock.Net/Matchers/LinqMatcher.cs index 19efe9ae..76330fab 100644 --- a/src/WireMock.Net/Matchers/LinqMatcher.cs +++ b/src/WireMock.Net/Matchers/LinqMatcher.cs @@ -6,7 +6,7 @@ using Newtonsoft.Json.Linq; using WireMock.Extensions; using WireMock.Models; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -57,7 +57,7 @@ namespace WireMock.Matchers /// Throw an exception when the internal matching fails because of invalid input. public LinqMatcher(MatchBehaviour matchBehaviour, bool throwException = false, [NotNull] params AnyOf[] patterns) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Matchers/RegexMatcher.cs b/src/WireMock.Net/Matchers/RegexMatcher.cs index 8ee94cae..f85fd582 100644 --- a/src/WireMock.Net/Matchers/RegexMatcher.cs +++ b/src/WireMock.Net/Matchers/RegexMatcher.cs @@ -6,7 +6,7 @@ using JetBrains.Annotations; using WireMock.Extensions; using WireMock.Models; using WireMock.RegularExpressions; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -61,7 +61,7 @@ namespace WireMock.Matchers /// Use RegexExtended (default = true). public RegexMatcher(MatchBehaviour matchBehaviour, [NotNull, RegexPattern] AnyOf[] patterns, bool ignoreCase = false, bool throwException = false, bool useRegexExtended = true) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); _patterns = patterns; IgnoreCase = ignoreCase; diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageBodyMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageBodyMatcher.cs index 89df34ff..36d3a3da 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageBodyMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageBodyMatcher.cs @@ -3,7 +3,7 @@ using System; using System.Linq; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -70,7 +70,7 @@ namespace WireMock.Matchers.Request /// The function. public RequestMessageBodyMatcher([NotNull] Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); Func = func; } @@ -80,7 +80,7 @@ namespace WireMock.Matchers.Request /// The function. public RequestMessageBodyMatcher([NotNull] Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); DataFunc = func; } @@ -90,7 +90,7 @@ namespace WireMock.Matchers.Request /// The function. public RequestMessageBodyMatcher([NotNull] Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); JsonFunc = func; } @@ -100,7 +100,7 @@ namespace WireMock.Matchers.Request /// The function. public RequestMessageBodyMatcher([NotNull] Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); BodyDataFunc = func; } @@ -110,7 +110,7 @@ namespace WireMock.Matchers.Request /// The matchers. public RequestMessageBodyMatcher([NotNull] params IMatcher[] matchers) { - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(matchers, nameof(matchers)); Matchers = matchers; } diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageClientIPMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageClientIPMatcher.cs index 78f7d678..52096ac9 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageClientIPMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageClientIPMatcher.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -36,7 +36,7 @@ namespace WireMock.Matchers.Request /// The matchers. public RequestMessageClientIPMatcher([NotNull] params IStringMatcher[] matchers) { - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(matchers, nameof(matchers)); Matchers = matchers; } @@ -46,7 +46,7 @@ namespace WireMock.Matchers.Request /// The clientIP functions. public RequestMessageClientIPMatcher([NotNull] params Func[] funcs) { - Check.NotNull(funcs, nameof(funcs)); + Guard.NotNull(funcs, nameof(funcs)); Funcs = funcs; } diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageCompositeMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageCompositeMatcher.cs index f2d456c3..c831c88f 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageCompositeMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageCompositeMatcher.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -27,7 +27,7 @@ namespace WireMock.Matchers.Request /// The CompositeMatcherType type (Defaults to 'And') protected RequestMessageCompositeMatcher([NotNull] IEnumerable requestMatchers, CompositeMatcherType type = CompositeMatcherType.And) { - Check.NotNull(requestMatchers, nameof(requestMatchers)); + Guard.NotNull(requestMatchers, nameof(requestMatchers)); _type = type; RequestMatchers = requestMatchers; diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageCookieMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageCookieMatcher.cs index 44b57745..d9cb5c52 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageCookieMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageCookieMatcher.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -39,8 +39,8 @@ namespace WireMock.Matchers.Request /// The match behaviour. public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase) { - Check.NotNull(name, nameof(name)); - Check.NotNull(pattern, nameof(pattern)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(pattern, nameof(pattern)); _matchBehaviour = matchBehaviour; _ignoreCase = ignoreCase; @@ -58,7 +58,7 @@ namespace WireMock.Matchers.Request public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params string[] patterns) : this(matchBehaviour, name, ignoreCase, patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast().ToArray()) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); } /// @@ -70,8 +70,8 @@ namespace WireMock.Matchers.Request /// Ignore the case from the pattern. public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(matchers, nameof(matchers)); _matchBehaviour = matchBehaviour; Name = name; @@ -85,7 +85,7 @@ namespace WireMock.Matchers.Request /// The funcs. public RequestMessageCookieMatcher([NotNull] params Func, bool>[] funcs) { - Check.NotNull(funcs, nameof(funcs)); + Guard.NotNull(funcs, nameof(funcs)); Funcs = funcs; } diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageHeaderMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageHeaderMatcher.cs index 2b920e48..a66fd1a1 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageHeaderMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageHeaderMatcher.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -40,8 +40,8 @@ namespace WireMock.Matchers.Request /// The match behaviour. public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase) { - Check.NotNull(name, nameof(name)); - Check.NotNull(pattern, nameof(pattern)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(pattern, nameof(pattern)); _matchBehaviour = matchBehaviour; _ignoreCase = ignoreCase; @@ -59,7 +59,7 @@ namespace WireMock.Matchers.Request public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params string[] patterns) : this(matchBehaviour, name, ignoreCase, patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast().ToArray()) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); } /// @@ -71,8 +71,8 @@ namespace WireMock.Matchers.Request /// Ignore the case from the pattern. public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(matchers, nameof(matchers)); _matchBehaviour = matchBehaviour; Name = name; @@ -86,7 +86,7 @@ namespace WireMock.Matchers.Request /// The funcs. public RequestMessageHeaderMatcher([NotNull] params Func, bool>[] funcs) { - Check.NotNull(funcs, nameof(funcs)); + Guard.NotNull(funcs, nameof(funcs)); Funcs = funcs; } diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageMethodMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageMethodMatcher.cs index d62587e3..73c49cd8 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageMethodMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageMethodMatcher.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -24,7 +24,7 @@ namespace WireMock.Matchers.Request /// The methods. public RequestMessageMethodMatcher(MatchBehaviour matchBehaviour, [NotNull] params string[] methods) { - Check.NotNull(methods, nameof(methods)); + Guard.NotNull(methods, nameof(methods)); _matchBehaviour = matchBehaviour; Methods = methods; diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageParamMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageParamMatcher.cs index 808d9001..65055d2e 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageParamMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageParamMatcher.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -64,7 +64,7 @@ namespace WireMock.Matchers.Request /// The matchers. public RequestMessageParamMatcher(MatchBehaviour matchBehaviour, [NotNull] string key, bool ignoreCase, [CanBeNull] IStringMatcher[] matchers) { - Check.NotNull(key, nameof(key)); + Guard.NotNull(key, nameof(key)); _matchBehaviour = matchBehaviour; Key = key; @@ -78,7 +78,7 @@ namespace WireMock.Matchers.Request /// The funcs. public RequestMessageParamMatcher([NotNull] params Func>, bool>[] funcs) { - Check.NotNull(funcs, nameof(funcs)); + Guard.NotNull(funcs, nameof(funcs)); Funcs = funcs; } diff --git a/src/WireMock.Net/Matchers/Request/RequestMessagePathMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessagePathMatcher.cs index c1106614..63edf8b5 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessagePathMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessagePathMatcher.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -36,7 +36,7 @@ namespace WireMock.Matchers.Request /// The matchers. public RequestMessagePathMatcher([NotNull] params IStringMatcher[] matchers) { - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(matchers, nameof(matchers)); Matchers = matchers; } @@ -47,7 +47,7 @@ namespace WireMock.Matchers.Request /// The path functions. public RequestMessagePathMatcher([NotNull] params Func[] funcs) { - Check.NotNull(funcs, nameof(funcs)); + Guard.NotNull(funcs, nameof(funcs)); Funcs = funcs; } diff --git a/src/WireMock.Net/Matchers/Request/RequestMessageUrlMatcher.cs b/src/WireMock.Net/Matchers/Request/RequestMessageUrlMatcher.cs index f437fbd2..092016a8 100644 --- a/src/WireMock.Net/Matchers/Request/RequestMessageUrlMatcher.cs +++ b/src/WireMock.Net/Matchers/Request/RequestMessageUrlMatcher.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers.Request { @@ -36,7 +36,7 @@ namespace WireMock.Matchers.Request /// The matchers. public RequestMessageUrlMatcher([NotNull] params IStringMatcher[] matchers) { - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(matchers, nameof(matchers)); Matchers = matchers; } @@ -46,7 +46,7 @@ namespace WireMock.Matchers.Request /// The url functions. public RequestMessageUrlMatcher([NotNull] params Func[] funcs) { - Check.NotNull(funcs, nameof(funcs)); + Guard.NotNull(funcs, nameof(funcs)); Funcs = funcs; } diff --git a/src/WireMock.Net/Matchers/SimMetricsMatcher.cs b/src/WireMock.Net/Matchers/SimMetricsMatcher.cs index c67d1563..94e30581 100644 --- a/src/WireMock.Net/Matchers/SimMetricsMatcher.cs +++ b/src/WireMock.Net/Matchers/SimMetricsMatcher.cs @@ -6,7 +6,7 @@ using SimMetrics.Net.API; using SimMetrics.Net.Metric; using WireMock.Extensions; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Matchers { @@ -71,7 +71,7 @@ namespace WireMock.Matchers /// Throw an exception when the internal matching fails because of invalid input. public SimMetricsMatcher(MatchBehaviour matchBehaviour, [NotNull] AnyOf[] patterns, SimMetricType simMetricType = SimMetricType.Levenstein, bool throwException = false) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Matchers/XPathMatcher.cs b/src/WireMock.Net/Matchers/XPathMatcher.cs index 3bfa7352..ab0c6e86 100644 --- a/src/WireMock.Net/Matchers/XPathMatcher.cs +++ b/src/WireMock.Net/Matchers/XPathMatcher.cs @@ -5,7 +5,7 @@ using AnyOfTypes; using JetBrains.Annotations; using WireMock.Extensions; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; #if !NETSTANDARD1_3 using Wmhelp.XPath2; #endif @@ -42,7 +42,7 @@ namespace WireMock.Matchers /// The patterns. public XPathMatcher(MatchBehaviour matchBehaviour, bool throwException = false, [NotNull] params AnyOf[] patterns) { - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(patterns, nameof(patterns)); MatchBehaviour = matchBehaviour; ThrowException = throwException; diff --git a/src/WireMock.Net/Models/UrlDetails.cs b/src/WireMock.Net/Models/UrlDetails.cs index c23f78ed..9459a0c1 100644 --- a/src/WireMock.Net/Models/UrlDetails.cs +++ b/src/WireMock.Net/Models/UrlDetails.cs @@ -1,5 +1,5 @@ using System; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Models { @@ -41,8 +41,8 @@ namespace WireMock.Models /// The URL (relative). public UrlDetails(Uri absoluteUrl, Uri url) { - Check.NotNull(absoluteUrl, nameof(absoluteUrl)); - Check.NotNull(url, nameof(url)); + Guard.NotNull(absoluteUrl, nameof(absoluteUrl)); + Guard.NotNull(url, nameof(url)); AbsoluteUrl = absoluteUrl; Url = url; diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs index 47bd28bd..3d29486f 100644 --- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs +++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs @@ -11,7 +11,7 @@ using Microsoft.Extensions.DependencyInjection; using WireMock.Logging; using WireMock.Owin.Mappers; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Owin { @@ -35,8 +35,8 @@ namespace WireMock.Owin public AspNetCoreSelfHost([NotNull] IWireMockMiddlewareOptions wireMockMiddlewareOptions, [NotNull] HostUrlOptions urlOptions) { - Check.NotNull(wireMockMiddlewareOptions, nameof(wireMockMiddlewareOptions)); - Check.NotNull(urlOptions, nameof(urlOptions)); + Guard.NotNull(wireMockMiddlewareOptions, nameof(wireMockMiddlewareOptions)); + Guard.NotNull(urlOptions, nameof(urlOptions)); _logger = wireMockMiddlewareOptions.Logger ?? new WireMockConsoleLogger(); diff --git a/src/WireMock.Net/Owin/GlobalExceptionMiddleware.cs b/src/WireMock.Net/Owin/GlobalExceptionMiddleware.cs index 0f43e878..51f99acf 100644 --- a/src/WireMock.Net/Owin/GlobalExceptionMiddleware.cs +++ b/src/WireMock.Net/Owin/GlobalExceptionMiddleware.cs @@ -12,7 +12,7 @@ using IContext = Microsoft.AspNetCore.Http.HttpContext; using Next = Microsoft.AspNetCore.Http.RequestDelegate; #endif using WireMock.Owin.Mappers; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Owin { @@ -24,8 +24,8 @@ namespace WireMock.Owin #if !USE_ASPNETCORE public GlobalExceptionMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinResponseMapper responseMapper) : base(next) { - Check.NotNull(options, nameof(options)); - Check.NotNull(responseMapper, nameof(responseMapper)); + Guard.NotNull(options, nameof(options)); + Guard.NotNull(responseMapper, nameof(responseMapper)); _options = options; _responseMapper = responseMapper; @@ -33,8 +33,8 @@ namespace WireMock.Owin #else public GlobalExceptionMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinResponseMapper responseMapper) { - Check.NotNull(options, nameof(options)); - Check.NotNull(responseMapper, nameof(responseMapper)); + Guard.NotNull(options, nameof(options)); + Guard.NotNull(responseMapper, nameof(responseMapper)); Next = next; _options = options; diff --git a/src/WireMock.Net/Owin/Mappers/OwinResponseMapper.cs b/src/WireMock.Net/Owin/Mappers/OwinResponseMapper.cs index f5d4f82a..efcfee1a 100644 --- a/src/WireMock.Net/Owin/Mappers/OwinResponseMapper.cs +++ b/src/WireMock.Net/Owin/Mappers/OwinResponseMapper.cs @@ -12,7 +12,7 @@ using RandomDataGenerator.Randomizers; using WireMock.Http; using WireMock.ResponseBuilders; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; #if !USE_ASPNETCORE using IResponse = Microsoft.Owin.IOwinResponse; #else @@ -47,7 +47,7 @@ namespace WireMock.Owin.Mappers /// The IWireMockMiddlewareOptions. public OwinResponseMapper(IWireMockMiddlewareOptions options) { - Check.NotNull(options, nameof(options)); + Guard.NotNull(options, nameof(options)); _options = options; } diff --git a/src/WireMock.Net/Owin/MappingMatcher.cs b/src/WireMock.Net/Owin/MappingMatcher.cs index ae156966..303a8348 100644 --- a/src/WireMock.Net/Owin/MappingMatcher.cs +++ b/src/WireMock.Net/Owin/MappingMatcher.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using WireMock.Extensions; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Owin { @@ -12,7 +12,7 @@ namespace WireMock.Owin public MappingMatcher(IWireMockMiddlewareOptions options) { - Check.NotNull(options, nameof(options)); + Guard.NotNull(options, nameof(options)); _options = options; } diff --git a/src/WireMock.Net/Owin/OwinSelfHost.cs b/src/WireMock.Net/Owin/OwinSelfHost.cs index 779f28b3..2d8df431 100644 --- a/src/WireMock.Net/Owin/OwinSelfHost.cs +++ b/src/WireMock.Net/Owin/OwinSelfHost.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using WireMock.Logging; using WireMock.Owin.Mappers; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Owin { @@ -22,8 +22,8 @@ namespace WireMock.Owin public OwinSelfHost([NotNull] IWireMockMiddlewareOptions options, [NotNull] HostUrlOptions urlOptions) { - Check.NotNull(options, nameof(options)); - Check.NotNull(urlOptions, nameof(urlOptions)); + Guard.NotNull(options, nameof(options)); + Guard.NotNull(urlOptions, nameof(urlOptions)); _options = options; _logger = options.Logger ?? new WireMockConsoleLogger(); diff --git a/src/WireMock.Net/Owin/WireMockMiddleware.cs b/src/WireMock.Net/Owin/WireMockMiddleware.cs index 4127abd0..ca8f3a57 100644 --- a/src/WireMock.Net/Owin/WireMockMiddleware.cs +++ b/src/WireMock.Net/Owin/WireMockMiddleware.cs @@ -7,7 +7,7 @@ using WireMock.Http; using WireMock.Owin.Mappers; using WireMock.Serialization; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; using WireMock.ResponseBuilders; using WireMock.Settings; #if !USE_ASPNETCORE @@ -35,18 +35,18 @@ namespace WireMock.Owin #if !USE_ASPNETCORE public WireMockMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinRequestMapper requestMapper, IOwinResponseMapper responseMapper, IMappingMatcher mappingMatcher) : base(next) { - _options = Check.NotNull(options, nameof(options)); - _requestMapper = Check.NotNull(requestMapper, nameof(requestMapper)); - _responseMapper = Check.NotNull(responseMapper, nameof(responseMapper)); - _mappingMatcher = Check.NotNull(mappingMatcher, nameof(mappingMatcher)); + _options = Guard.NotNull(options, nameof(options)); + _requestMapper = Guard.NotNull(requestMapper, nameof(requestMapper)); + _responseMapper = Guard.NotNull(responseMapper, nameof(responseMapper)); + _mappingMatcher = Guard.NotNull(mappingMatcher, nameof(mappingMatcher)); } #else public WireMockMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinRequestMapper requestMapper, IOwinResponseMapper responseMapper, IMappingMatcher mappingMatcher) { - _options = Check.NotNull(options, nameof(options)); - _requestMapper = Check.NotNull(requestMapper, nameof(requestMapper)); - _responseMapper = Check.NotNull(responseMapper, nameof(responseMapper)); - _mappingMatcher = Check.NotNull(mappingMatcher, nameof(mappingMatcher)); + _options = Guard.NotNull(options, nameof(options)); + _requestMapper = Guard.NotNull(requestMapper, nameof(requestMapper)); + _responseMapper = Guard.NotNull(responseMapper, nameof(responseMapper)); + _mappingMatcher = Guard.NotNull(mappingMatcher, nameof(mappingMatcher)); } #endif diff --git a/src/WireMock.Net/Proxy/ProxyHelper.cs b/src/WireMock.Net/Proxy/ProxyHelper.cs index f872ce39..5da5874f 100644 --- a/src/WireMock.Net/Proxy/ProxyHelper.cs +++ b/src/WireMock.Net/Proxy/ProxyHelper.cs @@ -11,7 +11,7 @@ using WireMock.ResponseBuilders; using WireMock.Settings; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Proxy { @@ -21,7 +21,7 @@ namespace WireMock.Proxy public ProxyHelper([NotNull] IWireMockServerSettings settings) { - _settings = Check.NotNull(settings, nameof(settings)); + _settings = Guard.NotNull(settings, nameof(settings)); } public async Task<(ResponseMessage Message, IMapping Mapping)> SendAsync( @@ -30,9 +30,9 @@ namespace WireMock.Proxy [NotNull] RequestMessage requestMessage, [NotNull] string url) { - Check.NotNull(client, nameof(client)); - Check.NotNull(requestMessage, nameof(requestMessage)); - Check.NotNull(url, nameof(url)); + Guard.NotNull(client, nameof(client)); + Guard.NotNull(requestMessage, nameof(requestMessage)); + Guard.NotNull(url, nameof(url)); var originalUri = new Uri(requestMessage.Url); var requiredUri = new Uri(url); diff --git a/src/WireMock.Net/RegularExpressions/RegexExtended.cs b/src/WireMock.Net/RegularExpressions/RegexExtended.cs index 505d9bbb..01d55054 100644 --- a/src/WireMock.Net/RegularExpressions/RegexExtended.cs +++ b/src/WireMock.Net/RegularExpressions/RegexExtended.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Text.RegularExpressions; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RegularExpressions { @@ -77,7 +77,7 @@ namespace WireMock.RegularExpressions /// Pattern to replace token for. private static string ReplaceGuidPattern(string pattern) { - Check.NotNull(pattern, nameof(pattern)); + Guard.NotNull(pattern, nameof(pattern)); foreach (var tokenPattern in GuidTokenPatterns) { diff --git a/src/WireMock.Net/RequestBuilders/Request.UsingMethods.cs b/src/WireMock.Net/RequestBuilders/Request.UsingMethods.cs index 393e7e92..b2039624 100644 --- a/src/WireMock.Net/RequestBuilders/Request.UsingMethods.cs +++ b/src/WireMock.Net/RequestBuilders/Request.UsingMethods.cs @@ -4,7 +4,7 @@ using System.Linq; using WireMock.Http; using WireMock.Matchers; using WireMock.Matchers.Request; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RequestBuilders { @@ -106,7 +106,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder UsingMethod(MatchBehaviour matchBehaviour, params string[] methods) { - Check.NotNullOrEmpty(methods, nameof(methods)); + Guard.NotNullOrEmpty(methods, nameof(methods)); _requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, methods)); return this; diff --git a/src/WireMock.Net/RequestBuilders/Request.WithBody.cs b/src/WireMock.Net/RequestBuilders/Request.WithBody.cs index a1f60b5f..a11c7bab 100644 --- a/src/WireMock.Net/RequestBuilders/Request.WithBody.cs +++ b/src/WireMock.Net/RequestBuilders/Request.WithBody.cs @@ -4,7 +4,7 @@ using System; using WireMock.Matchers; using WireMock.Matchers.Request; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RequestBuilders { @@ -40,7 +40,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithBody(IMatcher[] matchers) { - Check.NotNull(matchers, nameof(matchers)); + Guard.NotNull(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageBodyMatcher(matchers)); return this; @@ -49,7 +49,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithBody(Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); _requestMatchers.Add(new RequestMessageBodyMatcher(func)); return this; @@ -58,7 +58,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithBody(Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); _requestMatchers.Add(new RequestMessageBodyMatcher(func)); return this; @@ -67,7 +67,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithBody(Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); _requestMatchers.Add(new RequestMessageBodyMatcher(func)); return this; @@ -76,7 +76,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithBody(Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); _requestMatchers.Add(new RequestMessageBodyMatcher(func)); return this; diff --git a/src/WireMock.Net/RequestBuilders/Request.WithCookies.cs b/src/WireMock.Net/RequestBuilders/Request.WithCookies.cs index 870b6e59..215b9887 100644 --- a/src/WireMock.Net/RequestBuilders/Request.WithCookies.cs +++ b/src/WireMock.Net/RequestBuilders/Request.WithCookies.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using WireMock.Matchers; using WireMock.Matchers.Request; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RequestBuilders { @@ -17,8 +17,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) { - Check.NotNull(name, nameof(name)); - Check.NotNull(pattern, nameof(pattern)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(pattern, nameof(pattern)); _requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase)); return this; @@ -33,8 +33,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithCookie(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) { - Check.NotNull(name, nameof(name)); - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(patterns, nameof(patterns)); _requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, patterns)); return this; @@ -43,8 +43,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers)); return this; @@ -53,8 +53,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithCookie(string name, bool ignoreCase, params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers)); return this; @@ -63,8 +63,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithCookie(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, matchers)); return this; @@ -73,7 +73,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithCookie(params Func, bool>[] funcs) { - Check.NotNullOrEmpty(funcs, nameof(funcs)); + Guard.NotNullOrEmpty(funcs, nameof(funcs)); _requestMatchers.Add(new RequestMessageCookieMatcher(funcs)); return this; diff --git a/src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs b/src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs index 6ab32674..481b7524 100644 --- a/src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs +++ b/src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using WireMock.Matchers; using WireMock.Matchers.Request; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RequestBuilders { @@ -19,8 +19,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithHeader(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) { - Check.NotNull(name, nameof(name)); - Check.NotNull(pattern, nameof(pattern)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(pattern, nameof(pattern)); _requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, pattern, ignoreCase)); return this; @@ -35,8 +35,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithHeader(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) { - Check.NotNull(name, nameof(name)); - Check.NotNull(patterns, nameof(patterns)); + Guard.NotNull(name, nameof(name)); + Guard.NotNull(patterns, nameof(patterns)); _requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, ignoreCase, patterns)); return this; @@ -45,8 +45,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithHeader(string name, params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers)); return this; @@ -55,8 +55,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithHeader(string name, bool ignoreCase, params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers)); return this; @@ -65,8 +65,8 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithHeader(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers) { - Check.NotNull(name, nameof(name)); - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNull(name, nameof(name)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, ignoreCase, matchers)); return this; @@ -75,7 +75,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithHeader(params Func, bool>[] funcs) { - Check.NotNullOrEmpty(funcs, nameof(funcs)); + Guard.NotNullOrEmpty(funcs, nameof(funcs)); _requestMatchers.Add(new RequestMessageHeaderMatcher(funcs)); return this; diff --git a/src/WireMock.Net/RequestBuilders/Request.WithParam.cs b/src/WireMock.Net/RequestBuilders/Request.WithParam.cs index 2e9e740a..d6605070 100644 --- a/src/WireMock.Net/RequestBuilders/Request.WithParam.cs +++ b/src/WireMock.Net/RequestBuilders/Request.WithParam.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using WireMock.Matchers; using WireMock.Matchers.Request; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RequestBuilders { @@ -20,7 +20,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithParam(string key, bool ignoreCase, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch) { - Check.NotNull(key, nameof(key)); + Guard.NotNull(key, nameof(key)); _requestMatchers.Add(new RequestMessageParamMatcher(matchBehaviour, key, ignoreCase)); return this; @@ -59,7 +59,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithParam(string key, MatchBehaviour matchBehaviour, bool ignoreCase = false, params string[] values) { - Check.NotNull(key, nameof(key)); + Guard.NotNull(key, nameof(key)); _requestMatchers.Add(new RequestMessageParamMatcher(matchBehaviour, key, ignoreCase, values)); return this; @@ -74,7 +74,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithParam(string key, MatchBehaviour matchBehaviour, bool ignoreCase, params IStringMatcher[] matchers) { - Check.NotNull(key, nameof(key)); + Guard.NotNull(key, nameof(key)); _requestMatchers.Add(new RequestMessageParamMatcher(matchBehaviour, key, ignoreCase, matchers)); return this; @@ -83,7 +83,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithParam(params Func>, bool>[] funcs) { - Check.NotNullOrEmpty(funcs, nameof(funcs)); + Guard.NotNullOrEmpty(funcs, nameof(funcs)); _requestMatchers.Add(new RequestMessageParamMatcher(funcs)); return this; diff --git a/src/WireMock.Net/RequestBuilders/Request.cs b/src/WireMock.Net/RequestBuilders/Request.cs index 184a810b..114faba4 100644 --- a/src/WireMock.Net/RequestBuilders/Request.cs +++ b/src/WireMock.Net/RequestBuilders/Request.cs @@ -6,7 +6,7 @@ using System.Collections.ObjectModel; using System.Linq; using WireMock.Matchers; using WireMock.Matchers.Request; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.RequestBuilders { @@ -68,7 +68,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithClientIP(params IStringMatcher[] matchers) { - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageClientIPMatcher(matchers)); return this; @@ -83,7 +83,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithClientIP(MatchBehaviour matchBehaviour, params string[] clientIPs) { - Check.NotNullOrEmpty(clientIPs, nameof(clientIPs)); + Guard.NotNullOrEmpty(clientIPs, nameof(clientIPs)); _requestMatchers.Add(new RequestMessageClientIPMatcher(matchBehaviour, clientIPs)); return this; @@ -92,7 +92,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithClientIP(params Func[] funcs) { - Check.NotNullOrEmpty(funcs, nameof(funcs)); + Guard.NotNullOrEmpty(funcs, nameof(funcs)); _requestMatchers.Add(new RequestMessageClientIPMatcher(funcs)); return this; @@ -101,7 +101,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithPath(params IStringMatcher[] matchers) { - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessagePathMatcher(matchers)); return this; @@ -116,7 +116,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithPath(MatchBehaviour matchBehaviour, params string[] paths) { - Check.NotNullOrEmpty(paths, nameof(paths)); + Guard.NotNullOrEmpty(paths, nameof(paths)); _requestMatchers.Add(new RequestMessagePathMatcher(matchBehaviour, paths)); return this; @@ -125,7 +125,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithPath(params Func[] funcs) { - Check.NotNullOrEmpty(funcs, nameof(funcs)); + Guard.NotNullOrEmpty(funcs, nameof(funcs)); _requestMatchers.Add(new RequestMessagePathMatcher(funcs)); return this; @@ -134,7 +134,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithUrl(params IStringMatcher[] matchers) { - Check.NotNullOrEmpty(matchers, nameof(matchers)); + Guard.NotNullOrEmpty(matchers, nameof(matchers)); _requestMatchers.Add(new RequestMessageUrlMatcher(matchers)); return this; @@ -149,7 +149,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithUrl(MatchBehaviour matchBehaviour, params string[] urls) { - Check.NotNullOrEmpty(urls, nameof(urls)); + Guard.NotNullOrEmpty(urls, nameof(urls)); _requestMatchers.Add(new RequestMessageUrlMatcher(matchBehaviour, urls)); return this; @@ -158,7 +158,7 @@ namespace WireMock.RequestBuilders /// public IRequestBuilder WithUrl(params Func[] funcs) { - Check.NotNullOrEmpty(funcs, nameof(funcs)); + Guard.NotNullOrEmpty(funcs, nameof(funcs)); _requestMatchers.Add(new RequestMessageUrlMatcher(funcs)); return this; diff --git a/src/WireMock.Net/RequestMessage.cs b/src/WireMock.Net/RequestMessage.cs index fe3be8ea..b8945482 100644 --- a/src/WireMock.Net/RequestMessage.cs +++ b/src/WireMock.Net/RequestMessage.cs @@ -8,7 +8,7 @@ using System.Net; using WireMock.Models; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock { @@ -103,9 +103,9 @@ namespace WireMock /// The cookies. public RequestMessage([NotNull] UrlDetails urlDetails, [NotNull] string method, [NotNull] string clientIP, [CanBeNull] IBodyData bodyData = null, [CanBeNull] IDictionary headers = null, [CanBeNull] IDictionary cookies = null) { - Check.NotNull(urlDetails, nameof(urlDetails)); - Check.NotNull(method, nameof(method)); - Check.NotNull(clientIP, nameof(clientIP)); + Guard.NotNull(urlDetails, nameof(urlDetails)); + Guard.NotNull(method, nameof(method)); + Guard.NotNull(clientIP, nameof(clientIP)); AbsoluteUrl = urlDetails.AbsoluteUrl.ToString(); Url = urlDetails.Url.ToString(); diff --git a/src/WireMock.Net/ResponseBuilders/Response.WithCallback.cs b/src/WireMock.Net/ResponseBuilders/Response.WithCallback.cs index 34e68931..438268f8 100644 --- a/src/WireMock.Net/ResponseBuilders/Response.WithCallback.cs +++ b/src/WireMock.Net/ResponseBuilders/Response.WithCallback.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.ResponseBuilders { @@ -24,7 +24,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithCallback(Func callbackHandler) { - Check.NotNull(callbackHandler, nameof(callbackHandler)); + Guard.NotNull(callbackHandler, nameof(callbackHandler)); return WithCallbackInternal(true, callbackHandler); } @@ -32,14 +32,14 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithCallback(Func> callbackHandler) { - Check.NotNull(callbackHandler, nameof(callbackHandler)); + Guard.NotNull(callbackHandler, nameof(callbackHandler)); return WithCallbackInternal(true, callbackHandler); } private IResponseBuilder WithCallbackInternal(bool withCallbackUsed, Func callbackHandler) { - Check.NotNull(callbackHandler, nameof(callbackHandler)); + Guard.NotNull(callbackHandler, nameof(callbackHandler)); WithCallbackUsed = withCallbackUsed; Callback = callbackHandler; @@ -49,7 +49,7 @@ namespace WireMock.ResponseBuilders private IResponseBuilder WithCallbackInternal(bool withCallbackUsed, Func> callbackHandler) { - Check.NotNull(callbackHandler, nameof(callbackHandler)); + Guard.NotNull(callbackHandler, nameof(callbackHandler)); WithCallbackUsed = withCallbackUsed; CallbackAsync = callbackHandler; diff --git a/src/WireMock.Net/ResponseBuilders/Response.WithProxy.cs b/src/WireMock.Net/ResponseBuilders/Response.WithProxy.cs index 526364e0..d1c71386 100644 --- a/src/WireMock.Net/ResponseBuilders/Response.WithProxy.cs +++ b/src/WireMock.Net/ResponseBuilders/Response.WithProxy.cs @@ -1,7 +1,7 @@ using System.Net.Http; using WireMock.Http; using WireMock.Settings; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.ResponseBuilders { @@ -17,7 +17,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2ThumbprintOrSubjectName = null) { - Check.NotNullOrEmpty(proxyUrl, nameof(proxyUrl)); + Guard.NotNullOrEmpty(proxyUrl, nameof(proxyUrl)); var settings = new ProxyAndRecordSettings { @@ -31,7 +31,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithProxy(IProxyAndRecordSettings settings) { - Check.NotNull(settings, nameof(settings)); + Guard.NotNull(settings, nameof(settings)); ProxyAndRecordSettings = settings; diff --git a/src/WireMock.Net/ResponseBuilders/Response.cs b/src/WireMock.Net/ResponseBuilders/Response.cs index 6e59269f..e8633d9d 100644 --- a/src/WireMock.Net/ResponseBuilders/Response.cs +++ b/src/WireMock.Net/ResponseBuilders/Response.cs @@ -16,7 +16,7 @@ using WireMock.Transformers.Handlebars; using WireMock.Transformers.Scriban; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.ResponseBuilders { @@ -97,7 +97,7 @@ namespace WireMock.ResponseBuilders [PublicAPI] public static IResponseBuilder Create([NotNull] Func func) { - Check.NotNull(func, nameof(func)); + Guard.NotNull(func, nameof(func)); return new Response(func()); } @@ -159,7 +159,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithHeader(string name, params string[] values) { - Check.NotNull(name, nameof(name)); + Guard.NotNull(name, nameof(name)); ResponseMessage.AddHeader(name, values); return this; @@ -168,7 +168,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithHeaders(IDictionary headers) { - Check.NotNull(headers, nameof(headers)); + Guard.NotNull(headers, nameof(headers)); ResponseMessage.Headers = headers.ToDictionary(header => header.Key, header => new WireMockList(header.Value)); return this; @@ -177,7 +177,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithHeaders(IDictionary headers) { - Check.NotNull(headers, nameof(headers)); + Guard.NotNull(headers, nameof(headers)); ResponseMessage.Headers = headers.ToDictionary(header => header.Key, header => new WireMockList(header.Value)); return this; @@ -193,7 +193,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithBody(Func bodyFactory, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null) { - Check.NotNull(bodyFactory, nameof(bodyFactory)); + Guard.NotNull(bodyFactory, nameof(bodyFactory)); return WithCallbackInternal(true, req => new ResponseMessage { @@ -209,7 +209,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithBody(Func> bodyFactory, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null) { - Check.NotNull(bodyFactory, nameof(bodyFactory)); + Guard.NotNull(bodyFactory, nameof(bodyFactory)); return WithCallbackInternal(true, async req => new ResponseMessage { @@ -225,7 +225,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithBody(byte[] body, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null) { - Check.NotNull(body, nameof(body)); + Guard.NotNull(body, nameof(body)); ResponseMessage.BodyDestination = destination; ResponseMessage.BodyData = new BodyData(); @@ -251,7 +251,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithBodyFromFile(string filename, bool cache = true) { - Check.NotNull(filename, nameof(filename)); + Guard.NotNull(filename, nameof(filename)); ResponseMessage.BodyData = new BodyData { @@ -274,7 +274,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithBody(string body, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null) { - Check.NotNull(body, nameof(body)); + Guard.NotNull(body, nameof(body)); encoding = encoding ?? Encoding.UTF8; @@ -309,7 +309,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithBodyAsJson(object body, Encoding encoding = null, bool? indented = null) { - Check.NotNull(body, nameof(body)); + Guard.NotNull(body, nameof(body)); ResponseMessage.BodyDestination = null; ResponseMessage.BodyData = new BodyData @@ -350,7 +350,7 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithDelay(TimeSpan delay) { - Check.Condition(delay, d => d > TimeSpan.Zero, nameof(delay)); + Guard.Condition(delay, d => d > TimeSpan.Zero, nameof(delay)); Delay = delay; return this; @@ -365,8 +365,8 @@ namespace WireMock.ResponseBuilders /// public IResponseBuilder WithRandomDelay(int minimumMilliseconds = 0, int maximumMilliseconds = 60_000) { - Check.Condition(minimumMilliseconds, min => min >= 0, nameof(minimumMilliseconds)); - Check.Condition(maximumMilliseconds, max => max > minimumMilliseconds, nameof(maximumMilliseconds)); + Guard.Condition(minimumMilliseconds, min => min >= 0, nameof(minimumMilliseconds)); + Guard.Condition(maximumMilliseconds, max => max > minimumMilliseconds, nameof(maximumMilliseconds)); MinimumDelayMilliseconds = minimumMilliseconds; MaximumDelayMilliseconds = maximumMilliseconds; @@ -377,8 +377,8 @@ namespace WireMock.ResponseBuilders /// public async Task<(ResponseMessage Message, IMapping Mapping)> ProvideResponseAsync(RequestMessage requestMessage, IWireMockServerSettings settings) { - Check.NotNull(requestMessage, nameof(requestMessage)); - Check.NotNull(settings, nameof(settings)); + Guard.NotNull(requestMessage, nameof(requestMessage)); + Guard.NotNull(settings, nameof(settings)); if (Delay != null) { diff --git a/src/WireMock.Net/ResponseMessage.cs b/src/WireMock.Net/ResponseMessage.cs index 0e68c7dc..9420aee8 100644 --- a/src/WireMock.Net/ResponseMessage.cs +++ b/src/WireMock.Net/ResponseMessage.cs @@ -5,7 +5,7 @@ using System.Linq; using WireMock.ResponseBuilders; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock { @@ -44,7 +44,7 @@ namespace WireMock /// public void AddHeader(string name, params string[] values) { - Check.NotNullOrEmpty(values, nameof(values)); + Guard.NotNullOrEmpty(values, nameof(values)); var newHeaderValues = Headers.TryGetValue(name, out WireMockList existingValues) ? values.Union(existingValues).ToArray() diff --git a/src/WireMock.Net/Serialization/MappingToFileSaver.cs b/src/WireMock.Net/Serialization/MappingToFileSaver.cs index 6b6581fc..1d5a0954 100644 --- a/src/WireMock.Net/Serialization/MappingToFileSaver.cs +++ b/src/WireMock.Net/Serialization/MappingToFileSaver.cs @@ -2,7 +2,7 @@ using System.Linq; using Newtonsoft.Json; using WireMock.Settings; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Serialization { @@ -13,7 +13,7 @@ namespace WireMock.Serialization public MappingToFileSaver(IWireMockServerSettings settings, MappingConverter mappingConverter) { - Check.NotNull(settings, nameof(settings)); + Guard.NotNull(settings, nameof(settings)); _settings = settings; _mappingConverter = mappingConverter; diff --git a/src/WireMock.Net/Server/RespondWithAProvider.cs b/src/WireMock.Net/Server/RespondWithAProvider.cs index 80ba6626..ab1eb115 100644 --- a/src/WireMock.Net/Server/RespondWithAProvider.cs +++ b/src/WireMock.Net/Server/RespondWithAProvider.cs @@ -9,7 +9,7 @@ using WireMock.ResponseProviders; using WireMock.Settings; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Server { @@ -154,7 +154,7 @@ namespace WireMock.Server /// public IRespondWithAProvider WithTimeSettings(ITimeSettings timeSettings) { - Check.NotNull(timeSettings, nameof(timeSettings)); + Guard.NotNull(timeSettings, nameof(timeSettings)); TimeSettings = timeSettings; @@ -164,7 +164,7 @@ namespace WireMock.Server /// public IRespondWithAProvider WithWebhook(params IWebhook[] webhooks) { - Check.HasNoNulls(webhooks, nameof(webhooks)); + Guard.HasNoNulls(webhooks, nameof(webhooks)); Webhooks = webhooks; diff --git a/src/WireMock.Net/Server/WireMockServer.Admin.cs b/src/WireMock.Net/Server/WireMockServer.Admin.cs index b4ac8566..3ef204c3 100644 --- a/src/WireMock.Net/Server/WireMockServer.Admin.cs +++ b/src/WireMock.Net/Server/WireMockServer.Admin.cs @@ -24,7 +24,7 @@ using WireMock.Serialization; using WireMock.Settings; using WireMock.Types; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Server { @@ -206,7 +206,7 @@ namespace WireMock.Server [PublicAPI] public bool ReadStaticMappingAndAddOrUpdate([NotNull] string path) { - Check.NotNull(path, nameof(path)); + Guard.NotNull(path, nameof(path)); string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path); @@ -414,9 +414,9 @@ namespace WireMock.Server private Guid? ConvertMappingAndRegisterAsRespondProvider(MappingModel mappingModel, Guid? guid = null, string path = null) { - Check.NotNull(mappingModel, nameof(mappingModel)); - Check.NotNull(mappingModel.Request, nameof(mappingModel.Request)); - Check.NotNull(mappingModel.Response, nameof(mappingModel.Response)); + Guard.NotNull(mappingModel, nameof(mappingModel)); + Guard.NotNull(mappingModel.Request, nameof(mappingModel.Request)); + Guard.NotNull(mappingModel.Response, nameof(mappingModel.Response)); var requestBuilder = InitRequestBuilder(mappingModel.Request, true); if (requestBuilder == null) diff --git a/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs b/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs index 22ddfa5b..5730e978 100644 --- a/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs +++ b/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs @@ -9,7 +9,7 @@ using WireMock.Matchers; using WireMock.RequestBuilders; using WireMock.ResponseBuilders; using WireMock.Util; -using WireMock.Validation; +using Stef.Validation; using OrgMapping = WireMock.Org.Abstractions.Mapping; namespace WireMock.Server @@ -23,7 +23,7 @@ namespace WireMock.Server [PublicAPI] public void ReadStaticWireMockOrgMappingAndAddOrUpdate([NotNull] string path) { - Check.NotNull(path, nameof(path)); + Guard.NotNull(path, nameof(path)); string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path); diff --git a/src/WireMock.Net/Server/WireMockServer.cs b/src/WireMock.Net/Server/WireMockServer.cs index c3ad3dcf..d4db11c1 100644 --- a/src/WireMock.Net/Server/WireMockServer.cs +++ b/src/WireMock.Net/Server/WireMockServer.cs @@ -18,7 +18,7 @@ using WireMock.RequestBuilders; using WireMock.ResponseProviders; using WireMock.Serialization; using WireMock.Settings; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Server { @@ -93,7 +93,7 @@ namespace WireMock.Server [PublicAPI] public static WireMockServer Start([NotNull] IWireMockServerSettings settings) { - Check.NotNull(settings, nameof(settings)); + Guard.NotNull(settings, nameof(settings)); return new WireMockServer(settings); } @@ -122,7 +122,7 @@ namespace WireMock.Server [PublicAPI] public static WireMockServer Start(params string[] urls) { - Check.NotNullOrEmpty(urls, nameof(urls)); + Guard.NotNullOrEmpty(urls, nameof(urls)); return new WireMockServer(new WireMockServerSettings { @@ -155,7 +155,7 @@ namespace WireMock.Server [PublicAPI] public static WireMockServer StartWithAdminInterface(params string[] urls) { - Check.NotNullOrEmpty(urls, nameof(urls)); + Guard.NotNullOrEmpty(urls, nameof(urls)); return new WireMockServer(new WireMockServerSettings { @@ -172,7 +172,7 @@ namespace WireMock.Server [PublicAPI] public static WireMockServer StartWithAdminInterfaceAndReadStaticMappings(params string[] urls) { - Check.NotNullOrEmpty(urls, nameof(urls)); + Guard.NotNullOrEmpty(urls, nameof(urls)); return new WireMockServer(new WireMockServerSettings { @@ -413,8 +413,8 @@ namespace WireMock.Server [PublicAPI] public void SetAzureADAuthentication([NotNull] string tenant, [NotNull] string audience) { - Check.NotNull(tenant, nameof(tenant)); - Check.NotNull(audience, nameof(audience)); + Guard.NotNull(tenant, nameof(tenant)); + Guard.NotNull(audience, nameof(audience)); #if NETSTANDARD1_3 throw new NotSupportedException("AzureADAuthentication is not supported for NETStandard 1.3"); @@ -427,8 +427,8 @@ namespace WireMock.Server [PublicAPI] public void SetBasicAuthentication([NotNull] string username, [NotNull] string password) { - Check.NotNull(username, nameof(username)); - Check.NotNull(password, nameof(password)); + Guard.NotNull(username, nameof(username)); + Guard.NotNull(password, nameof(password)); _options.AuthenticationMatcher = new BasicAuthenticationMatcher(username, password); } diff --git a/src/WireMock.Net/Settings/WireMockServerSettingsParser.cs b/src/WireMock.Net/Settings/WireMockServerSettingsParser.cs index 101c80a0..24a38786 100644 --- a/src/WireMock.Net/Settings/WireMockServerSettingsParser.cs +++ b/src/WireMock.Net/Settings/WireMockServerSettingsParser.cs @@ -1,6 +1,6 @@ using JetBrains.Annotations; using WireMock.Logging; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Settings { @@ -18,7 +18,7 @@ namespace WireMock.Settings [PublicAPI] public static bool TryParseArguments([NotNull] string[] args, out IWireMockServerSettings settings, [CanBeNull] IWireMockLogger logger = null) { - Check.HasNoNulls(args, nameof(args)); + Guard.HasNoNulls(args, nameof(args)); var parser = new SimpleCommandLineParser(); parser.Parse(args); diff --git a/src/WireMock.Net/Transformers/Scriban/ScribanContextFactory.cs b/src/WireMock.Net/Transformers/Scriban/ScribanContextFactory.cs index bc5c79d2..d4614f5c 100644 --- a/src/WireMock.Net/Transformers/Scriban/ScribanContextFactory.cs +++ b/src/WireMock.Net/Transformers/Scriban/ScribanContextFactory.cs @@ -1,6 +1,6 @@ using WireMock.Handlers; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Transformers.Scriban { @@ -11,8 +11,8 @@ namespace WireMock.Transformers.Scriban public ScribanContextFactory(IFileSystemHandler fileSystemHandler, TransformerType transformerType) { - Check.NotNull(fileSystemHandler, nameof(fileSystemHandler)); - Check.Condition(transformerType, t => t == TransformerType.Scriban || t == TransformerType.ScribanDotLiquid, nameof(transformerType)); + Guard.NotNull(fileSystemHandler, nameof(fileSystemHandler)); + Guard.Condition(transformerType, t => t == TransformerType.Scriban || t == TransformerType.ScribanDotLiquid, nameof(transformerType)); _fileSystemHandler = fileSystemHandler; _transformerType = transformerType; diff --git a/src/WireMock.Net/Util/BodyParser.cs b/src/WireMock.Net/Util/BodyParser.cs index 82c9f392..55b7c820 100644 --- a/src/WireMock.Net/Util/BodyParser.cs +++ b/src/WireMock.Net/Util/BodyParser.cs @@ -8,7 +8,7 @@ using JetBrains.Annotations; using WireMock.Http; using WireMock.Matchers; using WireMock.Types; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Util { @@ -109,7 +109,7 @@ namespace WireMock.Util public static async Task ParseAsync([NotNull] BodyParserSettings settings) { - Check.NotNull(settings, nameof(settings)); + Guard.NotNull(settings, nameof(settings)); var bodyWithContentEncoding = await ReadBytesAsync(settings.Stream, settings.ContentEncoding, settings.DecompressGZipAndDeflate).ConfigureAwait(false); var data = new BodyData diff --git a/src/WireMock.Net/Util/DictionaryExtensions.cs b/src/WireMock.Net/Util/DictionaryExtensions.cs index a84fed07..58884fa3 100644 --- a/src/WireMock.Net/Util/DictionaryExtensions.cs +++ b/src/WireMock.Net/Util/DictionaryExtensions.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Util { @@ -19,7 +19,7 @@ namespace WireMock.Util /// The action. public static void Loop(this IDictionary dictionary, [NotNull] Action action) { - Check.NotNull(action, nameof(action)); + Guard.NotNull(action, nameof(action)); if (dictionary != null) { diff --git a/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs b/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs index ad4f4a48..d30cecf8 100644 --- a/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs +++ b/src/WireMock.Net/Util/EnhancedFileSystemWatcher.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Concurrent; using System.IO; using JetBrains.Annotations; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Util { @@ -58,7 +58,7 @@ namespace WireMock.Util /// The interval. public EnhancedFileSystemWatcher(int interval = DefaultWatchInterval) { - Check.Condition(interval, i => i >= 0, nameof(interval)); + Guard.Condition(interval, i => i >= 0, nameof(interval)); InitializeMembers(interval); } @@ -70,8 +70,8 @@ namespace WireMock.Util /// The interval. public EnhancedFileSystemWatcher([NotNull] string path, int interval = DefaultWatchInterval) : base(path) { - Check.NotNullOrEmpty(path, nameof(path)); - Check.Condition(interval, i => i >= 0, nameof(interval)); + Guard.NotNullOrEmpty(path, nameof(path)); + Guard.Condition(interval, i => i >= 0, nameof(interval)); InitializeMembers(interval); } @@ -84,9 +84,9 @@ namespace WireMock.Util /// The interval. public EnhancedFileSystemWatcher([NotNull] string path, [NotNull] string filter, int interval = DefaultWatchInterval) : base(path, filter) { - Check.NotNullOrEmpty(path, nameof(path)); - Check.NotNullOrEmpty(filter, nameof(filter)); - Check.Condition(interval, i => i >= 0, nameof(interval)); + Guard.NotNullOrEmpty(path, nameof(path)); + Guard.NotNullOrEmpty(filter, nameof(filter)); + Guard.Condition(interval, i => i >= 0, nameof(interval)); InitializeMembers(interval); } diff --git a/src/WireMock.Net/Util/FileHelper.cs b/src/WireMock.Net/Util/FileHelper.cs index cceca2ae..82b5c12b 100644 --- a/src/WireMock.Net/Util/FileHelper.cs +++ b/src/WireMock.Net/Util/FileHelper.cs @@ -1,7 +1,7 @@ using JetBrains.Annotations; using System.Threading; using WireMock.Handlers; -using WireMock.Validation; +using Stef.Validation; namespace WireMock.Util { @@ -12,8 +12,8 @@ namespace WireMock.Util public static bool TryReadMappingFileWithRetryAndDelay([NotNull] IFileSystemHandler handler, [NotNull] string path, out string value) { - Check.NotNull(handler, nameof(handler)); - Check.NotNullOrEmpty(path, nameof(path)); + Guard.NotNull(handler, nameof(handler)); + Guard.NotNullOrEmpty(path, nameof(path)); value = null; diff --git a/src/WireMock.Net/Util/UrlUtils.cs b/src/WireMock.Net/Util/UrlUtils.cs index 7ed37d65..7def9ee1 100644 --- a/src/WireMock.Net/Util/UrlUtils.cs +++ b/src/WireMock.Net/Util/UrlUtils.cs @@ -1,7 +1,7 @@ using System; using JetBrains.Annotations; using WireMock.Models; -using WireMock.Validation; +using Stef.Validation; #if !USE_ASPNETCORE using Microsoft.Owin; #else @@ -14,7 +14,7 @@ namespace WireMock.Util { public static UrlDetails Parse([NotNull] Uri uri, PathString pathBase) { - Check.NotNull(uri, nameof(uri)); + Guard.NotNull(uri, nameof(uri)); if (!pathBase.HasValue) { diff --git a/src/WireMock.Net/Validation/Check.cs b/src/WireMock.Net/Validation/Check.cs deleted file mode 100644 index 8aebecc0..00000000 --- a/src/WireMock.Net/Validation/Check.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using JetBrains.Annotations; - -// Copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Shared/Check.cs -namespace WireMock.Validation -{ - // [ExcludeFromCodeCoverage] - [DebuggerStepThrough] - internal static class Check - { - [ContractAnnotation("value:null => halt")] - public static T Condition([NoEnumeration] T value, [ValidatedNotNull, NotNull] Predicate condition, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName) - { - NotNull(condition, nameof(condition)); - NotNull(value, nameof(value)); - - if (!condition(value)) - { - NotNullOrEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentOutOfRangeException(parameterName); - } - - return value; - } - - [ContractAnnotation("value:null => halt")] - public static T NotNull([NoEnumeration] T value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName) - { - if (ReferenceEquals(value, null)) - { - NotNullOrEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentNullException(parameterName); - } - - return value; - } - - [ContractAnnotation("value:null => halt")] - public static T NotNull([NoEnumeration] T value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName, [ValidatedNotNull, NotNull] string propertyName) - { - if (ReferenceEquals(value, null)) - { - NotNullOrEmpty(parameterName, nameof(parameterName)); - NotNullOrEmpty(propertyName, nameof(propertyName)); - - throw new ArgumentException(CoreStrings.ArgumentPropertyNull(propertyName, parameterName)); - } - - return value; - } - - [ContractAnnotation("value:null => halt")] - public static IList NotNullOrEmpty(IList value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName) - { - NotNull(value, parameterName); - - if (value.Count == 0) - { - NotNullOrEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName)); - } - - return value; - } - - [ContractAnnotation("value:null => halt")] - public static string NotNullOrEmpty(string value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName) - { - Exception e = null; - if (ReferenceEquals(value, null)) - { - e = new ArgumentNullException(parameterName); - } - else if (value.Trim().Length == 0) - { - e = new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName)); - } - - if (e != null) - { - NotNullOrEmpty(parameterName, nameof(parameterName)); - - throw e; - } - - return value; - } - - public static IList HasNoNulls(IList value, [InvokerParameterName, ValidatedNotNull, NotNull] string parameterName) - where T : class - { - NotNull(value, parameterName); - - if (value.Any(e => e == null)) - { - NotNullOrEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentException(parameterName); - } - - return value; - } - } -} \ No newline at end of file diff --git a/src/WireMock.Net/Validation/CoreStrings.cs b/src/WireMock.Net/Validation/CoreStrings.cs deleted file mode 100644 index dc466b8b..00000000 --- a/src/WireMock.Net/Validation/CoreStrings.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -// copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Microsoft.EntityFrameworkCore/Properties/CoreStrings.resx -namespace WireMock.Validation -{ - // [ExcludeFromCodeCoverage] - internal static class CoreStrings - { - /// - /// The property '{property}' of the argument '{argument}' cannot be null. - /// - public static string ArgumentPropertyNull(string property, string argument) - { - return $"The property '{property}' of the argument '{argument}' cannot be null."; - } - - /// - /// The string argument '{argumentName}' cannot be empty. - /// - public static string ArgumentIsEmpty(string argumentName) - { - return $"The string argument '{argumentName}' cannot be empty."; - } - - /// - /// The entity type '{type}' provided for the argument '{argumentName}' must be a reference type. - /// - public static string InvalidEntityType(Type type, string argumentName) - { - return $"The entity type '{type}' provided for the argument '{argumentName}' must be a reference type."; - } - - /// - /// The collection argument '{argumentName}' must contain at least one element. - /// - public static string CollectionArgumentIsEmpty(string argumentName) - { - return $"The collection argument '{argumentName}' must contain at least one element."; - } - } -} \ No newline at end of file diff --git a/src/WireMock.Net/Validation/ValidatedNotNullAttribute.cs b/src/WireMock.Net/Validation/ValidatedNotNullAttribute.cs index d41d9f1c..5c4f1d05 100644 --- a/src/WireMock.Net/Validation/ValidatedNotNullAttribute.cs +++ b/src/WireMock.Net/Validation/ValidatedNotNullAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace WireMock.Validation { @@ -8,4 +8,4 @@ namespace WireMock.Validation internal class ValidatedNotNullAttribute : Attribute { } -} +} \ No newline at end of file diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 9f6b864a..c4504e66 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -55,7 +55,7 @@ - +