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

TestContext.TestDirectory throws for .net 2.0 DLL #44

Closed
nzain opened this issue Apr 12, 2016 · 5 comments
Closed

TestContext.TestDirectory throws for .net 2.0 DLL #44

nzain opened this issue Apr 12, 2016 · 5 comments

Comments

@nzain
Copy link

nzain commented Apr 12, 2016

NUnit is still compiled for old .net frameworks, which is great. I maintain a shared library used in old VS2008 net35 projects (phone 6.5, ugh) and also used in latest VS2015 net46 projects. Today I tried to transition from NUnit 2.6.4 to 3.2.0 running into current directory issues for resource files (content, copy if newer). Using the TestContext.CurrentContext.TestDirectory works fine for recent net46 projects using NuGet to pull NUnit.

However, referencing packages\NUnit.3.2.0\lib\net20\nunit.framework.dll from VS2008, net35 the call to TestContext.CurrentContext.TestDirectory throws a NullReferenceException, eventually because the working directory is null.

vs2008 debugger

@nzain
Copy link
Author

nzain commented Apr 12, 2016

Ok, I have to add that the solution does not always compile correctly (some strange WinCE vs Win32 linking issue, I guess). I'll have to resolve that first, before this can be considered a bug.

@CharliePoole
Copy link
Contributor

Is it a netcf-3.5 project rather than net-3.5? In that case you need to use the CF build of the nunit framework.

@nzain
Copy link
Author

nzain commented Apr 12, 2016

I just realized that the net20 assembly is not well compatible with net35 due to possibly duplicate definitions of the class ExtensionAttribute. I can't really reproduce it well, although my script deletes bin/obj and rebuilds the whole solution. Eventually, one of the third party libraries I referenced (closed source) defined the ExtensionAttribute, too. The build error I see is

CSC : warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from '[...]\packages\NUnit.3.2.0\lib\net20\nunit.framework.dll'
CSC : error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'
CSC : error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'
CSC : error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'

I'll try to track down, which assemblies (apart from nunit.framework) define this attribute. When I remove some of my unused DLLs the problem seems to be gone. Is it possible to built a net35 nunit.framework.dll? I didn't have the issue with version 2.6.4.

Edit: No, CF is not the root problem. Unit test project and referenced projects are regular net35 projects. I tried to completely remove the CF project and the problem persists.

@ChrisMaddock
Copy link
Member

The duplicate definitions problem is logged as nunit/nunit#1349 - there's a temporary workaround there, I believe.

@nzain
Copy link
Author

nzain commented Apr 12, 2016

Using a custom build for net35, this no longer happens. It seems some mixed partially successful build results caused this problem. => invalid & closed.

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

No branches or pull requests

3 participants