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

fix: Fixed an issue where custom AmazonEC2Client.DryRun() method was not working for non-BCL targets. Also included this method in IAmazonEC2 interface. #3602

Open
wants to merge 1 commit into
base: main-staging
Choose a base branch
from

Conversation

ashishdhingra
Copy link
Contributor

@ashishdhingra ashishdhingra commented Jan 9, 2025

Description

fix: Fixed an issue where custom AmazonEC2Client.DryRun() method was not working for non-BCL targets. Also included this method in IAmazonEC2 interface.

This PR addressed following:

  • Includes DryRun() method as part of IAmazonEC2 interface for easier mock-ability.
  • For non-BCL targets it includes NonPublic methods in reflection search. Kindly note that we need to explicitly use BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic.

Based on discussion with @normj, we should perhaps deprecate/obsolete this method in V4 and remove customization in ec2.customizations.json to not exclude DryRun property from request models (this was done due to legacy reasons when EC2 code was hand-coded). Created separate backlog item for it in Input queue.

Motivation and Context

Issue #3595

Testing

  • Tested locally using below code:

    IAmazonEC2 ec2Client = new AmazonEC2Client();
    var ec2DryRunRespose = ec2Client.DryRun(new StartInstancesRequest { InstanceIds = new() { "<<EC2InstanceID>>" } });

    No unit test/integration test was added since we would need to spin up new EC2 instance. We would also deprecate this method in V4.

  • Catapult dry-run completed successfully.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@ashishdhingra ashishdhingra requested a review from normj January 9, 2025 17:31
@ashishdhingra ashishdhingra force-pushed the user/ashdhin/EC2DryRun-NetStandard-Issue3595 branch from 919c662 to e1438c4 Compare January 9, 2025 22:12
…not working for non-BCL targets. Also included this method in IAmazonEC2 interface.
@ashishdhingra ashishdhingra force-pushed the user/ashdhin/EC2DryRun-NetStandard-Issue3595 branch from e1438c4 to 92bb5d8 Compare January 9, 2025 22:13
@@ -112,7 +112,7 @@ private static Dictionary<Type, DryRunInfo> MethodCache
_methodCache = new Dictionary<Type, DryRunInfo>();

var ec2RequestType = typeof(AmazonEC2Request);
var allMembers = typeof(AmazonEC2Client).GetMembers();
var allMembers = typeof(AmazonEC2Client).GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why you had to add BindingFlags.NonPublic, there are no private methods added in this PR.

I wonder if this could break AOT applications (probably need @normj's input here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed internal members to access synchronous versions of methods which are marked as internal. I had discussed this with @normj in person. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants