summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reiss <dreiss@apache.org>2009-01-06 19:49:33 +0000
committerDavid Reiss <dreiss@apache.org>2009-01-06 19:49:33 +0000
commitc654416843d84a9bd43add0dbc4567920947ea73 (patch)
treecadd3e7d5f9ff601332cb3c50a6d987b22b76936
parentb0f31ef92fae72f60162b9ef03b498551d529cb5 (diff)
downloadthrift-c654416843d84a9bd43add0dbc4567920947ea73.tar.gz
THRIFT-129. csharp: Make all Thrift structures extend TBase
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@732081 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--compiler/cpp/src/generate/t_csharp_generator.cc8
-rw-r--r--lib/csharp/src/Protocol/TBase.cs23
-rw-r--r--lib/csharp/src/Thrift.csproj1
3 files changed, 28 insertions, 4 deletions
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index a5c4bd142..088a025bc 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -387,18 +387,18 @@ void t_csharp_generator::generate_csharp_struct(t_struct* tstruct, bool is_excep
void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_struct* tstruct, bool is_exception, bool in_class, bool is_result) {
- if (!in_class)
- {
+ if (!in_class) {
start_csharp_namespace(out);
}
out << endl;
indent(out) << "[Serializable]" << endl;
- indent(out) << "public class " << tstruct->get_name() << " ";
+ indent(out) << "public class " << tstruct->get_name() << " : ";
if (is_exception) {
- out << ": Exception ";
+ out << "Exception, ";
}
+ out << "TBase";
out << endl;
diff --git a/lib/csharp/src/Protocol/TBase.cs b/lib/csharp/src/Protocol/TBase.cs
new file mode 100644
index 000000000..46c5e2a93
--- /dev/null
+++ b/lib/csharp/src/Protocol/TBase.cs
@@ -0,0 +1,23 @@
+//
+// TBase.cs
+//
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/using
+
+namespace Thrift.Protocol
+{
+ public interface TBase
+ {
+ ///
+ /// Reads the TObject from the given input protocol.
+ ///
+ void Read(TProtocol tProtocol);
+
+ ///
+ /// Writes the objects out to the protocol
+ ///
+ void Write(TProtocol tProtocol);
+ }
+}
diff --git a/lib/csharp/src/Thrift.csproj b/lib/csharp/src/Thrift.csproj
index 1a1a332d4..9f3f62097 100644
--- a/lib/csharp/src/Thrift.csproj
+++ b/lib/csharp/src/Thrift.csproj
@@ -46,6 +46,7 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Protocol\TBase.cs" />
<Compile Include="Protocol\TBinaryProtocol.cs" />
<Compile Include="Protocol\TField.cs" />
<Compile Include="Protocol\TList.cs" />