Skip to content

Commit

Permalink
提交一个 大josn 报错测试 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
wangning08115 committed Nov 21, 2024
1 parent 2bb03d2 commit 0eb3139
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Text;
using NewLife.Data;
using NewLife.Log;
using NewLife.Net;
Expand Down Expand Up @@ -41,6 +42,10 @@ static void ClientTest()

var rs = client.Invoke<Int32>("Big/Sum", new { a = 123, b = 456 });
XTrace.WriteLine("{0}+{1}={2}", 123, 456, rs);

//Big Json Test
var resBigJsonTest = client.Invoke<string>("Big/BigJsonTest");
XTrace.WriteLine($"resBigJsonTest.Length={resBigJsonTest.Length}");
}

class MyClient : ApiClient
Expand All @@ -66,11 +71,25 @@ public Int32 Sum(Int32 a, Int32 b)
}
public String ToUpper(String str) => str.ToUpper();


public IPacket Test(IPacket pk)
{
var buf = pk.ReadBytes().Select(e => (Byte)(e ^ 'x')).ToArray();

return (ArrayPacket)buf;
}
public string BigJsonTest()
{
StringBuilder sb = new StringBuilder();
//拼接10万次 就报错了
for (int i = 0; i < 100000; i++)
{
sb.AppendLine("big json big json big json big json big json big json big json big json big json big json big json big json big json big json big json big json big json big json big json ");
}
string str = sb.ToString();
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "bigJsonTest.txt", str);
Console.WriteLine($"sb.Length={str.Length}");
return str;
}
}
}

0 comments on commit 0eb3139

Please sign in to comment.