I am test meta conding, i want generate a part of XXX; code, i try to use b.directives.add(Directive.partOf(entryLib.name)); to do this, but i get part of 'test';, the ' is redundant.
class JsonSerializableBuilder implements Builder {
static const inputExtension = '.dart';
static const ouputExtension = '.json.dart';
@override
final buildExtensions = const {
inputExtension: [ouputExtension]
};
@override
Future<void> build(BuildStep buildStep) async {
final entryLib = await buildStep.inputLibrary;
// entryLib.name is 'test'
final jsonLibrary = Library((b) {
b.directives.add(Directive.partOf(entryLib.name));
});
final emitter = DartEmitter.scoped(
orderDirectives: true, useNullSafetySyntax: sourceLibIsNonNullable);
final rawOutput = jsonLibrary.accept(emitter).toString();
final jsonLibraryContent = DartFormatter().format(rawOutput);
final jsonLibraryAsset = buildStep.inputId.changeExtension(ouputExtension);
await buildStep.writeAsString(jsonLibraryAsset, jsonLibraryContent);
}
}
The generated file is
part of 'test';
I find code in code_builder-4.1.0\lib\src\emitter.dart 323 lines. The code not consider DirectiveType, use ' to all type.
I think it is a bug........
I am test meta conding, i want generate a
part of XXX;
code, i try to useb.directives.add(Directive.partOf(entryLib.name));
to do this, but i getpart of 'test';
, the'
is redundant.The generated file is
I find code in
code_builder-4.1.0\lib\src\emitter.dart
323 lines. The code not considerDirectiveType
, use'
to all type. I think it is a bug........