Issues with parsing project.json (in .NET Core projects)

Issue #263 resolved
Igor Soloydenko created an issue

I can't import project.json with project dependencies from an open-source GitHub hosted source code.

versionEyeIssue.PNG

Is it a bug or I am not using VersionEye the right way?

Thanks!

Comments (11)

  1. Robert Reiz

    Thanks for reporting this. I just tried to fetch in the file via the URL function and it didn't worked. Seems to be a bug. @timgluz can you double check that please?

  2. Igor Soloydenko reporter

    @timgluz Thanks for looking into it!

    This is actually a valid JSON document, IMO. Why do you think it's invalid?

    {
        "version": "1.0.0",
    
        "dependencies": {
            "NETStandard.Library": "1.6.0"
        },
    
        "frameworks": {
            "netstandard1.6": {
                "imports": "dnxcore50"
            }
        }
    }
    

    I have verified it is valid with http://jsonlint.com/

    It may be not a valid project.json document, though. I can't guarantee it. However, this document was only modified via Visual Studio 2015, so if the document is invalid, it may point us to a bug in VS itself.

  3. Igor Soloydenko reporter

    I am not sure if it is helpful, but here is a diff between the not working project.json from ObEq project and a working one from Mirror project.

    diff --git a/./ObEq.Tests/project.json b/../Mirror/Mirror.Tests/project.json
    index e727f67..528c808 100644
    --- a/./ObEq.Tests/project.json
    +++ b/../Mirror/Mirror.Tests/project.json
    @@ -1,14 +1,15 @@
    -<U+FEFF>{
    +{
       "version": "1.0.0-*",
       "testRunner": "xunit",
       "dependencies": {
    -    "ObEq": "1.0.0-*",
    +    "NETStandard.Library": "1.6.0",
         "xunit": "2.1.0",
    -    "NSubstitute": "2.0.0-alpha003",
         "dotnet-test-xunit": "1.0.0-rc2-build10025",
    -    "Microsoft.AspNetCore.TestHost": "1.0.0",
    -    "System.Diagnostics.TraceSource": "4.0.0-rc2-24027"
    +    "NSubstitute": "2.0.0-alpha003",
    +    "System.Diagnostics.TraceSource": "4.0.0-rc2-24027",
    +    "Mirror": "1.0.0"
       },
    +
       "frameworks": {
         "netcoreapp1.0": {
           "dependencies": {
    @@ -17,13 +18,11 @@
               "version": "1.0.0"
             }
           },
    +
           "imports": [
             "dnxcore50",
             "portable-net45+win8"
           ]
         }
    -  },
    -  "buildOptions": {
    -    "copyToOutput": [ "appsettings*.json" ]
       }
    -}
    \ No newline at end of file
    +}
    

    As you can see, there are at least two potentially important differences in these documents.

    1 Diff in the beginning of file -- a weird Unicode char

    -<U+FEFF>{
    +{
    

    2: Another one is in the very end of the document:

    \ No newline at end of file
    +}
    

    No new line at end vs presence of a new line char.

    Do you have integration tests that prove any of these characters may break project.json parsing? I apologize for not being able to check it quickly -- it's 2AM in the morning in Seattle now...

  4. Timo Sulg

    :D Yes, it is.

    I forgot to shut off JSON beautifier plugin when i was linting the source file the first time.

    Yep, i can now replicate the issue after curling raw file and not copy-pasteing it from raw-file;

    The issue really seems to be with the 'ZERO WIDTH NO-BREAK SPACE' at the beginning, which brokes ruby JSON parser;

  5. Igor Soloydenko reporter

    @timgluz I'll try to fix my project.json files then. I am not sure where this damn character comes from :(

    Could you positively confirm this is an issue with U+FEFF ? Is there a way for you to configure the Ruby JSON parser to tolerate these whitespace characters? Please, consider this as a feature request (that requires discussion with your team and project manager I guess).

    Thank you!

  6. Timo Sulg

    I've currently failing tests for U+FEFF case, but not for 2nd case;

    i'm currently working on a feature that would replace all unicode whitespaces to ascii space and it should be quick fix;

  7. Robert Reiz

    I just deployed the bugfix to production. Please test it again and confirm that it works for you. If it still doesn't work please re open this ticket.

  8. Igor Soloydenko reporter

    @reiz I modified my problematic files before I could test the fix and tell you for sure it is resolved.

    I did try to test the fix on some other project.json files in branches that should have give me an error too if the fix was not there. As of now, it worked for every file. Seems to be resolved. Thank you!

    P.S. You guys have a great response time!

  9. Log in to comment