}
}
-#if NETCOREAPP
- return _constructor.Invoke(BindingFlags.DoNotWrapExceptions, binder: null, parameters: _parameterValues, culture: null);
-#else
+#if NETFRAMEWORK || NETSTANDARD2_0
try
{
return _constructor.Invoke(_parameterValues);
// The above line will always throw, but the compiler requires we throw explicitly.
throw;
}
+#else
+ return _constructor.Invoke(BindingFlags.DoNotWrapExceptions, binder: null, parameters: _parameterValues, culture: null);
#endif
}
}
}
}
-#if NETSTANDARD2_1
- return constructorCallSite.ConstructorInfo.Invoke(BindingFlags.DoNotWrapExceptions, binder: null, parameters: parameterValues, culture: null);
-#else
+#if NETFRAMEWORK || NETSTANDARD2_0
try
{
return constructorCallSite.ConstructorInfo.Invoke(parameterValues);
// The above line will always throw, but the compiler requires we throw explicitly.
throw;
}
+#else
+ return constructorCallSite.ConstructorInfo.Invoke(BindingFlags.DoNotWrapExceptions, binder: null, parameters: parameterValues, culture: null);
#endif
}
// Only scope methods are cached
if (callSite.Cache.Location == CallSiteResultCacheLocation.Scope)
{
-#if NETSTANDARD2_1
- return _scopeResolverCache.GetOrAdd(callSite.Cache.Key, _buildTypeDelegate, callSite);
-#else
+#if NETFRAMEWORK || NETSTANDARD2_0
return _scopeResolverCache.GetOrAdd(callSite.Cache.Key, key => _buildTypeDelegate(key, callSite));
+#else
+ return _scopeResolverCache.GetOrAdd(callSite.Cache.Key, _buildTypeDelegate, callSite);
#endif
}
// Only scope methods are cached
if (callSite.Cache.Location == CallSiteResultCacheLocation.Scope)
{
-#if NETSTANDARD2_1
- return _scopeResolverCache.GetOrAdd(callSite.Cache.Key, _buildTypeDelegate, callSite);
-#else
+#if NETFRAMEWORK || NETSTANDARD2_0
return _scopeResolverCache.GetOrAdd(callSite.Cache.Key, key => _buildTypeDelegate(key, callSite));
+#else
+ return _scopeResolverCache.GetOrAdd(callSite.Cache.Key, _buildTypeDelegate, callSite);
#endif
}
public bool TryEnterOnCurrentStack()
{
-#if NETSTANDARD2_1
- if (RuntimeHelpers.TryEnsureSufficientExecutionStack())
- {
- return true;
- }
-#else
+#if NETFRAMEWORK || NETSTANDARD2_0
try
{
RuntimeHelpers.EnsureSufficientExecutionStack();
catch (InsufficientExecutionStackException)
{
}
+#else
+ if (RuntimeHelpers.TryEnsureSufficientExecutionStack())
+ {
+ return true;
+ }
#endif
if (_executionStackCount < MaxExecutionStackCount)
public TR RunOnEmptyStack<T1, T2, TR>(Func<T1, T2, TR> action, T1 arg1, T2 arg2)
{
- // Prefer ValueTuple when available to reduce dependencies on Tuple
-#if NETSTANDARD2_1
+#if NETFRAMEWORK || NETSTANDARD2_0
return RunOnEmptyStackCore(static s =>
{
- var t = ((Func<T1, T2, TR>, T1, T2))s;
+ var t = (Tuple<Func<T1, T2, TR>, T1, T2>)s;
return t.Item1(t.Item2, t.Item3);
- }, (action, arg1, arg2));
+ }, Tuple.Create(action, arg1, arg2));
#else
+ // Prefer ValueTuple when available to reduce dependencies on Tuple
return RunOnEmptyStackCore(static s =>
{
- var t = (Tuple<Func<T1, T2, TR>, T1, T2>)s;
+ var t = ((Func<T1, T2, TR>, T1, T2))s;
return t.Item1(t.Item2, t.Item3);
- }, Tuple.Create(action, arg1, arg2));
+ }, (action, arg1, arg2));
#endif
}