sdk icon indicating copy to clipboard operation
sdk copied to clipboard

dotnet muxer reports JSON syntax error when global.json is saved in UTF8+BOM

Open pakrym opened this issue 10 years ago • 28 comments

Steps to reproduce

  1. Save global.json in utf8 with byte order mark.
  2. dotnet build

Expected behavior

dotnet build shows no errors

Actual behavior

A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token

Environment data

dotnet --version output:

A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token
1.0.0-beta-002171

pakrym avatar Mar 31 '16 15:03 pakrym

//cc @piotrpMSFT @davidfowl @victorhurdugaci @pranavkm

pakrym avatar Mar 31 '16 15:03 pakrym

This makes build to fail.

dotnet build
A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token
Project 1 (.NETStandardApp,Version=v1.5) will be compiled because the CLI changed
Compiling 1 for .NETStandardApp,Version=v1.5
D:\temp\1\A JSON parsing exception occurred: * Line 1, Column 2 Syntax error: Malformed token

Compilation failed.
    0 Warning(s)
    1 Error(s)

Time elapsed 00:00:05.4565174

pakrym avatar Mar 31 '16 21:03 pakrym

@pakrym Why is this blocking given that JSON parsing was working all this while?

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

Because now its output makes dotnet build to fail

pakrym avatar Mar 31 '16 21:03 pakrym

Have you changed the format in which the .json files are saved?

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

No, it reports false positive for files with BOM

pakrym avatar Mar 31 '16 21:03 pakrym

Save global.json in utf8 with byte order mark.

How was this saved earlier when this worked? I am not aware of any JSON parsing changes that would result in this.

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

Reporting changed in https://github.com/dotnet/cli/commit/1428eb81cfb1e81251b8241d08e5fefd95882153, it started printing line numbers into stderr and dotnet build thinks its csc errors.

pakrym avatar Mar 31 '16 21:03 pakrym

Are you suggesting that if trace_error was not executed, the build would have succeeded as that would be strange given that json parsing failed?

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

global.json is perfectly valid json file, it just has UTF8 BOM encoding which corehost can not process correctly. So yes, build would have succeeded if this error wasn't written to stderr.

pakrym avatar Mar 31 '16 21:03 pakrym

I'm not fixing it

pakrym avatar Mar 31 '16 21:03 pakrym

This will only make it write to stdout instead stderror

pakrym avatar Mar 31 '16 21:03 pakrym

Casablanca does not support BOM. If you think this is blocking for RTM, let us discuss.

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

I think it blocks RC2, VS saves json files with BOM by default.

pakrym avatar Mar 31 '16 21:03 pakrym

With your workaround in place, I dont believe this is blocking for RC2. We can look into what can be done for RTM for Casablanca.

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

All users would see error message that is not true, how is this not an issue?

pakrym avatar Mar 31 '16 21:03 pakrym

And sdk selection feature won't work at all.

pakrym avatar Mar 31 '16 21:03 pakrym

Are there other editors that allow you to save JSON without BOM marker? If so, can that not be a workaround until RTM to author the json file? Or, are you suggesting there is a case where VS is used to create a project type that will have .json files with BOM markers?

gkhanna79 avatar Mar 31 '16 21:03 gkhanna79

File->Create project->Core console application creates global.json with BOM

pakrym avatar Mar 31 '16 22:03 pakrym

Cc @BillHiebert

schellap avatar Mar 31 '16 22:03 schellap