-
Notifications
You must be signed in to change notification settings - Fork 1
Array pointer extraction #184
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
base: main
Are you sure you want to change the base?
Conversation
…ray is converted to pointers if it contains NetObject instances
…Sharp into array-pointer-extraction
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.
Pull request overview
This PR adds support for passing arrays of .NET objects as arguments to .NET methods. Previously, only individual NetObject instances could be passed; now R lists or arrays containing NetObject instances can be passed as well, with their pointers automatically extracted.
- Enhanced argument processing to extract pointers from lists/arrays of
NetObjectinstances - Added test coverage for both single and array
NetObjectarguments - Updated documentation to clarify requirements for passing arrays of .NET objects
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| R/rSharp-internal.R | Added logic to detect and extract pointers from lists of NetObject instances |
| tests/testthat/test-net-object.R | Added tests verifying single and array NetObject arguments work correctly |
| vignettes/user-guide.Rmd | Documented requirement that array elements must all be NetObject instances |
| NEWS.md | Added changelog entry for array support feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…stems-Pharmacology/rSharp into array-pointer-extraction
| return arg != null && arg.GetType() == typeof(TestObject); | ||
| } | ||
|
|
||
| public static bool ArrayOfObjectsArgument(Object[] arg) |
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.
This is obviously going to work, but the issue is that you have a method that will accept a collection of any objects, now it's up to the domain API to iterate through it and make sure they are appropriate, do the type conversions and handle errors.
rSharp cannot help with that because it has no domain knowledge, so it can only perform this kind of conversion for string, int, float etc. That's why you can pass arrays of numbers and strings.
It might be fine to include this in rSharp, but I would not use it for OSPSuite-R. Instead, I would add items to collections one-at-a-time, similar to ConcurrentSimulationRunner
This way rSharp matches method names and types through reflection automatically.
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.
Or find a way to implement this as TestObject[] arg and have rSharp create the array dynamically somehow.
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.
Yes agree for the use in ospsuite. Just wanted to add this functionality here as I already imlemented it.
No description provided.