-
Notifications
You must be signed in to change notification settings - Fork 735
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
Make a generic equals constraint #4845
Comments
@nunit/framework-team Looking for thoughts on timing here. Given that
However this would also mean we must redeclare all methods on the generic constraint via |
We can never make a good generic API which restricts modifiers when deriving from that. Please see my remarks: #4848 (comment) and #4848 (comment) for a different approach as demonstrated in PRs: #4847, #4848, #4853 |
I see them serving different, complimentary needs myself. For example, two ValueTuples of I would, however, suggest we aim to agree upon similar approaches in how we do it in order to keep the API and behaviours consistent. I think so far we have approached things differently. My own aim for minimizing breaking changes on a catch-all constraint seems to have worked syntactically but has brought with it some challenges that can't be fully resolved without a breaking change later. If we wanted to consider binary or source breaking changes as part of yours and my current work then I would be interested in hearing some thoughts from the broader team as well. |
My changes don't affect this. For all complex cases we will fallback to the existing |
Agreed! I think our PRs tackle different use cases and needs. However, as both our PRs would either benefit from or require breaking changes to implement, I'd been hoping to hear from another @nunit/framework-team member their thoughts on timing for such changes. A few options I'd see for when the changes could happen:
I would say we should try and limit the number of releases with breaking changes, whatever that may look like, in order to simplify upgrade paths. @manfred-brands To be clear: I think there's a lot of value with your type-specialization PRs. I just think it's worth discussing when we do them to ensure we're all in agreement on timing. |
The second case here, runtime exceptions, if a PR prevents that, it is not a breaking change to me. The first case, don't make sense , assuming this is like EqualTo(42).Within(5).Seconds and similar stuff, I would also not regard as a breaking change, at least not in a type-safe world. I have not gone into the details of all of what you're discussing, but can we split the stuff into:
Everything is in 0 at start, then move it into one of the three as we know and learn more. For 1) and 2) , the PRs go into the 4.X release train. I see no problem with major version changes. We should just collect up more than one thing in a major release. Otherwise we can surely have 1-4 major releases a year. That said, I don't think we should waste efforts (if that is what it is - some of what I understand from some writing above), in making things temporarily work. I would prefer to just add that to the vNext train and move on. (Ref #4845 (comment))
I would go for the breaking changes, if it is not obvious and simple to do it with a non-breaking change, but then put it into the vNext train. What we did with the 3 to 4 version change was pretty good. We had a good migration guide. And, we used the analyzer to help people. We could do the same again with 4 to 5. PS: For the 5.0 we should put out a beta version on nuget.org. It gets more traction than the alpha myget packages we have. PS2: I noticed that the transfer to 4 took quite some time for people. The pick up of 4. was slow in the beginning, but lately it has really picked up. The 3.13.3 is still the one that have the most downloads last 6 weeks, but now 4.1 is second. 4.2.2 is also picking up speed quickly. |
Thanks @OsirisTerje and neat to see the uptake of 4 increasing. FWIW I think we're all in agreement on the "shifting of runtime errors to compiler errors", especially in the context of tests as it will likely result in a non-passing test either way. Something I'm a little less clear on would be something like below: [Test]
public void MyTest() => Assert.That(1, Is.EqualTo(1).IgnoreCase); The EDIT: Though reading your description again, I think this falls into category 3 as the existing behaviour is not a runtime error? |
Returning back to the catch-all generic constraint, I think it would also likely be easier if done as a breaking change in vNext. At which point I think it could be a nice time to try and get generics as far into the constraints as possible. |
As part of expanding generics support for the constraints API, we would need to make the equals constraint generic.
This would be one piece of the larger effort described in #53
The text was updated successfully, but these errors were encountered: