Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Bug: Nullable context in Json.NET 12.0.3 crashes testing inside Unity #37

Closed
applejag opened this issue Jan 4, 2020 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@applejag
Copy link
Owner

applejag commented Jan 4, 2020

Description

Newtonsoft.Json 12.0.3 introduced usage of the nullable context. It works fine when building the package thanks to the Microsoft.Net.Compilers.Toolset NuGet package that can compile to .NET Framework even if the code contains nullable references syntax.

Less so lucky with Mono inside Unity.

Expected behavior

Mono compiles the Newtonsoft.Json.Tests code to then let Unity Test Framework run all the NUnit tests.

Actual behavior

Syntax error.

Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(371,53): error CS1003: Syntax error, ',' expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(390,36): error CS1525: Invalid expression term 'byte'
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(390,41): error CS0443: Syntax error; value expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(390,43): error CS1525: Invalid expression term ')'
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(390,43): error CS1003: Syntax error, ':' expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(408,19): error CS1001: Identifier expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(408,19): error CS1003: Syntax error, ',' expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(408,21): error CS1002: ; expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(417,24): error CS1525: Invalid expression term 'byte'
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(417,29): error CS0443: Syntax error; value expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(417,31): error CS1525: Invalid expression term ')'
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(417,31): error CS1003: Syntax error, ':' expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(417,32): error CS1002: ; expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(421,2): error CS1024: Preprocessor directive expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(541,2): error CS1024: Preprocessor directive expected
Assets/Newtonsoft.Json.Tests/Linq/JTokenTests.cs(608,2): error CS1024: Preprocessor directive expected
-----CompilerOutput:-stderr----------
-----EndCompilerOutput---------------

Full logs:
https://app.circleci.com/jobs/github/jilleJr/Newtonsoft.Json-for-Unity/468

Details

Host machine OS running Unity Editor 👉 Linux

Unity build target 👉 Linux (Mono)

Newtonsoft.Json-for-Unity package version 👉 12.0.301

I was using Unity version 👉 2019.2.11f1, 2018.4.14f1

@applejag applejag added the bug Something isn't working label Jan 4, 2020
@applejag applejag self-assigned this Jan 4, 2020
@applejag
Copy link
Owner Author

applejag commented Jan 4, 2020

Turns out referencing the correct NUnit.Framework version (3.5.0.0) in the Newtonsoft.Json.Tests then it can be build by the side and then Unity will see the tests from within the precompiled dll and they're fully runnable.

For reference, found the correct NUnit version by inspecting the Library/PackageCache/[email protected]/net35/unity-custom/nunit.framework.dll, from within the Unity project.

Tested in Unity 2019.2.11f1.

image

For reasons I do not know, there are 5 tests that did not run. Unity won't show which they are. Shows 0 tests if I filter to only show tests that did not run. Weird /shrug

@applejag
Copy link
Owner Author

applejag commented Jan 19, 2020

Fixed by #36

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant