Testura.Code
Testura.Code copied to clipboard
Add netstandard2.0 support to allow using Testura.Code within a Roslyn source generator project
I'm working on making some source generators I use in my own projects into it's own project, later to be published on NuGet, and I saw this project while I was cleaning up the code a bit and looking for a way to make my code generation a bit nicer. I decided to try and port this project to the .NET version required for source generators.
- [X] Add
netstandard2.0target toTestura.CodeandTestura.Code.Tests - [X] Add
PolySharpdependency toTestura.Codeto polyfill features from newer C# versions intonetstandard2.0builds- This is a source generator only dependency, so it should not be a transitive dependency pulled in by projects depending on
Testura.Code, and the source generator only adds code when targeting newer C# versions with older target frameworks.
- This is a source generator only dependency, so it should not be a transitive dependency pulled in by projects depending on
- [X] Fix code that relies on non-polyfilled C# features within
Testura.Codeuntil the project builds - [x] Make test project build
- [ ] Make sure tests succeed
Will update in comments on my current progress so far on this.
Current progress on getting tests to build - the NUnit3TestAdapter project is being restored using .NETFramework4.x.x packages, instead of any specific netstandard2.0 packages. Looking into finding a solution for this.
1>Testura.Code.Tests.csproj: Error NU1701 : Warning As Error: Package 'NUnit3TestAdapter 4.3.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
So, I have the tests building with my change now, but I cannot actually run them - even on unmodified sources from this repository instead of my fork, the tests don't pass. At a glance, it looks like your tests don't actually support running on non-Windows systems, and my primary development system is a MacOS system. Specifically, I get errors like this from the failing tests that I looked at briefly:
System.IO.FileNotFoundException : Could not find a part of the path '/Users/pearl/code/Testura.Code/src/Testura.Code.Tests/bin/Debug/net6.0/C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\/mscorlib.dll'.
which seems to be a mix of a MacOS and a Windows path.
Would one of you guys be able to run the unit tests for me and let me know if all of the tests pass? Keep in mind that I'm not sure if Visual Studio actually supports running anything except the newest framework version's tests natively - you may have to use the dotnet test command line tool to run it. I usually handle running tests on multi-targeted projects by running them in JetBrains Rider, which has a dropdown to select which target frameworks to run a test for.
After running the tests on another machine and finding out it hard-requires .net 4.5, I'm skipping the tests and marking the PR as ready for review, since there's no reasonable way to run the tests as the tests require a long-unsupported .NET version to run.
I have just seen this a year later. Nice work! I don't have Pull Request rights. I will try to contact the main developer for this and see if we can get it merged in