-
Notifications
You must be signed in to change notification settings - Fork 179
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
Deprecate ClearConfiguration #1767
Comments
Out of interest, why is deprecation breaking? |
FTR most of the previous deprecations are not labelled as breaking. |
Hi @adamralph, nice to see you here! |
(we started applying this rule for 5.0.0, I think, which is why earlier deprecations weren't labelled as breaking) |
hey @thomaslevesque, thanks for the explanation. FWIW, IMO those changes are not breaking. If someone has enabled "treat warnings as errors", they are effectively asking the SDK to break their build on non-breaking changes. The messages are still, semantically, warnings. Ultimately, a consumer could configure their build to break in reaction to any type of change, and you have no control over that. The only thing you have control over of is the semantics of the change you are making, and in the case of adding FWIW, the approach we use for NServiceBus is:
Note that we also combine this with a recommendation to upgrade one major version at a time, which allows the messages of the obsolete attributes to guide them. |
Hi @adamralph, I see your point. Your approach in NServiceBus is interesting. You effectively remove the member at the same point as we do (major + 2), but you start warning the user earlier, which I think is good. With our approach, we go directly from "warning that the user could ignore" to "remove the method completely", which leaves the user wondering what to do about it. I like the idea of "obsolete with true", which forces the user to take action, and still gives information about what to do (assuming the error message says what to use instead). @blairconrad what do you think? |
Hey, @adamralph. Long time no see! I think @thomaslevesque has the reasoning right. We didn't want to excessively bother people who had "treat warnings as errors" on. @adamralph, your point ("they literally asked for it", if I may paraphrase) is valid. I'm not fussy. I think the current approach is fine, but the NServiceBus one also seems like a good one. I'm okay to adopt it. If we do, I'd consider documenting the what and why so we have a record. Issue labels seems like the best existing wiki page, if we didn't want to create a new one… |
There's also something in SemVer about this:
|
I'm fine with a change, including to the NServiceBus model. Glad to see it's consistent with SemVer's recommendation, but keep in mind, FIE's current approach is as well. We do document, issue a new minor with the deprecation in place (and a major), and finally a new major with the functionality removed. |
Perhaps I'm misunderstanding then. If all your deprecations are treated as breaking, then you only release them in majors, no? |
I believe that in practice there's always a new minor before the major. I'm not arguing against a switch to the model followed by NServiceBus. |
@blairconrad so you do release the deprecation in a minor? By "deprecation" I mean decoration with |
Some minor release will have the deprecation. Oh! I get it. You're reading
as
That's why we're not quite lining up. I suppose this is an interpretation, but I don't think having the |
This is getting confusing. 😆 Would it be correct to say that your definition of "deprecation" is:
? And therefore you are saying that you do indeed "release" a deprecation in a minor? My definition of "deprecation" is
I believe you are only doing that in a major, correct? |
Yes |
I see @thomaslevesque got in before I could finish this comment. I'ma finish anyhow! A concrete example may make it more clear. Let's take the change in call repetition syntax that was (somewhat) recently introduced. It was possible to add the new API alongside the old one until we removed the old one.
As you say, the Again, not fighting a switch to another model (for example the one NServiceBus uses), just saying that I don't the current one is so horrible. |
@blairconrad thanks for the clarification. It is these statements that confused me:
Anyhow, it all goes back to the same question: is adding IMO it's non-breaking, and IYO (up until now at least) it's breaking. That's fine. I wanted to provide you with another POV for consideration, but ultimately the decision is, of course, yours. |
Sure thing, @adamralph. And the NSubstitute way is interesting. But I do think there's a question beyond whether In particular, I'm thinking of a scenario where a client using version 4.3.0, 4.4.0 deprecates an endpoint via |
I assume you meant NServiceBus. I don't think @adamralph left FakeItEasy to go working on NSubstitute 😄 |
This change has been released as part of FakeItEasy 7.0.0-beta.1. |
This change has also been released as part of FakeItEasy 7.0.0. |
I see in the linked issue that clearing the configuration supposedly removed its strictness. My use case is an integration test using a Test WebApplicationFactory in dotnet. I get an httpclient from that and for test performance reasons we prefer to do that once per test class, not per test. The client caches its server so without an ability to change fakes we're a bit out of luck. I can override it, but if I don't carefully make each fake a "once" call, the config will bleed from test to test. Any better ways around this? |
Not supposedly; it definitely did (which was not intended, of course).
I feel like I'm missing something here. The |
Our test factory subclass allows setting certain internal objects' Dependency Injection. Essentially it calls this ReplaceService method on the mocks. Then the client gets created and future calls to ReplaceService don't affect the cached server so we're stuck with the service that gets assigned when the client is first created (and if tests run out of order it can cause chaos).
Solutions (both crummy): |
Ah, I see. Indeed, that's a scenario where @blairconrad any idea on how to solve this? |
Or maybe you could do something like this:
The service is registered as transient, so the delegate is evaluated every time, but will always return |
Hey, @rmiller333. Sorry you're having problems. @thomaslevesque, I was going to suggest some variation on "provide a service that proxies the Fake and just replace the Fake underneath". This is no different than your suggestion, only you have code! I suppose another option might be to instead of clearing configuration, configure the Fake to DoNothing on all incoming calls. It's not the same as clearing out the rules list, but it should have a similar effect. |
It's not the same in the sense that it doesn't remove existing rules, but it still overrides them, so I think it produces exactly the same effect. So basically, where you were doing |
As discussed in #1764, it's somewhat confusing, and untangling it is probably not worth the effort. The preferred method of getting a Fake with no configuration is to just make a new one.
The text was updated successfully, but these errors were encountered: