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

DYN-6985 Get item from list with negative index (Wishlist #187) #15205

Merged

Conversation

tinrobot2000
Copy link
Contributor

@tinrobot2000 tinrobot2000 commented May 10, 2024

Purpose

Update to List.GetItemAtIndex to allow negative index (get from right to left) retrieval
DynamoDS/DynamoWishlist#187

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Update to List.GetItemAtIndex to allow negative index (get from right to left) retrieval

Reviewers

@DynamoDS/dynamo

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

@QilongTang QilongTang added this to the 3.2 milestone May 13, 2024
Copy link

github-actions bot commented May 13, 2024

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net8.0

@QilongTang
Copy link
Contributor

hi @tinrobot2000 Thanks a lot for proposing this PR, my team will review and make a decision soon on this. Good work on addressing wishlist issue!

@reddyashish
Copy link
Contributor

@aparajit-pratap @mjkkirschner Do you think this is as per design to not gte the negative index from the list items?

@mjkkirschner
Copy link
Member

@aparajit-pratap @mjkkirschner Do you think this is as per design to not gte the negative index from the list items?

If you checkout the builtin implementation of Get indexing it does support negative indices:

public static object ValueAtIndex(IList list, int index)

I think this would be an okay change but it requires the following changes IMO.

  1. a test
  2. consider performance impact, 1 if statement probably is not too bad.
  3. I don't see any reason to raise the IndexOutOfRangeException, the indexing operation is going to do that anyway, what am I missing?

@QilongTang QilongTang modified the milestones: 3.2, 3.3 May 20, 2024
@QilongTang QilongTang changed the title Get item from list with negative index (Wishlist #187) DYN-6985 Get item from list with negative index (Wishlist #187) May 24, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-6985

@QilongTang
Copy link
Contributor

@aparajit-pratap @mjkkirschner Do you think this is as per design to not gte the negative index from the list items?

If you checkout the builtin implementation of Get indexing it does support negative indices:

public static object ValueAtIndex(IList list, int index)

I think this would be an okay change but it requires the following changes IMO.

  1. a test
  2. consider performance impact, 1 if statement probably is not too bad.
  3. I don't see any reason to raise the IndexOutOfRangeException, the indexing operation is going to do that anyway, what am I missing?

Hi @mjkkirschner I think when index is too large or too negative to handle, it could be out of range so exception is only needed in that case. I am adding unit tests for those cases as well.

@QilongTang QilongTang merged commit 1f062c7 into DynamoDS:master May 28, 2024
24 checks passed
@mjkkirschner
Copy link
Member

mjkkirschner commented May 29, 2024

Hi @mjkkirschner I think when index is too large or too negative to handle, it could be out of range so exception is only needed in that case. I am adding unit tests for those cases as well.

yeah I'm still not getting it - when you do

var x= int[1]
var y = x[10000000]

that will throw an out of range exception, you don't have to detect it yourself first...

denizmaral added a commit to denizmaral/Dynamo that referenced this pull request May 30, 2024
the changes from DynamoDS#15205 require an update here. If the element is not in the list it should return null instead of -1.
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.

None yet

4 participants