-
Notifications
You must be signed in to change notification settings - Fork 748
Add support for .NET5.0 OSPlatformAttribute #3926
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
Conversation
8e2b77e
to
8efce97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks fine by me.
I've only left a minor nitpicks.
src/NUnitFramework/framework/Attributes/OSPlatformTranslator.cs
Outdated
Show resolved
Hide resolved
/// </summary> | ||
/// <param name="possibleSupportedOSPlatformAttribute"></param> | ||
/// <returns></returns> | ||
public static object Translate(object possibleSupportedOSPlatformAttribute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would prefer something like that:
public static bool TryTranslate(object possibleSupportedOSPlatformAttribute, out PlatformAttribute platformAttribute);
That would make it more obvious what this method returns.
And then use it smth like that:
OSPlatformTranslator.TryTranslate(attribute, out var platformAttribute) ? platformAttribute : attribute
(Your option is more concise though, so I don't insist to hard)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of #3941 I have to changes this, combining multiple OSPlatformAttribute
into a single PlatformAttribute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining this, I was going to ask why the need to handle PlatformAttribute
in the translator. Are you saying that this PR will also fix #3941 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevenaw This PR will as a side effect combine multiple Platform attributes into one, thereby 'fixing' #3941. It depends if the owners want that or change the AllowMultiple flag.
The main reason I combine it here is for code that currently use both SupportOSPlatform
and Platform
. The first for the .NET compiler, the 2nd for nunit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manfred-brands Sorry it's taken me a few days to get back to you. That makes a lot of sense, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is fix to fix #3941 and keep the AllowMultiple as it is.
b61af83
to
8d9b37b
Compare
@mikkelbu MacOS builds fail with "The repository primary signature validity period has expired". Also fails in 'master'. |
Let's ignore the MacOS failures for now. It looks like a problem with the build images being out of date. I can override and merge. |
I also noticed the problems with builds which was also why I manually triggered https://nunit.visualstudio.com/NUnit/_build/results?buildId=4256&view=results, but I've not had time to look at it the last couple of week. Regarding failures like this I proposed to run the builds every day in #3928, but so far I've not heard any feedback. EDIT: I've made a PR that should fix the CI on MacOS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manfred-brands Thanks for investigating + putting this PR up! I have one suggestion that may help with ensuring these tests continue to run in the future
src/NUnitFramework/tests/Attributes/OSPlatformAttributeTests.cs
Outdated
Show resolved
Hide resolved
8d9b37b
to
afa2578
Compare
Perform a few compiler suggested changes.
Thanks for your contribution @manfred-brands ! We'll need a second approval before the PR can be merged. |
LGTM. Thanks for your contribution @manfred-brands ! |
Fixes #3866
Approach taken is to convert a
SupportedOSPlatformAttribute
into aPlatformAttribute
withInclude
anda
UnsupportedOSPlatformAttribute
into aPlatformAttribute
withExclude
.Here the passed in PlatformName is translated into a Platform that is supported by NUnit.
Currently only supported are:
Other names are passed verbatim, like: Android, Browser.
These will result in invalid Platform name errors in NUnit.