From 98e6575345d1cfad7a25d56ef25b24937f47a2ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 21 Jul 2026 16:26:17 +0200 Subject: [PATCH] Remove unnecessary preprocessor directives in the EF Core stores --- .../OpenIddictEntityFrameworkCoreBuilder.cs | 3 +-- ...penIddictEntityFrameworkCoreApplicationStore.cs | 14 ++------------ ...nIddictEntityFrameworkCoreAuthorizationStore.cs | 14 ++------------ .../OpenIddictEntityFrameworkCoreResourceStore.cs | 14 ++------------ .../OpenIddictEntityFrameworkCoreScopeStore.cs | 14 ++------------ .../OpenIddictEntityFrameworkCoreTokenStore.cs | 14 ++------------ 6 files changed, 11 insertions(+), 62 deletions(-) diff --git a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs index 65dd6e6e..a24b3799 100644 --- a/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs +++ b/src/OpenIddict.EntityFrameworkCore/OpenIddictEntityFrameworkCoreBuilder.cs @@ -100,7 +100,6 @@ public sealed class OpenIddictEntityFrameworkCoreBuilder where TToken : OpenIddictEntityFrameworkCoreToken where TKey : notnull, IEquatable { -#if NET // If the specified key type isn't a string (which is special-cased by the stores to avoid having to resolve // a TypeDescriptor instance) and the platform supports type registration, register the key type to ensure the // TypeDescriptor associated with that type will be preserved by the IL Linker and can be resolved at runtime. @@ -108,7 +107,7 @@ public sealed class OpenIddictEntityFrameworkCoreBuilder { TypeDescriptor.RegisterType(); } -#endif + Services.Replace(ServiceDescriptor.Scoped(static provider => provider.GetRequiredService>())); Services.Replace(ServiceDescriptor.Scoped(static provider => diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs index 74000097..49de4576 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs @@ -1151,12 +1151,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return (TKey?) converter.ConvertFromInvariantString(identifier); } @@ -1182,12 +1177,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return converter.ConvertToInvariantString(identifier); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs index 26bd043b..22ea424d 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs @@ -1086,12 +1086,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return (TKey?) converter.ConvertFromInvariantString(identifier); } @@ -1117,12 +1112,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return converter.ConvertToInvariantString(identifier); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs index ae9710e1..3294f0f2 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreResourceStore.cs @@ -605,12 +605,7 @@ public class OpenIddictEntityFrameworkCoreResourceStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return (TKey?) converter.ConvertFromInvariantString(identifier); } @@ -636,12 +631,7 @@ public class OpenIddictEntityFrameworkCoreResourceStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return converter.ConvertToInvariantString(identifier); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs index b5e907d3..80593c3e 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs @@ -709,12 +709,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return (TKey?) converter.ConvertFromInvariantString(identifier); } @@ -740,12 +735,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return converter.ConvertToInvariantString(identifier); } diff --git a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs index 5297ec21..d21d45df 100644 --- a/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs +++ b/src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreTokenStore.cs @@ -1199,12 +1199,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return (TKey?) converter.ConvertFromInvariantString(identifier); } @@ -1230,12 +1225,7 @@ public class OpenIddictEntityFrameworkCoreTokenStore< else { - var converter = -#if NET - TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); -#else - TypeDescriptor.GetConverter(typeof(TKey)); -#endif + var converter = TypeDescriptor.GetConverterFromRegisteredType(typeof(TKey)); return converter.ConvertToInvariantString(identifier); }