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

Refactoring of RuntimeFramework and RuntimeFrameworkService #448

Merged
merged 4 commits into from
Dec 3, 2019

Conversation

CharliePoole
Copy link
Contributor

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 to RuntimeFrameworkService

Second commit creates a compatible implementation of the FrameworkName class in the .NET 2.0 build of nunit.engine.core.

Third commit makes use of FrameworkName by including it as a property of RuntimeFramework 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.

@CharliePoole CharliePoole changed the title Issue 445 Refactoring of RuntimeFramework and RuntimeFrameworkService Dec 2, 2019
@mikkelbu
Copy link
Contributor

mikkelbu commented Dec 2, 2019

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).

@CharliePoole
Copy link
Contributor Author

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.

Copy link
Contributor

@mikkelbu mikkelbu left a 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-agent/Program.cs Outdated Show resolved Hide resolved
src/TestEngine/nunit.engine/nunit.engine.csproj Outdated Show resolved Hide resolved
@@ -279,6 +281,10 @@ public void StopService()

public void StartService()
{
_runtimeService = ServiceContext.GetService<IRuntimeFrameworkService>();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@immeraufdemhund immeraufdemhund left a 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

@CharliePoole
Copy link
Contributor Author

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.

@CharliePoole CharliePoole merged commit 9e4e05a into master Dec 3, 2019
@CharliePoole CharliePoole deleted the issue-445 branch December 3, 2019 18:58
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.

3 participants