-
Notifications
You must be signed in to change notification settings - Fork 636
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
DYN-1476: AllowRankReductionAttribute on Zero Touch seems to be broken #9542
Conversation
…d debug menu. Deleted debug menu items.
@scottmitchell I think this is a clean and simple solution! I would "LGTM" this after some tests :) |
@@ -64,6 +64,26 @@ protected FFIMemberInfo(MemberInfo info) | |||
Info = info; | |||
} | |||
|
|||
internal void CheckForRankReductionAttribute(Dictionary<MethodInfo, Attribute[]> getterAttributes) |
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.
name is okay to me, but just considering others - copyRankReductionAttribute?
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.
Would you add some function comments, what you have mentioned in this PR description is good enough
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.
@QilongTang yes, I'll add some comments. @mjkkirschner yeah I like that better. Or maybe "AttachRankReductionAttribute"
it looks good to me, lets add some tests. |
LGTM with a few comments and looking forward to tests |
@scottmitchell you can add dummy test classes and methods/properties to |
Thanks @aparajit-pratap, I was going to ask about that |
@@ -784,7 +784,7 @@ private void RegisterFunctionPointer(string functionName, MemberInfo method, Lis | |||
else if (CoreUtils.IsGetter(functionName)) | |||
{ | |||
f = new GetterFunctionPointer(Module, functionName, method, retype); | |||
(f as GetterFunctionPointer).ReflectionInfo.CheckForRankReductionAttribute(mGetterAttributes); | |||
(f as GetterFunctionPointer).ReflectionInfo.CopyRankReductionAttribute(mGetterAttributes); |
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.
Sorry, but I think the earlier name was more appropriate considering the context in which it is used. It first checks and then only copies.
test/Engine/FFITarget/TestObjects.cs
Outdated
@@ -457,4 +457,35 @@ public void Dispose() | |||
} | |||
} | |||
|
|||
public class TestRankReduce : IDisposable |
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.
You don't need to make this class an IDisposable
.
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.
did you intend to dispose this class?
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.
I only implemented IDisposable
because the other test objects in this file did. I didn't really have any intentions for it.
test/Engine/FFITarget/TestObjects.cs
Outdated
private string RankReduceTestField; | ||
|
||
[AllowRankReduction] | ||
public List<string> RankReduceArrowProperty => new List<string> { RankReduceTestField }; |
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.
How is this syntax different from the RankReducePropertyGetter
?
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.
It's just syntactic sugar for the getter. Testing one of these would suffice.
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.
Fair enough. I just carried this over from the test cases I used during development. I removed the arrow property and added a method test (not sure if this exists anywhere else).
@scottmitchell some minor comments and then LGTM! |
why are the builds failing here? |
@mjkkirschner The console shows all clear 18 smoke tests pass and all good, ever see this happens? |
all checks clear 👍 |
@aparajit-pratap @mjkkirschner @QilongTang Thanks for your alls comments. I think I've addressed everything—Let me know if I haven't. Otherwise, I'll go ahead and merge once the checks pass. |
@scottmitchell please send a cherry pick if this is labeled 2.2 |
DynamoDS#9542) * update * Brought truncated search results and full query search out from behind debug menu. Deleted debug menu items. * Added CheckForRankReductionAttribute() method to FFIMemberInfo * Cleaned up CheckForRankReductionAttribute * Added AllowRankReductionAttribute tests * Comments. Change method name. * Update tests, method name * Corrected test names * Fixed annoying diff
…rties (#9542) (#9549) * DYN-1476: AllowRankReductionAttribute on Zero Touch seems to be broken (#9542) * update * Brought truncated search results and full query search out from behind debug menu. Deleted debug menu items. * Added CheckForRankReductionAttribute() method to FFIMemberInfo * Cleaned up CheckForRankReductionAttribute * Added AllowRankReductionAttribute tests * Comments. Change method name. * Update tests, method name * Corrected test names * Fixed annoying diff * DYN-1476 Follow Up: Remove Rank Reduction from Dictionary.Values (#9550) * update * Brought truncated search results and full query search out from behind debug menu. Deleted debug menu items. * Removed AllowRankReduction from Dictionary.Values. Added TODO
Purpose
Jira issue DYN-1476.
This PR addresses a bug where the
AllowRankReductionAttribute
does not work for Zero Touch properties. The typical use case for theAllowRankReductionAttribute
is to reduce the rank of the return value of methods—rather than return a list of a single item, the method will return just the item. This does not currently work for properties because a property's attributes are not automatically applied to that property's getter (which is what actually get's invoked by the Zero Touch node). For example, this does not currently result in rank reduction of theget_SomeProperty
return value:A work around is possible by explicitly declaring the getter with
AllowRankReductionAttribute
:There are a couple possible solutions here:
Solution 1: Change nothing, and simply message to users that they must explicitly declare getters if they want to use this attribute. However, this behavior could be confusing to a Zero Touch developer.
Solution 2: Copy the attribute from the property to its getter at runtime—that could happen here. This may be possible, but certainly isn't trivial. Some info on that here: https://stackoverflow.com/questions/14663763/how-to-add-an-attribute-to-a-property-at-runtime
Solution 3: Add another rank reduction check later in the function invoke process, where the property attributes are available—maybe here.
Solution 4 (this PR): Create a way to pass the property's
AllowRankReductionAttribute
down to theFFIMemberInfo
instance created from the getter, without actually adding the attribute to the getter. This seems to be the least invasive way to add this functionality to Zero Touch properties. However, it may not be the cleanest.Declarations
Check these if you believe they are true
*.resx
filesReviewers
@aparajit-pratap @mjkkirschner
FYIs
@QilongTang