-
Notifications
You must be signed in to change notification settings - Fork 209
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
Disallow part of dotted.name;
.
#2358
Comments
dart-lang/linter#3567 added a lint to enforce using strings in |
Can something be done to also remove |
Not sure how auto-generating The reason for part files having a Generating |
Won't the macro be able to add code to arbitrary file ? When it see a |
Macros won't save their generated code back to disk. They generate code during compilation, so the code can react to changes in the macro tag, macro implementation or the library the macro applies to. If a tool sees the part file first, it doesn't know which library to find and therefore not which macro to apply to generate the |
// ----- Library 'lib1.dart'.
library lib;
import 'dart:io';
part 'part.dart';
// ----- Library 'lib2.dart'.
library lib;
import 'some_other_library_that_provides_replacements_for_some_io_things';
part 'part.dart';
// ----- Part file 'part.dart'.
part of lib;
// Implementation of something that needs io-ish features, but which can
// be compiled using 'dart:io' as well as 'some_other_...'.
... A program could then import 'lib1.dart' or 'lib2.dart', depending on whether it's possible or impossible to have an |
We introduced the
part of "librarypath.dart";
part-of syntax because it allows tools to go from a part file to the containing library file without needing to guess the context of compilation. It was an alternative to, and improvement on, the existingpart of name.of.library;
syntax.And we also did it because we have moved away from requiring libraries to have names, and needing to add a name to a library, just to let it have a
part
declaration, seemed unnecessary. (Like library names in general.)I suggest that we remove the old syntax entirely for Dart 3.0.
There is no lint for this, but it's in the style guide. There might still be uses in the wild. It should be an easy migration to implement for dartfix.
The internal
dart:
platform libraries are heavy users ofpart
files and does not work if you writepart of "dart:async";
(at least didn't at some point in the past, where we tried migration away from the name-based syntax). We should fix that too.(Preferably also fix #1073, so users can completely stop using unnecessary library names).
The text was updated successfully, but these errors were encountered: