From aa9be33620f961b0be0cd774eeb6ac8ca4abbca4 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Fri, 13 Feb 2026 20:26:19 +0100 Subject: [PATCH] sc --- Directory.Build.props | 20 +---- .../WireMock.Net.Abstractions.csproj | 25 +++---- .../Matchers/CSharpCodeMatcher.cs | 75 +------------------ .../Owin/AspNetCoreSelfHost.cs | 2 +- .../Server/WireMockServer.cs | 4 - .../Mappers/OpenApiPathsMapper.cs | 6 +- .../WireMock.Net.OpenApiParser.csproj | 15 +++- .../WireMock.Net.Shared.csproj | 23 ++++-- .../WireMock.Net.Testcontainers.csproj | 8 +- .../IntegrationTests.cs | 3 +- 10 files changed, 48 insertions(+), 133 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8f994548..fb7d7038 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -46,14 +46,11 @@ true - + low all - - - @@ -68,19 +65,4 @@ runtime; build; native; contentfiles; analyzers; buildtransitive --> - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj index 0a945b3e..2ed3b3e9 100644 --- a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj +++ b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj @@ -34,12 +34,19 @@ true - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - \ No newline at end of file diff --git a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs index 218839ff..99ca8b11 100644 --- a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs +++ b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs @@ -1,7 +1,5 @@ // Copyright © WireMock.Net -using System; -using System.Linq; using System.Reflection; using System.Text; using AnyOfTypes; @@ -106,74 +104,6 @@ public class CSharpCodeMatcher : ICSharpCodeMatcher var inputValue = isMatchWithString ? input : JObject.FromObject(input); var source = GetSourceForIsMatchWithString(pattern, isMatchWithString); - object? result; - - //#if (NET451 || NET452) - // var compilerParams = new System.CodeDom.Compiler.CompilerParameters - // { - // GenerateInMemory = true, - // GenerateExecutable = false, - // ReferencedAssemblies = - // { - // "System.dll", - // "System.Core.dll", - // "Microsoft.CSharp.dll", - // "Newtonsoft.Json.dll" - // } - // }; - - // using (var codeProvider = new Microsoft.CSharp.CSharpCodeProvider()) - // { - // var compilerResults = codeProvider.CompileAssemblyFromSource(compilerParams, source); - - // if (compilerResults.Errors.Count != 0) - // { - // var errors = from System.CodeDom.Compiler.CompilerError er in compilerResults.Errors select er.ToString(); - // throw new WireMockException(string.Join(", ", errors)); - // } - - // var helper = compilerResults.CompiledAssembly?.CreateInstance("CodeHelper"); - // if (helper == null) - // { - // throw new WireMockException("CSharpCodeMatcher: Unable to create instance from WireMock.CodeHelper"); - // } - - // var methodInfo = helper.GetType().GetMethod("IsMatch"); - // if (methodInfo == null) - // { - // throw new WireMockException("CSharpCodeMatcher: Unable to find method 'IsMatch' in WireMock.CodeHelper"); - // } - - // try - // { - // result = methodInfo.Invoke(helper, new[] { inputValue }); - // } - // catch (Exception ex) - // { - // throw new WireMockException("CSharpCodeMatcher: Unable to call method 'IsMatch' in WireMock.CodeHelper", ex); - // } - // } - //#elif (NET46 || net462) - // dynamic script; - // try - // { - // script = CSScriptLibrary.CSScript.Evaluator.CompileCode(source).CreateObject("*"); - // } - // catch (Exception ex) - // { - // throw new WireMockException("CSharpCodeMatcher: Unable to create compiler for WireMock.CodeHelper", ex); - // } - - // try - // { - // result = script.IsMatch(inputValue); - // } - // catch (Exception ex) - // { - // throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex); - // } - - //#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0_OR_GREATER || NET48) Assembly assembly; try { @@ -194,6 +124,7 @@ public class CSharpCodeMatcher : ICSharpCodeMatcher throw new WireMockException("CSharpCodeMatcher: Unable to create object from assembly", ex); } + object? result; try { result = script.IsMatch(inputValue); @@ -202,9 +133,7 @@ public class CSharpCodeMatcher : ICSharpCodeMatcher { 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"); - //#endif + try { return (bool)result; diff --git a/src/WireMock.Net.Minimal/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net.Minimal/Owin/AspNetCoreSelfHost.cs index 636662bb..650aabeb 100644 --- a/src/WireMock.Net.Minimal/Owin/AspNetCoreSelfHost.cs +++ b/src/WireMock.Net.Minimal/Owin/AspNetCoreSelfHost.cs @@ -135,7 +135,7 @@ internal partial class AspNetCoreSelfHost } else { - var urlOptions = _urlOptions?.Urls?.ToArray() ?? []; + var urlOptions = _urlOptions.Urls?.ToArray() ?? []; for (int i = 0; i < urlOptions.Length; i++) { diff --git a/src/WireMock.Net.Minimal/Server/WireMockServer.cs b/src/WireMock.Net.Minimal/Server/WireMockServer.cs index f2af7fa8..be62134c 100644 --- a/src/WireMock.Net.Minimal/Server/WireMockServer.cs +++ b/src/WireMock.Net.Minimal/Server/WireMockServer.cs @@ -537,15 +537,11 @@ public partial class WireMockServer : IWireMockServer Guard.NotNull(tenant); Guard.NotNull(audience); -//#if NETSTANDARD1_3 -// throw new NotSupportedException("AzureADAuthentication is not supported for NETStandard 1.3"); -//#else _options.AuthenticationMatcher = new AzureADAuthenticationMatcher( new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler(), new Microsoft.IdentityModel.Protocols.ConfigurationManager($"https://login.microsoftonline.com/{tenant}/.well-known/openid-configuration", new Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever()), tenant, audience); -//#endif } /// diff --git a/src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs b/src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs index 2c922363..8662a133 100644 --- a/src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs +++ b/src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs @@ -293,17 +293,17 @@ internal class OpenApiPathsMapper(WireMockOpenApiParserSettings settings) return newPath; } - private IDictionary? MapHeaders(string? responseContentType, IDictionary? headers) + private Dictionary? MapHeaders(string? responseContentType, IDictionary? headers) { var mappedHeaders = headers? - .ToDictionary(item => item.Key, _ => GetExampleMatcherModel(null, _settings.HeaderPatternToUse).Pattern!) ?? new Dictionary(); + .ToDictionary(item => item.Key, _ => GetExampleMatcherModel(null, _settings.HeaderPatternToUse).Pattern!) ?? []; if (!string.IsNullOrEmpty(responseContentType)) { mappedHeaders.TryAdd(HeaderContentType, responseContentType); } - return mappedHeaders.Keys.Any() ? mappedHeaders : null; + return mappedHeaders.Count > 0 ? mappedHeaders : null; } private IList? MapQueryParameters(IEnumerable queryParameters) diff --git a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj index bbd0d7b4..080a3dc4 100644 --- a/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj +++ b/src/WireMock.Net.OpenApiParser/WireMock.Net.OpenApiParser.csproj @@ -23,12 +23,19 @@ true - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/WireMock.Net.Shared/WireMock.Net.Shared.csproj b/src/WireMock.Net.Shared/WireMock.Net.Shared.csproj index bda537d2..6309f03d 100644 --- a/src/WireMock.Net.Shared/WireMock.Net.Shared.csproj +++ b/src/WireMock.Net.Shared/WireMock.Net.Shared.csproj @@ -26,14 +26,6 @@ true - - - - - @@ -57,4 +49,19 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + \ No newline at end of file diff --git a/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj b/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj index 26bdbbe0..c7a16884 100644 --- a/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj +++ b/src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj @@ -31,14 +31,14 @@ - + diff --git a/test/WireMock.Net.Aspire.Tests/IntegrationTests.cs b/test/WireMock.Net.Aspire.Tests/IntegrationTests.cs index 2a0ab465..55d67bf6 100644 --- a/test/WireMock.Net.Aspire.Tests/IntegrationTests.cs +++ b/test/WireMock.Net.Aspire.Tests/IntegrationTests.cs @@ -4,11 +4,10 @@ using System.Net.Http.Json; using AwesomeAssertions; using Projects; using WireMock.Net.Aspire.Tests.Facts; -using Xunit.Abstractions; namespace WireMock.Net.Aspire.Tests; -public class IntegrationTests(ITestOutputHelper output) +public class IntegrationTests { private record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary);