From d831a21773d789fae1b1d0b52b3d6378f377b8b1 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Fri, 13 Feb 2009 03:09:52 +0000 Subject: [PATCH] THRIFT-309. Make Thrift's C# mapping .NET 2.0 (Mono 1.2.4) compatible git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@743963 13f79535-47bb-0310-9956-ffa450edef68 --- .../cpp/src/generate/t_csharp_generator.cc | 5 +- configure.ac | 4 +- lib/csharp/Makefile.am | 7 +- lib/csharp/src/Collections/THashSet.cs | 142 ++++++++++++++++++ lib/csharp/src/Protocol/TBinaryProtocol.cs | 1 - lib/csharp/src/Protocol/TField.cs | 22 +-- lib/csharp/src/Protocol/TList.cs | 15 +- lib/csharp/src/Protocol/TMap.cs | 22 +-- lib/csharp/src/Protocol/TMessage.cs | 22 +-- lib/csharp/src/Protocol/TMessageType.cs | 2 - lib/csharp/src/Protocol/TProtocol.cs | 1 - lib/csharp/src/Protocol/TProtocolException.cs | 2 - lib/csharp/src/Protocol/TProtocolFactory.cs | 2 - lib/csharp/src/Protocol/TProtocolUtil.cs | 2 - lib/csharp/src/Protocol/TSet.cs | 15 +- lib/csharp/src/Protocol/TStruct.cs | 8 +- lib/csharp/src/Protocol/TType.cs | 2 - lib/csharp/src/Server/TServer.cs | 1 - lib/csharp/src/Server/TSimpleServer.cs | 2 - lib/csharp/src/Server/TThreadPoolServer.cs | 2 - lib/csharp/src/Server/TThreadedServer.cs | 6 +- lib/csharp/src/TApplicationException.cs | 2 - lib/csharp/src/TProcessor.cs | 2 - lib/csharp/src/Thrift.csproj | 7 +- .../src/Transport/TBufferedTransport.cs | 3 - lib/csharp/src/Transport/TServerSocket.cs | 2 - lib/csharp/src/Transport/TServerTransport.cs | 2 - lib/csharp/src/Transport/TSocket.cs | 2 - lib/csharp/src/Transport/TStreamTransport.cs | 2 - lib/csharp/src/Transport/TTransport.cs | 2 - .../src/Transport/TTransportException.cs | 2 - lib/csharp/src/Transport/TTransportFactory.cs | 3 - test/csharp/CSharpServer.cs | 2 - test/csharp/ThriftTest/Program.cs | 2 - test/csharp/ThriftTest/TestClient.cs | 9 +- test/csharp/ThriftTest/TestServer.cs | 12 +- test/csharp/ThriftTest/ThriftTest.csproj | 13 +- test/csharp/ThriftTest/maketest.sh | 3 + 38 files changed, 235 insertions(+), 120 deletions(-) create mode 100644 lib/csharp/src/Collections/THashSet.cs create mode 100755 test/csharp/ThriftTest/maketest.sh diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc index 2463c469..df1d59c5 100644 --- a/compiler/cpp/src/generate/t_csharp_generator.cc +++ b/compiler/cpp/src/generate/t_csharp_generator.cc @@ -145,7 +145,8 @@ string t_csharp_generator::csharp_type_usings() { "using System.Collections.Generic;\n" + "using System.Text;\n" + "using System.IO;\n" + - "using Thrift;\n"; + "using Thrift;\n" + + "using Thrift.Collections;\n"; } string t_csharp_generator::csharp_thrift_usings() { @@ -1534,7 +1535,7 @@ string t_csharp_generator::type_name(t_type* ttype, bool in_container, bool in_i ", " + type_name(tmap->get_val_type(), true) + ">"; } else if (ttype->is_set()) { t_set* tset = (t_set*) ttype; - return "HashSet<" + type_name(tset->get_elem_type(), true) + ">"; + return "THashSet<" + type_name(tset->get_elem_type(), true) + ">"; } else if (ttype->is_list()) { t_list* tlist = (t_list*) ttype; return "List<" + type_name(tlist->get_elem_type(), true) + ">"; diff --git a/configure.ac b/configure.ac index f88bf49d..040ae06b 100644 --- a/configure.ac +++ b/configure.ac @@ -41,9 +41,11 @@ AM_CONDITIONAL([AMX_HAVE_ZLIB], [test "$success" = "yes"]) AX_THRIFT_LIB(csharp, [C#], yes) if test "$with_csharp" = "yes"; then - PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no) + PKG_CHECK_MODULES(MONO, mono >= 2.0.0, net_3_5=yes, net_3_5=no) + PKG_CHECK_MODULES(MONO, mono >= 1.2.4, have_mono=yes, have_mono=no) fi AM_CONDITIONAL(WITH_MONO, [test "$have_mono" = "yes"]) +AM_CONDITIONAL(NET_2_0, [test "$net_3_5" = "no"]) AX_THRIFT_LIB(java, [Java], yes) if test "$with_java" = "yes"; then diff --git a/lib/csharp/Makefile.am b/lib/csharp/Makefile.am index 710cd12f..4ceb9e05 100644 --- a/lib/csharp/Makefile.am +++ b/lib/csharp/Makefile.am @@ -1,4 +1,5 @@ THRIFTCODE= \ + src/Collections/THashSet.cs \ src/Protocol/TBase.cs \ src/Protocol/TProtocolException.cs \ src/Protocol/TProtocolFactory.cs \ @@ -31,10 +32,14 @@ THRIFTCODE= \ CSC=gmcs +if NET_2_0 +MONO_DEFINES=/d:NET_2_0 +endif + all-local: Thrift.dll Thrift.dll: $(THRIFTCODE) - $(CSC) $(THRIFTCODE) /out:Thrift.dll /target:library /langversion:linq + $(CSC) $(THRIFTCODE) /out:Thrift.dll /target:library $(MONO_DEFINES) clean-local: $(RM) Thrift.dll diff --git a/lib/csharp/src/Collections/THashSet.cs b/lib/csharp/src/Collections/THashSet.cs new file mode 100644 index 00000000..51a09b59 --- /dev/null +++ b/lib/csharp/src/Collections/THashSet.cs @@ -0,0 +1,142 @@ +/** + * 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; +using System.Collections.Generic; + +namespace Thrift.Collections +{ + public class THashSet : ICollection + { +#if NET_2_0 + TDictSet set = new TDictSet(); +#else + HashSet set = new HashSet(); +#endif + public int Count + { + get { return set.Count; } + } + + public bool IsReadOnly + { + get { return set.IsReadOnly; } + } + + public void Add(T item) + { + set.Add(item); + } + + public void Clear() + { + set.Clear(); + } + + public bool Contains(T item) + { + return set.Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + set.CopyTo(array, arrayIndex); + } + + public IEnumerator GetEnumerator() + { + return set.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)set).GetEnumerator(); + } + + public bool Remove(T item) + { + return set.Remove(item); + } + +#if NET_2_0 + private class TDictSet : ICollection + { + Dictionary> dict = new Dictionary>(); + + public int Count + { + get { return dict.Count; } + } + + public bool IsReadOnly + { + get { return false; } + } + + public IEnumerator GetEnumerator() + { + return ((IEnumerable)dict.Keys).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return dict.Keys.GetEnumerator(); + } + + public bool Add(V item) + { + if (!dict.ContainsKey(item)) + { + dict[item] = this; + return true; + } + + return false; + } + + void ICollection.Add(V item) + { + Add(item); + } + + public void Clear() + { + dict.Clear(); + } + + public bool Contains(V item) + { + return dict.ContainsKey(item); + } + + public void CopyTo(V[] array, int arrayIndex) + { + dict.Keys.CopyTo(array, arrayIndex); + } + + public bool Remove(V item) + { + return dict.Remove(item); + } + } +#endif + } + +} diff --git a/lib/csharp/src/Protocol/TBinaryProtocol.cs b/lib/csharp/src/Protocol/TBinaryProtocol.cs index 5df20210..2f2f4a1b 100644 --- a/lib/csharp/src/Protocol/TBinaryProtocol.cs +++ b/lib/csharp/src/Protocol/TBinaryProtocol.cs @@ -12,7 +12,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; using System.Text; using Thrift.Transport; diff --git a/lib/csharp/src/Protocol/TField.cs b/lib/csharp/src/Protocol/TField.cs index 93c0738a..bda17608 100644 --- a/lib/csharp/src/Protocol/TField.cs +++ b/lib/csharp/src/Protocol/TField.cs @@ -18,30 +18,34 @@ namespace Thrift.Protocol { public struct TField { + private string name; + private TType type; + private short id; + public TField(string name, TType type, short id) :this() { - Name = name; - Type = type; - ID = id; + this.name = name; + this.type = type; + this.id = id; } public string Name { - get; - set; + get { return name; } + set { name = value; } } public TType Type { - get; - set; + get { return type; } + set { type = value; } } public short ID { - get; - set; + get { return id; } + set { id = value; } } } } diff --git a/lib/csharp/src/Protocol/TList.cs b/lib/csharp/src/Protocol/TList.cs index ccce522b..5e4fa390 100644 --- a/lib/csharp/src/Protocol/TList.cs +++ b/lib/csharp/src/Protocol/TList.cs @@ -18,23 +18,26 @@ namespace Thrift.Protocol { public struct TList { + private TType elementType; + private int count; + public TList(TType elementType, int count) :this() { - ElementType = elementType; - Count = count; + this.elementType = elementType; + this.count = count; } public TType ElementType { - get; - set; + get { return elementType; } + set { elementType = value; } } public int Count { - get; - set; + get { return count; } + set { count = value; } } } } diff --git a/lib/csharp/src/Protocol/TMap.cs b/lib/csharp/src/Protocol/TMap.cs index a71e52a9..48130276 100644 --- a/lib/csharp/src/Protocol/TMap.cs +++ b/lib/csharp/src/Protocol/TMap.cs @@ -18,30 +18,34 @@ namespace Thrift.Protocol { public struct TMap { + private TType keyType; + private TType valueType; + private int count; + public TMap(TType keyType, TType valueType, int count) :this() { - KeyType = keyType; - ValueType = valueType; - Count = count; + this.keyType = keyType; + this.valueType = valueType; + this.count = count; } public TType KeyType { - get; - set; + get { return keyType; } + set { keyType = value; } } public TType ValueType { - get; - set; + get { return valueType; } + set { valueType = value; } } public int Count { - get; - set; + get { return count; } + set { count = value; } } } } diff --git a/lib/csharp/src/Protocol/TMessage.cs b/lib/csharp/src/Protocol/TMessage.cs index 15dfce03..3818da01 100644 --- a/lib/csharp/src/Protocol/TMessage.cs +++ b/lib/csharp/src/Protocol/TMessage.cs @@ -18,30 +18,34 @@ namespace Thrift.Protocol { public struct TMessage { + private string name; + private TMessageType type; + private int seqID; + public TMessage(string name, TMessageType type, int seqid) :this() { - Name = name; - Type = type; - SeqID = seqid; + this.name = name; + this.type = type; + this.seqID = seqid; } public string Name { - get; - set; + get { return name; } + set { name = value; } } public TMessageType Type { - get; - set; + get { return type; } + set { type = value; } } public int SeqID { - get; - set; + get { return seqID; } + set { seqID = value; } } } } diff --git a/lib/csharp/src/Protocol/TMessageType.cs b/lib/csharp/src/Protocol/TMessageType.cs index 6e6ead76..d458d533 100644 --- a/lib/csharp/src/Protocol/TMessageType.cs +++ b/lib/csharp/src/Protocol/TMessageType.cs @@ -11,8 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Protocol { diff --git a/lib/csharp/src/Protocol/TProtocol.cs b/lib/csharp/src/Protocol/TProtocol.cs index 2702ad80..6e48faca 100644 --- a/lib/csharp/src/Protocol/TProtocol.cs +++ b/lib/csharp/src/Protocol/TProtocol.cs @@ -11,7 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; using System.Text; using Thrift.Transport; diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs index db38d88c..f43a7ccb 100644 --- a/lib/csharp/src/Protocol/TProtocolException.cs +++ b/lib/csharp/src/Protocol/TProtocolException.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Protocol { diff --git a/lib/csharp/src/Protocol/TProtocolFactory.cs b/lib/csharp/src/Protocol/TProtocolFactory.cs index 756bb5e3..4e15bb13 100644 --- a/lib/csharp/src/Protocol/TProtocolFactory.cs +++ b/lib/csharp/src/Protocol/TProtocolFactory.cs @@ -10,8 +10,6 @@ // See accompanying file LICENSE or visit the Thrift site at: // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; using Thrift.Transport; namespace Thrift.Protocol diff --git a/lib/csharp/src/Protocol/TProtocolUtil.cs b/lib/csharp/src/Protocol/TProtocolUtil.cs index a65ea0fa..577182c5 100644 --- a/lib/csharp/src/Protocol/TProtocolUtil.cs +++ b/lib/csharp/src/Protocol/TProtocolUtil.cs @@ -11,8 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Protocol { diff --git a/lib/csharp/src/Protocol/TSet.cs b/lib/csharp/src/Protocol/TSet.cs index 0bfc29e4..cdf38490 100644 --- a/lib/csharp/src/Protocol/TSet.cs +++ b/lib/csharp/src/Protocol/TSet.cs @@ -18,23 +18,26 @@ namespace Thrift.Protocol { public struct TSet { + private TType elementType; + private int count; + public TSet(TType elementType, int count) :this() { - ElementType = elementType; - Count = count; + this.elementType = elementType; + this.count = count; } public TType ElementType { - get; - set; + get { return elementType; } + set { elementType = value; } } public int Count { - get; - set; + get { return count; } + set { count = value; } } } } diff --git a/lib/csharp/src/Protocol/TStruct.cs b/lib/csharp/src/Protocol/TStruct.cs index 62f60fdb..1a7d5721 100644 --- a/lib/csharp/src/Protocol/TStruct.cs +++ b/lib/csharp/src/Protocol/TStruct.cs @@ -17,16 +17,18 @@ namespace Thrift.Protocol { public struct TStruct { + private string name; + public TStruct(string name) :this() { - Name = name; + this.name = name; } public string Name { - get; - set; + get { return name; } + set { name = value; } } } } diff --git a/lib/csharp/src/Protocol/TType.cs b/lib/csharp/src/Protocol/TType.cs index 257ac6bc..5cc6178d 100644 --- a/lib/csharp/src/Protocol/TType.cs +++ b/lib/csharp/src/Protocol/TType.cs @@ -11,8 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Protocol { diff --git a/lib/csharp/src/Server/TServer.cs b/lib/csharp/src/Server/TServer.cs index afb2b9f3..f5f617ac 100644 --- a/lib/csharp/src/Server/TServer.cs +++ b/lib/csharp/src/Server/TServer.cs @@ -11,7 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; using Thrift.Protocol; using Thrift.Transport; using System.IO; diff --git a/lib/csharp/src/Server/TSimpleServer.cs b/lib/csharp/src/Server/TSimpleServer.cs index 95f39623..912b4a34 100644 --- a/lib/csharp/src/Server/TSimpleServer.cs +++ b/lib/csharp/src/Server/TSimpleServer.cs @@ -10,8 +10,6 @@ // See accompanying file LICENSE or visit the Thrift site at: // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; using Thrift.Transport; using Thrift.Protocol; diff --git a/lib/csharp/src/Server/TThreadPoolServer.cs b/lib/csharp/src/Server/TThreadPoolServer.cs index b44487fd..e3c5cded 100644 --- a/lib/csharp/src/Server/TThreadPoolServer.cs +++ b/lib/csharp/src/Server/TThreadPoolServer.cs @@ -10,8 +10,6 @@ // See accompanying file LICENSE or visit the Thrift site at: // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; using System.Threading; using Thrift.Protocol; using Thrift.Transport; diff --git a/lib/csharp/src/Server/TThreadedServer.cs b/lib/csharp/src/Server/TThreadedServer.cs index a4d33a5e..2928f31c 100644 --- a/lib/csharp/src/Server/TThreadedServer.cs +++ b/lib/csharp/src/Server/TThreadedServer.cs @@ -11,8 +11,8 @@ // http://developers.facebook.com/thrift/using using System; using System.Collections.Generic; -using System.Text; using System.Threading; +using Thrift.Collections; using Thrift.Protocol; using Thrift.Transport; @@ -28,7 +28,7 @@ namespace Thrift.Server private readonly int maxThreads; private Queue clientQueue; - private HashSet clientThreads; + private THashSet clientThreads; private object clientLock; private Thread workerThread; @@ -73,7 +73,7 @@ namespace Thrift.Server this.maxThreads = maxThreads; clientQueue = new Queue(); clientLock = new object(); - clientThreads = new HashSet(); + clientThreads = new THashSet(); } /// diff --git a/lib/csharp/src/TApplicationException.cs b/lib/csharp/src/TApplicationException.cs index 42486643..cb3353b1 100644 --- a/lib/csharp/src/TApplicationException.cs +++ b/lib/csharp/src/TApplicationException.cs @@ -11,8 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; using Thrift.Protocol; namespace Thrift diff --git a/lib/csharp/src/TProcessor.cs b/lib/csharp/src/TProcessor.cs index 2cbddd72..679e3f69 100644 --- a/lib/csharp/src/TProcessor.cs +++ b/lib/csharp/src/TProcessor.cs @@ -11,8 +11,6 @@ // http://developers.facebook.com/thrift/using using System; -using System.Collections.Generic; -using System.Text; using Thrift.Protocol; namespace Thrift diff --git a/lib/csharp/src/Thrift.csproj b/lib/csharp/src/Thrift.csproj index 9f3f6209..1eb4355d 100644 --- a/lib/csharp/src/Thrift.csproj +++ b/lib/csharp/src/Thrift.csproj @@ -38,14 +38,9 @@ 3.5 - - - - - - + diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs index 96a07417..bd4ba95f 100644 --- a/lib/csharp/src/Transport/TBufferedTransport.cs +++ b/lib/csharp/src/Transport/TBufferedTransport.cs @@ -7,9 +7,6 @@ // using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; namespace Thrift.Transport diff --git a/lib/csharp/src/Transport/TServerSocket.cs b/lib/csharp/src/Transport/TServerSocket.cs index a6caf90c..3559ce72 100644 --- a/lib/csharp/src/Transport/TServerSocket.cs +++ b/lib/csharp/src/Transport/TServerSocket.cs @@ -9,8 +9,6 @@ // All rights reserved. using System; -using System.Collections.Generic; -using System.Text; using System.Net.Sockets; diff --git a/lib/csharp/src/Transport/TServerTransport.cs b/lib/csharp/src/Transport/TServerTransport.cs index 6b05a158..bff62e1f 100644 --- a/lib/csharp/src/Transport/TServerTransport.cs +++ b/lib/csharp/src/Transport/TServerTransport.cs @@ -8,8 +8,6 @@ // Copyright (C) 2007 imeem, inc. // All rights reserved. using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Transport { diff --git a/lib/csharp/src/Transport/TSocket.cs b/lib/csharp/src/Transport/TSocket.cs index c790fce2..cc7eefdb 100644 --- a/lib/csharp/src/Transport/TSocket.cs +++ b/lib/csharp/src/Transport/TSocket.cs @@ -10,8 +10,6 @@ // using System; -using System.Collections.Generic; -using System.Text; using System.Net.Sockets; namespace Thrift.Transport diff --git a/lib/csharp/src/Transport/TStreamTransport.cs b/lib/csharp/src/Transport/TStreamTransport.cs index ca14ecf8..f74f59a8 100644 --- a/lib/csharp/src/Transport/TStreamTransport.cs +++ b/lib/csharp/src/Transport/TStreamTransport.cs @@ -10,8 +10,6 @@ // using System; -using System.Collections.Generic; -using System.Text; using System.IO; namespace Thrift.Transport diff --git a/lib/csharp/src/Transport/TTransport.cs b/lib/csharp/src/Transport/TTransport.cs index 915cbc93..c95d98ef 100644 --- a/lib/csharp/src/Transport/TTransport.cs +++ b/lib/csharp/src/Transport/TTransport.cs @@ -10,8 +10,6 @@ // using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Transport { diff --git a/lib/csharp/src/Transport/TTransportException.cs b/lib/csharp/src/Transport/TTransportException.cs index daf21d8f..fa1f6b58 100644 --- a/lib/csharp/src/Transport/TTransportException.cs +++ b/lib/csharp/src/Transport/TTransportException.cs @@ -10,8 +10,6 @@ // using System; -using System.Collections.Generic; -using System.Text; namespace Thrift.Transport { diff --git a/lib/csharp/src/Transport/TTransportFactory.cs b/lib/csharp/src/Transport/TTransportFactory.cs index a0a6c2bb..02806494 100644 --- a/lib/csharp/src/Transport/TTransportFactory.cs +++ b/lib/csharp/src/Transport/TTransportFactory.cs @@ -9,9 +9,6 @@ // All rights reserved. // using System; -using System.Collections.Generic; -using System.Text; - namespace Thrift.Transport { diff --git a/test/csharp/CSharpServer.cs b/test/csharp/CSharpServer.cs index 32cc7034..5eef03b0 100644 --- a/test/csharp/CSharpServer.cs +++ b/test/csharp/CSharpServer.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Thrift.Server; using Thrift.Transport; diff --git a/test/csharp/ThriftTest/Program.cs b/test/csharp/ThriftTest/Program.cs index 09bd84f9..38605256 100644 --- a/test/csharp/ThriftTest/Program.cs +++ b/test/csharp/ThriftTest/Program.cs @@ -4,8 +4,6 @@ // http://developers.facebook.com/thrift/ using System; -using System.Collections.Generic; -using System.Text; using Thrift.Transport; using Thrift.Protocol; using Thrift.Test; //generated code diff --git a/test/csharp/ThriftTest/TestClient.cs b/test/csharp/ThriftTest/TestClient.cs index bcdb00e5..42b21b8a 100644 --- a/test/csharp/ThriftTest/TestClient.cs +++ b/test/csharp/ThriftTest/TestClient.cs @@ -1,11 +1,10 @@ using System; using System.Collections.Generic; -using System.Text; - +using System.Threading; +using Thrift.Collections; using Thrift.Protocol; using Thrift.Transport; using Thrift.Test; -using System.Threading; namespace Test { @@ -247,7 +246,7 @@ namespace Test Console.WriteLine("}"); //set - HashSet setout = new HashSet(); + THashSet setout = new THashSet(); for (int j = -2; j < 3; j++) { setout.Add(j); @@ -268,7 +267,7 @@ namespace Test } Console.Write("})"); - HashSet setin = client.testSet(setout); + THashSet setin = client.testSet(setout); Console.Write(" = {"); first = true; diff --git a/test/csharp/ThriftTest/TestServer.cs b/test/csharp/ThriftTest/TestServer.cs index 4efe4b4d..18952d44 100644 --- a/test/csharp/ThriftTest/TestServer.cs +++ b/test/csharp/ThriftTest/TestServer.cs @@ -4,9 +4,8 @@ // http://developers.facebook.com/thrift/ using System; using System.Collections.Generic; -using System.Text; +using Thrift.Collections; using Thrift.Test; //generated code - using Thrift.Transport; using Thrift.Protocol; using Thrift.Server; @@ -99,7 +98,7 @@ namespace Test return thing; } - public HashSet testSet(HashSet thing) + public THashSet testSet(THashSet thing) { Console.WriteLine("testSet({"); bool first = true; @@ -305,10 +304,13 @@ namespace Test TServer serverEngine; // Simple Server - // serverEngine = new TSimpleServer(testProcessor, tServerSocket); + serverEngine = new TSimpleServer(testProcessor, tServerSocket); // ThreadPool Server - serverEngine = new TThreadPoolServer(testProcessor, tServerSocket); + // serverEngine = new TThreadPoolServer(testProcessor, tServerSocket); + + // Threaded Server + // serverEngine = new TThreadedServer(testProcessor, tServerSocket); testHandler.server = serverEngine; diff --git a/test/csharp/ThriftTest/ThriftTest.csproj b/test/csharp/ThriftTest/ThriftTest.csproj index 8e61173d..3f427fd7 100644 --- a/test/csharp/ThriftTest/ThriftTest.csproj +++ b/test/csharp/ThriftTest/ThriftTest.csproj @@ -51,17 +51,6 @@ - - 3.5 - - - 3.5 - - - 3.5 - - - False .\ThriftImpl.dll @@ -117,6 +106,6 @@ $(ProjectDir)\..\..\..\compiler\cpp\thrift.exe -csharp -o $(ProjectDir) $(Projec cd $(ProjectDir) -C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /t:library /out:.\ThriftImpl.dll /recurse:.\gen-csharp\* /reference:$(ProjectDir)..\..\..\lib\csharp\src\bin\Debug\Thrift.dll +$(MSBuildToolsPath)\Csc.exe /t:library /out:.\ThriftImpl.dll /recurse:.\gen-csharp\* /reference:$(ProjectDir)..\..\..\lib\csharp\src\bin\Debug\Thrift.dll diff --git a/test/csharp/ThriftTest/maketest.sh b/test/csharp/ThriftTest/maketest.sh new file mode 100755 index 00000000..aab34b73 --- /dev/null +++ b/test/csharp/ThriftTest/maketest.sh @@ -0,0 +1,3 @@ +#!/bin/sh +../../../compiler/cpp/thrift --gen csharp -o . ../../ThriftTest.thrift +gmcs /t:library /out:./ThriftImpl.dll /recurse:./gen-csharp/* /reference:../../../lib/csharp/Thrift.dll -- 2.17.1