-
Notifications
You must be signed in to change notification settings - Fork 243
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
AssemblyCleanup in generic base class throws exception #1890
Comments
Hi @pi3k14, I confirm that I can reproduce the bug. We will investigate it and fix it asap. |
This is happening because we are trying to call a method on an open generic type The assembly cleanup and assembly initialization is not tied to any particular class so we cannot really know what This is probably not a problem for most of cleanups, because they are probably not referring to the What we can do is that we:
Option 2 is probably most performant for us, if we want to allow this functionality, but not very logical for the user I am afraid. |
Thanks for the investigation @nohwnd ❤️ Doing a quick look this seems to be unsupported scenario for xUnit so I would probably favor option 1, add an analyzer for such case and create a feature request ticket for option 2 to see if we get some thumbs up and plan implementing or not based on that. WDYT? |
If going for option 1 I would strongly urge you to fix #1889 |
I agree that making it unsupported is the right call here. It is both performant and easy to workaround, because you simply need to add another class that will hold the assembly level setups and cleanups. Which to me even seems cleaner. |
If doing operations on the generic type, e.g. a specific DbContext, that would neither be simple or cleaner. |
In that case you would need to run AssemblyInitialize / Cleanup for every type that is mentioned as T right? e.g. following the example above:
There would be 2 invocations for AssemblyCleanup one for T = int and one for T = double. That seems doable, but I am not sure if that is not a little unexpected, if the cleanup is not the reason why there is a T.
Not the best example I admit, but the only one I can think of right now. |
@nohwnd Assigning you this issue for milestone 3.3. The idea is to add a a code check and report a runtime issue as we do for other invalid layout. @cvpoienaru will add a code analyzer for this. |
✅ Successfully linked to Azure Boards work item(s): |
Self-assigning so you have more time for native AOT. I already know what to fix and how to fix so will be able to do a quick PR. |
Describe the bug
MSTest.TestFramework 3.0.4
AssemblyCleanup in generic base class throws exception
AB#1950772
The text was updated successfully, but these errors were encountered: