Skip to content
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

Replace OctopusRepositoryExtensions with methods that reuse RootResource #869

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rosslovas
Copy link
Contributor

@rosslovas rosslovas commented Aug 13, 2024

IOctopusAsyncRepository and IOctopusRepository have extension methods ForSpace and ForSystem which return a new repository with a different scope. This had the unintended consequence of discarding a cached RootResource if the repository had one, meaning the repository with the changed scope will have to do a fresh HTTP request to /api to get the root resource that could potentially have been avoided.

This PR replaces these extension methods with methods on the repository themselves, which call a new constructor that is able to keep track of the cached RootResource if there was one, solving this problem.

While I would expect most consumers to be unaffected by this change, it is technically a breaking change for certain niche scenarios. A few examples:

  • a consumer had declared their own ForSpace/ForSystem extension methods, but now method resolution prefers the actual instance methods over those extension methods; solvable via renaming the extension method(s) to avoid the conflict
  • a consumer created a class that inherits from a repository that was declaring its own ForSpace/ForSystem method(s); these now must specify the override keyword
  • a consumer created a custom class that implements IOctopus(Async)Repository; now they have two new methods to implement themselves

As such, I will bump the major version here with +semver: breaking.

@rosslovas rosslovas force-pushed the bft/reuse-root-resource branch 4 times, most recently from 165e431 to 317fb74 Compare August 14, 2024 23:46
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.

1 participant