-
Notifications
You must be signed in to change notification settings - Fork 224
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
udpate method builder #355
Conversation
WalkthroughRecent updates to the Natasha.CSharp.Extension library introduce new extensions for converting methods to asynchronous, unsafe, and standard delegates for both Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai review |
Actions performedReview triggered.
|
未检测到合适的 ISSUE 推荐给您。感谢您的反馈!
|
UT Test - Ubuntu1 tests 1 ✅ 0s ⏱️ Results for commit 0a54e00. |
UT Test - Windows1 tests 1 ✅ 0s ⏱️ Results for commit 0a54e00. |
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.
Actionable comments posted: 12
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaAsyncDelegateExtension.cs (1 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaDelegateExtension.cs (2 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaUnsafeAsyncDelegateExtension.cs (1 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaUnsafeDelegateExtension.cs (1 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToAsyncMethodExtension.cs (1 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToBuilderExtension.cs (2 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToMethodExtension.cs (1 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToUnsafeAsyncMethodExtension.cs (1 hunks)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToUnsafeMethodExtension.cs (1 hunks)
Files skipped from review due to trivial changes (1)
- src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaDelegateExtension.cs
Additional comments not posted (22)
src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToBuilderExtension.cs (2)
40-46
: LGTM! Verify theWithMetadata
method implementation.The method
WithMetadata
is correctly implemented, but ensure that the method inNatashaSlimMethodBuilder
is functionally accurate.
47-53
: LGTM! Verify the genericWithMetadata<T>
method implementation.The method
WithMetadata<T>
is correctly implemented, but ensure that the generic method inNatashaSlimMethodBuilder
is functionally accurate.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToMethodExtension.cs (4)
4-7
: LGTM! Verify theToDelegate<Action<T1>>
method implementation.The method
ToAction<T1>
is correctly implemented, but ensure that theToDelegate<Action<T1>>
method inNatashaSlimMethodBuilder
is functionally accurate.
8-11
: LGTM! Verify theToDelegate<Action<T1, T2>>
method implementation.The method
ToAction<T1, T2>
is correctly implemented, but ensure that theToDelegate<Action<T1, T2>>
method inNatashaSlimMethodBuilder
is functionally accurate.
56-59
: LGTM! Verify theToDelegate<Func<T1>>
method implementation.The method
ToFunc<T1>
is correctly implemented, but ensure that theToDelegate<Func<T1>>
method inNatashaSlimMethodBuilder
is functionally accurate.
60-63
: LGTM! Verify theToDelegate<Func<T1, T2>>
method implementation.The method
ToFunc<T1, T2>
is correctly implemented, but ensure that theToDelegate<Func<T1, T2>>
method inNatashaSlimMethodBuilder
is functionally accurate.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToAsyncMethodExtension.cs (4)
4-7
: LGTM! Verify theToAsyncDelegate<Action<T1>>
method implementation.The method
ToAsyncAction<T1>
is correctly implemented, but ensure that theToAsyncDelegate<Action<T1>>
method inNatashaSlimMethodBuilder
is functionally accurate.
8-11
: LGTM! Verify theToAsyncDelegate<Action<T1, T2>>
method implementation.The method
ToAsyncAction<T1, T2>
is correctly implemented, but ensure that theToAsyncDelegate<Action<T1, T2>>
method inNatashaSlimMethodBuilder
is functionally accurate.
56-59
: LGTM! Verify theToAsyncDelegate<Func<T1>>
method implementation.The method
ToAsyncFunc<T1>
is correctly implemented, but ensure that theToAsyncDelegate<Func<T1>>
method inNatashaSlimMethodBuilder
is functionally accurate.
60-63
: LGTM! Verify theToAsyncDelegate<Func<T1, T2>>
method implementation.The method
ToAsyncFunc<T1, T2>
is correctly implemented, but ensure that theToAsyncDelegate<Func<T1, T2>>
method inNatashaSlimMethodBuilder
is functionally accurate.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToUnsafeMethodExtension.cs (4)
4-7
: LGTM! Verify theToUnsafeDelegate<Action<T1>>
method implementation.The method
ToUnsafeAction<T1>
is correctly implemented, but ensure that theToUnsafeDelegate<Action<T1>>
method inNatashaSlimMethodBuilder
is functionally accurate.
8-11
: LGTM! Verify theToUnsafeDelegate<Action<T1, T2>>
method implementation.The method
ToUnsafeAction<T1, T2>
is correctly implemented, but ensure that theToUnsafeDelegate<Action<T1, T2>>
method inNatashaSlimMethodBuilder
is functionally accurate.
56-59
: LGTM! Verify theToUnsafeDelegate<Func<T1>>
method implementation.The method
ToUnsafeFunc<T1>
is correctly implemented, but ensure that theToUnsafeDelegate<Func<T1>>
method inNatashaSlimMethodBuilder
is functionally accurate.
60-63
: LGTM! Verify theToUnsafeDelegate<Func<T1, T2>>
method implementation.The method
ToUnsafeFunc<T1, T2>
is correctly implemented, but ensure that theToUnsafeDelegate<Func<T1, T2>>
method inNatashaSlimMethodBuilder
is functionally accurate.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToUnsafeAsyncMethodExtension.cs (2)
4-7
: EnsureWithSmartMethodBuilder
andToUnsafeAsyncDelegate
are ValidVerify that
WithSmartMethodBuilder
andToUnsafeAsyncDelegate
methods exist and function as expected. This ensures that the conversion from string to unsafe async delegate is correctly implemented.
56-59
: EnsureWithSmartMethodBuilder
andToUnsafeAsyncDelegate
are ValidVerify that
WithSmartMethodBuilder
andToUnsafeAsyncDelegate
methods exist and function as expected. This ensures that the conversion from string to unsafe async delegate is correctly implemented.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaAsyncDelegateExtension.cs (2)
9-12
: EnsureToAsyncDelegate
is ValidVerify that
ToAsyncDelegate
method exists and functions as expected. This ensures that the conversion from method builder to async delegate is correctly implemented.
60-63
: EnsureToAsyncDelegate
is ValidVerify that
ToAsyncDelegate
method exists and functions as expected. This ensures that the conversion from method builder to async delegate is correctly implemented.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaUnsafeDelegateExtension.cs (2)
9-12
: EnsureToUnsafeDelegate
is ValidVerify that
ToUnsafeDelegate
method exists and functions as expected. This ensures that the conversion from method builder to unsafe delegate is correctly implemented.
60-63
: EnsureToUnsafeDelegate
is ValidVerify that
ToUnsafeDelegate
method exists and functions as expected. This ensures that the conversion from method builder to unsafe delegate is correctly implemented.src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/MethodExtension/NatashaUnsafeAsyncDelegateExtension.cs (2)
9-12
: EnsureToUnsafeAsyncDelegate
is ValidVerify that
ToUnsafeAsyncDelegate
method exists and functions as expected. This ensures that the conversion from method builder to unsafe async delegate is correctly implemented.
60-63
: EnsureToUnsafeAsyncDelegate
is ValidVerify that
ToUnsafeAsyncDelegate
method exists and functions as expected. This ensures that the conversion from method builder to unsafe async delegate is correctly implemented.
#region Action Delegate | ||
public static Action<T1> ToUnsafeAsyncAction<T1>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1>>(); | ||
} | ||
public static Action<T1, T2> ToUnsafeAsyncAction<T1, T2>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2>>(); | ||
} | ||
public static Action<T1, T2, T3> ToUnsafeAsyncAction<T1, T2, T3>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3>>(); | ||
} | ||
public static Action<T1, T2, T3, T4> ToUnsafeAsyncAction<T1, T2, T3, T4>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5> ToUnsafeAsyncAction<T1, T2, T3, T4, T5>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); | ||
} |
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.
Consider Reducing Repetition
There is a high degree of repetition in the methods. Consider using a generic helper method or a loop to minimize redundancy.
private static Action<T> ToUnsafeAsyncAction<T>(this string script, int parameterCount)
{
// Example implementation:
// This is just a conceptual example. The actual implementation might differ.
switch (parameterCount)
{
case 1: return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1>>();
case 2: return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2>>();
case 3: return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Action<T1, T2, T3>>();
// Add more cases as needed
default: throw new ArgumentException("Unsupported number of parameters");
}
}
#region Func Delegate | ||
public static Func<T1> ToUnsafeAsyncFunc<T1>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1>>(); | ||
} | ||
public static Func<T1, T2> ToUnsafeAsyncFunc<T1, T2>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2>>(); | ||
} | ||
public static Func<T1, T2, T3> ToUnsafeAsyncFunc<T1, T2, T3>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3>>(); | ||
} | ||
public static Func<T1, T2, T3, T4> ToUnsafeAsyncFunc<T1, T2, T3, T4>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this string script) | ||
{ | ||
return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); | ||
} |
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.
Consider Reducing Repetition
Similar to the Action
delegate methods, there is a high degree of repetition. Consider using a generic helper method or a loop to minimize redundancy.
private static Func<T> ToUnsafeAsyncFunc<T>(this string script, int parameterCount)
{
// Example implementation:
switch (parameterCount)
{
case 1: return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1>>();
case 2: return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2>>();
case 3: return script.WithSmartMethodBuilder().ToUnsafeAsyncDelegate<Func<T1, T2, T3>>();
// Add more cases as needed
default: throw new ArgumentException("Unsupported number of parameters");
}
}
@@ -0,0 +1,105 @@ | |||
public static class StringToUnsafeAsyncMethodExtension |
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.
Remove BOM Character
The file contains a BOM (Byte Order Mark) character at the beginning. This can cause issues in some systems.
-public static class StringToUnsafeAsyncMethodExtension
+public static class StringToUnsafeAsyncMethodExtension
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public static class StringToUnsafeAsyncMethodExtension | |
public static class StringToUnsafeAsyncMethodExtension |
#region Action Delegate | ||
public static Action<T1> ToAsyncAction<T1>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1>>(); | ||
} | ||
public static Action<T1, T2> ToAsyncAction<T1, T2>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2>>(); | ||
} | ||
public static Action<T1, T2, T3> ToAsyncAction<T1, T2, T3>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3>>(); | ||
} | ||
public static Action<T1, T2, T3, T4> ToAsyncAction<T1, T2, T3, T4>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5> ToAsyncAction<T1, T2, T3, T4, T5>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6> ToAsyncAction<T1, T2, T3, T4, T5, T6>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7> ToAsyncAction<T1, T2, T3, T4, T5, T6, T7>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8> ToAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); |
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.
Consider Reducing Repetition
There is a high degree of repetition in the methods. Consider using a generic helper method or a loop to minimize redundancy.
private static Action<T> ToAsyncAction<T>(this NatashaSlimMethodBuilder builder, int parameterCount)
{
// Example implementation:
// This is just a conceptual example. The actual implementation might differ.
switch (parameterCount)
{
case 1: return builder.ToAsyncDelegate<Action<T1>>();
case 2: return builder.ToAsyncDelegate<Action<T1, T2>>();
case 3: return builder.ToAsyncDelegate<Action<T1, T2, T3>>();
// Add more cases as needed
default: throw new ArgumentException("Unsupported number of parameters");
}
}
#region Func Delegate | ||
public static Func<T1> ToAsyncFunc<T1>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1>>(); | ||
} | ||
public static Func<T1, T2> ToAsyncFunc<T1, T2>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2>>(); | ||
} | ||
public static Func<T1, T2, T3> ToAsyncFunc<T1, T2, T3>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3>>(); | ||
} | ||
public static Func<T1, T2, T3, T4> ToAsyncFunc<T1, T2, T3, T4>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5> ToAsyncFunc<T1, T2, T3, T4, T5>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6> ToAsyncFunc<T1, T2, T3, T4, T5, T6>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7> ToAsyncFunc<T1, T2, T3, T4, T5, T6, T7>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8> ToAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); |
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.
Consider Reducing Repetition
Similar to the Action
delegate methods, there is a high degree of repetition. Consider using a generic helper method or a loop to minimize redundancy.
private static Func<T> ToAsyncFunc<T>(this NatashaSlimMethodBuilder builder, int parameterCount)
{
// Example implementation:
switch (parameterCount)
{
case 1: return builder.ToAsyncDelegate<Func<T1>>();
case 2: return builder.ToAsyncDelegate<Func<T1, T2>>();
case 3: return builder.ToAsyncDelegate<Func<T1, T2, T3>>();
// Add more cases as needed
default: throw new ArgumentException("Unsupported number of parameters");
}
}
#region Func Delegate | ||
public static Func<T1> ToUnsafeFunc<T1>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1>>(); | ||
} | ||
public static Func<T1, T2> ToUnsafeFunc<T1, T2>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2>>(); | ||
} | ||
public static Func<T1, T2, T3> ToUnsafeFunc<T1, T2, T3>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3>>(); | ||
} | ||
public static Func<T1, T2, T3, T4> ToUnsafeFunc<T1, T2, T3, T4>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5> ToUnsafeFunc<T1, T2, T3, T4, T5>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6> ToUnsafeFunc<T1, T2, T3, T4, T5, T6>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7> ToUnsafeFunc<T1, T2, T3, T4, T5, T6, T7>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8> ToUnsafeFunc<T1, T2, T3, T4, T5, T6, T7, T8>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToUnsafeFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToUnsafeFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToUnsafeFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToUnsafeFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); |
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.
Consider Reducing Repetition
Similar to the Action
delegate methods, there is a high degree of repetition. Consider using a generic helper method or a loop to minimize redundancy.
private static Func<T> ToUnsafeFunc<T>(this NatashaSlimMethodBuilder builder, int parameterCount)
{
// Example implementation:
switch (parameterCount)
{
case 1: return builder.ToUnsafeDelegate<Func<T1>>();
case 2: return builder.ToUnsafeDelegate<Func<T1, T2>>();
case 3: return builder.ToUnsafeDelegate<Func<T1, T2, T3>>();
// Add more cases as needed
default: throw new ArgumentException("Unsupported number of parameters");
}
}
@@ -0,0 +1,112 @@ | |||
|
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.
Remove BOM Character
The file contains a BOM (Byte Order Mark) character at the beginning. This can cause issues in some systems.
-
+
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
|
#region Action Delegate | ||
public static Action<T1> ToUnsafeAsyncAction<T1>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1>>(); | ||
} | ||
public static Action<T1, T2> ToUnsafeAsyncAction<T1, T2>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2>>(); | ||
} | ||
public static Action<T1, T2, T3> ToUnsafeAsyncAction<T1, T2, T3>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3>>(); | ||
} | ||
public static Action<T1, T2, T3, T4> ToUnsafeAsyncAction<T1, T2, T3, T4>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5> ToUnsafeAsyncAction<T1, T2, T3, T4, T5>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToUnsafeAsyncAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); |
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.
Consider Reducing Repetition
There is a high degree of repetition in the methods. Consider using a generic helper method or a loop to minimize redundancy.
private static Action<T> ToUnsafeAsyncAction<T>(this NatashaSlimMethodBuilder builder, int parameterCount)
{
// Example implementation:
// This is just a conceptual example. The actual implementation might differ.
switch (parameterCount)
{
case 1: return builder.ToUnsafeAsyncDelegate<Action<T1>>();
case 2: return builder.ToUnsafeAsyncDelegate<Action<T1, T2>>();
case 3: return builder.ToUnsafeAsyncDelegate<Action<T1, T2, T3>>();
// Add more cases as needed
default: throw new ArgumentException("Unsupported number of parameters");
}
}
#region Func Delegate | ||
public static Func<T1> ToUnsafeAsyncFunc<T1>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1>>(); | ||
} | ||
public static Func<T1, T2> ToUnsafeAsyncFunc<T1, T2>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2>>(); | ||
} | ||
public static Func<T1, T2, T3> ToUnsafeAsyncFunc<T1, T2, T3>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3>>(); | ||
} | ||
public static Func<T1, T2, T3, T4> ToUnsafeAsyncFunc<T1, T2, T3, T4>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> ToUnsafeAsyncFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this NatashaSlimMethodBuilder builder) | ||
{ | ||
return builder.ToUnsafeAsyncDelegate<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); |
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.
Consider Reducing Repetition
Similar to the Action
delegate methods, there is a high degree of repetition. Consider using a generic helper method or a loop to minimize redundancy.
private static Func<T> ToUnsafeAsyncFunc<T>(this NatashaSlimMethodBuilder builder, int parameterCount)
{
// Example implementation:
<!-- This is an auto-generated comment by CodeRabbit -->
@@ -0,0 +1,112 @@ | |||
|
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.
Remove BOM Character
The file contains a BOM (Byte Order Mark) character at the beginning. This can cause issues in some systems.
-
+
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
|
Summary by CodeRabbit
SystemDelegateExtension
toNatashaDelegateExtension
.StringExtension
toStringToBuilderExtension
.