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

Support base-class tests from external assemblies #315

Merged
merged 7 commits into from
Apr 19, 2017

Conversation

gimpf
Copy link

@gimpf gimpf commented Apr 10, 2017

Fixes #314

The problem was caused because the Mono.Cecil failed to resolve types from external assemblies, even if they are in the same directory.

This is fixed by explicitly adding the directory of the base-library to the search-path for Mono's assembly-resolver.

This fix works for me, but I'd have to lie when I'd say I've tested it extensively. Please see gimpf/nunit3-vs-adapter-issue314 for a test-case. It fails using the regular adapter, but works using the fixes from this PR.

@CharliePoole CharliePoole changed the title Fix Issue 314: Support base-class tests from external assemblies Support base-class tests from external assemblies Apr 10, 2017
@CharliePoole
Copy link
Member

The PR looks like an improvement. I'm vaguely aware that we recently made almost the same change, however, so I want to look more closely when I'm back home with my development system in a few hours.

This doesn't explain that you are seeing the same problem with the console runner, since your fix would not have anything to do with that.

@CharliePoole CharliePoole self-assigned this Apr 10, 2017
@CharliePoole CharliePoole self-requested a review April 11, 2017 02:42
Copy link
Member

@CharliePoole CharliePoole left a comment

Choose a reason for hiding this comment

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

This resolves the case although it doesn't go as far as @OsirisTerje 's fix in PR nunit/nunit-vs-adapter#149. That fix handles types that are defined in a referenced assembly located in a different directory. @OsirisTerje do you think that's necessary in the VS environment?

@CharliePoole
Copy link
Member

I approved but with a question for @OsirisTerje. We need his second review to merge. Thanks for your work!

@gimpf
Copy link
Author

gimpf commented Apr 11, 2017

@CharliePoole Sorry that I didn't find the existing work. It didn't occur to me that searching for "navigation" would turn up some work in progress, though that's rather obvious in hindsight... Thanks for integrating it ;-)

@gimpf gimpf closed this Apr 11, 2017
@gimpf gimpf reopened this Apr 11, 2017
@CharliePoole
Copy link
Member

Well it's in a different repo and so hard to find unless you know it's there.

Markus Grüneis added 2 commits April 12, 2017 11:39
* Remove inactive code
* When searching for navigation data, make the iteration
  through the base classes explicit
@gimpf
Copy link
Author

gimpf commented Apr 12, 2017

I've now integrated the changes from the nunit2 adapter, and cleaned up the code a bit for readability.

Since this navigation problem is strictly dependent on having multiple assemblies, should we extend the NavigationDataTests (that is, introduce another test assembly), or do you use separate integration tests for such issues?

@OsirisTerje
Copy link
Member

@gimpf Good that you integrated those changes, and yes, @CharliePoole , I think that is necessary, this was what solved the 2.X adapter issue. I am not sure exactly how this works out with the different Mono.Cecil libs, but I would better be safe than sorry here.
@gimpf About the integration tests, we have discussed them earlier, but currently we dont have any other than what is in the repo. If you want to add another test assembly, it will not harm in any way., If they start to slow down things we can always move them later, but then they are done - so, yes please, if you want to.

Markus Grüneis added 4 commits April 12, 2017 12:32
When resolving base-types via `TypeReference.Resolve()`,
no symbols are read.  As a result, base-classes in
external assemblies could not provide navigation-info
(SequencePoint would always be null).

Also, while reworking the operations around the `.Resolve()`,
also catch any assembly resolution error, as we do not have
any guarantee that our Mono.Cecil search path really is
identical to the .NET's one.
@gimpf
Copy link
Author

gimpf commented Apr 12, 2017

@OsirisTerje I've now added two additional tests for the NavigationDataProvider for types that reference other assemblies. Also, since the first time I opened the PR, I've refactored some things, you might want to revisit the code.

Those two new tests brought to light another issue regarding the navigation-data: The way we resolved the base-types caused that no navigation-data for the types was loaded. I remember that you mentioned an issue regarding "cannot jump to source" in the linked issue. That might be resolved now as well (though I haven't checked).

Regarding the PR itself, I from my side consider it complete, but I'll remain available for fixing issues from code reviews or tests.

Thanks for your support!

@CharliePoole
Copy link
Member

@OsirisTerje I was just trying to figure out whether the use case (base assembly in a different directory) can arise in normal use. I guess it would require the user to define two different output directories and turn off local copy... odd but possible.

@gimpf Re-reviewing!

@CharliePoole
Copy link
Member

This still looks good to me.

@rprouse
Copy link
Member

rprouse commented Apr 19, 2017

This looks good to me too. @OsirisTerje shall we merge? I will need to merge this into my PR.

@OsirisTerje
Copy link
Member

OsirisTerje commented Apr 19, 2017

@rprouse Yep, looks fine to me too.

Your call :-)

@rprouse rprouse merged commit cf70e19 into nunit:master Apr 19, 2017
@gimpf gimpf deleted the issue-314-testcase-conversion branch April 20, 2017 10:54
@kantnisha
Copy link

Is this change released?

@rprouse
Copy link
Member

rprouse commented Nov 14, 2017

@kantnisha yes, this is in the current released version.

@kantnisha
Copy link

thanks

@kantnisha
Copy link

Does this work on VS2017? Anyone tried?

@OsirisTerje
Copy link
Member

See comments on #314 and also try the repro here on the NUnit3 branch, https://github.com/OsirisTerje/NUnitTestAdapterIssue143
Ref @CharliePoole comments on #314 you might need to tweak the repro to check your exact case.
And yes, this should work on VS2017 and earlier.
Do you have any issues related to this?

@jnm2 jnm2 mentioned this pull request Feb 18, 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
5 participants