I have a solution in Visual Studio 2019 containing a WinForms .Net Framework 4.8 project and a .Net 5.0 test project. The WinForms project contains all my windows forms and some helper classes. The test project contains unit test code (using Xunit).
In my unit tests I want to test certain elements of my forms. For this I need a reference to System.Windows.Forms. The problem is that I am unable to add this reference to my test project. When clicking "Add project reference", there is no option to add assemblies as there is in the WinForms project.
How do I get this reference added? And why is it not possible to add assemblies to the test project?
I read this question, which seems to suggest that I need to delete my test project and replace it with a .net Framework 4.8 project. But this confuses me, since there is only one option available when creating a Xunit test project, namely .Net Core. So if Xunit is only for .Net Core projects, then how do I test a .Net Framework project?
Reading this question, I tried adding the reference manually to my .csproj file, but then I get compiler warning "Package 'System.Windows.Forms 4.0.0'... This package may not be fully compatible with your project.". Should I be concerned about this warning? This is probably a clue that I'm not supposed to do it this way.