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

Merge .NET Standard Engine code back into the main solution #479

Merged
merged 33 commits into from
Nov 28, 2018
Merged

Conversation

rprouse
Copy link
Member

@rprouse rprouse commented Oct 7, 2018

This is the work @ChrisMaddock and I have been doing on merging the .NET Standard version of the engine back into the main solution. I am putting the pull request up because we are getting close to done and wanted to involve the team in the final steps.

I think that the tasks that we want to complete before a merge are;

  • Add the .NET Standard engine and engine.api into the NuGet packages
  • Test this version of the engine in the adapter in Visual Studio and with dotnet test on the command line.

Once this is complete, we can start exploring the other enhancements that @ChrisMaddock has entered recently like allowing the console runner to run Core tests, adding a Core console runner, allowing the engine to load Core extensions, adding back features to the .NET Standard engine like communicating to an agent, etc.

@ChrisMaddock
Copy link
Member

Thanks for putting this up Rob. (And fixing my NuGet packaging. 😩)

Never asked before - what was your thinking on adding a .NET Standard 1.3 engine - was it Xamarin support? I ask, as I'm not sure the dependencies are available on the Xamarin platforms (XmlDocument appears not to be available on iOS/Android - although I'd have to dig more deeply to check!) If we're only intending to support .NET Core with this engine however, then I'm not sure why you dropped the target level from 1.6?

@rprouse
Copy link
Member Author

rprouse commented Oct 12, 2018

I've tested this build in the adapter and everything seems to be working fine in my test projects, so I think we are pretty close to being able to merge this.

what was your thinking on adding a .NET Standard 1.3 engine

To be honest, this has been on the back burner so long that I forget why I made that change 😦 The adapter needs to be compiled .NET Core 1.0 which is fine for 1.6 and the latest versions of Xamarin support it. It might have been for the original Windows 10 UWP, but even that could go to 1.4. We should probably bring it up to latest we can manage. Do you think that should be 1.4 for UWP support, or 1.6 for more features?

@ChrisMaddock
Copy link
Member

Hmm, we don’t have a runner for original UWP, but of course that would allow others to consume the engine.

I wonder if we should stick at 1.6 for now, until that demand is expressed? UWP is a very small part of our userbase - so much so, I’d be tempted to wonder if the portable agent could be sufficient.

@ChrisMaddock
Copy link
Member

I had CI working before, but it now keeps failing at the same point in restoring packages on iOS. 😞

I may give it a whirl on VSTS at some point instead...

@rprouse
Copy link
Member Author

rprouse commented Oct 13, 2018

I updated to .NET Standard 1.6 and the only new functionality that it enabled was getting the command line arguments. The two other big areas that I'd hoped to enable, extensions and running tests async, were still not possible because Assembly.LoadFrom and Thread are still not available in 1.6. We may as well leave these at 1.3 in the hope of adding full UWP support to the adapter.

I'm pushing some minor fixes that I found while going through trying to enable features for 1.6.

I think this is ready for review.

@rprouse rprouse changed the title WIP - .NET Standard Engine Merge .NET Standard Engine code back into the main solution Oct 13, 2018
Copy link
Member

@ChrisMaddock ChrisMaddock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this was a marathon! Didn't find any major problems, just a few things that might be nice to tidy up. Lot's of these are simple things that I can do myself - but I'll come back to them another day.

Looks great Rob! 😄

@@ -434,6 +447,7 @@ internal void FindExtensionsInAssembly(ExtensionAssembly assembly)
return;
}
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this functionality, I think means the Engine will crash if it encounters an extension targeting a framework it can't load. If we can't inspect, perhaps we should try/catch instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a unit test for this where the .NET Core 2.0 targeted tests try to load extensions from the .NET 3.5 assembly and visa-versa. Interestingly, .NET 3.5 correctly throws an NUnitEngineException because it thinks the .NET Core 2.0 targets the 4.0 full framework. The .NET Core 2.0 seems to successfully load the .NET 3.5 extensions. Both of these behaviors seem wrong to me.

src/NUnitEngine/nunit.engine/RuntimeFramework.cs Outdated Show resolved Hide resolved
src/CommonAssemblyInfo.cs Outdated Show resolved Hide resolved
@ChrisMaddock
Copy link
Member

We may as well leave these at 1.3 in the hope of adding full UWP support to the adapter.

This sounds like a sensible enough justification to me! 👍

@ChrisMaddock
Copy link
Member

Great, thanks Rob - and no worries!

@rprouse
Copy link
Member Author

rprouse commented Nov 20, 2018

@ChrisMaddock I've resolved the merge conflicts, updated to .NET Standard 1.6 and got the load engine from another directory test passing. See the changes in TestEngineActivator.CreateInstance() for .NET Standard 1.6.

@ChrisMaddock
Copy link
Member

ChrisMaddock commented Nov 20, 2018

Awesome! Sorry, I haven't had time to get back to this recently!

I started a PR nunit/nunit3-vs-adapter#562 to update the adapter to the current engine release, so that we can hopefully easily switch to this version once it's done. Unfortunately that seems to be non-trivial, but it's a WIP!

@rprouse
Copy link
Member Author

rprouse commented Nov 23, 2018

Looks like my recent changes or maybe the merge from master broke packaging in Cake. I am fixing it. @ChrisMaddock anything else we should do before merging this PR and moving on to the additional tasks? I started this branch back in May, so it would be nice to get it behind us 😄

@rprouse
Copy link
Member Author

rprouse commented Nov 23, 2018

Packaging has been fixed, now the new load engine from another directory is failing on Travis Linux on .NET 2.0

1) Failed : NUnit.Engine.Services.Tests.ExtensionServiceTests.FailsGracefullyLoadingOtherFrameworkExtensionAssembly
  Expected: <NUnit.Engine.NUnitEngineException>
  But was:  no exception thrown
  at NUnit.Engine.Services.Tests.ExtensionServiceTests.FailsGracefullyLoadingOtherFrameworkExtensionAssembly () [0x00000] in <839ae0be2830488ba956d1dfeb047f37>:0 

@ChrisMaddock
Copy link
Member

Yes - let’s get this merged! I’m pretty busy at the moment, but will try and give it a final look over at some point, unless you’re happy that the latest changes are simple?

Also - the failing test you’ve posted looks like a different test from the newly added one? Can’t see the appveyor logs on my phone myself.

@rprouse
Copy link
Member Author

rprouse commented Nov 23, 2018

the failing test you’ve posted looks like a different test from the newly added one? Can’t see the appveyor logs on my phone myself.

You're right, I misread that. I didn't get much of a chance to look at it last night. I ended up struggling with getting my Linux environment instead. I'll probably be able to get back to it tomorrow.

The latest changes I made are fairly small. You can concentrate a review on the new .NET Standard 1.6 version of TestEngineActivator.CreateInstance. That was the only change of substance.

@rprouse
Copy link
Member Author

rprouse commented Nov 23, 2018

Further to that, we might be able to use the NETSTANDARD1_6 version of CreateInstance for the NETSTANDARD2_0 target. I was just playing it safe.

ChrisMaddock
ChrisMaddock previously approved these changes Nov 27, 2018
Copy link
Member

@ChrisMaddock ChrisMaddock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, Rob! Few simple corrections left - would be good to double check the nuspec dependency noted is still required, if you haven't already. Other than that, I think the last thing to do is fix this test! 😄

My week's pretty busy still - might get a chance to have a quick look at the weekend. 🙂

@@ -47,7 +47,7 @@
[assembly: AssemblyConfiguration(".NET 3.5")]
#elif NET20
[assembly: AssemblyConfiguration(".NET 2.0")]
#elif NETSTANDARD1_3 || NETCOREAPP1_1
#elif NETSTANDARD1_6 || NETCOREAPP1_1
[assembly: AssemblyConfiguration(".NET Standard 1.3")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs updating, and it's friend on line 29. 😄

@@ -19,7 +19,7 @@
<copyright>Copyright (c) 2018 Charlie Poole, Rob Prouse</copyright>
<dependencies>
<group targetFramework="net20" />
<group targetFramework="netstandard1.3">
<group targetFramework="netstandard1.6">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if any dependencies are redundant with the retargetting - looks like System.Reflection.TypeExtension is the only possibility. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update - looks like it can be removed, commit incoming. 😄

src/CommonAssemblyInfo.cs Outdated Show resolved Hide resolved
src/CommonAssemblyInfo.cs Outdated Show resolved Hide resolved
build.cake Outdated Show resolved Hide resolved
build.cake Outdated Show resolved Hide resolved
build.cake Outdated Show resolved Hide resolved
@ChrisMaddock ChrisMaddock dismissed stale reviews from themself via 5c9e23e November 27, 2018 13:08
@ChrisMaddock
Copy link
Member

Assigned myself so I could apply PR 'code suggestions' (which were all trivial) - that was a super sweet experience! 😄

@ChrisMaddock ChrisMaddock force-pushed the issue-388b branch 2 times, most recently from 4b163b6 to 014340a Compare November 27, 2018 22:09
@ChrisMaddock
Copy link
Member

Last commit fixes the two outstanding issues - so to my mind, this is now ready to be merged! 😱 @rprouse - I'll leave it with you to merge when you're happy!

Last things I patched up:

  1. System.Reflection.TypeExtension dependency needed under NS1.3 seemed unnecessary under NS1.6, so I removed it
  2. The failing test was due to Assembly.GetEntryAssembly() returning null on mono, and thus the framework loading validation not being run. I just added the line below for now - although I assume trying to load a Net Core extension under mono would now lead to an noisier failure later in the process. Maybe something we should log for future...
//May be null on mono
Assume.That(Assembly.GetEntryAssembly(), Is.Not.Null, "Entry assembly is null, framework loading validation will be skipped.");

@mikkelbu
Copy link
Member

We also had some unexpected behaviour regarding Assembly.GetEntryAssembly() in nunit/nunit#3084 (comment).

@rprouse
Copy link
Member Author

rprouse commented Nov 28, 2018

Looks good, I was just looking at making the same fixes tonight 😄

If anyone is using it, I updated the docker image that build-mono-docker.ps1 uses to the latest release of .NET Core 2.6.1. I was using that for testing locally.

@rprouse rprouse merged commit aaef18f into master Nov 28, 2018
@rprouse rprouse deleted the issue-388b branch November 28, 2018 02:44
@mikkelbu mikkelbu added this to the 3.10 milestone Dec 11, 2018
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.

None yet

4 participants