-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactoring of RuntimeFramework and RuntimeFrameworkService #448
Conversation
I can take a look at it now, but I think it would also be good to have import from @ChrisMaddock given that he has proposed something similar (and also worked with the code, see e.g. nunit/nunit-console#702 and related issues). |
Thanks @mikkelbu! @ChrisMaddock You unfortunately don't come up as a suggested name on this project so I sometimes forget you! Love to have you take a look as well. |
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 must admit that I got lost several times trying to review this, so I find it hard to determine how much the overall change improves the code (I think so, but I've not worked with any parts of this code, so most of it is quite new to me).
I've left some comments, questions etc. as I'm better with the details :).
src/TestEngine/nunit.engine.core/Internal/TargetFrameworkHelper.cs
Outdated
Show resolved
Hide resolved
@@ -279,6 +281,10 @@ public void StopService() | |||
|
|||
public void StartService() | |||
{ | |||
_runtimeService = ServiceContext.GetService<IRuntimeFrameworkService>(); |
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 would prefer either to lookup IRuntimeFrameworkService
in the constructor or perhaps just in LaunchAgentProcess
right now it seems to occur far from declaration and usage.
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.
Our general pattern is for any service to look up other services it depends on in StartService, giving an error if that service is not available. ServiceManager
then aborts the run if the dependency was not found. See RecentFilesService
as another exampe of a dependency.
BTW I always had the idea that we could make service initialization order-independent by detecting such dependencies first. However, for now, we have to add services and initialize in an order that takes the dependencies into account.
src/TestEngine/nunit.engine.tests/Compatibility/FrameworkNameTests.cs
Outdated
Show resolved
Hide resolved
src/TestEngine/nunit.engine.tests/Compatibility/FrameworkNameTests.cs
Outdated
Show resolved
Hide resolved
src/TestEngine/nunit.engine/Services/RuntimeFrameworkService.cs
Outdated
Show resolved
Hide resolved
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 can't find anything additional
Thanks to both of you. I made all the changes except for the comment about how one Service should initialize another Service on which it depends. If we want to change that, I think it has to be a global change to all Services at once. Leaving the comment unresolved in case we want to discuss more. |
This is preliminary refactoring in preparation for working on issue #445. I intended to fix the issue in one PR, but it's looking more complicated than I thought and I want to merge this now.
First commit removes all knowledge of available frameworks from
RuntimeFramework
, moving it toRuntimeFrameworkService
Second commit creates a compatible implementation of the
FrameworkName
class in the .NET 2.0 build ofnunit.engine.core
.Third commit makes use of
FrameworkName
by including it as a property ofRuntimeFramework
but no further use is made of the property as yet.@immeraufdemhund @mikkelbu I'd appreciate a quick look at this, if you can find the time. I'm going to base my fix for #447 off of this PR, which is why I need to merge it.