dub icon indicating copy to clipboard operation
dub copied to clipboard

Use a typed PackageRecipe for packagesuppliers

Open skoppe opened this issue 3 years ago • 4 comments

Instead of dealing with raw json, it is better to parse it at first sight.

skoppe avatar Sep 16 '22 15:09 skoppe

Yes! I've been wanting this for a while, but the problem is that it's a breaking change for library users. Instead adding a final function that forwards to the implementation might do the trick ?

Geod24 avatar Sep 16 '22 15:09 Geod24

but the problem is that it's a breaking change for library users.

Ah, you mean people who inherit from AbstractFallbackPackageSupplier.

Hmm yes, likely not many, but still.

skoppe avatar Sep 16 '22 17:09 skoppe

Ah, you mean people who inherit from AbstractFallbackPackageSupplier.

Hmm yes, likely not many, but still.

Actually, changing the return type of fetchPackageRecipe means anyone implementing the PackageSupplier interface. Still, likely not many, but there aren't many users of Dub as a library. Adding a final function that does the job would help in the short term, and we can just rework this interface in a future major version.

Geod24 avatar Sep 17 '22 09:09 Geod24

@skoppe : If you can find a small change to make (e.g. the [] => null changes) and PR it separately, that would whitelist you for future CI runs of Github, otherwise you'll need someone to keep on approving it every time you update this PR.

Geod24 avatar Sep 17 '22 09:09 Geod24

@Geod24 I don't quite understand how final is going to help, maybe I am missing something.

The way I see it is that I can't just change the PackageSupplier interface, since it is public, and people might have inherited from it.

This means we need to keep the Json fetchPackageRecipe(string packageId, Dependency dep, bool pre_release) function for a while, and deprecate it.

Additionally I can't just add a Nullable!PackageRecipe fetchPackageRecipe(string packageId, Dependency dep, bool pre_release) function, without providing a base implementation. Not to mention that its name conflicts with the deprecated one.


I think I need to add a fetchRecipe function with a base implementation that just calls the original fetchPackageRecipe, while deprecating the latter.

Using that I can implement both fetchRecipe and fetchPackageRecipe in the current package suppliers.

skoppe avatar Oct 15 '22 14:10 skoppe

I think I need to add a [...]

Yes, that's what I was recommending. final because "function body only allowed in final functions in interface".

Geod24 avatar Oct 16 '22 08:10 Geod24