diff --git a/src/OpenFeature/Api.cs b/src/OpenFeature/Api.cs
index 8d0e22f5..440242da 100644
--- a/src/OpenFeature/Api.cs
+++ b/src/OpenFeature/Api.cs
@@ -127,7 +127,26 @@ public FeatureClient GetClient(string name = null, string version = null, ILogge
///
///
/// A list of
- public void AddHooks(IEnumerable hooks) => this._hooks.PushRange(hooks.ToArray());
+ public void AddHooks(IEnumerable hooks)
+#if NET7_0_OR_GREATER
+ => this._hooks.PushRange(hooks as Hook[] ?? hooks.ToArray());
+#else
+ {
+ // See: https://github.com/dotnet/runtime/issues/62121
+ if (hooks is Hook[] array)
+ {
+ if (array.Length > 0)
+ this._hooks.PushRange(array);
+
+ return;
+ }
+
+ array = hooks.ToArray();
+
+ if (array.Length > 0)
+ this._hooks.PushRange(array);
+ }
+#endif
///
/// Adds a hook to global hooks list
diff --git a/src/OpenFeature/OpenFeatureClient.cs b/src/OpenFeature/OpenFeatureClient.cs
index 9ea9b13a..d979dae1 100644
--- a/src/OpenFeature/OpenFeatureClient.cs
+++ b/src/OpenFeature/OpenFeatureClient.cs
@@ -106,7 +106,26 @@ public void RemoveHandler(ProviderEventTypes type, EventHandlerDelegate handler)
}
///
- public void AddHooks(IEnumerable hooks) => this._hooks.PushRange(hooks.ToArray());
+ public void AddHooks(IEnumerable hooks)
+#if NET7_0_OR_GREATER
+ => this._hooks.PushRange(hooks as Hook[] ?? hooks.ToArray());
+#else
+ {
+ // See: https://github.com/dotnet/runtime/issues/62121
+ if (hooks is Hook[] array)
+ {
+ if (array.Length > 0)
+ this._hooks.PushRange(array);
+
+ return;
+ }
+
+ array = hooks.ToArray();
+
+ if (array.Length > 0)
+ this._hooks.PushRange(array);
+ }
+#endif
///
public IEnumerable GetHooks() => this._hooks.Reverse();