source_gen
source_gen copied to clipboard
SharedPartBuilder partId validation regex and error message are inconsistent
https://github.com/dart-lang/source_gen/blob/master/source_gen/lib/src/builder.dart
If partId provided to the SharedPartBuilder doesn't meet regex validation, an error is thrown:
if (!_partIdRegExp.hasMatch(partId)) {
throw ArgumentError.value(
partId,
'partId',
'`partId` can only contain letters, numbers, `_` and `.`. '
'It cannot start or end with `.`.',
);
}
It states partId can contain a period, however, here's the regex:
const partIdRegExpLiteral = r'[A-Za-z_\d-]+';
final _partIdRegExp = RegExp('^$partIdRegExpLiteral\$');
As you can see, no period is allowed.
Either the error message or regex should be updated to be consistent.