cleanup some #if for NETSTANDARD1_3

This commit is contained in:
Stef Heyenrath
2025-08-31 11:07:25 +02:00
parent 5c221ff4fa
commit bb561c94d0
17 changed files with 67 additions and 65 deletions

View File

@@ -1,6 +1,6 @@
// Copyright © WireMock.Net
#if !NETSTANDARD1_3
//#if !NETSTANDARD1_3
using System;
using System.Diagnostics.CodeAnalysis;
using System.IdentityModel.Tokens.Jwt;
@@ -112,4 +112,4 @@ internal class AzureADAuthenticationMatcher : IStringMatcher
return false;
}
}
#endif
//#endif

View File

@@ -1,6 +1,6 @@
// Copyright © WireMock.Net
#if NET451 || NET452 || NET46 || NET461 || NET48 || NETSTANDARD1_3 || NETSTANDARD2_0
#if NET48
using System.Text.RegularExpressions;
using WireMock.Constants;

View File

@@ -56,10 +56,10 @@ internal static class HttpClientBuilder
}
}
#if !NETSTANDARD1_3
//#if !NETSTANDARD1_3
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = (message, cert, chain, errors) => true;
#endif
//#endif
return HttpClientFactory2.Create(handler);
}

View File

@@ -11,9 +11,9 @@ using WireMock.Models;
using Stef.Validation;
using WireMock.Admin.Mappings;
using WireMock.Util;
#if !NETSTANDARD1_3
//#if !NETSTANDARD1_3
using Wmhelp.XPath2;
#endif
//#endif
namespace WireMock.Matchers;
@@ -151,18 +151,18 @@ public class XPathMatcher : IStringMatcher
var xmlNamespaceManager = GetXmlNamespaceManager(xmlNamespaceMap);
if (xmlNamespaceManager == null)
{
#if NETSTANDARD1_3
return navigator.Evaluate(xpath);
#else
//#if NETSTANDARD1_3
//return navigator.Evaluate(xpath);
//#else
return navigator.XPath2Evaluate(xpath);
#endif
//#endif
}
#if NETSTANDARD1_3
return navigator.Evaluate(xpath, xmlNamespaceManager);
#else
//#if NETSTANDARD1_3
//return navigator.Evaluate(xpath, xmlNamespaceManager);
//#else
return navigator.XPath2Evaluate(xpath, xmlNamespaceManager);
#endif
//#endif
}
private XmlNamespaceManager? GetXmlNamespaceManager(IEnumerable<XmlNamespace>? xmlNamespaceMap)

View File

@@ -136,17 +136,17 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
#if NET8_0
_logger.Info("Server using .NET 8.0");
#elif NET48
_logger.Info("Server using .NET Framework 4.6.1 or higher");
_logger.Info("Server using .NET Framework 4.8");
#endif
#if NETSTANDARD1_3
return Task.Run(() =>
{
_host.Run(token);
});
#else
//#if NETSTANDARD1_3
// return Task.Run(() =>
// {
// _host.Run(token);
// });
//#else
return _host.RunAsync(token);
#endif
//#endif
}
catch (Exception e)
{

View File

@@ -541,15 +541,15 @@ 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
//#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<Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfiguration>($"https://login.microsoftonline.com/{tenant}/.well-known/openid-configuration", new Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever()),
tenant,
audience);
#endif
//#endif
}
/// <inheritdoc cref="IWireMockServer.SetBasicAuthentication(string, string)" />

View File

@@ -24,7 +24,7 @@ internal static class WireMockHandlebarsHelpers
GetBaseDirectory(),
};
#if !NETSTANDARD1_3_OR_GREATER
//#if !NETSTANDARD1_3_OR_GREATER
void Add(string? path, ICollection<string> customHelperPaths)
{
if (!string.IsNullOrEmpty(path))
@@ -36,7 +36,7 @@ internal static class WireMockHandlebarsHelpers
Add(Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location), paths);
Add(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), paths);
Add(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName), paths);
#endif
//#endif
o.CustomHelperPaths = paths;
o.CustomHelpers = new Dictionary<string, IHelpers>();
@@ -49,7 +49,7 @@ internal static class WireMockHandlebarsHelpers
private static string GetBaseDirectory()
{
#if NETSTANDARD1_3_OR_GREATER || NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
return AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar);
#else
return AppDomain.CurrentDomain.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar);

View File

@@ -18,12 +18,12 @@ internal static class CultureInfoUtils
try
{
#if !NETSTANDARD1_3
//#if !NETSTANDARD1_3
if (int.TryParse(value, out var culture))
{
return new CultureInfo(culture);
}
#endif
//#endif
if (string.Equals(value, nameof(CultureInfo.CurrentCulture), StringComparison.OrdinalIgnoreCase))
{
return CultureInfo.CurrentCulture;

View File

@@ -37,9 +37,9 @@ internal static class PortUtils
}
finally
{
#if !NETSTANDARD1_3
//#if !NETSTANDARD1_3
portSocket.Close();
#endif
//#endif
portSocket.Dispose();
}
}
@@ -75,9 +75,9 @@ internal static class PortUtils
{
foreach (var socket in sockets)
{
#if !NETSTANDARD1_3
//#if !NETSTANDARD1_3
socket.Close();
#endif
//#endif
socket.Dispose();
}
}