Skip to content
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

Merged
merged 1 commit into from
Jul 10, 2024
Merged

udpate method builder #355

merged 1 commit into from
Jul 10, 2024

Conversation

NMSAzulX
Copy link
Collaborator

@NMSAzulX NMSAzulX commented Jul 10, 2024

Summary by CodeRabbit

  • New Features
    • Introduced functionality to convert methods into asynchronous delegates.
    • Added extensions to create unsafe asynchronous delegates from strings.
    • Extensions for generating Action and Func delegates from strings.
  • Refactor
    • Renamed class SystemDelegateExtension to NatashaDelegateExtension.
    • Renamed class StringExtension to StringToBuilderExtension.

Copy link

coderabbitai bot commented Jul 10, 2024

Walkthrough

Recent updates to the Natasha.CSharp.Extension library introduce new extensions for converting methods to asynchronous, unsafe, and standard delegates for both Action and Func types. Various classes have been renamed and extended to handle these conversions, providing developers with more flexibility in executing dynamic methods with multiple input parameters, asynchronously and safely.

Changes

File Path Change Summary
src/Natasha.CSharp/Extension/.../NatashaAsyncDelegateExtension.cs Added methods for converting methods to asynchronous Action and Func delegates using NatashaSlimMethodBuilder.
src/Natasha.CSharp/Extension/.../NatashaDelegateExtension.cs Renamed SystemDelegateExtension to NatashaDelegateExtension with no significant logic changes.
src/Natasha.CSharp/Extension/.../NatashaUnsafeAsyncDelegateExtension.cs Introduced methods to convert methods into unsafe asynchronous Action and Func delegates with various generic type parameters.
src/Natasha.CSharp/Extension/.../NatashaUnsafeDelegateExtension.cs Added methods to convert instances to unsafe Action and Func delegates with different numbers of generic type parameters.
src/Natasha.CSharp/Extension/.../StringExtension/StringToAsyncMethodExtension.cs New file introducing extensions to convert strings to asynchronous Action and Func delegates.
src/Natasha.CSharp/Extension/.../StringExtension/StringToBuilderExtension.cs Renamed StringExtension to StringToBuilderExtension and added WithMetadata methods.
src/Natasha.CSharp/Extension/.../StringExtension/StringToMethodExtension.cs New extensions for converting strings to Action and Func delegates with varying generic parameters.
src/Natasha.CSharp/Extension/.../StringExtension/StringToUnsafeAsyncMethodExtension.cs Added extensions for converting strings into unsafe asynchronous Action and Func delegates.
src/Natasha.CSharp/Extension/.../StringExtension/StringToUnsafeMethodExtension.cs New file introducing methods to convert strings to unsafe Action and Func delegates.

Poem

In the realm of Natasha so bright,
Methods convert to async, taking flight,
With unsafe delegates in tow,
Builders help the process flow.
Strings transform with grace and ease,
Coding bunnies, jump and tease.
Celebrate this change with cheer,
New features have now appeared! 🌟


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@NMSAzulX
Copy link
Collaborator Author

@coderabbitai review

Copy link

coderabbitai bot commented Jul 10, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@NMSAzulX
Copy link
Collaborator Author

未检测到合适的 ISSUE 推荐给您。感谢您的反馈!

该条自动推荐信息来自于 nms-bot.

Copy link

UT Test - Ubuntu

1 tests   1 ✅  0s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 0a54e00.

Copy link

UT Test - Windows

1 tests   1 ✅  0s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 0a54e00.

Copy link

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 85aa30d and 0a54e00.

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 the WithMetadata method implementation.

The method WithMetadata is correctly implemented, but ensure that the method in NatashaSlimMethodBuilder is functionally accurate.


47-53: LGTM! Verify the generic WithMetadata<T> method implementation.

The method WithMetadata<T> is correctly implemented, but ensure that the generic method in NatashaSlimMethodBuilder is functionally accurate.

src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToMethodExtension.cs (4)

4-7: LGTM! Verify the ToDelegate<Action<T1>> method implementation.

The method ToAction<T1> is correctly implemented, but ensure that the ToDelegate<Action<T1>> method in NatashaSlimMethodBuilder is functionally accurate.


8-11: LGTM! Verify the ToDelegate<Action<T1, T2>> method implementation.

The method ToAction<T1, T2> is correctly implemented, but ensure that the ToDelegate<Action<T1, T2>> method in NatashaSlimMethodBuilder is functionally accurate.


56-59: LGTM! Verify the ToDelegate<Func<T1>> method implementation.

The method ToFunc<T1> is correctly implemented, but ensure that the ToDelegate<Func<T1>> method in NatashaSlimMethodBuilder is functionally accurate.


60-63: LGTM! Verify the ToDelegate<Func<T1, T2>> method implementation.

The method ToFunc<T1, T2> is correctly implemented, but ensure that the ToDelegate<Func<T1, T2>> method in NatashaSlimMethodBuilder is functionally accurate.

src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToAsyncMethodExtension.cs (4)

4-7: LGTM! Verify the ToAsyncDelegate<Action<T1>> method implementation.

The method ToAsyncAction<T1> is correctly implemented, but ensure that the ToAsyncDelegate<Action<T1>> method in NatashaSlimMethodBuilder is functionally accurate.


8-11: LGTM! Verify the ToAsyncDelegate<Action<T1, T2>> method implementation.

The method ToAsyncAction<T1, T2> is correctly implemented, but ensure that the ToAsyncDelegate<Action<T1, T2>> method in NatashaSlimMethodBuilder is functionally accurate.


56-59: LGTM! Verify the ToAsyncDelegate<Func<T1>> method implementation.

The method ToAsyncFunc<T1> is correctly implemented, but ensure that the ToAsyncDelegate<Func<T1>> method in NatashaSlimMethodBuilder is functionally accurate.


60-63: LGTM! Verify the ToAsyncDelegate<Func<T1, T2>> method implementation.

The method ToAsyncFunc<T1, T2> is correctly implemented, but ensure that the ToAsyncDelegate<Func<T1, T2>> method in NatashaSlimMethodBuilder is functionally accurate.

src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToUnsafeMethodExtension.cs (4)

4-7: LGTM! Verify the ToUnsafeDelegate<Action<T1>> method implementation.

The method ToUnsafeAction<T1> is correctly implemented, but ensure that the ToUnsafeDelegate<Action<T1>> method in NatashaSlimMethodBuilder is functionally accurate.


8-11: LGTM! Verify the ToUnsafeDelegate<Action<T1, T2>> method implementation.

The method ToUnsafeAction<T1, T2> is correctly implemented, but ensure that the ToUnsafeDelegate<Action<T1, T2>> method in NatashaSlimMethodBuilder is functionally accurate.


56-59: LGTM! Verify the ToUnsafeDelegate<Func<T1>> method implementation.

The method ToUnsafeFunc<T1> is correctly implemented, but ensure that the ToUnsafeDelegate<Func<T1>> method in NatashaSlimMethodBuilder is functionally accurate.


60-63: LGTM! Verify the ToUnsafeDelegate<Func<T1, T2>> method implementation.

The method ToUnsafeFunc<T1, T2> is correctly implemented, but ensure that the ToUnsafeDelegate<Func<T1, T2>> method in NatashaSlimMethodBuilder is functionally accurate.

src/Natasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/StringExtension/StringToUnsafeAsyncMethodExtension.cs (2)

4-7: Ensure WithSmartMethodBuilder and ToUnsafeAsyncDelegate are Valid

Verify that WithSmartMethodBuilder and ToUnsafeAsyncDelegate methods exist and function as expected. This ensures that the conversion from string to unsafe async delegate is correctly implemented.


56-59: Ensure WithSmartMethodBuilder and ToUnsafeAsyncDelegate are Valid

Verify that WithSmartMethodBuilder and ToUnsafeAsyncDelegate 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: Ensure ToAsyncDelegate is Valid

Verify that ToAsyncDelegate method exists and functions as expected. This ensures that the conversion from method builder to async delegate is correctly implemented.


60-63: Ensure ToAsyncDelegate is Valid

Verify 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: Ensure ToUnsafeDelegate is Valid

Verify that ToUnsafeDelegate method exists and functions as expected. This ensures that the conversion from method builder to unsafe delegate is correctly implemented.


60-63: Ensure ToUnsafeDelegate is Valid

Verify 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: Ensure ToUnsafeAsyncDelegate is Valid

Verify 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: Ensure ToUnsafeAsyncDelegate is Valid

Verify that ToUnsafeAsyncDelegate method exists and functions as expected. This ensures that the conversion from method builder to unsafe async delegate is correctly implemented.

Comment on lines +3 to +51
#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>>();
}
Copy link

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");
    }
}

Comment on lines +55 to +103
#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>>();
}
Copy link

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
Copy link

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.

Suggested change
public static class StringToUnsafeAsyncMethodExtension
public static class StringToUnsafeAsyncMethodExtension

Comment on lines +8 to +55
#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>>();
Copy link

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");
    }
}

Comment on lines +60 to +107
#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>>();
Copy link

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");
    }
}

Comment on lines +60 to +107
#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>>();
Copy link

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 @@

Copy link

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.

Suggested change


Comment on lines +8 to +55
#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>>();
Copy link

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");
    }
}

Comment on lines +60 to +107
#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>>();
Copy link

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 @@

Copy link

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.

Suggested change


@NMSAzulX NMSAzulX merged commit a3b880f into dev.next Jul 10, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

1 participant