diff --git a/Directory.Build.props b/Directory.Build.props
index 25aef65d..eb93f374 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -21,10 +21,7 @@
true
true
false
- false
true
- true
- true
@@ -37,6 +34,11 @@
35a561290d20de2f
+
+ $(MeziantouPolyfill_ExcludedPolyfills);M:System.OperatingSystem.
+ $(MeziantouPolyfill_ExcludedPolyfills);T:System.Net.Http.
+
+
$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))
$(ProgramFiles)\dotnet
diff --git a/Directory.Build.targets b/Directory.Build.targets
index dc320ece..6db20806 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -59,12 +59,15 @@
$(DefineConstants);SUPPORTS_AUTHORIZATION_MIDDLEWARE
$(DefineConstants);SUPPORTS_BCL_ASYNC_ENUMERABLE
$(DefineConstants);SUPPORTS_BULK_DBSET_OPERATIONS
+ $(DefineConstants);SUPPORTS_CHUNK_LINQ_EXTENSION
$(DefineConstants);SUPPORTS_DBSET_VALUETASK_FINDASYNC
$(DefineConstants);SUPPORTS_ENDPOINT_ROUTING
$(DefineConstants);SUPPORTS_ENVIRONMENT_PROCESS_PATH
+ $(DefineConstants);SUPPORTS_HEXADECIMAL_STRING_CONVERSION
$(DefineConstants);SUPPORTS_HTTP_CLIENT_DEFAULT_REQUEST_VERSION
$(DefineConstants);SUPPORTS_HTTP_CLIENT_DEFAULT_REQUEST_VERSION_POLICY
$(DefineConstants);SUPPORTS_HTTP_CLIENT_RESILIENCE
+ $(DefineConstants);SUPPORTS_INT32_RANDOM_NUMBER_GENERATOR_METHODS
$(DefineConstants);SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS
$(DefineConstants);SUPPORTS_NAMED_PIPE_STATIC_FACTORY_WITH_ACL
$(DefineConstants);SUPPORTS_ONE_SHOT_HASHING_METHODS
@@ -73,6 +76,7 @@
$(DefineConstants);SUPPORTS_PEM_ENCODED_KEY_IMPORT
$(DefineConstants);SUPPORTS_REDIRECTION_ON_SIGN_IN
$(DefineConstants);SUPPORTS_TEXT_ELEMENT_ENUMERATOR
+ $(DefineConstants);SUPPORTS_VALUETASK_COMPLETED_TASK
$(DefineConstants);SUPPORTS_WINFORMS_TASK_DIALOG
$(DefineConstants);SUPPORTS_ZLIB_COMPRESSION
@@ -155,19 +159,6 @@
$(DefineConstants);SUPPORTS_WINDOWS_RUNTIME
-
-
-
- $(DefineConstants);FeatureRuntimeInformation
-
-
-
-
-
-
-
-
-
diff --git a/Directory.Packages.props b/Directory.Packages.props
index e0efa239..b38e6fba 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -20,39 +20,40 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
diff --git a/README.md b/README.md
index be6da3c6..4c7dbc6d 100644
--- a/README.md
+++ b/README.md
@@ -183,7 +183,7 @@ To reference the OpenIddict MyGet feed, **create a `NuGet.config` file** (at the
-



































+

































--------------
diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
index b3ad01df..abcca956 100644
--- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
+++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs
@@ -79,10 +79,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
{{~ end ~}}
public OpenIddictClientWebIntegrationBuilder Add{{ provider.name }}(Action configuration)
{
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(configuration);
Services.Configure(options =>
{
@@ -132,10 +129,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
[EditorBrowsable(EditorBrowsableState.Advanced)]
public {{ provider.name }} AddClientAuthenticationMethods(params string[] methods)
{
- if (methods is null)
- {
- throw new ArgumentNullException(nameof(methods));
- }
+ ArgumentNullException.ThrowIfNull(methods);
return Set(registration => registration.ClientAuthenticationMethods.UnionWith(methods));
}
@@ -149,10 +143,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
[EditorBrowsable(EditorBrowsableState.Advanced)]
public {{ provider.name }} AddCodeChallengeMethods(params string[] methods)
{
- if (methods is null)
- {
- throw new ArgumentNullException(nameof(methods));
- }
+ ArgumentNullException.ThrowIfNull(methods);
return Set(registration => registration.CodeChallengeMethods.UnionWith(methods));
}
@@ -166,10 +157,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
[EditorBrowsable(EditorBrowsableState.Advanced)]
public {{ provider.name }} AddGrantTypes(params string[] types)
{
- if (types is null)
- {
- throw new ArgumentNullException(nameof(types));
- }
+ ArgumentNullException.ThrowIfNull(types);
return Set(registration => registration.GrantTypes.UnionWith(types));
}
@@ -183,10 +171,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
[EditorBrowsable(EditorBrowsableState.Advanced)]
public {{ provider.name }} AddResponseModes(params string[] modes)
{
- if (modes is null)
- {
- throw new ArgumentNullException(nameof(modes));
- }
+ ArgumentNullException.ThrowIfNull(modes);
return Set(registration => registration.ResponseModes.UnionWith(modes));
}
@@ -200,10 +185,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
[EditorBrowsable(EditorBrowsableState.Advanced)]
public {{ provider.name }} AddResponseTypes(params string[] types)
{
- if (types is null)
- {
- throw new ArgumentNullException(nameof(types));
- }
+ ArgumentNullException.ThrowIfNull(types);
return Set(registration => registration.ResponseTypes.UnionWith(types));
}
@@ -215,10 +197,7 @@ public sealed partial class OpenIddictClientWebIntegrationBuilder
/// The instance.
public {{ provider.name }} AddScopes(params string[] scopes)
{
- if (scopes is null)
- {
- throw new ArgumentNullException(nameof(scopes));
- }
+ ArgumentNullException.ThrowIfNull(scopes);
return Set(registration => registration.Scopes.UnionWith(scopes));
}
diff --git a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs
index 42bf09c7..3a7328c6 100644
--- a/shared/OpenIddict.Extensions/OpenIddictHelpers.cs
+++ b/shared/OpenIddict.Extensions/OpenIddictHelpers.cs
@@ -656,7 +656,7 @@ internal static class OpenIddictHelpers
///
public static byte[] CreateRandomArray(int size)
{
- using var algorithm = GetAlgorithmFromConfig() switch
+ var algorithm = GetAlgorithmFromConfig() switch
{
RandomNumberGenerator result => result,
null => null,
@@ -665,13 +665,35 @@ internal static class OpenIddictHelpers
// If no custom random number generator was registered, use either the static GetBytes() or
// Fill() APIs on platforms that support them or create a default instance provided by the BCL.
+#if SUPPORTS_ONE_SHOT_RANDOM_NUMBER_GENERATOR_METHODS
if (algorithm is null)
{
- return RandomNumberGenerator.GetBytes(size / 8);
- }
+ var array = new byte[size / 8];
+ algorithm.GetBytes(array);
+ return array;
+ }
+#endif
var array = new byte[size / 8];
- algorithm.GetBytes(array);
+
+#if SUPPORTS_STATIC_RANDOM_NUMBER_GENERATOR_METHODS
+ if (algorithm is null)
+ {
+ RandomNumberGenerator.Fill(array);
+ return array;
+ }
+#else
+ algorithm ??= RandomNumberGenerator.Create();
+#endif
+ try
+ {
+ algorithm.GetBytes(array);
+ }
+
+ finally
+ {
+ algorithm.Dispose();
+ }
return array;
@@ -692,30 +714,40 @@ internal static class OpenIddictHelpers
///
public static string CreateRandomString(ReadOnlySpan charset, int count)
{
- using var algorithm = GetAlgorithmFromConfig() switch
+ var algorithm = GetAlgorithmFromConfig() switch
{
RandomNumberGenerator result => result,
null => null,
var result => throw new CryptographicException(SR.FormatID0351(result.GetType().FullName))
};
- var builder = new StringBuilder();
-
- for (var index = 0; index < count; index++)
+ try
{
- // Pick a character in the specified charset by generating a random index.
- builder.Append(charset[index: algorithm switch
+ var builder = new StringBuilder();
+
+ for (var index = 0; index < count; index++)
{
- // If no custom random number generator was registered, use the static GetInt32() API.
- null => RandomNumberGenerator.GetInt32(0, charset.Length),
+ // Pick a character in the specified charset by generating a random index.
+ builder.Append(charset[index: algorithm switch
+ {
+#if SUPPORTS_INT32_RANDOM_NUMBER_GENERATOR_METHODS
+ // If no custom random number generator was registered, use
+ // the static GetInt32() API on platforms that support it.
+ null => RandomNumberGenerator.GetInt32(0, charset.Length),
+#endif
+ // Otherwise, create a default implementation if necessary
+ // and use the local function that achieves the same result.
+ _ => GetInt32(algorithm ??= RandomNumberGenerator.Create(), 0..charset.Length)
+ }]);
+ }
- // Otherwise, create a default implementation if necessary
- // and use the local function that achieves the same result.
- _ => GetInt32(algorithm, 0..charset.Length)
- }]);
+ return builder.ToString();
}
- return builder.ToString();
+ finally
+ {
+ algorithm?.Dispose();
+ }
static int GetInt32(RandomNumberGenerator algorithm, Range range)
{
diff --git a/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs
new file mode 100644
index 00000000..07f12b29
--- /dev/null
+++ b/shared/OpenIddict.Extensions/OpenIddictPolyfills.cs
@@ -0,0 +1,306 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+ * See https://github.com/openiddict/openiddict-core for more information concerning
+ * the license and the contributors participating to this project.
+ */
+
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
+
+namespace OpenIddict.Extensions;
+
+///
+/// Exposes common polyfills used by the OpenIddict assemblies.
+///
+internal static class OpenIddictPolyfills
+{
+ extension(ArgumentOutOfRangeException)
+ {
+ /// Throws an if is negative.
+ /// The argument to validate as non-negative.
+ /// The name of the parameter with which corresponds.
+ public static void ThrowIfNegative(T value, [CallerArgumentExpression(nameof(value))] string? paramName = null)
+ where T : struct, IComparable
+ {
+ switch (value)
+ {
+ case byte or ushort or uint or ulong or char:
+ return;
+ case sbyte n:
+ if (n < 0)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+ case short n:
+ if (n < 0)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+ case int n:
+ if (n < 0)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+ case long n:
+ if (n < 0L)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+
+ case float n:
+ if (n < 0F)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+ case double n:
+ if (n < 0D)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+ case decimal n:
+ if (n < 0M)
+ ThrowArgumentOutOfRangeException(paramName, value);
+ return;
+ default:
+ throw new InvalidOperationException($"Invalid type '{typeof(T).AssemblyQualifiedName}' for {paramName}.");
+ }
+
+ static void ThrowArgumentOutOfRangeException(string? paramName, object value)
+ {
+ throw new ArgumentOutOfRangeException(paramName, value, $"{paramName} ('{value}') must not be negative.");
+ }
+ }
+ }
+
+ extension(Convert)
+ {
+#if !SUPPORTS_HEXADECIMAL_STRING_CONVERSION
+
+ /// Converts the specified string, which encodes binary data as hex characters, to an equivalent 8-bit unsigned integer array.
+ /// The string to convert.
+ /// An array of 8-bit unsigned integers that is equivalent to .
+ /// is null.
+ /// The length of , is not zero or a multiple of 2.
+ /// The format of is invalid. contains a non-hex character.
+ public static byte[] FromHexString(string s)
+ {
+ if ((uint) s.Length % 2 is not 0)
+ {
+ throw new FormatException(SR.GetResourceString(SR.ID0413));
+ }
+
+ var array = new byte[s.Length / 2];
+
+ for (var index = 0; index < s.Length; index += 2)
+ {
+ array[index / 2] = Convert.ToByte(s.Substring(index, 2), 16);
+ }
+
+ return array;
+ }
+#endif
+ }
+
+ extension(IEnumerable source)
+ {
+#if !SUPPORTS_CHUNK_LINQ_EXTENSION
+ ///
+ /// Split the elements of a sequence into chunks of size at most .
+ ///
+ ///
+ /// Every chunk except the last will be of size .
+ /// The last chunk will contain the remaining elements and may be of a smaller size.
+ ///
+ /// Maximum size of each chunk.
+ ///
+ /// An that contains the elements of the input
+ /// sequence split into chunks of size .
+ ///
+ public IEnumerable Chunk(int size)
+ {
+ // Note: this polyfill was directly copied from .NET's source code:
+ // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Linq/src/System/Linq/Chunk.cs.
+
+ using IEnumerator enumerator = source.GetEnumerator();
+
+ if (enumerator.MoveNext())
+ {
+ var count = Math.Min(size, 4);
+ int index;
+
+ do
+ {
+ var array = new TSource[count];
+
+ array[0] = enumerator.Current;
+ index = 1;
+
+ if (size != array.Length)
+ {
+ for (; index < size && enumerator.MoveNext(); index++)
+ {
+ if (index >= array.Length)
+ {
+ count = (int) Math.Min((uint) size, 2 * (uint) array.Length);
+ Array.Resize(ref array, count);
+ }
+
+ array[index] = enumerator.Current;
+ }
+ }
+
+ else
+ {
+ var local = array;
+ Debug.Assert(local.Length == size);
+ for (; (uint) index < (uint) local.Length && enumerator.MoveNext(); index++)
+ {
+ local[index] = enumerator.Current;
+ }
+ }
+
+ if (index != array.Length)
+ {
+ Array.Resize(ref array, index);
+ }
+
+ yield return array;
+ }
+
+ while (index >= size && enumerator.MoveNext());
+ }
+ }
+#endif
+ }
+
+ extension(OperatingSystem)
+ {
+#if !SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON
+ ///
+ /// Indicates whether the current application is running on Android.
+ ///
+ public static bool IsAndroid() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID"));
+
+ ///
+ /// Check for the Android API level (returned by 'ro.build.version.sdk') with a >=
+ /// version comparison. Used to guard APIs that were added in the given Android release.
+ ///
+ public static bool IsAndroidVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
+ => IsAndroid() && IsOSVersionAtLeast(major, minor, build, revision);
+
+ ///
+ /// Indicates whether the current application is running on iOS or MacCatalyst.
+ ///
+ [SupportedOSPlatformGuard("maccatalyst")]
+ public static bool IsIOS() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("IOS"));
+
+ ///
+ /// Check for the iOS/MacCatalyst version (returned by 'libobjc.get_operatingSystemVersion')
+ /// with a >= version comparison. Used to guard APIs that were added in the given iOS release.
+ ///
+ [SupportedOSPlatformGuard("maccatalyst")]
+ public static bool IsIOSVersionAtLeast(int major, int minor = 0, int build = 0)
+ => IsIOS() && IsOSVersionAtLeast(major, minor, build, 0);
+
+ ///
+ /// Indicates whether the current application is running on Linux.
+ ///
+ public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
+
+ ///
+ /// Indicates whether the current application is running on Mac Catalyst.
+ ///
+ public static bool IsMacCatalyst() => RuntimeInformation.IsOSPlatform(OSPlatform.Create("MACCATALYST"));
+
+ ///
+ /// Check for the Mac Catalyst version (iOS version as presented in Apple documentation) with a >=
+ /// version comparison. Used to guard APIs that were added in the given Mac Catalyst release.
+ ///
+ public static bool IsMacCatalystVersionAtLeast(int major, int minor = 0, int build = 0)
+ => IsMacCatalyst() && IsOSVersionAtLeast(major, minor, build, 0);
+
+ ///
+ /// Indicates whether the current application is running on macOS.
+ ///
+ public static bool IsMacOS() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
+
+ ///
+ /// Check for the macOS version (returned by 'libobjc.get_operatingSystemVersion') with a >=
+ /// version comparison. Used to guard APIs that were added in the given macOS release.
+ ///
+ public static bool IsMacOSVersionAtLeast(int major, int minor = 0, int build = 0)
+ => IsMacOS() && IsOSVersionAtLeast(major, minor, build, 0);
+
+ ///
+ /// Indicates whether the current application is running on Windows.
+ ///
+ public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+
+ ///
+ /// Check for the Windows version (returned by 'RtlGetVersion') with a >= version
+ /// comparison. Used to guard APIs that were added in the given Windows release.
+ ///
+ public static bool IsWindowsVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
+ {
+ if (Environment.OSVersion.Platform is PlatformID.Win32NT &&
+ Environment.OSVersion.Version >= new Version(major, minor, build, revision))
+ {
+ return true;
+ }
+
+ // Note: on older versions of .NET, Environment.OSVersion.Version is known to be affected by
+ // the compatibility shims used by Windows 10+ when the application doesn't have a manifest
+ // that explicitly indicates it's compatible with Windows 10 and higher. To avoid that, a
+ // second pass using RuntimeInformation.OSDescription (that calls NtDll.RtlGetVersion() under
+ // the hood) is made. Note: no version is returned on UWP due to the missing Win32 API.
+ return RuntimeInformation.OSDescription.StartsWith("Microsoft Windows ", StringComparison.OrdinalIgnoreCase) &&
+ RuntimeInformation.OSDescription["Microsoft Windows ".Length..] is string value &&
+ Version.TryParse(value, out Version? version) && version >= new Version(major, minor, build, revision);
+ }
+#endif
+ }
+
+ extension(ValueTask)
+ {
+#if !SUPPORTS_VALUETASK_COMPLETED_TASK
+ ///
+ /// Gets a task that has already completed successfully.
+ ///
+ public static ValueTask CompletedTask => default;
+#endif
+ }
+
+ extension(ValueTask)
+ {
+#if !SUPPORTS_VALUETASK_COMPLETED_TASK
+ ///
+ /// Gets a task that has already completed successfully.
+ ///
+ public static ValueTask CompletedTask => default;
+#endif
+ }
+
+#if !SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON
+ static bool IsOSVersionAtLeast(int major, int minor, int build, int revision)
+ {
+ Version current = Environment.OSVersion.Version;
+
+ if (current.Major != major)
+ {
+ return current.Major > major;
+ }
+ if (current.Minor != minor)
+ {
+ return current.Minor > minor;
+ }
+
+ int currentBuild = current.Build < 0 ? 0 : current.Build;
+ build = build < 0 ? 0 : build;
+ if (currentBuild != build)
+ {
+ return currentBuild > build;
+ }
+
+ int currentRevision = current.Revision < 0 ? 0 : current.Revision;
+ revision = revision < 0 ? 0 : revision;
+
+ return currentRevision >= revision;
+ }
+#endif
+}
diff --git a/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj b/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj
index a3cc3048..05fc3fd6 100644
--- a/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj
+++ b/src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj
@@ -38,6 +38,11 @@
+
+
+
+
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs
index cfedce9c..5f64eec8 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinBuilder.cs
@@ -38,10 +38,7 @@ public sealed class OpenIddictClientOwinBuilder
/// The instance.
public OpenIddictClientOwinBuilder Configure(Action configuration)
{
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(configuration);
Services.Configure(configuration);
@@ -137,10 +134,7 @@ public sealed class OpenIddictClientOwinBuilder
/// The instance.
public OpenIddictClientOwinBuilder SetCookieManager(ICookieManager manager)
{
- if (manager is null)
- {
- throw new ArgumentNullException(nameof(manager));
- }
+ ArgumentNullException.ThrowIfNull(manager);
return Configure(options => options.CookieManager = manager);
}
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs
index 1c1ca226..dd09d6d8 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinConfiguration.cs
@@ -30,10 +30,7 @@ public sealed class OpenIddictClientOwinConfiguration : IConfigureOptions
public void Configure(OpenIddictClientOptions options)
{
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
+ ArgumentNullException.ThrowIfNull(options);
// Register the built-in event handlers used by the OpenIddict OWIN Client components.
options.Handlers.AddRange(OpenIddictClientOwinHandlers.DefaultHandlers);
@@ -42,10 +39,7 @@ public sealed class OpenIddictClientOwinConfiguration : IConfigureOptions
public void PostConfigure(string? name, OpenIddictClientOwinOptions options)
{
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
+ ArgumentNullException.ThrowIfNull(options);
// If no cookie manager was explicitly configured but the OWIN application builder was registered as a service
// (which is required when using Autofac with the built-in Katana authentication middleware, as they require
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinExtensions.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinExtensions.cs
index d864568b..0c1992b7 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinExtensions.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinExtensions.cs
@@ -24,10 +24,7 @@ public static class OpenIddictClientOwinExtensions
/// The instance.
public static OpenIddictClientOwinBuilder UseOwin(this OpenIddictClientBuilder builder)
{
- if (builder is null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
+ ArgumentNullException.ThrowIfNull(builder);
builder.Services.AddWebEncoders();
@@ -68,15 +65,8 @@ public static class OpenIddictClientOwinExtensions
public static OpenIddictClientBuilder UseOwin(
this OpenIddictClientBuilder builder, Action configuration)
{
- if (builder is null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(builder);
+ ArgumentNullException.ThrowIfNull(configuration);
configuration(builder.UseOwin());
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlerFilters.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlerFilters.cs
index 4a494c6b..15b7cac7 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlerFilters.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlerFilters.cs
@@ -30,10 +30,7 @@ public static class OpenIddictClientOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnablePostLogoutRedirectionEndpointPassthrough);
}
@@ -53,10 +50,7 @@ public static class OpenIddictClientOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableRedirectionEndpointPassthrough);
}
@@ -75,10 +69,7 @@ public static class OpenIddictClientOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableErrorPassthrough);
}
@@ -92,10 +83,7 @@ public static class OpenIddictClientOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(context.Transaction.GetOwinRequest() is not null);
}
@@ -114,10 +102,7 @@ public static class OpenIddictClientOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(!_options.CurrentValue.DisableTransportSecurityRequirement);
}
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs
index 25f53236..c3c1d529 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs
@@ -5,6 +5,7 @@
*/
using System.Collections.Immutable;
+using Microsoft.Extensions.Options;
using Owin;
namespace OpenIddict.Client.Owin;
@@ -61,10 +62,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ApplyAuthorizationRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs
index 68a935ff..d5e42a83 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs
@@ -59,10 +59,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ApplyEndSessionRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
index cfc18cbd..af9c0d70 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
@@ -92,10 +92,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -146,10 +143,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -196,10 +190,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -242,10 +233,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public async ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -328,10 +316,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
if (context.GrantType is GrantTypes.DeviceCode)
{
@@ -362,10 +347,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
if (!string.IsNullOrEmpty(context.Nonce))
{
@@ -403,10 +385,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.StateTokenPrincipal is { Identity: ClaimsIdentity }, SR.GetResourceString(SR.ID4006));
@@ -529,10 +508,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
if (context.GrantType is GrantTypes.DeviceCode)
{
@@ -564,10 +540,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -687,10 +660,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -726,10 +696,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// If an explicit response type was specified, don't overwrite it.
if (!string.IsNullOrEmpty(context.ResponseMode))
@@ -826,10 +793,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// Note: using a correlation cookie serves as an injection/antiforgery protection as the request
// will always be rejected if a cookie corresponding to the request forgery protection claim
@@ -920,10 +884,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessSignOutContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1033,10 +994,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessSignOutContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1079,10 +1037,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(ProcessSignOutContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// Note: using a correlation cookie serves as an injection/antiforgery protection as the request
// will always be rejected if a cookie corresponding to the request forgery protection claim
@@ -1175,10 +1130,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
context.SkipRequest();
@@ -1206,10 +1158,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1249,10 +1198,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1302,10 +1248,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1369,10 +1312,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1413,10 +1353,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -1452,10 +1389,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public async ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If the HTTP context cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1526,10 +1460,7 @@ public static partial class OpenIddictClientOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
context.Logger.LogInformation(6145, SR.GetResourceString(SR.ID6145));
context.HandleRequest();
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHelpers.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHelpers.cs
index 45dbb571..4bb75548 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinHelpers.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinHelpers.cs
@@ -4,6 +4,7 @@
* the license and the contributors participating to this project.
*/
+using Microsoft.Extensions.Options;
using OpenIddict.Client;
using OpenIddict.Client.Owin;
@@ -23,10 +24,7 @@ public static class OpenIddictClientOwinHelpers
/// The instance.
public static IAppBuilder UseOpenIddictClient(this IAppBuilder app)
{
- if (app is null)
- {
- throw new ArgumentNullException(nameof(app));
- }
+ ArgumentNullException.ThrowIfNull(app);
return app.Use();
}
@@ -38,10 +36,7 @@ public static class OpenIddictClientOwinHelpers
/// The instance or if it couldn't be found.
public static IOwinRequest? GetOwinRequest(this OpenIddictClientTransaction transaction)
{
- if (transaction is null)
- {
- throw new ArgumentNullException(nameof(transaction));
- }
+ ArgumentNullException.ThrowIfNull(transaction);
if (!transaction.Properties.TryGetValue(typeof(IOwinRequest).FullName!, out object? property))
{
@@ -63,10 +58,7 @@ public static class OpenIddictClientOwinHelpers
/// The .
public static OpenIddictClientEndpointType GetOpenIddictClientEndpointType(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictClientTransaction).FullName)?.EndpointType ?? default;
}
@@ -78,10 +70,7 @@ public static class OpenIddictClientOwinHelpers
/// The instance or if it couldn't be found.
public static OpenIddictRequest? GetOpenIddictClientRequest(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictClientTransaction).FullName)?.Request;
}
@@ -93,10 +82,7 @@ public static class OpenIddictClientOwinHelpers
/// The instance or if it couldn't be found.
public static OpenIddictResponse? GetOpenIddictClientResponse(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictClientTransaction).FullName)?.Response;
}
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddleware.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddleware.cs
index fa41471b..a7276307 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddleware.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddleware.cs
@@ -58,6 +58,8 @@ public sealed class OpenIddictClientOwinMiddleware : AuthenticationMiddleware
public override async Task Invoke(IOwinContext context)
{
+ ArgumentNullException.ThrowIfNull(context);
+
// Retrieve the existing authentication delegate.
var function = context.Get("security.Authenticate");
diff --git a/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddlewareFactory.cs b/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddlewareFactory.cs
index d843f33d..8fb1e11f 100644
--- a/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddlewareFactory.cs
+++ b/src/OpenIddict.Client.Owin/OpenIddictClientOwinMiddlewareFactory.cs
@@ -37,10 +37,7 @@ public sealed class OpenIddictClientOwinMiddlewareFactory : OwinMiddleware
///
public override Task Invoke(IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var provider = context.Get(typeof(IServiceProvider).FullName) ??
throw new InvalidOperationException(SR.GetResourceString(SR.ID0316));
diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj b/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj
index 7c8cc5ca..1aa3a77d 100644
--- a/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj
+++ b/src/OpenIddict.Client.SystemIntegration/OpenIddict.Client.SystemIntegration.csproj
@@ -30,7 +30,7 @@
allow loading dependencies that are not strong-named), the warning can be safely disabled.
-->
$(NoWarn);CS8002
- $(DefineConstants);FeatureRuntimeInformation;FeatureValueTuple
+ $(DefineConstants);FeatureValueTuple
diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs
index ed274d2d..83c6fd8a 100644
--- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs
+++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationConfiguration.cs
@@ -62,12 +62,9 @@ public sealed class OpenIddictClientSystemIntegrationConfiguration : IConfigureO
ArgumentNullException.ThrowIfNull(options);
// Ensure the operating system version is supported.
- if ((OperatingSystem.IsAndroid() && !OperatingSystem.IsAndroidVersionAtLeast(21)) ||
- (OperatingSystem.IsIOS() && !OperatingSystem.IsIOSVersionAtLeast(12)) ||
- OperatingSystem.IsLinux() ||
- (OperatingSystem.IsMacCatalyst() && !OperatingSystem.IsMacCatalystVersionAtLeast(13, 1)) ||
- (OperatingSystem.IsMacOS() && !OperatingSystem.IsMacOSVersionAtLeast(10, 15)) ||
- (OperatingSystem.IsWindows() && !OperatingSystem.IsWindowsVersionAtLeast(7)))
+ if (!OperatingSystem.IsAndroidVersionAtLeast(21) && !OperatingSystem.IsIOSVersionAtLeast(12) &&
+ !OperatingSystem.IsLinux() && !OperatingSystem.IsMacCatalystVersionAtLeast(13, 1) &&
+ !OperatingSystem.IsMacOSVersionAtLeast(10, 15) && !OperatingSystem.IsWindowsVersionAtLeast(7))
{
throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0389));
}
diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs
index 31f6d5c1..02a364bc 100644
--- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs
+++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationExtensions.cs
@@ -28,12 +28,9 @@ public static class OpenIddictClientSystemIntegrationExtensions
ArgumentNullException.ThrowIfNull(builder);
// Ensure the operating system version is supported.
- if ((OperatingSystem.IsAndroid() && !OperatingSystem.IsAndroidVersionAtLeast(21)) ||
- (OperatingSystem.IsIOS() && !OperatingSystem.IsIOSVersionAtLeast(12)) ||
- OperatingSystem.IsLinux() ||
- (OperatingSystem.IsMacCatalyst() && !OperatingSystem.IsMacCatalystVersionAtLeast(13, 1)) ||
- (OperatingSystem.IsMacOS() && !OperatingSystem.IsMacOSVersionAtLeast(10, 15)) ||
- (OperatingSystem.IsWindows() && !OperatingSystem.IsWindowsVersionAtLeast(7)))
+ if (!OperatingSystem.IsAndroidVersionAtLeast(21) && !OperatingSystem.IsIOSVersionAtLeast(12) &&
+ !OperatingSystem.IsLinux() && !OperatingSystem.IsMacCatalystVersionAtLeast(13, 1) &&
+ !OperatingSystem.IsMacOSVersionAtLeast(10, 15) && !OperatingSystem.IsWindowsVersionAtLeast(7))
{
throw new PlatformNotSupportedException(SR.GetResourceString(SR.ID0389));
}
diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs
index 9ff291fe..079c8ee1 100644
--- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs
+++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHelpers.cs
@@ -77,7 +77,7 @@ public static class OpenIddictClientSystemIntegrationHelpers
[SupportedOSPlatformGuard("maccatalyst13.1")]
[SupportedOSPlatformGuard("macos10.15")]
internal static bool IsASWebAuthenticationSessionSupported()
-#if SUPPORTS_AUTHENTICATION_SERVICES && SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON
+#if SUPPORTS_AUTHENTICATION_SERVICES
=> OperatingSystem.IsIOSVersionAtLeast(12) ||
OperatingSystem.IsMacCatalystVersionAtLeast(13) ||
OperatingSystem.IsMacOSVersionAtLeast(10, 15);
@@ -92,7 +92,7 @@ public static class OpenIddictClientSystemIntegrationHelpers
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[SupportedOSPlatformGuard("android21.0")]
internal static bool IsCustomTabsIntentSupported()
-#if SUPPORTS_ANDROIDX_BROWSER && SUPPORTS_OPERATING_SYSTEM_VERSIONS_COMPARISON
+#if SUPPORTS_ANDROIDX_BROWSER
=> OperatingSystem.IsAndroidVersionAtLeast(21);
#else
=> false;
diff --git a/src/OpenIddict.Client.SystemNetHttp/OpenIddict.Client.SystemNetHttp.csproj b/src/OpenIddict.Client.SystemNetHttp/OpenIddict.Client.SystemNetHttp.csproj
index ea267002..968b12e7 100644
--- a/src/OpenIddict.Client.SystemNetHttp/OpenIddict.Client.SystemNetHttp.csproj
+++ b/src/OpenIddict.Client.SystemNetHttp/OpenIddict.Client.SystemNetHttp.csproj
@@ -6,7 +6,6 @@
$(NetCoreTargetFrameworks);
$(NetStandardTargetFrameworks)
- $(DefineConstants);FeatureRuntimeInformation
diff --git a/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs b/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs
index 7b380cc9..7f328ce8 100644
--- a/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs
+++ b/src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs
@@ -142,7 +142,7 @@ public sealed class OpenIddictClientHandlerDescriptor
/// The builder instance, so that calls can be easily chained.
public Builder SetType(OpenIddictClientHandlerType type)
{
- if (!Enum.IsDefined(typeof(OpenIddictClientHandlerType), type))
+ if (!Enum.IsDefined(type))
{
throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(OpenIddictClientHandlerType));
}
diff --git a/src/OpenIddict.Client/OpenIddictClientModels.cs b/src/OpenIddict.Client/OpenIddictClientModels.cs
index 0a6fc86d..3132e9e8 100644
--- a/src/OpenIddict.Client/OpenIddictClientModels.cs
+++ b/src/OpenIddict.Client/OpenIddictClientModels.cs
@@ -26,7 +26,7 @@ public static class OpenIddictClientModels
public CancellationToken CancellationToken { get; init; }
///
- /// Gets or sets the nonce that was returned during the challenge operation.
+ /// Gets or sets the nonce that was returned during the challenge or sign-out operation.
///
public required string Nonce { get; init; }
diff --git a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
index 7c5d6bfa..2b35cf8b 100644
--- a/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
+++ b/src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
@@ -849,7 +849,7 @@ public class OpenIddictScopeManager : IOpenIddictScopeManager where TSco
yield return new ValidationResult(SR.GetResourceString(SR.ID2044));
}
- else if (name!.Contains(Separators.Space[0]))
+ else if (name.Contains(Separators.Space[0]))
{
yield return new ValidationResult(SR.GetResourceString(SR.ID2045));
}
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs
index cc83a7ec..8b36a12b 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinBuilder.cs
@@ -37,10 +37,7 @@ public sealed class OpenIddictServerOwinBuilder
/// The instance.
public OpenIddictServerOwinBuilder Configure(Action configuration)
{
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(configuration);
Services.Configure(configuration);
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs
index 73a13881..ae00aa30 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinConfiguration.cs
@@ -19,10 +19,7 @@ public sealed class OpenIddictServerOwinConfiguration : IConfigureOptions
public void Configure(OpenIddictServerOptions options)
{
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
+ ArgumentNullException.ThrowIfNull(options);
// Register the built-in event handlers used by the OpenIddict OWIN server components.
options.Handlers.AddRange(OpenIddictServerOwinHandlers.DefaultHandlers);
@@ -34,10 +31,7 @@ public sealed class OpenIddictServerOwinConfiguration : IConfigureOptions
public void PostConfigure(string? name, OpenIddictServerOwinOptions options)
{
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
+ ArgumentNullException.ThrowIfNull(options);
if (options.AuthenticationMode is AuthenticationMode.Active)
{
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs
index 996dbe58..72fa200b 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinExtensions.cs
@@ -24,10 +24,7 @@ public static class OpenIddictServerOwinExtensions
/// The instance.
public static OpenIddictServerOwinBuilder UseOwin(this OpenIddictServerBuilder builder)
{
- if (builder is null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
+ ArgumentNullException.ThrowIfNull(builder);
builder.Services.AddWebEncoders();
@@ -71,15 +68,8 @@ public static class OpenIddictServerOwinExtensions
public static OpenIddictServerBuilder UseOwin(
this OpenIddictServerBuilder builder, Action configuration)
{
- if (builder is null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(builder);
+ ArgumentNullException.ThrowIfNull(configuration);
configuration(builder.UseOwin());
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs
index c7c865f9..3b1193ea 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlerFilters.cs
@@ -28,10 +28,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableAuthorizationEndpointPassthrough);
}
@@ -51,10 +48,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableEndSessionEndpointPassthrough);
}
@@ -73,10 +67,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableErrorPassthrough);
}
@@ -90,10 +81,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(context.Transaction.GetOwinRequest() is not null);
}
@@ -112,10 +100,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(!_options.CurrentValue.DisableTransportSecurityRequirement);
}
@@ -135,10 +120,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableTokenEndpointPassthrough);
}
@@ -158,10 +140,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableUserInfoEndpointPassthrough);
}
@@ -181,10 +160,7 @@ public static class OpenIddictServerOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(_options.CurrentValue.EnableEndUserVerificationEndpointPassthrough);
}
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs
index 3dbd3993..0ce2d6ac 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs
@@ -81,10 +81,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyAuthorizationResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
if (context is not { BaseUri.IsAbsoluteUri: true, RequestUri.IsAbsoluteUri: true })
{
@@ -145,10 +142,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public async ValueTask HandleAsync(ApplyAuthorizationResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -231,10 +225,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyAuthorizationResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -292,10 +283,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyAuthorizationResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs
index d6f45fc8..a4b99066 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs
@@ -77,10 +77,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyEndUserVerificationResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
index 2a1fcc52..57071039 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
@@ -61,10 +61,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyEndSessionResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
if (context is not { BaseUri.IsAbsoluteUri: true, RequestUri.IsAbsoluteUri: true })
{
@@ -119,10 +116,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyEndSessionResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -179,10 +173,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ApplyEndSessionResponseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
index f03b96cb..ea560cc8 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
@@ -78,10 +78,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -132,10 +129,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -177,10 +171,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -224,10 +215,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!);
if (properties is not { Dictionary.Count: > 0 })
@@ -302,10 +290,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!);
if (properties is not null)
@@ -344,10 +329,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessSignInContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!);
if (properties is not { Dictionary.Count: > 0 })
@@ -423,10 +405,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(ProcessSignOutContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!);
if (properties is not { Dictionary.Count: > 0 })
@@ -501,10 +480,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -555,10 +531,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public async ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -641,10 +614,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public async ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -720,10 +690,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID4008));
@@ -786,10 +753,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID4008));
@@ -885,10 +849,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Request is not null, SR.GetResourceString(SR.ID4008));
@@ -933,10 +894,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
switch (context.EndpointType)
{
@@ -983,10 +941,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -1049,10 +1004,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1102,10 +1054,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1169,10 +1118,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1213,10 +1159,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -1330,10 +1273,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -1378,10 +1318,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public async ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -1437,10 +1374,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -1479,10 +1413,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public async ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -1553,10 +1484,7 @@ public static partial class OpenIddictServerOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
context.Logger.LogInformation(6145, SR.GetResourceString(SR.ID6145));
context.HandleRequest();
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs
index 24389ecb..8682ce96 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinHelpers.cs
@@ -23,10 +23,7 @@ public static class OpenIddictServerOwinHelpers
/// The instance.
public static IAppBuilder UseOpenIddictServer(this IAppBuilder app)
{
- if (app is null)
- {
- throw new ArgumentNullException(nameof(app));
- }
+ ArgumentNullException.ThrowIfNull(app);
return app.Use();
}
@@ -38,10 +35,7 @@ public static class OpenIddictServerOwinHelpers
/// The instance or if it couldn't be found.
public static IOwinRequest? GetOwinRequest(this OpenIddictServerTransaction transaction)
{
- if (transaction is null)
- {
- throw new ArgumentNullException(nameof(transaction));
- }
+ ArgumentNullException.ThrowIfNull(transaction);
if (!transaction.Properties.TryGetValue(typeof(IOwinRequest).FullName!, out object? property))
{
@@ -63,10 +57,7 @@ public static class OpenIddictServerOwinHelpers
/// The .
public static OpenIddictServerEndpointType GetOpenIddictServerEndpointType(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictServerTransaction).FullName)?.EndpointType ?? default;
}
@@ -78,10 +69,7 @@ public static class OpenIddictServerOwinHelpers
/// The instance or null if it couldn't be found.
public static OpenIddictRequest? GetOpenIddictServerRequest(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictServerTransaction).FullName)?.Request;
}
@@ -93,10 +81,7 @@ public static class OpenIddictServerOwinHelpers
/// The instance or null if it couldn't be found.
public static OpenIddictResponse? GetOpenIddictServerResponse(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictServerTransaction).FullName)?.Response;
}
diff --git a/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs b/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs
index 54211ae3..547b1e89 100644
--- a/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs
+++ b/src/OpenIddict.Server.Owin/OpenIddictServerOwinMiddlewareFactory.cs
@@ -37,10 +37,7 @@ public sealed class OpenIddictServerOwinMiddlewareFactory : OwinMiddleware
///
public override Task Invoke(IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var provider = context.Get(typeof(IServiceProvider).FullName) ??
throw new InvalidOperationException(SR.GetResourceString(SR.ID0121));
diff --git a/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs b/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs
index 8a8ad74b..7cbc3ee0 100644
--- a/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs
+++ b/src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs
@@ -142,7 +142,7 @@ public sealed class OpenIddictServerHandlerDescriptor
/// The builder instance, so that calls can be easily chained.
public Builder SetType(OpenIddictServerHandlerType type)
{
- if (!Enum.IsDefined(typeof(OpenIddictServerHandlerType), type))
+ if (!Enum.IsDefined(type))
{
throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(OpenIddictServerHandlerType));
}
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs
index 2aa3190d..e9adf4cb 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinBuilder.cs
@@ -36,10 +36,7 @@ public sealed class OpenIddictValidationOwinBuilder
/// The instance.
public OpenIddictValidationOwinBuilder Configure(Action configuration)
{
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(configuration);
Services.Configure(configuration);
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs
index e2c7365a..804276fb 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinConfiguration.cs
@@ -18,10 +18,7 @@ public sealed class OpenIddictValidationOwinConfiguration : IConfigureOptions
public void Configure(OpenIddictValidationOptions options)
{
- if (options is null)
- {
- throw new ArgumentNullException(nameof(options));
- }
+ ArgumentNullException.ThrowIfNull(options);
// Register the built-in event handlers used by the OpenIddict OWIN validation components.
options.Handlers.AddRange(OpenIddictValidationOwinHandlers.DefaultHandlers);
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs
index 54ed03b1..e330061f 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinExtensions.cs
@@ -24,10 +24,7 @@ public static class OpenIddictValidationOwinExtensions
/// The instance.
public static OpenIddictValidationOwinBuilder UseOwin(this OpenIddictValidationBuilder builder)
{
- if (builder is null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
+ ArgumentNullException.ThrowIfNull(builder);
// Note: unlike regular OWIN middleware, the OpenIddict validation middleware is registered
// as a scoped service in the DI container. This allows containers that support middleware
@@ -62,15 +59,8 @@ public static class OpenIddictValidationOwinExtensions
public static OpenIddictValidationBuilder UseOwin(
this OpenIddictValidationBuilder builder, Action configuration)
{
- if (builder is null)
- {
- throw new ArgumentNullException(nameof(builder));
- }
-
- if (configuration is null)
- {
- throw new ArgumentNullException(nameof(configuration));
- }
+ ArgumentNullException.ThrowIfNull(builder);
+ ArgumentNullException.ThrowIfNull(configuration);
configuration(builder.UseOwin());
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs
index d1ddfd16..9d9a8487 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlerFilters.cs
@@ -28,10 +28,7 @@ public static class OpenIddictValidationOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(!_options.CurrentValue.DisableAccessTokenExtractionFromAuthorizationHeader);
}
@@ -51,10 +48,7 @@ public static class OpenIddictValidationOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(!_options.CurrentValue.DisableAccessTokenExtractionFromBodyForm);
}
@@ -74,10 +68,7 @@ public static class OpenIddictValidationOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(!_options.CurrentValue.DisableAccessTokenExtractionFromQueryString);
}
@@ -91,10 +82,7 @@ public static class OpenIddictValidationOwinHandlerFilters
///
public ValueTask IsActiveAsync(BaseContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return new(context.Transaction.GetOwinRequest() is not null);
}
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs
index 982d0579..ff446be6 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs
@@ -80,10 +80,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(ProcessRequestContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -133,10 +130,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -180,10 +174,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// If a token was already resolved, don't overwrite it.
if (!string.IsNullOrEmpty(context.AccessToken))
@@ -232,10 +223,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public async ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// If a token was already resolved, don't overwrite it.
if (!string.IsNullOrEmpty(context.AccessToken))
@@ -289,10 +277,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(ProcessAuthenticationContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// If a token was already resolved, don't overwrite it.
if (!string.IsNullOrEmpty(context.AccessToken))
@@ -340,10 +325,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!);
if (properties is not { Dictionary.Count: > 0 })
@@ -418,10 +400,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(ProcessChallengeContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var properties = context.Transaction.GetProperty(typeof(AuthenticationProperties).FullName!);
if (properties is not null)
@@ -459,10 +438,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -509,10 +485,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -562,10 +535,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -629,10 +599,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
@@ -673,10 +640,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
Debug.Assert(context.Transaction.Response is not null, SR.GetResourceString(SR.ID4007));
@@ -772,10 +736,7 @@ public static partial class OpenIddictValidationOwinHandlers
///
public ValueTask HandleAsync(TContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
// This handler only applies to OWIN requests. If The OWIN request cannot be resolved,
// this may indicate that the request was incorrectly processed by another server stack.
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs
index bfe25fcb..89c883e4 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHelpers.cs
@@ -23,10 +23,7 @@ public static class OpenIddictValidationOwinHelpers
/// The instance.
public static IAppBuilder UseOpenIddictValidation(this IAppBuilder app)
{
- if (app is null)
- {
- throw new ArgumentNullException(nameof(app));
- }
+ ArgumentNullException.ThrowIfNull(app);
return app.Use();
}
@@ -38,10 +35,7 @@ public static class OpenIddictValidationOwinHelpers
/// The instance or if it couldn't be found.
public static IOwinRequest? GetOwinRequest(this OpenIddictValidationTransaction transaction)
{
- if (transaction is null)
- {
- throw new ArgumentNullException(nameof(transaction));
- }
+ ArgumentNullException.ThrowIfNull(transaction);
if (!transaction.Properties.TryGetValue(typeof(IOwinRequest).FullName!, out object? property))
{
@@ -63,10 +57,7 @@ public static class OpenIddictValidationOwinHelpers
/// The .
public static OpenIddictValidationEndpointType GetOpenIddictValidationEndpointType(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictValidationTransaction).FullName)?.EndpointType ?? default;
}
@@ -78,10 +69,7 @@ public static class OpenIddictValidationOwinHelpers
/// The instance or null if it couldn't be found.
public static OpenIddictRequest? GetOpenIddictValidationRequest(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictValidationTransaction).FullName)?.Request;
}
@@ -93,10 +81,7 @@ public static class OpenIddictValidationOwinHelpers
/// The instance or null if it couldn't be found.
public static OpenIddictResponse? GetOpenIddictValidationResponse(this IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
return context.Get(typeof(OpenIddictValidationTransaction).FullName)?.Response;
}
diff --git a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs
index d1483332..a2d1c841 100644
--- a/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs
+++ b/src/OpenIddict.Validation.Owin/OpenIddictValidationOwinMiddlewareFactory.cs
@@ -37,10 +37,7 @@ public sealed class OpenIddictValidationOwinMiddlewareFactory : OwinMiddleware
///
public override Task Invoke(IOwinContext context)
{
- if (context is null)
- {
- throw new ArgumentNullException(nameof(context));
- }
+ ArgumentNullException.ThrowIfNull(context);
var provider = context.Get(typeof(IServiceProvider).FullName) ??
throw new InvalidOperationException(SR.GetResourceString(SR.ID0168));
diff --git a/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj b/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj
index 5ed8891f..3b2fcfcb 100644
--- a/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj
+++ b/src/OpenIddict.Validation.SystemNetHttp/OpenIddict.Validation.SystemNetHttp.csproj
@@ -6,7 +6,6 @@
$(NetCoreTargetFrameworks);
$(NetStandardTargetFrameworks)
- $(DefineConstants);FeatureRuntimeInformation
diff --git a/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs b/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs
index 23718380..98be205b 100644
--- a/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs
+++ b/src/OpenIddict.Validation/OpenIddictValidationHandlerDescriptor.cs
@@ -142,7 +142,7 @@ public sealed class OpenIddictValidationHandlerDescriptor
/// The builder instance, so that calls can be easily chained.
public Builder SetType(OpenIddictValidationHandlerType type)
{
- if (!Enum.IsDefined(typeof(OpenIddictValidationHandlerType), type))
+ if (!Enum.IsDefined(type))
{
throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(OpenIddictValidationHandlerType));
}