diff options
author | Jens Geyer <jensg@apache.org> | 2021-04-09 22:55:11 +0200 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2021-04-10 10:10:27 +0200 |
commit | 2b2ea622b67c9b0be4e6baf09cc604fad887cae4 (patch) | |
tree | 773fdaf85fae7f68787d17a68e514dae0632ac7b /test/netstd | |
parent | 6228b907e0a01659515e8e4715c70f540fe07589 (diff) | |
download | thrift-2b2ea622b67c9b0be4e6baf09cc604fad887cae4.tar.gz |
THRIFT-5396 deprecate "Async" method postfix
Client: netstd
Patch: Jens Geyer
This closes #2374
Diffstat (limited to 'test/netstd')
-rw-r--r-- | test/netstd/Client/GlobalSuppressions.cs | 26 | ||||
-rw-r--r-- | test/netstd/Client/TestClient.cs | 70 | ||||
-rw-r--r-- | test/netstd/Server/GlobalSuppressions.cs | 26 | ||||
-rw-r--r-- | test/netstd/Server/TestServer.cs | 47 |
4 files changed, 59 insertions, 110 deletions
diff --git a/test/netstd/Client/GlobalSuppressions.cs b/test/netstd/Client/GlobalSuppressions.cs deleted file mode 100644 index 34fdc7953..000000000 --- a/test/netstd/Client/GlobalSuppressions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Performance", "CA1822", Justification = "<Ausstehend>", Scope = "module")] -[assembly: SuppressMessage("Style", "IDE0083", Justification = "<Ausstehend>", Scope = "module")] diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs index ec9025055..70a21e172 100644 --- a/test/netstd/Client/TestClient.cs +++ b/test/netstd/Client/TestClient.cs @@ -353,7 +353,7 @@ namespace ThriftTest try { - ReturnCode |= ExecuteClientTestAsync(client).GetAwaiter().GetResult(); ; + ReturnCode |= ExecuteClientTest(client).GetAwaiter().GetResult(); ; } catch (Exception ex) { @@ -469,7 +469,7 @@ namespace ThriftTest amount = 15 * 1024 * 1024; break; default: - throw new ArgumentException(nameof(testcase)); + throw new ArgumentException("invalid argument",nameof(testcase)); } var retval = new byte[amount]; @@ -499,16 +499,16 @@ namespace ThriftTest return token.Token; } - public static async Task<int> ExecuteClientTestAsync(ThriftTest.Client client) + public static async Task<int> ExecuteClientTest(ThriftTest.Client client) { var returnCode = 0; Console.Write("testVoid()"); - await client.testVoidAsync(MakeTimeoutToken()); + await client.testVoid(MakeTimeoutToken()); Console.WriteLine(" = void"); Console.Write("testString(\"Test\")"); - var s = await client.testStringAsync("Test", MakeTimeoutToken()); + var s = await client.testString("Test", MakeTimeoutToken()); Console.WriteLine(" = \"" + s + "\""); if ("Test" != s) { @@ -517,7 +517,7 @@ namespace ThriftTest } Console.Write("testBool(true)"); - var t = await client.testBoolAsync((bool)true, MakeTimeoutToken()); + var t = await client.testBool((bool)true, MakeTimeoutToken()); Console.WriteLine(" = " + t); if (!t) { @@ -525,7 +525,7 @@ namespace ThriftTest returnCode |= ErrorBaseTypes; } Console.Write("testBool(false)"); - var f = await client.testBoolAsync((bool)false, MakeTimeoutToken()); + var f = await client.testBool((bool)false, MakeTimeoutToken()); Console.WriteLine(" = " + f); if (f) { @@ -534,7 +534,7 @@ namespace ThriftTest } Console.Write("testByte(1)"); - var i8 = await client.testByteAsync((sbyte)1, MakeTimeoutToken()); + var i8 = await client.testByte((sbyte)1, MakeTimeoutToken()); Console.WriteLine(" = " + i8); if (1 != i8) { @@ -543,7 +543,7 @@ namespace ThriftTest } Console.Write("testI32(-1)"); - var i32 = await client.testI32Async(-1, MakeTimeoutToken()); + var i32 = await client.testI32(-1, MakeTimeoutToken()); Console.WriteLine(" = " + i32); if (-1 != i32) { @@ -552,7 +552,7 @@ namespace ThriftTest } Console.Write("testI64(-34359738368)"); - var i64 = await client.testI64Async(-34359738368, MakeTimeoutToken()); + var i64 = await client.testI64(-34359738368, MakeTimeoutToken()); Console.WriteLine(" = " + i64); if (-34359738368 != i64) { @@ -562,7 +562,7 @@ namespace ThriftTest // TODO: Validate received message Console.Write("testDouble(5.325098235)"); - var dub = await client.testDoubleAsync(5.325098235, MakeTimeoutToken()); + var dub = await client.testDouble(5.325098235, MakeTimeoutToken()); Console.WriteLine(" = " + dub); if (5.325098235 != dub) { @@ -570,7 +570,7 @@ namespace ThriftTest returnCode |= ErrorBaseTypes; } Console.Write("testDouble(-0.000341012439638598279)"); - dub = await client.testDoubleAsync(-0.000341012439638598279, MakeTimeoutToken()); + dub = await client.testDouble(-0.000341012439638598279, MakeTimeoutToken()); Console.WriteLine(" = " + dub); if (-0.000341012439638598279 != dub) { @@ -586,7 +586,7 @@ namespace ThriftTest Console.Write("testBinary({0} bytes)", binOut.Length); try { - var binIn = await client.testBinaryAsync(binOut, MakeTimeoutToken()); + var binIn = await client.testBinary(binOut, MakeTimeoutToken()); Console.WriteLine(" = {0} bytes", binIn.Length); if (binIn.Length != binOut.Length) { @@ -636,7 +636,7 @@ namespace ThriftTest I32_thing = -3, I64_thing = -5 }; - var i = await client.testStructAsync(o, MakeTimeoutToken()); + var i = await client.testStruct(o, MakeTimeoutToken()); Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}"); // TODO: Validate received message @@ -647,7 +647,7 @@ namespace ThriftTest Struct_thing = o, I32_thing = 5 }; - var i2 = await client.testNestAsync(o2, MakeTimeoutToken()); + var i2 = await client.testNest(o2, MakeTimeoutToken()); i = i2.Struct_thing; Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}"); @@ -672,7 +672,7 @@ namespace ThriftTest } Console.Write("})"); - var mapin = await client.testMapAsync(mapout, MakeTimeoutToken()); + var mapin = await client.testMap(mapout, MakeTimeoutToken()); Console.Write(" = {"); first = true; @@ -712,7 +712,7 @@ namespace ThriftTest } Console.Write("})"); - var listin = await client.testListAsync(listout, MakeTimeoutToken()); + var listin = await client.testList(listout, MakeTimeoutToken()); Console.Write(" = {"); first = true; @@ -753,7 +753,7 @@ namespace ThriftTest } Console.Write("})"); - var setin = await client.testSetAsync(setout, MakeTimeoutToken()); + var setin = await client.testSet(setout, MakeTimeoutToken()); Console.Write(" = {"); first = true; @@ -773,7 +773,7 @@ namespace ThriftTest Console.Write("testEnum(ONE)"); - var ret = await client.testEnumAsync(Numberz.ONE, MakeTimeoutToken()); + var ret = await client.testEnum(Numberz.ONE, MakeTimeoutToken()); Console.WriteLine(" = " + ret); if (Numberz.ONE != ret) { @@ -782,7 +782,7 @@ namespace ThriftTest } Console.Write("testEnum(TWO)"); - ret = await client.testEnumAsync(Numberz.TWO, MakeTimeoutToken()); + ret = await client.testEnum(Numberz.TWO, MakeTimeoutToken()); Console.WriteLine(" = " + ret); if (Numberz.TWO != ret) { @@ -791,7 +791,7 @@ namespace ThriftTest } Console.Write("testEnum(THREE)"); - ret = await client.testEnumAsync(Numberz.THREE, MakeTimeoutToken()); + ret = await client.testEnum(Numberz.THREE, MakeTimeoutToken()); Console.WriteLine(" = " + ret); if (Numberz.THREE != ret) { @@ -800,7 +800,7 @@ namespace ThriftTest } Console.Write("testEnum(FIVE)"); - ret = await client.testEnumAsync(Numberz.FIVE, MakeTimeoutToken()); + ret = await client.testEnum(Numberz.FIVE, MakeTimeoutToken()); Console.WriteLine(" = " + ret); if (Numberz.FIVE != ret) { @@ -809,7 +809,7 @@ namespace ThriftTest } Console.Write("testEnum(EIGHT)"); - ret = await client.testEnumAsync(Numberz.EIGHT, MakeTimeoutToken()); + ret = await client.testEnum(Numberz.EIGHT, MakeTimeoutToken()); Console.WriteLine(" = " + ret); if (Numberz.EIGHT != ret) { @@ -818,7 +818,7 @@ namespace ThriftTest } Console.Write("testTypedef(309858235082523)"); - var uid = await client.testTypedefAsync(309858235082523L, MakeTimeoutToken()); + var uid = await client.testTypedef(309858235082523L, MakeTimeoutToken()); Console.WriteLine(" = " + uid); if (309858235082523L != uid) { @@ -828,7 +828,7 @@ namespace ThriftTest // TODO: Validate received message Console.Write("testMapMap(1)"); - var mm = await client.testMapMapAsync(1, MakeTimeoutToken()); + var mm = await client.testMapMap(1, MakeTimeoutToken()); Console.Write(" = {"); foreach (var key in mm.Keys) { @@ -862,7 +862,7 @@ namespace ThriftTest truck }; Console.Write("testInsanity()"); - var whoa = await client.testInsanityAsync(insane, MakeTimeoutToken()); + var whoa = await client.testInsanity(insane, MakeTimeoutToken()); Console.Write(" = {"); foreach (var key in whoa.Keys) { @@ -927,14 +927,14 @@ namespace ThriftTest var arg4 = Numberz.FIVE; long arg5 = 5000000; Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + ",{" + string.Join(",", tmpMultiDict) + "}," + arg4 + "," + arg5 + ")"); - var multiResponse = await client.testMultiAsync(arg0, arg1, arg2, multiDict, arg4, arg5, MakeTimeoutToken()); + var multiResponse = await client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5, MakeTimeoutToken()); Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n"); try { Console.WriteLine("testException(\"Xception\")"); - await client.testExceptionAsync("Xception", MakeTimeoutToken()); + await client.testException("Xception", MakeTimeoutToken()); Console.WriteLine("*** FAILED ***"); returnCode |= ErrorExceptions; } @@ -955,7 +955,7 @@ namespace ThriftTest try { Console.WriteLine("testException(\"TException\")"); - await client.testExceptionAsync("TException", MakeTimeoutToken()); + await client.testException("TException", MakeTimeoutToken()); Console.WriteLine("*** FAILED ***"); returnCode |= ErrorExceptions; } @@ -972,7 +972,7 @@ namespace ThriftTest try { Console.WriteLine("testException(\"ok\")"); - await client.testExceptionAsync("ok", MakeTimeoutToken()); + await client.testException("ok", MakeTimeoutToken()); // OK } catch (Exception ex) @@ -985,7 +985,7 @@ namespace ThriftTest try { Console.WriteLine("testMultiException(\"Xception\", ...)"); - await client.testMultiExceptionAsync("Xception", "ignore", MakeTimeoutToken()); + await client.testMultiException("Xception", "ignore", MakeTimeoutToken()); Console.WriteLine("*** FAILED ***"); returnCode |= ErrorExceptions; } @@ -1006,7 +1006,7 @@ namespace ThriftTest try { Console.WriteLine("testMultiException(\"Xception2\", ...)"); - await client.testMultiExceptionAsync("Xception2", "ignore", MakeTimeoutToken()); + await client.testMultiException("Xception2", "ignore", MakeTimeoutToken()); Console.WriteLine("*** FAILED ***"); returnCode |= ErrorExceptions; } @@ -1027,7 +1027,7 @@ namespace ThriftTest try { Console.WriteLine("testMultiException(\"success\", \"OK\")"); - if ("OK" != (await client.testMultiExceptionAsync("success", "OK", MakeTimeoutToken())).String_thing) + if ("OK" != (await client.testMultiException("success", "OK", MakeTimeoutToken())).String_thing) { Console.WriteLine("*** FAILED ***"); returnCode |= ErrorExceptions; @@ -1043,7 +1043,7 @@ namespace ThriftTest Console.WriteLine("Test Oneway(1)"); var sw = new Stopwatch(); sw.Start(); - await client.testOnewayAsync(1, MakeTimeoutToken()); + await client.testOneway(1, MakeTimeoutToken()); sw.Stop(); if (sw.ElapsedMilliseconds > 1000) { @@ -1057,7 +1057,7 @@ namespace ThriftTest sw.Start(); var token = MakeTimeoutToken(20000); for (var k = 0; k < times; ++k) - await client.testVoidAsync(token); + await client.testVoid(token); sw.Stop(); Console.WriteLine(" = {0} ms a testVoid() call", sw.ElapsedMilliseconds / times); return returnCode; diff --git a/test/netstd/Server/GlobalSuppressions.cs b/test/netstd/Server/GlobalSuppressions.cs deleted file mode 100644 index 34fdc7953..000000000 --- a/test/netstd/Server/GlobalSuppressions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Performance", "CA1822", Justification = "<Ausstehend>", Scope = "module")] -[assembly: SuppressMessage("Style", "IDE0083", Justification = "<Ausstehend>", Scope = "module")] diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs index bec9fae44..895c3ffd5 100644 --- a/test/netstd/Server/TestServer.cs +++ b/test/netstd/Server/TestServer.cs @@ -35,6 +35,7 @@ using Thrift.Transport; using Thrift.Transport.Server; #pragma warning disable IDE0063 // using can be simplified, we don't +#pragma warning disable IDE0057 // substr can be simplified, we don't namespace ThriftTest { @@ -190,7 +191,7 @@ namespace ThriftTest { public TServer Server { get; set; } private readonly int handlerID; - private readonly StringBuilder sb = new StringBuilder(); + private readonly StringBuilder sb = new(); private readonly TestLogDelegate logger; public TestHandlerAsync() @@ -209,61 +210,61 @@ namespace ThriftTest Console.Write(sb.ToString()); } - public Task testVoidAsync(CancellationToken cancellationToken) + public Task testVoid(CancellationToken cancellationToken) { logger.Invoke("testVoid()"); return Task.CompletedTask; } - public Task<string> testStringAsync(string thing, CancellationToken cancellationToken) + public Task<string> testString(string thing, CancellationToken cancellationToken) { logger.Invoke("testString({0})", thing); return Task.FromResult(thing); } - public Task<bool> testBoolAsync(bool thing, CancellationToken cancellationToken) + public Task<bool> testBool(bool thing, CancellationToken cancellationToken) { logger.Invoke("testBool({0})", thing); return Task.FromResult(thing); } - public Task<sbyte> testByteAsync(sbyte thing, CancellationToken cancellationToken) + public Task<sbyte> testByte(sbyte thing, CancellationToken cancellationToken) { logger.Invoke("testByte({0})", thing); return Task.FromResult(thing); } - public Task<int> testI32Async(int thing, CancellationToken cancellationToken) + public Task<int> testI32(int thing, CancellationToken cancellationToken) { logger.Invoke("testI32({0})", thing); return Task.FromResult(thing); } - public Task<long> testI64Async(long thing, CancellationToken cancellationToken) + public Task<long> testI64(long thing, CancellationToken cancellationToken) { logger.Invoke("testI64({0})", thing); return Task.FromResult(thing); } - public Task<double> testDoubleAsync(double thing, CancellationToken cancellationToken) + public Task<double> testDouble(double thing, CancellationToken cancellationToken) { logger.Invoke("testDouble({0})", thing); return Task.FromResult(thing); } - public Task<byte[]> testBinaryAsync(byte[] thing, CancellationToken cancellationToken) + public Task<byte[]> testBinary(byte[] thing, CancellationToken cancellationToken) { logger.Invoke("testBinary({0} bytes)", thing.Length); return Task.FromResult(thing); } - public Task<Xtruct> testStructAsync(Xtruct thing, CancellationToken cancellationToken) + public Task<Xtruct> testStruct(Xtruct thing, CancellationToken cancellationToken) { logger.Invoke("testStruct({{\"{0}\", {1}, {2}, {3}}})", thing.String_thing, thing.Byte_thing, thing.I32_thing, thing.I64_thing); return Task.FromResult(thing); } - public Task<Xtruct2> testNestAsync(Xtruct2 nest, CancellationToken cancellationToken) + public Task<Xtruct2> testNest(Xtruct2 nest, CancellationToken cancellationToken) { var thing = nest.Struct_thing; logger.Invoke("testNest({{{0}, {{\"{1}\", {2}, {3}, {4}, {5}}}}})", @@ -276,7 +277,7 @@ namespace ThriftTest return Task.FromResult(nest); } - public Task<Dictionary<int, int>> testMapAsync(Dictionary<int, int> thing, CancellationToken cancellationToken) + public Task<Dictionary<int, int>> testMap(Dictionary<int, int> thing, CancellationToken cancellationToken) { sb.Clear(); sb.Append("testMap({{"); @@ -298,7 +299,7 @@ namespace ThriftTest return Task.FromResult(thing); } - public Task<Dictionary<string, string>> testStringMapAsync(Dictionary<string, string> thing, CancellationToken cancellationToken) + public Task<Dictionary<string, string>> testStringMap(Dictionary<string, string> thing, CancellationToken cancellationToken) { sb.Clear(); sb.Append("testStringMap({{"); @@ -320,7 +321,7 @@ namespace ThriftTest return Task.FromResult(thing); } - public Task<THashSet<int>> testSetAsync(THashSet<int> thing, CancellationToken cancellationToken) + public Task<THashSet<int>> testSet(THashSet<int> thing, CancellationToken cancellationToken) { sb.Clear(); sb.Append("testSet({{"); @@ -342,7 +343,7 @@ namespace ThriftTest return Task.FromResult(thing); } - public Task<List<int>> testListAsync(List<int> thing, CancellationToken cancellationToken) + public Task<List<int>> testList(List<int> thing, CancellationToken cancellationToken) { sb.Clear(); sb.Append("testList({{"); @@ -364,19 +365,19 @@ namespace ThriftTest return Task.FromResult(thing); } - public Task<Numberz> testEnumAsync(Numberz thing, CancellationToken cancellationToken) + public Task<Numberz> testEnum(Numberz thing, CancellationToken cancellationToken) { logger.Invoke("testEnum({0})", thing); return Task.FromResult(thing); } - public Task<long> testTypedefAsync(long thing, CancellationToken cancellationToken) + public Task<long> testTypedef(long thing, CancellationToken cancellationToken) { logger.Invoke("testTypedef({0})", thing); return Task.FromResult(thing); } - public Task<Dictionary<int, Dictionary<int, int>>> testMapMapAsync(int hello, CancellationToken cancellationToken) + public Task<Dictionary<int, Dictionary<int, int>>> testMapMap(int hello, CancellationToken cancellationToken) { logger.Invoke("testMapMap({0})", hello); var mapmap = new Dictionary<int, Dictionary<int, int>>(); @@ -395,7 +396,7 @@ namespace ThriftTest return Task.FromResult(mapmap); } - public Task<Dictionary<long, Dictionary<Numberz, Insanity>>> testInsanityAsync(Insanity argument, CancellationToken cancellationToken) + public Task<Dictionary<long, Dictionary<Numberz, Insanity>>> testInsanity(Insanity argument, CancellationToken cancellationToken) { logger.Invoke("testInsanity()"); @@ -428,7 +429,7 @@ namespace ThriftTest return Task.FromResult(insane); } - public Task<Xtruct> testMultiAsync(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5, + public Task<Xtruct> testMulti(sbyte arg0, int arg1, long arg2, Dictionary<short, string> arg3, Numberz arg4, long arg5, CancellationToken cancellationToken) { logger.Invoke("testMulti()"); @@ -441,7 +442,7 @@ namespace ThriftTest return Task.FromResult(hello); } - public Task testExceptionAsync(string arg, CancellationToken cancellationToken) + public Task testException(string arg, CancellationToken cancellationToken) { logger.Invoke("testException({0})", arg); if (arg == "Xception") @@ -460,7 +461,7 @@ namespace ThriftTest return Task.CompletedTask; } - public Task<Xtruct> testMultiExceptionAsync(string arg0, string arg1, CancellationToken cancellationToken) + public Task<Xtruct> testMultiException(string arg0, string arg1, CancellationToken cancellationToken) { logger.Invoke("testMultiException({0}, {1})", arg0, arg1); if (arg0 == "Xception") @@ -487,7 +488,7 @@ namespace ThriftTest return Task.FromResult(result); } - public Task testOnewayAsync(int secondsToSleep, CancellationToken cancellationToken) + public Task testOneway(int secondsToSleep, CancellationToken cancellationToken) { logger.Invoke("testOneway({0}), sleeping...", secondsToSleep); Task.Delay(secondsToSleep * 1000, cancellationToken).GetAwaiter().GetResult(); |