-
Notifications
You must be signed in to change notification settings - Fork 755
Make IgnoreAttribute.Reason public
#4781
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
manfred-brands
left a comment
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 @RenderMichael
I think throwing an exception at the earliest opportunity is normally an improvement, but I'm not sure here.
There is a slight chance of an unexpected exception when a user did:
[Ignore(null!, Until = "2025-01-06")]
The other issues is throwing an exception in an Attribute constructor.
We had issues in the past where this stopped test discovery, instead of failing the tests itself.
IgnoreAttribute.Reason public, null check up-frontIgnoreAttribute.Reason public
I don't think it should be Note that even if we declare it as non-nullable, if the consuming project is not nullable aware, they can specify |
|
A null reason seems like an error in some cases, but valid in others. I propose changing the This will change existing code which does |
|
I believe that will trigger a roslyn warning. Which then has to be suppressed. PS. Not at pc right now |
|
@CharliePoole Do you remember the Until option and code around that? Never used it myself, not even aware of it, and not seen it used either. |
In that case the PR is ready for review. |
|
@OsirisTerje I think I was involved when it was first added but lots has changed with the introduction of nullables. Basically, however, the intention of Ignore was to always require a reason. We got some pushback on that from users who wanted an easy way to skip a test without leaving a note behind, but we resisted it. I think the loophole that @manfred-brands points out was probably unintended, but it's possible someone thought that the existence of a date served as a reason... i.e. that something would be fixed by that date. IMO, that "something" should be given as the reason. This, btw, is why Ignore is treated as a type of warning as opposed to tests we always want to skip, e.g. on a particular platform. A warning without any text isn't much of a warning! |
OsirisTerje
left a comment
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.
Lgtm





fixes #4777
test.Properties.Set will throw on a null reason:https://github.com/nunit/nunit/blob/main/src/NUnitFramework/framework/Internal/PropertyBag.cs#L51So I'm adding a null-check up-front. If that's not necessary or desirable I can remove it.