Skip to content

Disable Header Should Prevent Any Extra Output #706

@TheMaverickProgrammer

Description

@TheMaverickProgrammer

Dart SDK version: 3.0.4 (stable) (Wed Jun 7 14:55:32 2023 +0000) on "windows_x64"

I'm using a custom builder to generate JSON from some annotations used in another program. You can think of it like Protobuf. This is working fine but I was surprised that using a header value of an empty string still produced the auto-generated message in the output .json file, which is not compliant to the .json spec. My work-around at the moment is just to trim the file contents after the last line but it seems counter-intuitive to have to do this at all.

Example:

Builder yarnJsonBuilder(BuilderOptions options) => LibraryBuilder(
    YarnGenerator(),
    generatedExtension: '.yarn.json',
    formatOutput: (code) => code
        .split(
            r'// **************************************************************************')
        .last
        .trim(),
    header: '');

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions