-
Notifications
You must be signed in to change notification settings - Fork 315
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
ITestLoggerWithParameters | ITestLogger async issue #4749
Comments
Is there a goal that you are trying to achieve? We cannot redesign the whole way vstest is done, and it was written in a time where async hardly existed as a construct in C#. |
I'd like use a lib that I'd like to trigger on messages. But the API surface only supports async methods. I'm not saying that you should redesign it. Though I would recommend to introduce a new interface which can be used for extensibility that supports async methods. This should apply to Collectors / Adapters / Discoverer / Executer and whatever extensibility point exists within vstest. For now I would say it would be sufficient to have a Listener upgraded for my case for now... But I would be happy to see that the lookup would look for additional new generation types that are capable to handle async workloads. From implementation perspective I don't think it would be a huge deal to introduce these types. |
Unfortunately that is not so easy. The design where commands (as method calls) flow one way and responses flow as events the other way is common in the whole codebase. For your approach we would have to switch to a message bus or something and then "emulate" the events. I would be up for it, but it would have to be used extensively throughout the whole codebase, and this big refactoring is not something we want to do right now. |
I don't think it's something that it's required at least not for the logger scenario. When getting the implementaion of logger in TestLoggerManager.cs why don't you check for another interface IDisposable() for discovery. If the logger implements it then call it once the testmanager disposes. The implementation could use that to wait for the internal tasks to be completed (which is not nice) though could be leveraged to add a Task.Wait() on the collected async events that we need to wait for. I know it's ugly but the implementations do not require synchronization context so deadlock can be avoided. Or back to my suggestion. Within InternalTestManager you have full control of triggering the events like: LoggerManager.HandleDiscoveredTests(discoveredTestsEvent); It can have a default implementation which can be used to wrap the older types to be "backward" compatible like:
Then instead of triggering the event call the async method which needs to be waited but it's fine to have LoggerManager.HandleDiscoveredTests(discoveredTestsEvent).ConfigureAwait(false).GetAwaiter().GetResult(); there IMHO. What do you think? PS.: |
Thanks for the suggestions. We can come up with a lot of workarounds, but I would like to avoid introducing a one off solutions that are not building on a solid foundation. The internal architecture is different and does not mesh well with async workloads. |
Description
Using the following interface types there's no way that you can garatnee that a service can "finish" it's work if there's no sync alternative.
Event handlers were fine before Tasks but if you would write (async void) anything that will reach the first await will treat the event as returned.
Steps to reproduce
Expected behavior
Console should be reached.
Actual behavior
Won't be logging.
Diagnostic logs
⏹️
Environment
🌎
Proposal
There are couple of ways to solve it:
virtual void DiscoveredTests(DiscoveredTestsEventArgs e) { return; }
virtual Task DiscoveredTests(DiscoveredTestsEventArgs e) { return Task.Completed; }
Or feel free to come up with any proper solution you might like. But this is not a very fortunate situation...
The text was updated successfully, but these errors were encountered: