Skip to content

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

Merged
merged 4 commits into from
Oct 24, 2021

Conversation

manfred-brands
Copy link
Member

@manfred-brands manfred-brands commented Sep 6, 2021

Fixes #3866

Approach taken is to convert a SupportedOSPlatformAttribute into a PlatformAttribute with Include and
a UnsupportedOSPlatformAttribute into a PlatformAttribute with Exclude.

Here the passed in PlatformName is translated into a Platform that is supported by NUnit.
Currently only supported are:

.NET 5 PlatformName NUnit Platform
Windows Win
Windows[0-9] Windows[0-9]
OsX, MacOS MacOsX
Linux Linux

Other names are passed verbatim, like: Android, Browser.
These will result in invalid Platform name errors in NUnit.

@manfred-brands manfred-brands marked this pull request as ready for review September 6, 2021 08:41
Copy link
Member

@Dreamescaper Dreamescaper left a 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.

/// </summary>
/// <param name="possibleSupportedOSPlatformAttribute"></param>
/// <returns></returns>
public static object Translate(object possibleSupportedOSPlatformAttribute)
Copy link
Member

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)

Copy link
Member Author

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

Copy link
Member

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 ?

Copy link
Member Author

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.

Copy link
Member

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!

Copy link
Member

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.

@manfred-brands
Copy link
Member Author

@mikkelbu MacOS builds fail with "The repository primary signature validity period has expired". Also fails in 'master'.

@rprouse
Copy link
Member

rprouse commented Sep 28, 2021

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.

@mikkelbu
Copy link
Member

mikkelbu commented Sep 28, 2021

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.

Copy link
Member

@stevenaw stevenaw left a 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

Perform a few compiler suggested changes.
@stevenaw
Copy link
Member

stevenaw commented Oct 5, 2021

Thanks for your contribution @manfred-brands ! We'll need a second approval before the PR can be merged.

@stevenaw stevenaw merged commit d8e06e8 into nunit:master Oct 24, 2021
@stevenaw
Copy link
Member

LGTM. Thanks for your contribution @manfred-brands !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SupportedOSPlatform
5 participants