Skip to content

Commit

Permalink
Deprecate Package JSON constructor
Browse files Browse the repository at this point in the history
Over the last year, various JSON overloads have been deprecated,
leaving space for more typed interfaces.
This Package constructor had resisted for long,
as the PackageSupplier interface returns JSON itself.
While changing it would be a breaking change and is not
currently possible, we can at least hoist the parsing one level.
  • Loading branch information
Geod24 committed Jan 9, 2024
1 parent 30761d9 commit 9566425
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,8 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend

private Package getPackageRaw(string name, Dependency dep)
{
import dub.recipe.json;

auto basename = getBasePackageName(name);

// for sub packages, first try to get them from the base package
Expand Down Expand Up @@ -1854,7 +1856,9 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend
auto desc = ps.fetchPackageRecipe(name, VersionRange(vers, vers), prerelease);
if (desc.type == Json.Type.null_)
continue;
auto ret = new Package(desc);
PackageRecipe recipe;
parseJson(recipe, desc, null);
auto ret = new Package(recipe);
m_remotePackages[key] = ret;
return ret;
} catch (Exception e) {
Expand Down
1 change: 1 addition & 0 deletions source/dub/package_.d
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Package {
instead of the one declared in the package recipe, or the one
determined by invoking the VCS (GIT currently).
*/
deprecated("Provide an already parsed PackageRecipe instead of a JSON object")
this(Json json_recipe, NativePath root = NativePath(), Package parent = null, string version_override = "")
{
import dub.recipe.json;
Expand Down

0 comments on commit 9566425

Please sign in to comment.