diff --git a/Directory.Build.props b/Directory.Build.props index 4310c281..8992cf32 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ - 1.0.25 + 1.0.27 diff --git a/GitHubReleaseNotes.txt b/GitHubReleaseNotes.txt index dd30771c..15d9f12b 100644 --- a/GitHubReleaseNotes.txt +++ b/GitHubReleaseNotes.txt @@ -1,3 +1,3 @@ https://github.com/StefH/GitHubReleaseNotes -GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --version 1.0.25.0 \ No newline at end of file +GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --version 1.0.27.0 \ No newline at end of file diff --git a/src/WireMock.Net/IMapping.cs b/src/WireMock.Net/IMapping.cs index 06660035..e8d95c18 100644 --- a/src/WireMock.Net/IMapping.cs +++ b/src/WireMock.Net/IMapping.cs @@ -80,11 +80,11 @@ namespace WireMock bool IsAdminInterface { get; } /// - /// ResponseToAsync + /// ProvideResponseAsync /// /// The request message. /// The . - Task ResponseToAsync(RequestMessage requestMessage); + Task ProvideResponseAsync(RequestMessage requestMessage); /// /// Gets the RequestMatchResult based on the RequestMessage. diff --git a/src/WireMock.Net/Mapping.cs b/src/WireMock.Net/Mapping.cs index 12537206..c7b4578c 100644 --- a/src/WireMock.Net/Mapping.cs +++ b/src/WireMock.Net/Mapping.cs @@ -77,8 +77,8 @@ namespace WireMock NextState = nextState; } - /// - public async Task ResponseToAsync(RequestMessage requestMessage) + /// + public async Task ProvideResponseAsync(RequestMessage requestMessage) { return await Provider.ProvideResponseAsync(requestMessage, Settings); } diff --git a/src/WireMock.Net/Owin/WireMockMiddleware.cs b/src/WireMock.Net/Owin/WireMockMiddleware.cs index f63545c0..cdef69e3 100644 --- a/src/WireMock.Net/Owin/WireMockMiddleware.cs +++ b/src/WireMock.Net/Owin/WireMockMiddleware.cs @@ -118,7 +118,7 @@ namespace WireMock.Owin await Task.Delay(_options.RequestProcessingDelay.Value); } - response = await targetMapping.ResponseToAsync(request); + response = await targetMapping.ProvideResponseAsync(request); if (targetMapping.Scenario != null) { @@ -129,7 +129,7 @@ namespace WireMock.Owin } catch (Exception ex) { - _options.Logger.Error("HttpStatusCode set to 500"); + _options.Logger.Error($"Providing a Response for Mapping '{result.TargetMapping.Guid}' failed. HttpStatusCode set to 500. Exception: {ex}"); response = ResponseMessageBuilder.Create(JsonConvert.SerializeObject(ex), 500); } finally diff --git a/src/WireMock.Net/Server/FluentMockServer.Admin.cs b/src/WireMock.Net/Server/FluentMockServer.Admin.cs index d3c18f37..e1e6124e 100644 --- a/src/WireMock.Net/Server/FluentMockServer.Admin.cs +++ b/src/WireMock.Net/Server/FluentMockServer.Admin.cs @@ -1,6 +1,3 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.IO; @@ -8,6 +5,9 @@ using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using JetBrains.Annotations; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using WireMock.Admin.Mappings; using WireMock.Admin.Scenarios; using WireMock.Admin.Settings; diff --git a/src/WireMock.Net/Server/FluentMockServer.LogEntries.cs b/src/WireMock.Net/Server/FluentMockServer.LogEntries.cs index 551c74f7..0ad13469 100644 --- a/src/WireMock.Net/Server/FluentMockServer.LogEntries.cs +++ b/src/WireMock.Net/Server/FluentMockServer.LogEntries.cs @@ -27,7 +27,7 @@ namespace WireMock.Server /// Gets the request logs. /// [PublicAPI] - public IEnumerable LogEntries => new ReadOnlyCollection(_options.LogEntries); + public IEnumerable LogEntries => new ReadOnlyCollection(_options.LogEntries.ToArray()); /// /// The search log-entries based on matchers. diff --git a/src/WireMock.Net/Util/CloneUtils.cs b/src/WireMock.Net/Util/CloneUtils.cs new file mode 100644 index 00000000..75b9d2ec --- /dev/null +++ b/src/WireMock.Net/Util/CloneUtils.cs @@ -0,0 +1,29 @@ +using FastDeepCloner; +using System; +using System.Runtime.Serialization; + +namespace WireMock.Util +{ + internal static class CloneUtils + { + private static FastDeepClonerSettings settings = new FastDeepCloner.FastDeepClonerSettings() + { + FieldType = FastDeepCloner.FieldType.FieldInfo, + OnCreateInstance = new FastDeepCloner.Extensions.CreateInstance((Type type) => + { +#if !NETSTANDARD1_3 + return FormatterServices.GetUninitializedObject(type); +#else + +#endif + }) + }; + + public static T DeepClone(T objectToBeCloned) where T : class + { + //return CloneExtensionsEx.CloneFactory.GetClone(objectToBeCloned); + // Expression.Lambda>(Expression.New(type)).Compile() + return FastDeepCloner.DeepCloner.Clone(objectToBeCloned, settings); + } + } +} \ No newline at end of file diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 355acfcf..815e5f4c 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -45,6 +45,7 @@ + @@ -64,6 +65,8 @@ + +