Skip to content

Commit 6067480

Browse files
committed
Add UnityLite package
1 parent 38ac231 commit 6067480

File tree

77 files changed

+2234
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2234
-74
lines changed

Json.Net.Unity3D.sln

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json", "src\Newtonsoft.Json\Newtonsoft.Json.csproj", "{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}"
77
EndProject
@@ -11,16 +11,20 @@ Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
1313
Release|Any CPU = Release|Any CPU
14+
ReleaseLite|Any CPU = ReleaseLite|Any CPU
1415
EndGlobalSection
1516
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1617
{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1718
{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
1819
{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
1920
{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}.ReleaseLite|Any CPU.ActiveCfg = ReleaseLite|Any CPU
22+
{955B96F2-6AFB-4C2F-AAA5-9BFD6DDCB3BD}.ReleaseLite|Any CPU.Build.0 = ReleaseLite|Any CPU
2023
{DD26402C-A73F-47F8-B8BC-F6D9353AA9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2124
{DD26402C-A73F-47F8-B8BC-F6D9353AA9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
2225
{DD26402C-A73F-47F8-B8BC-F6D9353AA9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
2326
{DD26402C-A73F-47F8-B8BC-F6D9353AA9E0}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{DD26402C-A73F-47F8-B8BC-F6D9353AA9E0}.ReleaseLite|Any CPU.ActiveCfg = Release|Any CPU
2428
EndGlobalSection
2529
GlobalSection(SolutionProperties) = preSolution
2630
HideSolutionNode = FALSE

NOTE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Note
2+
3+
## Assembly Size
4+
5+
Newtonsoft Json.NET 8.0.2
6+
- NET45: Json.NET for .NET45
7+
- NET35: Json.NET for .NET35
8+
- Unity = NET35 with Unity support
9+
- UnityLite = Unity - Json.Linq - Bson
10+
11+
| | NET45 | NET35 | Unity | UnityLite |
12+
| :--------- | ------: | ------: | ------: | --------: |
13+
| String | 66,256 | 58,372 | 44,528 | 35,448 |
14+
| Blob | 44,116 | 34,628 | 25,268 | 19,668 |
15+
| UserString | 52,736 | 47,168 | 37,632 | 28,580 |
16+
| Guid | 16 | 16 | 16 | 16 |
17+
| Table | 153,708 | 117,064 | 87,212 | 61,576 |
18+
| Method | 169,310 | 154,787 | 119,086 | 89,958 |
19+
| Etc | 35,074 | 31,357 | 21,106 | 14,098 |
20+
| Total | 521,216 | 443,392 | 334,848 | 249,344 |
21+
| Relative | 100% | 85% | 64% | 47% |

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ Following works are done to make Json.NET support Unity3D.
3535
- Remove JPath class to reduce size of DLL.
3636
- Remove DiagnosticsTraceWriter support.
3737

38+
For Unity.Lite version, additional works are done to make more lite.
39+
40+
- Remove JsonLinq (JToken, ...)
41+
- Remove Bson
42+
3843
## FAQ
44+
3945
- Q: App stops throwing MissingMethodException for ComponentModel.TypeConverter like this.
4046
```
4147
MissingMethodException: Method not found:

build.fsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ Target "Clean" (fun _ ->
2828
)
2929

3030
Target "Build" (fun _ ->
31+
// Regular
3132
!! buildSolutionFile
3233
|> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration ]
3334
|> Log "Build-Output: "
35+
// Lite
36+
!! buildSolutionFile
37+
|> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration + "Lite" ]
38+
|> Log "Build-Output: "
3439
)
3540

3641
Target "Test" (fun _ ->
@@ -42,9 +47,14 @@ Target "Test" (fun _ ->
4247
OutputFile = testDir @@ "TestResult.xml" })
4348
)
4449

45-
Target "Package" (fun _ ->
50+
Target "Package" (fun _ ->
51+
(!! ("src/Newtonsoft.Json/bin/" + buildConfiguration + "/Newtonsoft.Json.dll*")) |> Copy "src/UnityPackage/Assets/Middlewares/JsonNet"
52+
("src/Newtonsoft.Json/bin/" + buildConfiguration + "Lite/Newtonsoft.Json.dll") |> CopyFile "src/UnityPackageLite/Assets/Middlewares/JsonNet/Newtonsoft.Json.Lite.dll"
53+
("src/Newtonsoft.Json/bin/" + buildConfiguration + "Lite/Newtonsoft.Json.dll.mdb") |> CopyFile "src/UnityPackageLite/Assets/Middlewares/JsonNet/Newtonsoft.Json.Lite.dll.mdb"
4654
Unity (Path.GetFullPath "src/UnityPackage") "-executeMethod PackageBuilder.BuildPackage"
55+
Unity (Path.GetFullPath "src/UnityPackageLite") "-executeMethod PackageBuilder.BuildPackage"
4756
(!! "src/UnityPackage/*.unitypackage") |> Seq.iter (fun p -> MoveFile binDir p)
57+
(!! "src/UnityPackageLite/*.unitypackage") |> Seq.iter (fun p -> MoveFile binDir p)
4858
)
4959

5060
Target "Help" (fun _ ->

src/Newtonsoft.Json/Bson/BsonBinaryType.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525

2626
using System;
2727

28+
#if NO_BSON
29+
30+
// Dummy namespace
31+
namespace Newtonsoft.Json.Bson
32+
{
33+
class Dummy { }
34+
}
35+
36+
#else
37+
2838
namespace Newtonsoft.Json.Bson
2939
{
3040
internal enum BsonBinaryType : byte
@@ -41,4 +51,6 @@ internal enum BsonBinaryType : byte
4151
Md5 = 0x05,
4252
UserDefined = 0x80
4353
}
44-
}
54+
}
55+
56+
#endif

src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26+
#if !NO_BSON
27+
2628
using System;
2729
using System.Globalization;
2830
using System.IO;
@@ -328,4 +330,6 @@ private int CalculateSize(BsonToken t)
328330
}
329331
}
330332
}
331-
}
333+
}
334+
335+
#endif

src/Newtonsoft.Json/Bson/BsonObjectId.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26+
#if !NO_BSON
27+
2628
using System;
2729
using Newtonsoft.Json.Utilities;
2830

@@ -54,4 +56,6 @@ public BsonObjectId(byte[] value)
5456
Value = value;
5557
}
5658
}
57-
}
59+
}
60+
61+
#endif

src/Newtonsoft.Json/Bson/BsonReader.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26+
#if !NO_BSON
27+
2628
using System;
2729
using System.Collections.Generic;
2830
using System.Globalization;
@@ -566,13 +568,13 @@ private byte[] ReadBinary(out BsonBinaryType binaryType)
566568

567569
binaryType = (BsonBinaryType)ReadByte();
568570

569-
#pragma warning disable 612,618
571+
#pragma warning disable 612, 618
570572
// the old binary type has the data length repeated in the data for some reason
571573
if (binaryType == BsonBinaryType.BinaryOld && !_jsonNet35BinaryCompatibility)
572574
{
573575
dataLength = ReadInt32();
574576
}
575-
#pragma warning restore 612,618
577+
#pragma warning restore 612, 618
576578

577579
return ReadBytes(dataLength);
578580
}
@@ -824,4 +826,6 @@ private byte[] ReadBytes(int count)
824826
return _reader.ReadBytes(count);
825827
}
826828
}
827-
}
829+
}
830+
831+
#endif

src/Newtonsoft.Json/Bson/BsonToken.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26+
#if !NO_BSON
27+
2628
using System.Collections;
2729
using System.Collections.Generic;
2830

@@ -154,4 +156,6 @@ internal class BsonProperty
154156
public BsonString Name { get; set; }
155157
public BsonToken Value { get; set; }
156158
}
157-
}
159+
}
160+
161+
#endif

src/Newtonsoft.Json/Bson/BsonType.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
// OTHER DEALINGS IN THE SOFTWARE.
2424
#endregion
2525

26+
#if !NO_BSON
27+
2628
namespace Newtonsoft.Json.Bson
2729
{
2830
internal enum BsonType : sbyte
@@ -48,4 +50,6 @@ internal enum BsonType : sbyte
4850
MinKey = -1,
4951
MaxKey = 127
5052
}
51-
}
53+
}
54+
55+
#endif

0 commit comments

Comments
 (0)