Sdk: Comments in project.json array literals incorrectly read as array elements

Created on 14 May 2016  路  5Comments  路  Source: dotnet/sdk

Steps to reproduce

Add the following to your project.json

"buildOptions": {
  "embed": {
    "exclude": [
      //"Strings.fr.resx"
    ]
  }
}

Expected behavior

Application runs as expected with the fr resources.dll (if "Strings.fr.resx" exists, this isn't necessary to reproduce) in the output since there is nothing in the exclude array.

Actual behavior

> dotnet run
Illegal characters in path.
Parameter name: path

Same output is in build, publish and some others since it seems to attempt to interpret //"Strings.fr.resx" as a path

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc2-002678)

Product Information:
 Version:     1.0.0-rc2-002678
 Commit Sha:  3b2ea9d14b

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64

Most helpful comment

That's the point: from my perspective (someone new to C#/.NET stack) that's perfectly illegal to use comments in JSON: http://stackoverflow.com/questions/244777/can-i-use-comments-inside-a-json-file
http://www.ietf.org/rfc/rfc7159.txt
So for me that's not an issue

All 5 comments

But that JSON is incorrect, as there are no comments support in JSON. Do you want add some usage pattern from xproj or other tooling?

JSON.Net supports comments

mmm ... yeah. This issue was sort of beaten to death back in https://github.com/aspnet/Announcements/issues/24

TL;DR ... JSON (pure JSON) does not support comments; therefore this is the equivalent of just typing random characters into the file, which of course one wouldn't expect to work. :smile: I was hoping back in those days for JSON5, but that was rejected on the grounds that tooling should adopt the pure standard. Now that we'll be going to csproj, this won't matter soon.

That's the point: from my perspective (someone new to C#/.NET stack) that's perfectly illegal to use comments in JSON: http://stackoverflow.com/questions/244777/can-i-use-comments-inside-a-json-file
http://www.ietf.org/rfc/rfc7159.txt
So for me that's not an issue

Seems to me that the behavior here is very close to the JSON spec. Also, as @GuardRex mentions above, this issue has been debated previously on ASP.NET Core repos. I will close this issue. If you believe that this an error, please reopen.

Was this page helpful?
0 / 5 - 0 ratings