-
Notifications
You must be signed in to change notification settings - Fork 5
V9.0.0/delegate additions relocation #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7a12939
a8e67c7
83c597d
dfebf50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,8 +214,8 @@ public static TResult SafeInvoke<TResult>(Func<TResult> initializer, Func<TResul | |
| { | ||
| Validator.ThrowIfNull(initializer); | ||
| Validator.ThrowIfNull(tester); | ||
| var f1 = FuncFactory.Create(tester, default); | ||
| var f2 = ActionFactory.Create(catcher, default); | ||
| var f1 = new FuncFactory<MutableTuple<TResult>, TResult>(tuple => tester(tuple.Arg1), new MutableTuple<TResult>(default), tester); | ||
| var f2 = new ActionFactory<MutableTuple<Exception>>(tuple => catcher?.Invoke(tuple.Arg1), new MutableTuple<Exception>(default), catcher); | ||
| return SafeInvokeCore(f1, initializer, f2); | ||
| } | ||
|
|
||
|
|
@@ -233,8 +233,8 @@ public static TResult SafeInvoke<T, TResult>(Func<TResult> initializer, Func<TRe | |
| { | ||
| Validator.ThrowIfNull(initializer); | ||
| Validator.ThrowIfNull(tester); | ||
| var f1 = FuncFactory.Create(tester, default, arg); | ||
| var f2 = ActionFactory.Create(catcher, default, arg); | ||
| var f1 = new FuncFactory<MutableTuple<TResult, T>, TResult>(tuple => tester(tuple.Arg1, tuple.Arg2), new MutableTuple<TResult, T>(default, arg), tester); | ||
| var f2 = new ActionFactory<MutableTuple<Exception, T>>(tuple => catcher?.Invoke(tuple.Arg1, tuple.Arg2), new MutableTuple<Exception, T>(default, arg), catcher); | ||
| return SafeInvokeCore(f1, initializer, f2); | ||
| } | ||
|
|
||
|
|
@@ -254,8 +254,8 @@ public static TResult SafeInvoke<T1, T2, TResult>(Func<TResult> initializer, Fun | |
| { | ||
| Validator.ThrowIfNull(initializer); | ||
| Validator.ThrowIfNull(tester); | ||
| var f1 = FuncFactory.Create(tester, default, arg1, arg2); | ||
| var f2 = ActionFactory.Create(catcher, default, arg1, arg2); | ||
| var f1 = new FuncFactory<MutableTuple<TResult, T1, T2>, TResult>(tuple => tester(tuple.Arg1, tuple.Arg2, tuple.Arg3), new MutableTuple<TResult, T1, T2>(default, arg1, arg2), tester); | ||
| var f2 = new ActionFactory<MutableTuple<Exception, T1, T2>>(tuple => catcher?.Invoke(tuple.Arg1, tuple.Arg2, tuple.Arg3), new MutableTuple<Exception, T1, T2>(default, arg1, arg2), catcher); | ||
| return SafeInvokeCore(f1, initializer, f2); | ||
| } | ||
|
|
||
|
|
@@ -277,8 +277,8 @@ public static TResult SafeInvoke<T1, T2, T3, TResult>(Func<TResult> initializer, | |
| { | ||
| Validator.ThrowIfNull(initializer); | ||
| Validator.ThrowIfNull(tester); | ||
| var f1 = FuncFactory.Create(tester, default, arg1, arg2, arg3); | ||
| var f2 = ActionFactory.Create(catcher, default, arg1, arg2, arg3); | ||
| var f1 = new FuncFactory<MutableTuple<TResult, T1, T2, T3>, TResult>(tuple => tester(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4), new MutableTuple<TResult, T1, T2, T3>(default, arg1, arg2, arg3), tester); | ||
| var f2 = new ActionFactory<MutableTuple<Exception, T1, T2, T3>>(tuple => catcher?.Invoke(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4), new MutableTuple<Exception, T1, T2, T3>(default, arg1, arg2, arg3), catcher); | ||
| return SafeInvokeCore(f1, initializer, f2); | ||
| } | ||
|
|
||
|
|
@@ -302,8 +302,8 @@ public static TResult SafeInvoke<T1, T2, T3, T4, TResult>(Func<TResult> initiali | |
| { | ||
| Validator.ThrowIfNull(initializer); | ||
| Validator.ThrowIfNull(tester); | ||
| var f1 = FuncFactory.Create(tester, default, arg1, arg2, arg3, arg4); | ||
| var f2 = ActionFactory.Create(catcher, default, arg1, arg2, arg3, arg4); | ||
| var f1 = new FuncFactory<MutableTuple<TResult, T1, T2, T3, T4>, TResult>(tuple => tester(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4, tuple.Arg5), new MutableTuple<TResult, T1, T2, T3, T4>(default, arg1, arg2, arg3, arg4), tester); | ||
| var f2 = new ActionFactory<MutableTuple<Exception, T1, T2, T3, T4>>(tuple => catcher?.Invoke(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4, tuple.Arg5), new MutableTuple<Exception, T1, T2, T3, T4>(default, arg1, arg2, arg3, arg4), catcher); | ||
| return SafeInvokeCore(f1, initializer, f2); | ||
| } | ||
|
|
||
|
|
@@ -329,15 +329,15 @@ public static TResult SafeInvoke<T1, T2, T3, T4, T5, TResult>(Func<TResult> init | |
| { | ||
| Validator.ThrowIfNull(initializer); | ||
| Validator.ThrowIfNull(tester); | ||
| var f1 = FuncFactory.Create(tester, default, arg1, arg2, arg3, arg4, arg5); | ||
| var f2 = ActionFactory.Create(catcher, default, arg1, arg2, arg3, arg4, arg5); | ||
| var f1 = new FuncFactory<MutableTuple<TResult, T1, T2, T3, T4, T5>, TResult>(tuple => tester(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4, tuple.Arg5, tuple.Arg6), new MutableTuple<TResult, T1, T2, T3, T4, T5>(default, arg1, arg2, arg3, arg4, arg5), tester); | ||
| var f2 = new ActionFactory<MutableTuple<Exception, T1, T2, T3, T4, T5>>(tuple => catcher?.Invoke(tuple.Arg1, tuple.Arg2, tuple.Arg3, tuple.Arg4, tuple.Arg5, tuple.Arg6), new MutableTuple<Exception, T1, T2, T3, T4, T5>(default, arg1, arg2, arg3, arg4, arg5), catcher); | ||
| return SafeInvokeCore(f1, initializer, f2); | ||
| } | ||
|
|
||
| private static TResult SafeInvokeCore<TTester, TResult, TCatcher>(FuncFactory<TTester, TResult> testerFactory, Func<TResult> initializer, ActionFactory<TCatcher> catcherFactory) | ||
| where TResult : class, IDisposable | ||
| where TTester : Template<TResult> | ||
| where TCatcher : Template<Exception> | ||
| where TTester : MutableTuple<TResult> | ||
| where TCatcher : MutableTuple<Exception> | ||
|
Comment on lines
+339
to
+340
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generic constraints may be too restrictive in SafeInvokeCore The generic constraints on Details:
Suggested Fix: Adjust the generic constraints to accept any where TTester : IMutableTuple
where TCatcher : IMutableTupleEnsure that such a base class or interface ( |
||
| { | ||
| TResult result = null; | ||
| try | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ public static class ActivatorFactory | |
| /// <seealso cref="Activator.CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo)"/>. | ||
| public static TInstance CreateInstance<TInstance>(Action<ActivatorOptions> setup = null) | ||
| { | ||
| var factory = FuncFactory.Create<TInstance>(null); | ||
| var factory = new FuncFactory<MutableTuple, TInstance>(null, new MutableTuple()); | ||
| return CreateInstanceCore(factory, setup); | ||
| } | ||
|
|
||
|
|
@@ -33,7 +33,7 @@ public static TInstance CreateInstance<TInstance>(Action<ActivatorOptions> setup | |
| /// <seealso cref="Activator.CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo)"/>. | ||
| public static TInstance CreateInstance<T, TInstance>(T arg, Action<ActivatorOptions> setup = null) | ||
| { | ||
| var factory = FuncFactory.Create<T, TInstance>(null, arg); | ||
| var factory = new FuncFactory<MutableTuple<T>, TInstance>(null, new MutableTuple<T>(arg)); | ||
| return CreateInstanceCore(factory, setup); | ||
| } | ||
|
|
||
|
|
@@ -50,7 +50,7 @@ public static TInstance CreateInstance<T, TInstance>(T arg, Action<ActivatorOpti | |
| /// <seealso cref="Activator.CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo)"/>. | ||
| public static TInstance CreateInstance<T1, T2, TInstance>(T1 arg1, T2 arg2, Action<ActivatorOptions> setup = null) | ||
| { | ||
| var factory = FuncFactory.Create<T1, T2, TInstance>(null, arg1, arg2); | ||
| var factory = new FuncFactory<MutableTuple<T1, T2>, TInstance>(null, new MutableTuple<T1, T2>(arg1, arg2)); | ||
| return CreateInstanceCore(factory, setup); | ||
| } | ||
|
|
||
|
|
@@ -69,7 +69,7 @@ public static TInstance CreateInstance<T1, T2, TInstance>(T1 arg1, T2 arg2, Acti | |
| /// <seealso cref="Activator.CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo)"/>. | ||
| public static TInstance CreateInstance<T1, T2, T3, TInstance>(T1 arg1, T2 arg2, T3 arg3, Action<ActivatorOptions> setup = null) | ||
| { | ||
| var factory = FuncFactory.Create<T1, T2, T3, TInstance>(null, arg1, arg2, arg3); | ||
| var factory = new FuncFactory<MutableTuple<T1, T2, T3>, TInstance>(null, new MutableTuple<T1, T2, T3>(arg1, arg2, arg3)); | ||
| return CreateInstanceCore(factory, setup); | ||
| } | ||
|
|
||
|
|
@@ -90,7 +90,7 @@ public static TInstance CreateInstance<T1, T2, T3, TInstance>(T1 arg1, T2 arg2, | |
| /// <seealso cref="Activator.CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo)"/>. | ||
| public static TInstance CreateInstance<T1, T2, T3, T4, TInstance>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, Action<ActivatorOptions> setup = null) | ||
| { | ||
| var factory = FuncFactory.Create<T1, T2, T3, T4, TInstance>(null, arg1, arg2, arg3, arg4); | ||
| var factory = new FuncFactory<MutableTuple<T1, T2, T3, T4>, TInstance>(null, new MutableTuple<T1, T2, T3, T4>(arg1, arg2, arg3, arg4)); | ||
| return CreateInstanceCore(factory, setup); | ||
| } | ||
|
|
||
|
|
@@ -113,11 +113,11 @@ public static TInstance CreateInstance<T1, T2, T3, T4, TInstance>(T1 arg1, T2 ar | |
| /// <seealso cref="Activator.CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo)"/>. | ||
| public static TInstance CreateInstance<T1, T2, T3, T4, T5, TInstance>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, Action<ActivatorOptions> setup = null) | ||
| { | ||
| var factory = FuncFactory.Create<T1, T2, T3, T4, T5, TInstance>(null, arg1, arg2, arg3, arg4, arg5); | ||
| var factory = new FuncFactory<MutableTuple<T1, T2, T3, T4, T5>, TInstance>(null, new MutableTuple<T1, T2, T3, T4, T5>(arg1, arg2, arg3, arg4, arg5)); | ||
| return CreateInstanceCore(factory, setup); | ||
| } | ||
|
|
||
| private static TInstance CreateInstanceCore<TTuple, TInstance>(FuncFactory<TTuple, TInstance> factory, Action<ActivatorOptions> setup = null) where TTuple : Template | ||
| private static TInstance CreateInstanceCore<TTuple, TInstance>(FuncFactory<TTuple, TInstance> factory, Action<ActivatorOptions> setup = null) where TTuple : MutableTuple | ||
| { | ||
| var options = Patterns.Configure(setup); | ||
| return (TInstance)Activator.CreateInstance(typeof(TInstance), options.Flags, options.Binder, factory.GenericArguments.ToArray(), options.FormatProvider as CultureInfo); | ||
|
Comment on lines
+120
to
123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Remaining references to
🔗 Analysis chainConstraint change to Changing the type constraint from Please confirm that all references to To verify, you can run the following script: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify there are no remaining references to 'Template' in the codebase.
# Test: Search for 'Template' references. Expect: No matches.
rg --type cs 'Template'
Length of output: 705 |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential index mismatch in tuple arguments
In the
SafeInvoke<T1, T2, T3, T4, T5, TResult>method, there appears to be an off-by-one error in accessing tuple arguments.Details:
The
MutableTuple<TResult, T1, T2, T3, T4, T5>should have argumentsArg1toArg6.In the lambda expression:
tuple.Arg6corresponds toT5, butMutableTuple<TResult, T1, T2, T3, T4, T5>defines only six arguments, withArg1beingTResultandArg6beingT5.Similarly, in the
new MutableTupleinitialization:The arguments align with
Arg1toArg6, but it's crucial to ensure that the mapping is correct.Suggested Fix:
Verify that the
MutableTupleclass properly definesArg1toArg6and that the arguments correspond correctly to the expected types. Ensure thattuple.Arg6is valid and maps toT5.