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 a0fed576..23b9b418 100644
--- a/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj
+++ b/examples/WireMock.Net.Console.NETCoreApp3/WireMock.Net.Console.NETCoreApp3.csproj
@@ -31,6 +31,7 @@
+
diff --git a/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs b/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs
index fe9b9b20..2b92c007 100644
--- a/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs
+++ b/examples/WireMock.Net.Console.Net452.Classic/MainApp.cs
@@ -11,6 +11,7 @@ using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;
using WireMock.Settings;
+using WireMock.Util;
namespace WireMock.Net.ConsoleApplication
{
@@ -515,6 +516,12 @@ namespace WireMock.Net.ConsoleApplication
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
.WithBodyAsJson(new { Id = "5bdf076c-5654-4b3e-842c-7caf1fabf8c9" }));
+ server
+ .Given(Request.Create().WithPath("/random200or505").UsingGet())
+ .RespondWith(Response.Create().WithCallback(request => new ResponseMessage
+ {
+ StatusCode = new Random().Next(1, 100) == 1 ? 504 : 200
+ }));
System.Console.WriteLine(JsonConvert.SerializeObject(server.MappingModels, Formatting.Indented));
diff --git a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj
index 85b1b2fa..590dc200 100644
--- a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj
+++ b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj
@@ -4,7 +4,7 @@
Commonly used interfaces, models, enumerations and types.
WireMock.Net.Abstractions
Stef Heyenrath
- netstandard1.0;netstandard2.0;net45
+ netstandard1.0;netstandard2.0;netstandard2.1;net45
true
WireMock.Net.Abstractions
WireMock.Net.Abstractions
diff --git a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj
index 5981f8a2..7e4cbffb 100644
--- a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj
+++ b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj
@@ -4,7 +4,7 @@
A RestClient using RestEase to access the admin interface.
WireMock.Net.RestClient
Stef Heyenrath
- netstandard1.1;netstandard2.0;net45
+ netstandard1.1;netstandard2.0;netstandard2.1;net45
true
WireMock.Net.RestClient
WireMock.Net.RestClient
diff --git a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj
index eb5acdac..d738a14c 100644
--- a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj
+++ b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj
@@ -3,7 +3,7 @@
Lightweight StandAlone Http Mocking Server for .Net.
WireMock.Net.StandAlone
Stef Heyenrath
- net451;net452;net46;net461;netstandard1.3;netstandard2.0
+ net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1
true
WireMock.Net.StandAlone
WireMock.Net.StandAlone
@@ -36,7 +36,7 @@
true
-
+
NETSTANDARD;USE_ASPNETCORE
diff --git a/src/WireMock.Net/Matchers/CSharpCodeMatcher.cs b/src/WireMock.Net/Matchers/CSharpCodeMatcher.cs
index 30b5e217..dbf166ba 100644
--- a/src/WireMock.Net/Matchers/CSharpCodeMatcher.cs
+++ b/src/WireMock.Net/Matchers/CSharpCodeMatcher.cs
@@ -82,7 +82,7 @@ namespace WireMock.Matchers
object result = null;
-#if NET451 || NET452
+#if (NET451 || NET452)
var compilerParams = new System.CodeDom.Compiler.CompilerParameters
{
GenerateInMemory = true,
@@ -122,36 +122,42 @@ namespace WireMock.Matchers
{
result = methodInfo.Invoke(helper, new[] { inputValue });
}
- catch
+ catch (Exception ex)
{
- throw new WireMockException("CSharpCodeMatcher: Unable to call method 'IsMatch' in WireMock.CodeHelper");
+ throw new WireMockException("CSharpCodeMatcher: Unable to call method 'IsMatch' in WireMock.CodeHelper", ex);
}
}
-#elif NET46 || NET461
+#elif (NET46 || NET461)
dynamic script;
try
{
script = CSScriptLibrary.CSScript.Evaluator.CompileCode(source).CreateObject("*");
}
- catch
+ catch (Exception ex)
{
- throw new WireMockException("CSharpCodeMatcher: Unable to create compiler for WireMock.CodeHelper");
+ throw new WireMockException("CSharpCodeMatcher: Unable to create compiler for WireMock.CodeHelper", ex);
}
try
{
result = script.IsMatch(inputValue);
}
- catch
+ catch (Exception ex)
{
- throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper");
+ throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex);
}
-#elif NETSTANDARD2_0
+
+#elif (NETSTANDARD2_0 || NETSTANDARD2_1)
dynamic script;
try
{
var assembly = CSScriptLib.CSScript.Evaluator.CompileCode(source);
+
+#if NETSTANDARD2_0
script = csscript.GenericExtensions.CreateObject(assembly, "*");
+#else
+ script = CSScriptLib.ReflectionExtensions.CreateObject(assembly,"*");
+#endif
}
catch (Exception ex)
{
@@ -164,10 +170,10 @@ namespace WireMock.Matchers
}
catch (Exception ex)
{
- throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper");
+ throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex);
}
#else
- throw new NotSupportedException("The 'CSharpCodeMatcher' cannot be used in netstandard 1.3");
+ throw new NotSupportedException("The 'CSharpCodeMatcher' cannot be used in netstandard 1.3");
#endif
try
{
diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs
index 78bdf9c0..0732462d 100644
--- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs
+++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs
@@ -139,6 +139,8 @@ namespace WireMock.Owin
_logger.Info("WireMock.Net server using netstandard1.3");
#elif NETSTANDARD2_0
_logger.Info("WireMock.Net server using netstandard2.0");
+#elif NETSTANDARD2_1
+ _logger.Info("WireMock.Net server using netstandard2.1");
#elif NET46
_logger.Info("WireMock.Net server using .net 4.6.1 or higher");
#endif
diff --git a/src/WireMock.Net/Owin/HostUrlOptions.cs b/src/WireMock.Net/Owin/HostUrlOptions.cs
index 0cb3927b..cd404dd2 100644
--- a/src/WireMock.Net/Owin/HostUrlOptions.cs
+++ b/src/WireMock.Net/Owin/HostUrlOptions.cs
@@ -33,7 +33,7 @@ namespace WireMock.Owin
private int FindFreeTcpPort()
{
-#if USE_ASPNETCORE || NETSTANDARD2_0
+#if USE_ASPNETCORE || NETSTANDARD2_0 || NETSTANDARD2_1
return 0;
#else
return PortUtils.FindFreeTcpPort();
diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj
index a6b80f84..5245eb61 100644
--- a/src/WireMock.Net/WireMock.Net.csproj
+++ b/src/WireMock.Net/WireMock.Net.csproj
@@ -5,7 +5,7 @@
Stef Heyenrath
- net451;net452;net46;net461;netstandard1.3;netstandard2.0
+ net451;net452;net46;net461;netstandard1.3;netstandard2.0;;netstandard2.1
true
WireMock.Net
WireMock.Net
@@ -48,7 +48,7 @@
WireMock.Net.ruleset
-
+
NETSTANDARD;USE_ASPNETCORE
@@ -140,6 +140,13 @@
+
+
+
+
+
+
+