From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../thrift/lib/csharp/test/JSON/JSONTest.csproj | 85 +++++++++++++++++++ .../thrift/lib/csharp/test/JSON/Program.cs | 95 ++++++++++++++++++++++ .../csharp/test/JSON/Properties/AssemblyInfo.cs | 55 +++++++++++++ .../thrift/lib/csharp/test/JSON/app.config | 21 +++++ 4 files changed, 256 insertions(+) create mode 100644 src/jaegertracing/thrift/lib/csharp/test/JSON/JSONTest.csproj create mode 100644 src/jaegertracing/thrift/lib/csharp/test/JSON/Program.cs create mode 100644 src/jaegertracing/thrift/lib/csharp/test/JSON/Properties/AssemblyInfo.cs create mode 100644 src/jaegertracing/thrift/lib/csharp/test/JSON/app.config (limited to 'src/jaegertracing/thrift/lib/csharp/test/JSON') diff --git a/src/jaegertracing/thrift/lib/csharp/test/JSON/JSONTest.csproj b/src/jaegertracing/thrift/lib/csharp/test/JSON/JSONTest.csproj new file mode 100644 index 000000000..f07d43eec --- /dev/null +++ b/src/jaegertracing/thrift/lib/csharp/test/JSON/JSONTest.csproj @@ -0,0 +1,85 @@ + + + + + Debug + x86 + 8.0.30703 + 2.0 + {E37A0034-DCBF-4886-A0DA-25A03D12D975} + Exe + Properties + JSONTest + JSONTest + v4.0 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + {499EB63C-D74C-47E8-AE48-A2FC94538E9D} + Thrift + + + + + \ No newline at end of file diff --git a/src/jaegertracing/thrift/lib/csharp/test/JSON/Program.cs b/src/jaegertracing/thrift/lib/csharp/test/JSON/Program.cs new file mode 100644 index 000000000..f61388ae7 --- /dev/null +++ b/src/jaegertracing/thrift/lib/csharp/test/JSON/Program.cs @@ -0,0 +1,95 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using Thrift.Protocol; +using Thrift.Transport; + +namespace JSONTest +{ + class Program + { + static void Main(string[] args) + { + TestThrift2365(); // JSON binary decodes too much data + TestThrift2336(); // hex encoding using \uXXXX where 0xXXXX > 0xFF + TestThrift3403(); // JSON escaped unicode surrogate pair support. + } + + + public static void TestThrift2365() + { + var rnd = new Random(); + for (var len = 0; len < 10; ++len) + { + byte[] dataWritten = new byte[len]; + rnd.NextBytes(dataWritten); + + Stream stm = new MemoryStream(); + TTransport trans = new TStreamTransport(null, stm); + TProtocol prot = new TJSONProtocol(trans); + prot.WriteBinary(dataWritten); + + stm.Position = 0; + trans = new TStreamTransport(stm, null); + prot = new TJSONProtocol(trans); + byte[] dataRead = prot.ReadBinary(); + + Debug.Assert(dataRead.Length == dataWritten.Length); + for (var i = 0; i < dataRead.Length; ++i) + Debug.Assert(dataRead[i] == dataWritten[i]); + } + } + + + public static void TestThrift2336() + { + const string RUSSIAN_TEXT = "\u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435"; + const string RUSSIAN_JSON = "\"\\u0420\\u0443\\u0441\\u0441\\u043a\\u043e\\u0435 \\u041d\\u0430\\u0437\\u0432\\u0430\\u043d\\u0438\\u0435\""; + + // prepare buffer with JSON data + byte[] rawBytes = new byte[RUSSIAN_JSON.Length]; + for (var i = 0; i < RUSSIAN_JSON.Length; ++i) + rawBytes[i] = (byte)(RUSSIAN_JSON[i] & (char)0xFF); // only low bytes + + // parse and check + var stm = new MemoryStream(rawBytes); + var trans = new TStreamTransport(stm, null); + var prot = new TJSONProtocol(trans); + Debug.Assert(prot.ReadString() == RUSSIAN_TEXT, "reading JSON with hex-encoded chars > 8 bit"); + } + + public static void TestThrift3403() + { + string GCLEF_TEXT = "\ud834\udd1e"; + const string GCLEF_JSON = "\"\\ud834\\udd1e\""; + + // parse and check + var stm = new MemoryStream(Encoding.UTF8.GetBytes(GCLEF_JSON)); + var trans = new TStreamTransport(stm, null); + var prot = new TJSONProtocol(trans); + Debug.Assert(prot.ReadString() == GCLEF_TEXT, "reading JSON with surrogate pair hex-encoded chars"); + } + } +} diff --git a/src/jaegertracing/thrift/lib/csharp/test/JSON/Properties/AssemblyInfo.cs b/src/jaegertracing/thrift/lib/csharp/test/JSON/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..fdff4a1a5 --- /dev/null +++ b/src/jaegertracing/thrift/lib/csharp/test/JSON/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("JSONTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("The Apache Software Foundation")] +[assembly: AssemblyProduct("Thrift")] +[assembly: AssemblyCopyright("The Apache Software Foundation")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("2b2e7d56-3e65-4368-92d7-e34d56b7105e")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/jaegertracing/thrift/lib/csharp/test/JSON/app.config b/src/jaegertracing/thrift/lib/csharp/test/JSON/app.config new file mode 100644 index 000000000..9c1919d4f --- /dev/null +++ b/src/jaegertracing/thrift/lib/csharp/test/JSON/app.config @@ -0,0 +1,21 @@ + + + + -- cgit v1.2.3