Thrift: C# Bindings.

Summary:
C# generator, library, and MS Build task contributed by imeem.

Reviewed By: mcslee

Test Plan:
Built the Thrift compiler and generated some C# code.
I'd love to say I installed Mono or Portable.NET and built the C# code,
but I did not.

Revert Plan: ok


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665421 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/csharp/src/Protocol/TBinaryProtocol.cs b/lib/csharp/src/Protocol/TBinaryProtocol.cs
new file mode 100644
index 0000000..36f03d0
--- /dev/null
+++ b/lib/csharp/src/Protocol/TBinaryProtocol.cs
@@ -0,0 +1,386 @@
+//
+//  TBinaryProtocol.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//		Will Palmeri <will@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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
+{
+	public class TBinaryProtocol : TProtocol
+	{
+		protected const uint VERSION_MASK = 0xffff0000;
+		protected const uint VERSION_1 = 0x80010000;
+
+		protected bool strictRead_ = false;
+		protected bool strictWrite_ = true;
+
+		protected int readLength_;
+		protected bool checkReadLength_ = false;
+
+
+		#region BinaryProtocol Factory
+		 /**
+		  * Factory
+		  */
+		  public class Factory : TProtocolFactory {
+
+			  protected bool strictRead_ = false;
+			  protected bool strictWrite_ = true;
+
+			  public Factory()
+				  :this(false, true)
+			  {
+			  }
+
+			  public Factory(bool strictRead, bool strictWrite)
+			  {
+				  strictRead_ = strictRead;
+				  strictWrite_ = strictWrite;
+			  }
+
+			public TProtocol GetProtocol(TTransport trans) {
+			  return new TBinaryProtocol(trans, strictRead_, strictWrite_);
+			}
+		  }
+
+		#endregion
+
+		public TBinaryProtocol(TTransport trans)
+			: this(trans, false, true)
+		{
+		}
+
+		public TBinaryProtocol(TTransport trans, bool strictRead, bool strictWrite)
+			:base(trans)
+		{
+			strictRead_ = strictRead;
+			strictWrite_ = strictWrite;
+		}
+
+		#region Write Methods
+
+		public override void WriteMessageBegin(TMessage message)
+		{
+			if (strictWrite_)
+			{
+				uint version = VERSION_1 | (uint)(message.Type);
+				WriteI32((int)version);
+				WriteString(message.Name);
+				WriteI32(message.SeqID);
+			}
+			else
+			{
+				WriteString(message.Name);
+				WriteByte((byte)message.Type);
+				WriteI32(message.SeqID);
+			}
+		}
+
+		public override void WriteMessageEnd()
+		{
+		}
+
+		public override void WriteStructBegin(TStruct struc)
+		{
+		}
+
+		public override void WriteStructEnd()
+		{
+		}
+
+		public override void WriteFieldBegin(TField field)
+		{
+			WriteByte((byte)field.Type);
+			WriteI16(field.ID);
+		}
+
+		public override void WriteFieldEnd()
+		{
+		}
+
+		public override void WriteFieldStop()
+		{
+			WriteByte((byte)TType.Stop);
+		}
+
+		public override void WriteMapBegin(TMap map)
+		{
+			WriteByte((byte)map.KeyType);
+			WriteByte((byte)map.ValueType);
+			WriteI32(map.Count);
+		}
+
+		public override void WriteMapEnd()
+		{
+		}
+
+		public override void WriteListBegin(TList list)
+		{
+			WriteByte((byte)list.ElementType);
+			WriteI32(list.Count);
+		}
+
+		public override void WriteListEnd()
+		{
+		}
+
+		public override void WriteSetBegin(TSet set)
+		{
+			WriteByte((byte)set.ElementType);
+			WriteI32(set.Count);
+		}
+
+		public override void WriteSetEnd()
+		{
+		}
+
+		public override void WriteBool(bool b)
+		{
+			WriteByte(b ? (byte)1 : (byte)0);
+		}
+
+		private byte[] bout = new byte[1];
+		public override void WriteByte(byte b)
+		{
+			bout[0] = b;
+			trans.Write(bout, 0, 1);
+		}
+
+		private byte[] i16out = new byte[2];
+		public override void WriteI16(short s)
+		{
+			i16out[0] = (byte)(0xff & (s >> 8));
+			i16out[1] = (byte)(0xff & s);
+			trans.Write(i16out, 0, 2);
+		}
+
+		private byte[] i32out = new byte[4];
+		public override void WriteI32(int i32)
+		{
+			i32out[0] = (byte)(0xff & (i32 >> 24));
+			i32out[1] = (byte)(0xff & (i32 >> 16));
+			i32out[2] = (byte)(0xff & (i32 >> 8));
+			i32out[3] = (byte)(0xff & i32);
+			trans.Write(i32out, 0, 4);
+		}
+
+		private byte[] i64out = new byte[8];
+		public override void WriteI64(long i64)
+		{
+			i64out[0] = (byte)(0xff & (i64 >> 56));
+			i64out[1] = (byte)(0xff & (i64 >> 48));
+			i64out[2] = (byte)(0xff & (i64 >> 40));
+			i64out[3] = (byte)(0xff & (i64 >> 32));
+			i64out[4] = (byte)(0xff & (i64 >> 24));
+			i64out[5] = (byte)(0xff & (i64 >> 16));
+			i64out[6] = (byte)(0xff & (i64 >> 8));
+			i64out[7] = (byte)(0xff & i64);
+			trans.Write(i64out, 0, 8);
+		}
+
+		public override void WriteDouble(double d)
+		{
+			WriteI64(BitConverter.DoubleToInt64Bits(d));
+		}
+
+		public override void WriteString(string s)
+		{
+			byte[] b = Encoding.UTF8.GetBytes(s);
+			WriteI32(b.Length);
+			trans.Write(b, 0, b.Length);
+		}
+
+		#endregion
+
+		#region ReadMethods
+
+		public override TMessage ReadMessageBegin()
+		{
+			TMessage message = new TMessage();
+			int size = ReadI32();
+			if (size < 0)
+			{
+				uint version = (uint)size & VERSION_MASK;
+				if (version != VERSION_1)
+				{
+					throw new TProtocolException(TProtocolException.BAD_VERSION, "Bad version in ReadMessageBegin: " + version);
+				}
+				message.Type = (TMessageType)(size & 0x000000ff);
+				message.Name = ReadString();
+				message.SeqID = ReadI32();
+			}
+			else
+			{
+				if (strictRead_)
+				{
+					throw new TProtocolException(TProtocolException.BAD_VERSION, "Missing version in readMessageBegin, old client?");
+				}
+				message.Name = ReadStringBody(size);
+				message.Type = (TMessageType)ReadByte();
+				message.SeqID = ReadI32();
+			}
+			return message;
+		}
+
+		public override void ReadMessageEnd()
+		{
+		}
+
+		public override TStruct ReadStructBegin()
+		{
+			return new TStruct();
+		}
+
+		public override void ReadStructEnd()
+		{
+		}
+
+		public override TField ReadFieldBegin()
+		{
+			TField field = new TField();
+			field.Type = (TType)ReadByte();
+
+			if (field.Type != TType.Stop)
+			{
+				field.ID = ReadI16();
+			}
+
+			return field;
+		}
+
+		public override void ReadFieldEnd()
+		{
+		}
+
+		public override TMap ReadMapBegin()
+		{
+			TMap map = new TMap();
+			map.KeyType = (TType)ReadByte();
+			map.ValueType = (TType)ReadByte();
+			map.Count = ReadI32();
+
+			return map;
+		}
+
+		public override void ReadMapEnd()
+		{
+		}
+
+		public override TList ReadListBegin()
+		{
+			TList list = new TList();
+			list.ElementType = (TType)ReadByte();
+			list.Count = ReadI32();
+
+			return list;
+		}
+
+		public override void ReadListEnd()
+		{
+		}
+
+		public override TSet ReadSetBegin()
+		{
+			TSet set = new TSet();
+			set.ElementType = (TType)ReadByte();
+			set.Count = ReadI32();
+
+			return set;
+		}
+
+		public override void ReadSetEnd()
+		{
+		}
+
+		public override bool ReadBool()
+		{
+			return ReadByte() == 1;
+		}
+
+		private byte[] bin = new byte[1];
+		public override byte ReadByte()
+		{
+			ReadAll(bin, 0, 1);
+			return bin[0];
+		}
+
+		private byte[] i16in = new byte[2];
+		public override short ReadI16()
+		{
+			ReadAll(i16in, 0, 2);
+			return (short)(((i16in[0] & 0xff) << 8) | ((i16in[1] & 0xff)));
+		}
+
+		private byte[] i32in = new byte[4];
+		public override int ReadI32()
+		{
+			ReadAll(i32in, 0, 4);
+			return (int)(((i32in[0] & 0xff) << 24) | ((i32in[1] & 0xff) << 16) | ((i32in[2] & 0xff) << 8) | ((i32in[3] & 0xff)));
+		}
+
+		private byte[] i64in = new byte[8];
+		public override long ReadI64()
+		{
+			ReadAll(i64in, 0, 8);
+			return (long)(((long)(i64in[0] & 0xff) << 56) | ((long)(i64in[1] & 0xff) << 48) | ((long)(i64in[2] & 0xff) << 40) | ((long)(i64in[3] & 0xff) << 32) |
+				((long)(i64in[4] & 0xff) << 24) | ((long)(i64in[5] & 0xff) << 16) | ((long)(i64in[6] & 0xff) << 8) | ((long)(i64in[7] & 0xff)));
+		}
+
+		public override double ReadDouble()
+		{
+			return BitConverter.Int64BitsToDouble(ReadI64());
+		}
+
+		public void SetReadLength(int readLength)
+		{
+			readLength_ = readLength;
+			checkReadLength_ = true;
+		}
+
+		protected void CheckReadLength(int length)
+		{
+			if (checkReadLength_)
+			{
+				readLength_ -= length;
+				if (readLength_ < 0)
+				{
+					throw new Exception("Message length exceeded: " + length);
+				}
+			}
+		}
+
+		public override string ReadString()
+		{
+			int size = ReadI32();
+			return ReadStringBody(size);
+		}
+
+		public string ReadStringBody(int size)
+		{
+			CheckReadLength(size);
+			byte[] buf = new byte[size];
+			trans.ReadAll(buf, 0, size);
+			return Encoding.UTF8.GetString(buf);
+		}
+
+		private int ReadAll(byte[] buf, int off, int len)
+		{
+			CheckReadLength(len);
+			return trans.ReadAll(buf, off, len);
+		}
+
+		#endregion
+	}
+}
diff --git a/lib/csharp/src/Protocol/TField.cs b/lib/csharp/src/Protocol/TField.cs
new file mode 100644
index 0000000..f18381f
--- /dev/null
+++ b/lib/csharp/src/Protocol/TField.cs
@@ -0,0 +1,50 @@
+//
+//  TField.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public class TField
+	{
+		public TField()
+		{
+		}
+
+		public TField(string name, TType type, short id)
+		{
+			Name = name;
+			Type = type;
+			ID = id;
+		}
+
+		public string Name
+		{
+			get;
+			set;
+		}
+
+		public TType Type
+		{
+			get;
+			set;
+		}
+
+		public short ID
+		{
+			get;
+			set;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TList.cs b/lib/csharp/src/Protocol/TList.cs
new file mode 100644
index 0000000..ff6aa53
--- /dev/null
+++ b/lib/csharp/src/Protocol/TList.cs
@@ -0,0 +1,43 @@
+//
+//  TList.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public class TList
+	{
+		public TList()
+		{
+		}
+
+		public TList(TType elementType, int count)
+		{
+			ElementType = elementType;
+			Count = count;
+		}
+
+		public TType ElementType
+		{
+			get;
+			set;
+		}
+
+		public int Count
+		{
+			get;
+			set;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TMap.cs b/lib/csharp/src/Protocol/TMap.cs
new file mode 100644
index 0000000..495bf7c
--- /dev/null
+++ b/lib/csharp/src/Protocol/TMap.cs
@@ -0,0 +1,50 @@
+//
+//  TMap.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public class TMap
+	{
+		public TMap()
+		{
+		}
+
+		public TMap(TType keyType, TType valueType, int count)
+		{
+			KeyType = keyType;
+			ValueType = valueType;
+			Count = count;
+		}
+
+		public TType KeyType
+		{
+			get;
+			set;
+		}
+
+		public TType ValueType
+		{
+			get;
+			set;
+		}
+
+		public int Count
+		{
+			get;
+			set;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TMessage.cs b/lib/csharp/src/Protocol/TMessage.cs
new file mode 100644
index 0000000..60df660
--- /dev/null
+++ b/lib/csharp/src/Protocol/TMessage.cs
@@ -0,0 +1,50 @@
+//
+//  TMessage.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public class TMessage
+	{
+		public TMessage()
+		{
+		}
+
+		public TMessage(string name, TMessageType type, int seqid)
+		{
+			Name = name;
+			Type = type;
+			SeqID = seqid;
+		}
+
+		public string Name
+		{
+			get;
+			set;
+		}
+
+		public TMessageType Type
+		{
+			get;
+			set;
+		}
+
+		public int SeqID
+		{
+			get;
+			set;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TMessageType.cs b/lib/csharp/src/Protocol/TMessageType.cs
new file mode 100644
index 0000000..1cadf31
--- /dev/null
+++ b/lib/csharp/src/Protocol/TMessageType.cs
@@ -0,0 +1,25 @@
+//
+//  TMessageType.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public enum TMessageType
+	{
+		Call = 1,
+		Reply = 2,
+		Exception = 3
+	}
+}
diff --git a/lib/csharp/src/Protocol/TProtocol.cs b/lib/csharp/src/Protocol/TProtocol.cs
new file mode 100644
index 0000000..f46b6d1
--- /dev/null
+++ b/lib/csharp/src/Protocol/TProtocol.cs
@@ -0,0 +1,75 @@
+//
+//  TProtocol.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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
+{
+	public abstract class TProtocol
+	{
+		protected TTransport trans;
+
+		protected TProtocol(TTransport trans)
+		{
+			this.trans = trans;
+		}
+
+		public TTransport Transport
+		{
+			get { return trans; }
+		}
+
+		public abstract void WriteMessageBegin(TMessage message);
+		public abstract void WriteMessageEnd();
+		public abstract void WriteStructBegin(TStruct struc);
+		public abstract void WriteStructEnd();
+		public abstract void WriteFieldBegin(TField field);
+		public abstract void WriteFieldEnd();
+		public abstract void WriteFieldStop();
+		public abstract void WriteMapBegin(TMap map);
+		public abstract void WriteMapEnd();
+		public abstract void WriteListBegin(TList list);
+		public abstract void WriteListEnd();
+		public abstract void WriteSetBegin(TSet set);
+		public abstract void WriteSetEnd();
+		public abstract void WriteBool(bool b);
+		public abstract void WriteByte(byte b);
+		public abstract void WriteI16(short i16);
+		public abstract void WriteI32(int i32);
+		public abstract void WriteI64(long i64);
+		public abstract void WriteDouble(double d);
+		public abstract void WriteString(string s);
+
+		public abstract TMessage ReadMessageBegin();
+		public abstract void ReadMessageEnd();
+		public abstract TStruct ReadStructBegin();
+		public abstract void ReadStructEnd();
+		public abstract TField ReadFieldBegin();
+		public abstract void ReadFieldEnd();
+		public abstract TMap ReadMapBegin();
+		public abstract void ReadMapEnd();
+		public abstract TList ReadListBegin();
+		public abstract void ReadListEnd();
+		public abstract TSet ReadSetBegin();
+		public abstract void ReadSetEnd();
+		public abstract bool ReadBool();
+		public abstract byte ReadByte();
+		public abstract short ReadI16();
+		public abstract int ReadI32();
+		public abstract long ReadI64();
+		public abstract double ReadDouble();
+		public abstract string ReadString();
+	}
+}
diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs
new file mode 100644
index 0000000..0941a81
--- /dev/null
+++ b/lib/csharp/src/Protocol/TProtocolException.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Thrift.Protocol
+{
+	class TProtocolException : Exception
+	{
+		public const int UNKNOWN = 0;
+		public const int INVALID_DATA = 1;
+		public const int NEGATIVE_SIZE = 2;
+		public const int SIZE_LIMIT = 3;
+		public const int BAD_VERSION = 4;
+
+		protected int type_ = UNKNOWN;
+
+		public TProtocolException()
+			: base()
+		{
+		}
+
+		public TProtocolException(int type)
+			: base()
+		{
+			type_ = type;
+		}
+
+		public TProtocolException(int type, String message)
+			: base(message)
+		{
+			type_ = type;
+		}
+
+		public TProtocolException(String message)
+			: base(message)
+		{
+		}
+
+		public int getType()
+		{
+			return type_;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TProtocolFactory.cs b/lib/csharp/src/Protocol/TProtocolFactory.cs
new file mode 100644
index 0000000..5434da9
--- /dev/null
+++ b/lib/csharp/src/Protocol/TProtocolFactory.cs
@@ -0,0 +1,23 @@
+//
+//  TProtocolFactory.cs
+//
+//  Begin:  Dec 3, 2007
+//  Authors: 
+//		Will Palmeri <wpalmeri@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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
+{
+	public interface TProtocolFactory
+	{
+		TProtocol GetProtocol(TTransport trans);
+	}
+}
diff --git a/lib/csharp/src/Protocol/TProtocolUtil.cs b/lib/csharp/src/Protocol/TProtocolUtil.cs
new file mode 100644
index 0000000..67f0ce6
--- /dev/null
+++ b/lib/csharp/src/Protocol/TProtocolUtil.cs
@@ -0,0 +1,88 @@
+//
+//  TProtocolUtil.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public static class TProtocolUtil
+	{
+		public static void Skip(TProtocol prot, TType type)
+		{
+			switch (type)
+			{
+				case TType.Bool:
+					prot.ReadBool();
+					break;
+				case TType.Byte:
+					prot.ReadByte();
+					break;
+				case TType.I16:
+					prot.ReadI16();
+					break;
+				case TType.I32:
+					prot.ReadI32();
+					break;
+				case TType.I64:
+					prot.ReadI64();
+					break;
+				case TType.Double:
+					prot.ReadDouble();
+					break;
+				case TType.String:
+					prot.ReadString();
+					break;
+				case TType.Struct:
+					prot.ReadStructBegin();
+					while (true)
+					{
+						TField field = prot.ReadFieldBegin();
+						if (field.Type == TType.Stop)
+						{
+							break;
+						}
+						Skip(prot, field.Type);
+						prot.ReadFieldEnd();
+					}
+					prot.ReadStructEnd();
+					break;
+				case TType.Map:
+					TMap map = prot.ReadMapBegin();
+					for (int i = 0; i < map.Count; i++)
+					{
+						Skip(prot, map.KeyType);
+						Skip(prot, map.ValueType);
+					}
+					prot.ReadMapEnd();
+					break;
+				case TType.Set:
+					TSet set = prot.ReadSetBegin();
+					for (int i = 0; i < set.Count; i++)
+					{
+						Skip(prot, set.ElementType);
+					}
+					prot.ReadSetEnd();
+					break;
+				case TType.List:
+					TList list = prot.ReadListBegin();
+					for (int i = 0; i < list.Count; i++)
+					{
+						Skip(prot, list.ElementType);
+					}
+					prot.ReadListEnd();
+					break;
+			}
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TSet.cs b/lib/csharp/src/Protocol/TSet.cs
new file mode 100644
index 0000000..c4c6fc3
--- /dev/null
+++ b/lib/csharp/src/Protocol/TSet.cs
@@ -0,0 +1,43 @@
+//
+//  TSet.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public class TSet
+	{
+		public TSet()
+		{
+		}
+
+		public TSet(TType elementType, int count)
+		{
+			ElementType = elementType;
+			Count = count;
+		}
+
+		public TType ElementType
+		{
+			get;
+			set;
+		}
+
+		public int Count
+		{
+			get;
+			set;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TStruct.cs b/lib/csharp/src/Protocol/TStruct.cs
new file mode 100644
index 0000000..88f12df
--- /dev/null
+++ b/lib/csharp/src/Protocol/TStruct.cs
@@ -0,0 +1,35 @@
+//
+//  TStruct.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public class TStruct
+	{
+		public TStruct()
+		{
+		}
+
+		public TStruct(string name)
+		{
+			Name = name;
+		}
+
+		public string Name
+		{
+			get;
+			set;
+		}
+	}
+}
diff --git a/lib/csharp/src/Protocol/TType.cs b/lib/csharp/src/Protocol/TType.cs
new file mode 100644
index 0000000..0badb33
--- /dev/null
+++ b/lib/csharp/src/Protocol/TType.cs
@@ -0,0 +1,35 @@
+//
+//  TType.cs
+//
+//  Begin:  Aug 19, 2007
+//  Authors: 
+//		Todd Berman <tberman@imeem.com>
+//
+//  Distributed under the Thrift Software License
+//
+//  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;
+
+namespace Thrift.Protocol
+{
+	public enum TType : byte
+	{
+		Stop = 0,
+		Void = 1,
+		Bool = 2,
+		Byte = 3,
+		Double = 4,
+		I16 = 6,
+		I32 = 8,
+		I64 = 10,
+		String = 11,
+		Struct = 12,
+		Map = 13,
+		Set = 14,
+		List = 15
+	}
+}