Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Migrate to null safety #93

Merged
merged 12 commits into from
Dec 2, 2020
Merged

Migrate to null safety #93

merged 12 commits into from
Dec 2, 2020

Conversation

lrhn
Copy link
Member

@lrhn lrhn commented Nov 9, 2020

Only migrated the non-deprecated code, as an extra incentive to get people off deprecated code.

Did not update the version number to 2.0.0-nullsafety.0 because pkg:test depends on null-safety<2.0.0.
It should be upgraded to depend on >=1.9.3 <3.0.0, so we can release a pkg:package_config 2.0.0 without the deprecated code.
Until then, we're stuck in package:test-recursive-dependency-hell.

@lrhn lrhn requested review from jakemac53 and natebosch November 9, 2020 15:05
@google-cla google-cla bot added the cla: yes label Nov 9, 2020
@jakemac53
Copy link
Contributor

Did not update the version number to 2.0.0-nullsafety.0 because pkg:test depends on null-safety<2.0.0.
It should be upgraded to depend on >=1.9.3 <3.0.0, so we can release a pkg:package_config 2.0.0 without the deprecated code.
Until then, we're stuck in package:test-recursive-dependency-hell.

This cycle only exists in dev dependencies, I would use dependency overrides to force the version of package:test. This is what glob, args, etc are doing.

The test package should not depend on a version range of its deps that allows both migrated and unmigrated versions (nor should any package), that seems very risky.

@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.7

@Deprecated("Use the package_config.json based API")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do the breaking version and delete these libs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the analyzer is still using the deprecated API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that because they need to use it or just haven't migrated?

Copy link
Member Author

@lrhn lrhn Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are reading .packages files directly, then using the legacy functionality in this package to parse the file into a map. That's not supported directly by the new API. You can read a .packages file into a PackageConfig object using

loadPackageConfig(file, preferNewest: false);

The plain map from name to package root isn't supported any more because it makes no sense for package_config.json files.

Sam is working on it now: dart-lang/sdk#44116

lib/src/discovery.dart Outdated Show resolved Hide resolved
Uri location,
Future<Uint8List /*?*/ > loader(Uri uri) /*?*/,
void onError(Object error) /*?*/,
Future<Uint8List?> loader(Uri uri)?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is pretty weird to have a nullable required positional argument like this... should we consider changing the api?

It seems like the only required argument should be location really and the others should be optional named args.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's internal API.
I usually don't bother with optional parameters for internal API, it's not there to be ergonomic, just to be clear and precise.

lib/src/package_config.dart Outdated Show resolved Hide resolved
lib/src/package_config_json.dart Outdated Show resolved Hide resolved
String /*?*/ packageUri;
String /*?*/ languageVersion;
Map<String, dynamic> /*?*/ extraData;
Package? parsePackage(Map<String, dynamic> entry) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been going with Map<String, Object?> for all the other packages because it makes the potential error conditions more explicit via explicit casts instead of dynamic calls.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove every instance of dynamic. And good riddance :)

@lrhn
Copy link
Member Author

lrhn commented Nov 12, 2020

Used dependency overrides and made it a 2.0.0 version without deprecated APIs.

Still can't be tested because the analyzer depends on the removed APIs.

Copy link
Contributor

@jakemac53 jakemac53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally LGTM, but we should wait until it can be tested to land it :).

@lrhn lrhn merged commit 92aed9e into master Dec 2, 2020
@lrhn
Copy link
Member Author

lrhn commented Dec 2, 2020

Tested, landed, will publish.

@lrhn lrhn deleted the nullsafety branch December 2, 2020 15:23
@pq
Copy link
Member

pq commented Dec 9, 2020

Curious what the status on publishing here is? I notice the build is broken but maybe this expected?

@natebosch
Copy link
Member

This had been blocked from being pulled into the SDK because of analyzer usage of a deprecated API.

That was migrated to a lib/src/ API which still isn't a good end state, but I don't know if that is a hard blocker for getting pulled into the SDK.

@lrhn - is this ready to get updated in the SDK? Is it still blocked by the analyzer lib/src import? dart-lang/sdk#44116

What is the next step to push on here?

@lrhn
Copy link
Member Author

lrhn commented Dec 10, 2020

I think it's fine to pull into the SDK as-is.

We'll fix the src/ dependency at some later point.

mosuem pushed a commit to dart-lang/tools that referenced this pull request Dec 9, 2024
* Migrate non-deprecated libraries to null safety.

* Major version increment, removing deprecated APIs.

This is the null safe, non-deprecated API for package_config.json
file manipulation.

Also address dart-lang/package_config#86.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants