Skip to content
Permalink
Browse files

trying

  • Loading branch information...
neuecc committed Sep 26, 2017
1 parent e902ffd commit 2de96d55e1aa73d48cd29267a694640c2181e082
Showing with 14,962 additions and 263 deletions.
  1. +1 −0 .gitignore
  2. +330 −36 README.md
  3. +28 −1 Utf8Json.sln
  4. +13 −0 make_unity_symlink.bat
  5. +1 −0 sandbox/ConsoleAppNet461/ConsoleAppNet461.csproj
  6. +23 −131 sandbox/ConsoleAppNet461/Program.cs
  7. +866 −0 sandbox/ConsoleAppNet461/gen_test.cs
  8. +68 −0 sandbox/ConsoleAppNet461/gen_test2.cs
  9. +17 −16 sandbox/DynamicCodeDumper/Program.cs
  10. +42 −0 src/Utf8Json.CodeGenerator/App.config
  11. +138 −0 src/Utf8Json.CodeGenerator/CodeAnalysis/Definitions.cs
  12. +780 −0 src/Utf8Json.CodeGenerator/CodeAnalysis/TypeCollector.cs
  13. +124 −0 src/Utf8Json.CodeGenerator/Generator/FormatterTemplate.tt
  14. +644 −0 src/Utf8Json.CodeGenerator/Generator/FormatterTemplate1.cs
  15. +78 −0 src/Utf8Json.CodeGenerator/Generator/ResolverTemplate.tt
  16. +449 −0 src/Utf8Json.CodeGenerator/Generator/ResolverTemplate1.cs
  17. +22 −0 src/Utf8Json.CodeGenerator/Generator/TemplatePartials.cs
  18. +1,463 −0 src/Utf8Json.CodeGenerator/Mono.Options/Options.cs
  19. +150 −0 src/Utf8Json.CodeGenerator/Program.cs
  20. +36 −0 src/Utf8Json.CodeGenerator/Properties/AssemblyInfo.cs
  21. +182 −0 src/Utf8Json.CodeGenerator/Utf8Json.CodeGenerator.csproj
  22. +182 −0 src/Utf8Json.CodeGenerator/Utils/RoslynExtensions.cs
  23. +55 −0 src/Utf8Json.CodeGenerator/packages.config
  24. +199 −0 src/Utf8Json.UnityClient/Assets/Scenes/Main.unity
  25. +284 −0 src/Utf8Json.UnityClient/Assets/Scripts/RuntimeUnitTestToolkit/Assert.cs
  26. +152 −0 src/Utf8Json.UnityClient/Assets/Scripts/RuntimeUnitTestToolkit/ChainingAssertion.Unity.cs
  27. +1,437 −0 src/Utf8Json.UnityClient/Assets/Scripts/RuntimeUnitTestToolkit/UnitTest.unity
  28. +368 −0 src/Utf8Json.UnityClient/Assets/Scripts/RuntimeUnitTestToolkit/UnitTestRunner.cs
  29. +131 −0 src/Utf8Json.UnityClient/Assets/Scripts/Tests/SimpleTest.cs
  30. +38 −0 src/Utf8Json.UnityClient/Assets/Scripts/Tests/_Loader.cs
  31. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/Attributes.cs
  32. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/Formatters
  33. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/IJsonFormatter.cs
  34. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/IJsonFormatterResolver.cs
  35. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/Internal
  36. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/JsonReader.cs
  37. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/JsonSerializer.NonGeneric.cs
  38. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/JsonSerializer.cs
  39. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/JsonToken.cs
  40. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/JsonWriter.cs
  41. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/Resolvers
  42. +280 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/Shims/Reflection.cs
  43. +1 −0 src/Utf8Json.UnityClient/Assets/Scripts/Utf8Json/Unity/ResolverAndFormatters.cs
  44. +17 −0 src/Utf8Json.UnityClient/ProjectSettings/AudioManager.asset
  45. +6 −0 src/Utf8Json.UnityClient/ProjectSettings/ClusterInputManager.asset
  46. +19 −0 src/Utf8Json.UnityClient/ProjectSettings/DynamicsManager.asset
  47. +7 −0 src/Utf8Json.UnityClient/ProjectSettings/EditorBuildSettings.asset
  48. +16 −0 src/Utf8Json.UnityClient/ProjectSettings/EditorSettings.asset
  49. +61 −0 src/Utf8Json.UnityClient/ProjectSettings/GraphicsSettings.asset
  50. +295 −0 src/Utf8Json.UnityClient/ProjectSettings/InputManager.asset
  51. +89 −0 src/Utf8Json.UnityClient/ProjectSettings/NavMeshAreas.asset
  52. +8 −0 src/Utf8Json.UnityClient/ProjectSettings/NetworkManager.asset
  53. +36 −0 src/Utf8Json.UnityClient/ProjectSettings/Physics2DSettings.asset
  54. +594 −0 src/Utf8Json.UnityClient/ProjectSettings/ProjectSettings.asset
  55. +1 −0 src/Utf8Json.UnityClient/ProjectSettings/ProjectVersion.txt
  56. +193 −0 src/Utf8Json.UnityClient/ProjectSettings/QualitySettings.asset
  57. +43 −0 src/Utf8Json.UnityClient/ProjectSettings/TagManager.asset
  58. +9 −0 src/Utf8Json.UnityClient/ProjectSettings/TimeManager.asset
  59. +34 −0 src/Utf8Json.UnityClient/ProjectSettings/UnityConnectSettings.asset
  60. +192 −0 src/Utf8Json.UnityClient/Utf8Json.UnityClient.csproj
  61. +20 −0 src/Utf8Json.UnityClient/Utf8Json.UnityClient.sln
  62. +766 −0 src/Utf8Json.UnityShims/ResolverAndFormatters.cs
  63. +189 −0 src/Utf8Json.UnityShims/Shims.cs
  64. +31 −0 src/Utf8Json.UnityShims/Utf8Json.UnityShims.csproj
  65. +112 −0 src/Utf8Json.UniversalCodeGenerator/CodeAnalysis/Definitions.cs
  66. +594 −0 src/Utf8Json.UniversalCodeGenerator/CodeAnalysis/TypeCollector.cs
  67. +619 −0 src/Utf8Json.UniversalCodeGenerator/Generator/FormatterTemplate1.cs
  68. +449 −0 src/Utf8Json.UniversalCodeGenerator/Generator/ResolverTemplate1.cs
  69. +23 −0 src/Utf8Json.UniversalCodeGenerator/Generator/TemplatePartials.cs
  70. +1,463 −0 src/Utf8Json.UniversalCodeGenerator/Mono.Options/Options.cs
  71. +159 −0 src/Utf8Json.UniversalCodeGenerator/Program.cs
  72. +172 −0 src/Utf8Json.UniversalCodeGenerator/Roslyn/RoslynExtensions.cs
  73. +19 −0 src/Utf8Json.UniversalCodeGenerator/Shims/CodeDom.cs
  74. +18 −0 src/Utf8Json.UniversalCodeGenerator/Utf8Json.UniversalCodeGenerator.csproj
  75. +9 −9 src/Utf8Json/Formatters/CollectionFormatters.cs
  76. +10 −0 src/Utf8Json/Formatters/DateTimeFormatter.cs
  77. +4 −0 src/Utf8Json/Formatters/DictionaryFormatter.cs
  78. +0 −1 src/Utf8Json/Formatters/DynamicObjectTypeFallbackFormatter.cs
  79. +22 −22 src/Utf8Json/Formatters/PrimitiveFormatter.cs
  80. +10 −3 src/Utf8Json/Formatters/StandardClassLibraryFormatters.cs
  81. +8 −8 src/Utf8Json/Formatters/TupleFormatter.cs
  82. +1 −1 src/Utf8Json/Formatters/TupleFormatter.tt
  83. +8 −8 src/Utf8Json/Formatters/ValueTupleFormatter.cs
  84. +1 −1 src/Utf8Json/Formatters/ValueTupleFormatter.tt
  85. +0 −1 src/Utf8Json/Internal/AutomataDictionary.cs
  86. +1 −1 src/Utf8Json/Internal/DoubleConversion/StringToDouble.cs
  87. +4 −4 src/Utf8Json/Internal/DoubleConversion/StringToDoubleConverter.cs
  88. +1 −1 src/Utf8Json/Internal/Emit/ILGeneratorExtensions.cs
  89. +1 −7 src/Utf8Json/Internal/Emit/MetaType.cs
  90. +6 −3 src/Utf8Json/JsonReader.cs
  91. +0 −1 src/Utf8Json/JsonSerializer.NonGeneric.cs
  92. +20 −5 src/Utf8Json/Resolvers/DynamicObjectResolver.cs
  93. +3 −0 src/Utf8Json/Resolvers/StandardResolver.cs
  94. +6 −3 src/Utf8Json/Utf8Json.csproj
@@ -287,3 +287,4 @@ __pycache__/
*.odx.cs
*.xsd.cs
/sandbox/PerfBenchmark/BenchmarkDotNet.Artifacts/results
/src/Utf8Json.UnityClient/Library
366 README.md

Large diffs are not rendered by default.

@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.15
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E2F54E97-DBD4-46C9-AE10-0D4394889F25}"
EndProject
@@ -25,6 +25,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utf8Json.AspNetCoreMvcForma
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfBenchmark", "sandbox\PerfBenchmark\PerfBenchmark.csproj", "{8F7C9DEC-7B36-4704-A5FE-7B59F766EB67}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utf8Json.CodeGenerator", "src\Utf8Json.CodeGenerator\Utf8Json.CodeGenerator.csproj", "{32B23162-7C3E-458B-A721-392B453FF1C5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utf8Json.UniversalCodeGenerator", "src\Utf8Json.UniversalCodeGenerator\Utf8Json.UniversalCodeGenerator.csproj", "{E9F023EE-3B1D-411E-AB70-49C895778603}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utf8Json.UnityShims", "src\Utf8Json.UnityShims\Utf8Json.UnityShims.csproj", "{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -80,6 +86,24 @@ Global
{8F7C9DEC-7B36-4704-A5FE-7B59F766EB67}.DumpAsm|Any CPU.Build.0 = DumpAsm|Any CPU
{8F7C9DEC-7B36-4704-A5FE-7B59F766EB67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F7C9DEC-7B36-4704-A5FE-7B59F766EB67}.Release|Any CPU.Build.0 = Release|Any CPU
{32B23162-7C3E-458B-A721-392B453FF1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32B23162-7C3E-458B-A721-392B453FF1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32B23162-7C3E-458B-A721-392B453FF1C5}.DumpAsm|Any CPU.ActiveCfg = Debug|Any CPU
{32B23162-7C3E-458B-A721-392B453FF1C5}.DumpAsm|Any CPU.Build.0 = Debug|Any CPU
{32B23162-7C3E-458B-A721-392B453FF1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32B23162-7C3E-458B-A721-392B453FF1C5}.Release|Any CPU.Build.0 = Release|Any CPU
{E9F023EE-3B1D-411E-AB70-49C895778603}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9F023EE-3B1D-411E-AB70-49C895778603}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9F023EE-3B1D-411E-AB70-49C895778603}.DumpAsm|Any CPU.ActiveCfg = Debug|Any CPU
{E9F023EE-3B1D-411E-AB70-49C895778603}.DumpAsm|Any CPU.Build.0 = Debug|Any CPU
{E9F023EE-3B1D-411E-AB70-49C895778603}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9F023EE-3B1D-411E-AB70-49C895778603}.Release|Any CPU.Build.0 = Release|Any CPU
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}.DumpAsm|Any CPU.ActiveCfg = Debug|Any CPU
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}.DumpAsm|Any CPU.Build.0 = Debug|Any CPU
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -93,6 +117,9 @@ Global
{6297FDF5-1F3E-486F-A808-0F1AB9865789} = {E2F54E97-DBD4-46C9-AE10-0D4394889F25}
{D32F3243-0511-4995-BE08-F6F82D8F7C85} = {E2F54E97-DBD4-46C9-AE10-0D4394889F25}
{8F7C9DEC-7B36-4704-A5FE-7B59F766EB67} = {F1550987-10B3-4D54-8A74-06160EC00F16}
{32B23162-7C3E-458B-A721-392B453FF1C5} = {E2F54E97-DBD4-46C9-AE10-0D4394889F25}
{E9F023EE-3B1D-411E-AB70-49C895778603} = {E2F54E97-DBD4-46C9-AE10-0D4394889F25}
{7D6E2A6A-E085-4733-9E9C-C139A4BA0F98} = {E2F54E97-DBD4-46C9-AE10-0D4394889F25}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B746BCB5-7190-4187-A08B-0D1714A61F70}
@@ -0,0 +1,13 @@
cd /d %~dp0
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\Attributes.cs" "..\..\..\..\Utf8Json\Attributes.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\IJsonFormatter.cs" "..\..\..\..\Utf8Json\IJsonFormatter.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\IJsonFormatterResolver.cs" "..\..\..\..\Utf8Json\IJsonFormatterResolver.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\JsonReader.cs" "..\..\..\..\Utf8Json\JsonReader.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\JsonWriter.cs" "..\..\..\..\Utf8Json\JsonWriter.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\JsonSerializer.cs" "..\..\..\..\Utf8Json\JsonSerializer.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\JsonSerializer.NonGeneric.cs" "..\..\..\..\Utf8Json\JsonSerializer.NonGeneric.cs"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\JsonToken.cs" "..\..\..\..\Utf8Json\JsonToken.cs"
mklink /D ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\Resolvers" "..\..\..\..\Utf8Json\Resolvers"
mklink /D ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\Formatters" "..\..\..\..\Utf8Json\Formatters"
mklink /D ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\Internal" "..\..\..\..\Utf8Json\Internal"
mklink ".\src\Utf8Json.UnityClient\Assets\Scripts\Utf8Json\Unity\ResolverAndFormatters.cs" "..\..\..\..\..\Utf8Json.UnityShims\ResolverAndFormatters.cs"
@@ -223,6 +223,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="gen_test.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@@ -18,6 +18,7 @@
using MessagePack.Resolvers;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using Utf8Json.Resolvers;


// [assembly: AllowPartiallyTrustedCallers]
@@ -44,139 +45,17 @@ static void Main(string[] args)
#if DEBUG


Utf8Json.Resolvers.CompositeResolver.RegisterAndSetAsDefault(
new IJsonFormatter[]{
Utf8Json.Resolvers.CompositeResolver.RegisterAndSetAsDefault(new IJsonFormatterResolver[]{
GeneratedResolver.Instance,
Utf8Json.Resolvers.StandardResolver.Default });

},
new[]
{
Utf8Json.Resolvers.EnumResolver.UnderlyingValue,
Utf8Json.Resolvers.StandardResolver.Default
});

var s = JsonSerializer.Serialize(new SimplePerson { Age = 99, LastName="foo" });

var person = new SimplePerson(true) { Age = 99, FirstName = "_yeah", LastName = "baz", FavoriteFruit = MyEnum.Apple };

//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.Default));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.CamelCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.SnakeCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.ExcludeNull));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.ExcludeNullCamelCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.ExcludeNullSnakeCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.AllowPrivate));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.AllowPrivateCamelCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.AllowPrivateSnakeCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.AllowPrivateExcludeNull));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.AllowPrivateExcludeNullCamelCase));
//Console.WriteLine(JsonSerializer.ToJsonString(person, Utf8Json.Resolvers.StandardResolver.AllowPrivateExcludeNullSnakeCase));


//Console.WriteLine("--------------");
//Console.WriteLine(JsonSerializer.ToJsonString(new { foo = "foooo", bar = "baaaaaaaaa" }));

//Console.WriteLine("--------------");

var json = JsonSerializer.NonGeneric.ToJsonString(1214141);
Console.WriteLine(json);

json = json.Replace("know", "know_i_know");

var re = (int)JsonSerializer.NonGeneric.Deserialize(typeof(int), json, Utf8Json.Resolvers.StandardResolver.Default);
Console.WriteLine(re);
//Console.WriteLine((re.Age, re.FirstName, re.LastName, re.FavoriteFruit));

//pz = null;
//var yeah = JsonSerializer.NonGeneric.Serialize(pz);
//Console.WriteLine(Encoding.UTF8.GetString(yeah));

//Console.WriteLine(writer.ToString());

//var reader = new JsonReader(writer.ToUtf8ByteArray());
//var p = f.Deserialize(ref reader, null);
//Console.WriteLine((p.Age, p.FirstName, p.LastName));
//p.ShoutFAndZ();

//JsonSerializer.NonGeneric


// DynamicObjectResolverAllowPrivate

//var rand = new Random(34151513);
//var obj1 = TargetClass.Create(rand);
//var objContractless = new TargetClassContractless(obj1);

//var f = new DynamicCodeDumper_TargetClassContractlessFormatter3();
//var w = new JsonWriter();
//f.Serialize(ref w, objContractless, Utf8Json.Resolvers.StandardResolver.Instance);

//Console.WriteLine(w.ToString());
//var r = new JsonReader(w.ToUtf8ByteArray());

//var v = f.Deserialize(ref r, Utf8Json.Resolvers.StandardResolver.Instance);
//Console.WriteLine(v);

//var s1 = Encoding.UTF8.GetBytes("\"あいうえお\"");
//var s2 = Encoding.UTF8.GetBytes("\"あいう\\tえお\"");
//var s3 = Encoding.UTF8.GetBytes("\"あいう\tえお\t\"");
//var s4 = Encoding.UTF8.GetBytes("\"\\u3042\\u3044\\u3046えお\"");
//var s5 = Encoding.UTF8.GetBytes("\"\\uD840\\uDC0B\"");

//var str1 = new JsonReader(s1, 0).ReadString();
//var str2 = new JsonReader(s2, 0).ReadString();
//var str3 = new JsonReader(s3, 0).ReadString();
//var str4 = new JsonReader(s4, 0).ReadString();
//var str5 = new JsonReader(s5, 0).ReadString();
//Console.WriteLine(str1);
//Console.WriteLine(str2);
//Console.WriteLine(str3);
//Console.WriteLine(str4);
//Console.WriteLine(str5);

//var xs = new[,]
//{
// { 1, 2, 3, 4, 9 },
// { 4, 5, 6, 7, 10 },
// { 10, 5, 6, 7, 10000 },
//};
//var f = new TwoDimentionalArrayFormatter<int>();


//var writer = new JsonWriter();
//f.Serialize(ref writer, xs, Utf8Json.Resolvers.StandardResolver.Default);
//Console.WriteLine(writer.ToString());

//var reader = new JsonReader(writer.ToUtf8ByteArray());
//var foo = f.Deserialize(ref reader, Utf8Json.Resolvers.StandardResolver.Default);

//foreach (var item in foo)
//{
// Console.WriteLine(item);
//}

////var ys = Int32ArrayFormatter.Default.Deserialize(ref reader, null);
////foreach (var item in ys)
////{
//// Console.WriteLine(item);
////}

////var writer = new JsonWriter();
////new SimplePersonFormatter().Serialize(ref writer, new SimplePerson { Age = 99, FirstName = "foo", LastName = "baz" }, null);
////var reader = new JsonReader(writer.ToUtf8ByteArray());
////dynamic v = Utf8Json.Formatters.PrimitiveObjectFormatter.Default.Deserialize(ref reader, null);
////Console.WriteLine(writer.ToString());
////Console.WriteLine((int)v["Age"]);
////Console.WriteLine((string)v["FirstName"]);
////Console.WriteLine((string)v["LastName"]);



//var xss = new ArrayBuffer<int>(4);
//xss.Add(10);
//xss.Add(20);
//xss.Add(30);
//xss.Add(40);
//xss.Add(50);
Console.WriteLine(Encoding.UTF8.GetString(s));

var hu = JsonSerializer.Deserialize<SimplePerson>(s);
Console.WriteLine(hu.Age);


#else
@@ -185,6 +64,17 @@ static void Main(string[] args)
}
}

public interface IInterface
{
string Huga { get; }
}

public class MyClassInter : IInterface
{
[System.Runtime.Serialization.DataMember]
public string Huga { get; set; }
}

public class MyResolver2 : IJsonFormatterResolver
{
// set your own composite formatter/resolvers.
@@ -240,12 +130,14 @@ public class SimplePerson
[DataMember(Name = "i_do\tnt_know")]
public int Age { get; set; }
public string FirstName { get; set; }
[IgnoreDataMember]
public string LastName { get; set; }
public MyEnum FavoriteFruit { get; set; }

//readonly int f;
//readonly int z;


public SimplePerson()
{

@@ -871,7 +763,7 @@ public SimplePerson Deserialize(ref JsonReader reader, IJsonFormatterResolver fo
while (!reader.ReadIsEndObjectWithSkipValueSeparator(ref count)) // "}", skip "," when count != 0
{
// automata lookup
var key = reader.ReadPropertyNameSegmentUnescaped();
var key = reader.ReadPropertyNameSegmentRaw();

int switchKey;
if (!dictionary.TryGetValue(key, out switchKey)) switchKey = -1;
@@ -1072,7 +964,7 @@ public unsafe TargetClassContractless Deserialize(ref JsonReader ptr, IJsonForma
int num = default;
while (!ptr.ReadIsEndObjectWithSkipValueSeparator(ref num))
{
ArraySegment<byte> arraySegment = ptr.ReadPropertyNameSegmentUnescaped();
ArraySegment<byte> arraySegment = ptr.ReadPropertyNameSegmentRaw();
byte* ptr3 = ptr2 + arraySegment.Offset;
int count = arraySegment.Count;
if (count != 0)

0 comments on commit 2de96d5

Please sign in to comment.
You can’t perform that action at this time.