-
Notifications
You must be signed in to change notification settings - Fork 14
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
BHoM_Engine: RunExtensionMethodAsync and TryRunExtensionMethodAsync added #3191
BHoM_Engine: RunExtensionMethodAsync and TryRunExtensionMethodAsync added #3191
Conversation
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 looks good to me. Because this is a "backend" base method, could you please add an Unit test in the BHoM_Engine_Tests solution too?
It can be a simple test that runs any existing extension method available in the base BHoM_Engine asynchronously, like Geometry()
for example.
This is where the test project is: https://github.com/BHoM/BHoM_Engine/tree/develop/.ci/unit-tests/Base_Engine_Tests
and this new test should sit in a new Compute
folder, in a file called like the method you're testing. Just follow the example of the IsNumeric unit test, for instance.
Thanks @alelom for having a look. I was thinking about adding a unit test before I made one up in GH, but the problem is that all Engine methods are synchronous, and it is not possible to call one via |
Haven't read everything through yet, but would agree being against adding a dummy method to the engine for the sake of testing 👍 |
It's actually well possible in DotNet -- just wrap the synchronous method in a var result = await Task.Run(() => MySyncMethod()); This usage is well justified for this use case. See this SO post for more info. |
Of course, if you have a chance to call
|
Yeah sure I meant maybe you could go ahead with a dummy method like: public static async Task<IGeometry> GeometryAsync(this IObject obj)
{
return await Task.Run(() => obj.Geometry());
} and use that for the invocation in the test. Or something similar |
Yeah, but then it needs to be added to a legit engine project to be reflected in the pool parsed by |
Apologies, it all came back to my mind – this is what I was thinking of having you do. However, I just remembered that I had prepared a "Test Engine" exactly for this purpose – mainly, for testing backend methods like the RunExtensionMethod. I had even added some unit tests, and they were all running fine locally. However, we had immense trouble making them run automatically via CI/CD when BHoMBot attempted to run them via NUnit. I ended up removing them after weeks of trying. tl;dr: let's not add this unit test method. Sorry for the long back and forth, I think it was useful to record this exchange anyways. |
@FraserGreenroyd to confirm, the following actions are now queued:
There are 51 requests in the queue ahead of you. |
The check |
The check |
@BHoMBot this is a DevOps instruction. I am requesting neutral checks on: unit-tests |
@FraserGreenroyd I have provided neutral checks to the checks requested. These checks will need to be run properly to obtain full results. |
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.
Approving based on stated procedure and our conversation above.
@BHoMBot check ready-to-merge |
@FraserGreenroyd to confirm, the following actions are now queued:
There are 129 requests in the queue ahead of you. |
Issues addressed by this PR
Closes #3140
Test files
Write a simple
public static async
Engine method takingBHoMObject
and try running it via script uploaded here.Changelog
Additional comments
The methods added are to large extent a rewrite of
TryRunExtensionMethod
. However,async
methods are not allowed to haveout
parameters, therefore I changed the method signature compared to synchronous flavour - happy to discuss if anyone has different/better ideas 👍