avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1515933 [2/4] - in /avro/trunk: ./ lang/csharp/ lang/csharp/lib/main/ lang/csharp/src/apache/codegen/ lang/csharp/src/apache/codegen/Properties/ lang/csharp/src/apache/ipc/ lang/csharp/src/apache/ipc/Generic/ lang/csharp/src/apache/ipc/Pro...
Date Tue, 20 Aug 2013 19:13:41 GMT
Added: avro/trunk/lang/csharp/src/apache/ipc/SocketTransceiver.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/SocketTransceiver.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/SocketTransceiver.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/SocketTransceiver.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,237 @@
+/**
+ * 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.Net;
+using System.Net.Sockets;
+using System.Threading;
+
+namespace Avro.ipc
+{
+    public class SocketTransceiver : Transceiver
+    {
+        private readonly byte[] header = new byte[4];
+        private readonly string host;
+        private readonly int port;
+        private readonly Stopwatch timeoutStopWatch;
+        private Socket channel;
+
+        private int serialNumber;
+
+        public SocketTransceiver(string host, int port)
+            : this(CreateSocket())
+        {
+            this.host = host;
+            this.port = port;
+
+            Connect();
+        }
+
+        public SocketTransceiver(Socket channel)
+        {
+            this.channel = channel;
+            this.channel.NoDelay = true;
+
+            timeoutStopWatch = new Stopwatch();
+        }
+
+        public override bool IsConnected
+        {
+            get
+            {
+                LockChannel();
+
+                try
+                {
+                    return Remote != null;
+                }
+                finally
+                {
+                    UnlockChannel();
+                }
+            }
+        }
+
+        public override Protocol Remote { get; set; }
+
+        public bool SocketConnected
+        {
+            get { return channel.Connected; }
+        }
+
+        public override string RemoteName
+        {
+            get
+            {
+                var ipEndPoint = ((IPEndPoint) channel.RemoteEndPoint);
+                return ipEndPoint.Address.ToString();
+            }
+        }
+
+        private static Socket CreateSocket()
+        {
+            return new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+        }
+
+        public void Connect()
+        {
+            channel.Connect(host, port);
+        }
+
+        public void Reconnect()
+        {
+            if (host == null)
+                throw new InvalidOperationException("Cannot reconnect to a null host");
+
+            channel = CreateSocket();
+            Connect();
+
+            Remote = null;
+        }
+
+        public void Disconnect()
+        {
+            if (channel != null && channel.Connected)
+            {
+                var myOpts = new LingerOption(true, 0);
+                channel.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
+                channel.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, myOpts);
+                channel.Close();
+            }
+        }
+
+        public override IList<MemoryStream> ReadBuffers()
+        {
+            // Ignore first part for now.
+            ReadBuffer(header, 4);
+
+            int numberOfLists = ReadInt();
+
+            // With 8 byte references, this supports creation of a generous 2GB list
+            const int MaxNumLists = 250000000;
+
+            if (numberOfLists > MaxNumLists)
+            {
+                Disconnect();
+                throw new AvroRuntimeException(
+                    string.Format("Excessively large list allocation request detected: {0} items! Connection closed.",
+                                  numberOfLists));
+            }
+
+            var buffers = new List<MemoryStream>(numberOfLists);
+
+            for (int i = 0; i < numberOfLists; i++)
+            {
+                // size of the list.
+                int length = ReadInt();
+
+                var buffer = new byte[length];
+                ReadBuffer(buffer, length);
+
+                buffers.Add(new MemoryStream(buffer));
+            }
+
+            return buffers;
+        }
+
+        public override void WriteBuffers(IList<MemoryStream> buffers)
+        {
+            if (buffers == null) return;
+
+            Interlocked.Increment(ref serialNumber);
+
+            byte[] serial = ConvertIntToBytes(serialNumber);
+            channel.Send(serial);
+
+            byte[] numBuffers = ConvertIntToBytes(buffers.Count);
+            channel.Send(numBuffers);
+
+            foreach (MemoryStream buffer in buffers)
+            {
+                var length = (int) buffer.Length;
+
+                byte[] bufferLength = ConvertIntToBytes(length);
+                channel.Send(bufferLength);
+
+                byte[] bytes = buffer.GetBuffer();
+                channel.Send(bytes, (int) buffer.Length, SocketFlags.None);
+            }
+        }
+
+        private int ReadInt()
+        {
+            ReadBuffer(header, 4);
+
+            int num = BitConverter.ToInt32(header, 0);
+            num = IPAddress.NetworkToHostOrder(num);
+            return num;
+        }
+
+        private static byte[] ConvertIntToBytes(int length)
+        {
+            int hostToNetworkOrder = IPAddress.HostToNetworkOrder(length);
+            byte[] bufferLength = BitConverter.GetBytes(hostToNetworkOrder);
+            return bufferLength;
+        }
+
+        private void ReadBuffer(byte[] buffer, int length)
+        {
+            if (length == 0)
+                return;
+            
+            int numReceived = 0;
+            do
+            {
+                numReceived += channel.Receive(buffer, numReceived, length - numReceived, SocketFlags.None);
+
+                Timeout(numReceived);
+            } while (numReceived < length);
+        }
+
+        private void Timeout(int numReceived)
+        {
+            if (numReceived == 0)
+            {
+                if (!timeoutStopWatch.IsRunning)
+                {
+                    timeoutStopWatch.Start();
+                }
+                else if (timeoutStopWatch.ElapsedMilliseconds > 10000)
+                {
+                    throw new TimeoutException(string.Format("Failed to receive any data after [{0}] milliseconds.",
+                                                             timeoutStopWatch.ElapsedMilliseconds));
+                }
+            }
+        }
+
+        public override void VerifyConnection()
+        {
+            if (!SocketConnected)
+            {
+                Reconnect();
+            }
+        }
+
+        public void Close()
+        {
+        }
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificRequestor.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificRequestor.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificRequestor.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificRequestor.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,105 @@
+/**
+ * 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.Linq;
+using Avro.IO;
+using Avro.Specific;
+using Castle.DynamicProxy;
+
+namespace Avro.ipc.Specific
+{
+    public class SpecificRequestor : Requestor, IInterceptor, ICallbackRequestor
+    {
+        private ISpecificProtocol specificProtocol;
+
+        private SpecificRequestor(Transceiver transceiver) :
+            base(transceiver, null)
+        {
+        }
+
+        void ICallbackRequestor.Request<TCallFuture>(string messageName, object[] args, object callback)
+        {
+            var specificCallback = (CallFuture<TCallFuture>) callback;
+            Request(messageName, args, specificCallback);
+        }
+
+        public void Intercept(IInvocation invocation)
+        {
+            string methodName = invocation.Method.Name;
+
+            int argumentsLength = invocation.Arguments.Length;
+            if (argumentsLength > 0 && LastArgumentIsCallback(invocation.Arguments[argumentsLength - 1]))
+            {
+                var args = new object[argumentsLength - 1];
+                Array.Copy(invocation.Arguments, args, argumentsLength - 1);
+                var callback = invocation.Arguments[argumentsLength - 1];
+
+                specificProtocol.Request(this, methodName, args, callback);
+            }
+            else
+            {
+                invocation.ReturnValue = Request(methodName, invocation.Arguments);
+            }
+        }
+
+        public static T CreateClient<T>(Transceiver transceiver) where T : class, ISpecificProtocol
+        {
+            var generator = new ProxyGenerator();
+
+            var specificRequestor = new SpecificRequestor(transceiver);
+            var client = generator.CreateClassProxy<T>(specificRequestor);
+            specificRequestor.specificProtocol = client;
+            specificRequestor.Local = client.Protocol;
+
+            return client;
+        }
+
+        public override void WriteRequest(RecordSchema schema, object request, Encoder encoder)
+        {
+            var args = (Object[]) request;
+            int i = 0;
+            foreach (Field p in schema.Fields)
+            {
+                new SpecificWriter<object>(p.Schema).Write(args[i++], encoder);
+            }
+        }
+
+        public override object ReadResponse(Schema writer, Schema reader, Decoder decoder)
+        {
+            return new SpecificReader<object>(writer, reader).Read(null, decoder);
+        }
+
+        public override Exception ReadError(Schema writer, Schema reader, Decoder decoder)
+        {
+            var response = new SpecificReader<object>(writer, reader).Read(null, decoder);
+
+            throw (Exception) response;
+        }
+
+        private static bool LastArgumentIsCallback(object o)
+        {
+            Type type = o.GetType();
+            Type[] interfaces = type.GetInterfaces();
+
+            bool isCallback =
+                interfaces.Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof (ICallback<>));
+            return isCallback;
+        }
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificResponder.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificResponder.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificResponder.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/Specific/SpecificResponder.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,83 @@
+/**
+ * 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.Reflection;
+using Avro.Generic;
+using Avro.IO;
+using Avro.Specific;
+using Avro.ipc.Generic;
+
+namespace Avro.ipc.Specific
+{
+    public class SpecificResponder<T> : GenericResponder
+        where T : class, ISpecificProtocol
+    {
+        private readonly T impl;
+
+        public SpecificResponder(T impl)
+            : base(impl.Protocol)
+        {
+            this.impl = impl;
+        }
+
+        public override object Respond(Message message, object request)
+        {
+            int numParams = message.Request.Fields.Count;
+            var parameters = new Object[numParams];
+            var parameterTypes = new Type[numParams];
+
+            int i = 0;
+
+            foreach (Field field in message.Request.Fields)
+            {
+                Type type = ObjectCreator.Instance.GetType(field.Schema);
+                parameterTypes[i] = type;
+                parameters[i] = ((GenericRecord) request)[field.Name];
+
+                i++;
+            }
+
+            MethodInfo method = typeof (T).GetMethod(message.Name, parameterTypes);
+            try
+            {
+                return method.Invoke(impl, parameters);
+            }
+            catch (TargetInvocationException ex)
+            {
+                throw ex.InnerException;
+            }
+        }
+
+        public override void WriteError(Schema schema, object error, Encoder output)
+        {
+            new SpecificWriter<object>(schema).Write(error, output);
+        }
+
+        public override object ReadRequest(Schema actual, Schema expected, Decoder input)
+        {
+            return new SpecificReader<object>(actual, expected).Read(null, input);
+        }
+
+        public override void WriteResponse(Schema schema, object response, Encoder output)
+        {
+            new SpecificWriter<object>(schema).Write(response, output);
+        }
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/ipc/Transceiver.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/Transceiver.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/Transceiver.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/Transceiver.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,98 @@
+/**
+ * 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.IO;
+using System.Threading;
+using Avro.IO;
+
+namespace Avro.ipc
+{
+    public abstract class Transceiver
+    {
+        private readonly object channelLock = new object();
+        private Thread threadWhenLocked;
+
+        public virtual bool IsConnected
+        {
+            get { return false; }
+        }
+
+        public abstract String RemoteName { get; }
+
+        public virtual Protocol Remote
+        {
+            get { throw new InvalidOperationException("Not connected."); }
+            set { }
+        }
+
+        public virtual IList<MemoryStream> Transceive(IList<MemoryStream> request)
+        {
+            if (request == null) throw new ArgumentNullException("request");
+
+            LockChannel();
+            try
+            {
+                WriteBuffers(request);
+                return ReadBuffers();
+            }
+            finally
+            {
+                UnlockChannel();
+            }
+        }
+
+        public virtual void VerifyConnection()
+        {
+        }
+
+        public void Transceive(IList<MemoryStream> request, ICallback<IList<MemoryStream>> callback)
+        {
+            if (request == null) throw new ArgumentNullException("request");
+
+            try
+            {
+                IList<MemoryStream> response = Transceive(request);
+                callback.HandleResult(response);
+            }
+            catch (IOException e)
+            {
+                callback.HandleException(e);
+            }
+        }
+
+        public void LockChannel()
+        {
+            Monitor.Enter(channelLock);
+
+            threadWhenLocked = Thread.CurrentThread;
+        }
+
+        public void UnlockChannel()
+        {
+            if (Thread.CurrentThread == threadWhenLocked)
+            {
+                Monitor.Exit(channelLock);
+            }
+        }
+
+        public abstract IList<MemoryStream> ReadBuffers();
+        public abstract void WriteBuffers(IList<MemoryStream> getBytes);
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeMatch.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeMatch.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeMatch.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeMatch.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,22 @@
+// ------------------------------------------------------------------------------
+// <auto-generated>
+//    Generated by MSBuild.exe, version 0.9.0.0
+//    Changes to this file may cause incorrect behavior and will be lost if code
+//    is regenerated
+// </auto-generated>
+// ------------------------------------------------------------------------------
+namespace org.apache.avro.ipc
+{
+	using System;
+	using System.Collections.Generic;
+	using System.Text;
+	using Avro;
+	using Avro.Specific;
+	
+	public enum HandshakeMatch
+	{
+		BOTH,
+		CLIENT,
+		NONE,
+	}
+}

Added: avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeRequest.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeRequest.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeRequest.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeRequest.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,97 @@
+// ------------------------------------------------------------------------------
+// <auto-generated>
+//    Generated by MSBuild.exe, version 0.9.0.0
+//    Changes to this file may cause incorrect behavior and will be lost if code
+//    is regenerated
+// </auto-generated>
+// ------------------------------------------------------------------------------
+namespace org.apache.avro.ipc
+{
+	using System;
+	using System.Collections.Generic;
+	using System.Text;
+	using Avro;
+	using Avro.Specific;
+	
+	public partial class HandshakeRequest : ISpecificRecord
+	{
+		private static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""HandshakeRequest"",""namespace"":""org.apache.avro.ipc"",""fields"":[{""name"":""clientHash"",""type"":{""type"":""fixed"",""name"":""MD5"",""namespace"":""org.apache.avro.ipc"",""size"":16}},{""name"":""clientProtocol"",""type"":[""null"",""string""]},{""name"":""serverHash"",""type"":""MD5""},{""name"":""meta"",""type"":[""null"",{""type"":""map"",""values"":""bytes""}]}]}");
+		private org.apache.avro.ipc.MD5 _clientHash;
+		private string _clientProtocol;
+		private org.apache.avro.ipc.MD5 _serverHash;
+		private IDictionary<string,System.Byte[]> _meta;
+		public virtual Schema Schema
+		{
+			get
+			{
+				return HandshakeRequest._SCHEMA;
+			}
+		}
+		public org.apache.avro.ipc.MD5 clientHash
+		{
+			get
+			{
+				return this._clientHash;
+			}
+			set
+			{
+				this._clientHash = value;
+			}
+		}
+		public string clientProtocol
+		{
+			get
+			{
+				return this._clientProtocol;
+			}
+			set
+			{
+				this._clientProtocol = value;
+			}
+		}
+		public org.apache.avro.ipc.MD5 serverHash
+		{
+			get
+			{
+				return this._serverHash;
+			}
+			set
+			{
+				this._serverHash = value;
+			}
+		}
+		public IDictionary<string,System.Byte[]> meta
+		{
+			get
+			{
+				return this._meta;
+			}
+			set
+			{
+				this._meta = value;
+			}
+		}
+		public virtual object Get(int fieldPos)
+		{
+			switch (fieldPos)
+			{
+			case 0: return this.clientHash;
+			case 1: return this.clientProtocol;
+			case 2: return this.serverHash;
+			case 3: return this.meta;
+			default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
+			};
+		}
+		public virtual void Put(int fieldPos, object fieldValue)
+		{
+			switch (fieldPos)
+			{
+			case 0: this.clientHash = (org.apache.avro.ipc.MD5)fieldValue; break;
+			case 1: this.clientProtocol = (System.String)fieldValue; break;
+			case 2: this.serverHash = (org.apache.avro.ipc.MD5)fieldValue; break;
+			case 3: this.meta = (IDictionary<string,System.Byte[]>)fieldValue; break;
+			default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
+			};
+		}
+	}
+}

Added: avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeResponse.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeResponse.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeResponse.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/HandshakeResponse.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,97 @@
+// ------------------------------------------------------------------------------
+// <auto-generated>
+//    Generated by MSBuild.exe, version 0.9.0.0
+//    Changes to this file may cause incorrect behavior and will be lost if code
+//    is regenerated
+// </auto-generated>
+// ------------------------------------------------------------------------------
+namespace org.apache.avro.ipc
+{
+	using System;
+	using System.Collections.Generic;
+	using System.Text;
+	using Avro;
+	using Avro.Specific;
+	
+	public partial class HandshakeResponse : ISpecificRecord
+	{
+		private static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""HandshakeResponse"",""namespace"":""org.apache.avro.ipc"",""fields"":[{""name"":""match"",""type"":{""type"":""enum"",""name"":""HandshakeMatch"",""namespace"":""org.apache.avro.ipc"",""symbols"":[""BOTH"",""CLIENT"",""NONE""]}},{""name"":""serverProtocol"",""type"":[""null"",""string""]},{""name"":""serverHash"",""type"":[""null"",{""type"":""fixed"",""name"":""MD5"",""namespace"":""org.apache.avro.ipc"",""size"":16}]},{""name"":""meta"",""type"":[""null"",{""type"":""map"",""values"":""bytes""}]}]}");
+		private org.apache.avro.ipc.HandshakeMatch _match;
+		private string _serverProtocol;
+		private org.apache.avro.ipc.MD5 _serverHash;
+		private IDictionary<string,System.Byte[]> _meta;
+		public virtual Schema Schema
+		{
+			get
+			{
+				return HandshakeResponse._SCHEMA;
+			}
+		}
+		public org.apache.avro.ipc.HandshakeMatch match
+		{
+			get
+			{
+				return this._match;
+			}
+			set
+			{
+				this._match = value;
+			}
+		}
+		public string serverProtocol
+		{
+			get
+			{
+				return this._serverProtocol;
+			}
+			set
+			{
+				this._serverProtocol = value;
+			}
+		}
+		public org.apache.avro.ipc.MD5 serverHash
+		{
+			get
+			{
+				return this._serverHash;
+			}
+			set
+			{
+				this._serverHash = value;
+			}
+		}
+		public IDictionary<string,System.Byte[]> meta
+		{
+			get
+			{
+				return this._meta;
+			}
+			set
+			{
+				this._meta = value;
+			}
+		}
+		public virtual object Get(int fieldPos)
+		{
+			switch (fieldPos)
+			{
+			case 0: return this.match;
+			case 1: return this.serverProtocol;
+			case 2: return this.serverHash;
+			case 3: return this.meta;
+			default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
+			};
+		}
+		public virtual void Put(int fieldPos, object fieldValue)
+		{
+			switch (fieldPos)
+			{
+			case 0: this.match = (org.apache.avro.ipc.HandshakeMatch)fieldValue; break;
+			case 1: this.serverProtocol = (System.String)fieldValue; break;
+			case 2: this.serverHash = (org.apache.avro.ipc.MD5)fieldValue; break;
+			case 3: this.meta = (IDictionary<string,System.Byte[]>)fieldValue; break;
+			default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
+			};
+		}
+	}
+}

Added: avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/MD5.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/MD5.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/MD5.cs (added)
+++ avro/trunk/lang/csharp/src/apache/ipc/org/apache/avro/ipc/MD5.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,39 @@
+// ------------------------------------------------------------------------------
+// <auto-generated>
+//    Generated by MSBuild.exe, version 0.9.0.0
+//    Changes to this file may cause incorrect behavior and will be lost if code
+//    is regenerated
+// </auto-generated>
+// ------------------------------------------------------------------------------
+namespace org.apache.avro.ipc
+{
+	using System;
+	using System.Collections.Generic;
+	using System.Text;
+	using Avro;
+	using Avro.Specific;
+	
+	public partial class MD5 : SpecificFixed
+	{
+		private static Schema _SCHEMA = Avro.Schema.Parse("{\"type\":\"fixed\",\"name\":\"MD5\",\"namespace\":\"org.apache.avro.ipc\",\"size\":16}");
+		private static uint fixedSize = 16;
+		public MD5() : 
+				base(fixedSize)
+		{
+		}
+		public override Schema Schema
+		{
+			get
+			{
+				return MD5._SCHEMA;
+			}
+		}
+		public static uint FixedSize
+		{
+			get
+			{
+				return MD5.fixedSize;
+			}
+		}
+	}
+}

Modified: avro/trunk/lang/csharp/src/apache/main/Avro.main.csproj
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Avro.main.csproj?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Avro.main.csproj (original)
+++ avro/trunk/lang/csharp/src/apache/main/Avro.main.csproj Tue Aug 20 19:13:39 2013
@@ -26,7 +26,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Avro</RootNamespace>
     <AssemblyName>Avro</AssemblyName>
-    <TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v3.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <FileUpgradeFlags>
     </FileUpgradeFlags>
@@ -47,6 +47,7 @@
     <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -107,8 +108,13 @@
     <Compile Include="Generic\GenericWriter.cs" />
     <Compile Include="IO\BinaryDecoder.cs" />
     <Compile Include="IO\BinaryEncoder.cs" />
+    <Compile Include="IO\ByteBufferInputStream.cs" />
+    <Compile Include="IO\ByteBufferOutputStream.cs" />
     <Compile Include="IO\Decoder.cs" />
     <Compile Include="IO\Encoder.cs" />
+    <Compile Include="IO\ICallback.cs" />
+    <Compile Include="IO\InputStream.cs" />
+    <Compile Include="IO\OutputStream.cs" />
     <Compile Include="IO\Resolver.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Protocol\Message.cs" />
@@ -132,6 +138,8 @@
     <Compile Include="Schema\SchemaParseException.cs" />
     <Compile Include="Schema\UnionSchema.cs" />
     <Compile Include="Schema\UnnamedSchema.cs" />
+    <Compile Include="Specific\SpecificException.cs" />
+    <Compile Include="Specific\SpecificProtocol.cs" />
     <Compile Include="Specific\ObjectCreator.cs" />
     <Compile Include="Specific\SpecificFixed.cs" />
     <Compile Include="Specific\SpecificReader.cs" />

Modified: avro/trunk/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/CodeGen/CodeGen.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/CodeGen/CodeGen.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/CodeGen/CodeGen.cs Tue Aug 20 19:13:39 2013
@@ -17,6 +17,8 @@
  */
 using System;
 using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.CodeDom;
 using System.CodeDom.Compiler;
@@ -155,6 +157,8 @@ namespace Avro
                             throw new CodeGenException("Names in protocol should only be of type NamedSchema, type found " + sn.Value.Tag);
                     }
                 }
+
+                processInterface(protocol);
             }
         }
 
@@ -319,6 +323,189 @@ namespace Avro
             codens.Types.Add(ctd);
         }
 
+        protected virtual void processInterface(Protocol protocol)
+        {
+            // Create abstract class
+            string protocolNameMangled = CodeGenUtil.Instance.Mangle(protocol.Name);
+
+            var ctd = new CodeTypeDeclaration(protocolNameMangled);
+            ctd.TypeAttributes = TypeAttributes.Abstract | TypeAttributes.Public;
+            ctd.IsClass = true;
+            ctd.BaseTypes.Add("Avro.Specific.ISpecificProtocol");
+
+            AddProtocolDocumentation(protocol, ctd);
+
+            // Add static protocol field.
+            var protocolField = new CodeMemberField();
+            protocolField.Attributes = MemberAttributes.Private | MemberAttributes.Static | MemberAttributes.Final;
+            protocolField.Name = "protocol";
+            protocolField.Type = new CodeTypeReference("readonly Avro.Protocol");
+
+            var cpe = new CodePrimitiveExpression(protocol.ToString());
+            var cmie = new CodeMethodInvokeExpression(
+                new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(Protocol)), "Parse"),
+                new CodeExpression[] { cpe });
+
+            protocolField.InitExpression = cmie;
+
+            ctd.Members.Add(protocolField);
+
+            // Add overridden Protocol method.
+            var property = new CodeMemberProperty();
+            property.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+            property.Name = "Protocol";
+            property.Type = new CodeTypeReference("Avro.Protocol");
+            property.HasGet = true;
+
+
+            property.GetStatements.Add(new CodeTypeReferenceExpression("return protocol"));
+            ctd.Members.Add(property);
+
+            //var requestMethod = CreateRequestMethod();
+            //ctd.Members.Add(requestMethod);
+
+            var requestMethod = CreateRequestMethod();
+            //requestMethod.Attributes |= MemberAttributes.Override;
+            var builder = new StringBuilder();
+
+            if (protocol.Messages.Count > 0)
+            {
+                builder.Append("switch(messageName)\n\t\t\t{");
+
+                foreach (var a in protocol.Messages)
+                {
+                    builder.Append("\n\t\t\t\tcase \"").Append(a.Key).Append("\":\n");
+
+                    bool unused = false;
+                    string type = getType(a.Value.Response, false, ref unused);
+
+                    builder.Append("\t\t\t\trequestor.Request<")
+                           .Append(type)
+                           .Append(">(messageName, args, callback);\n");
+                    builder.Append("\t\t\t\tbreak;\n");
+                }
+
+                builder.Append("\t\t\t}");
+            }
+            var cseGet = new CodeSnippetExpression(builder.ToString());
+
+            requestMethod.Statements.Add(cseGet);
+            ctd.Members.Add(requestMethod);
+
+            AddMethods(protocol, false, ctd);
+
+            string nspace = protocol.Namespace;
+            if (string.IsNullOrEmpty(nspace))
+                throw new CodeGenException("Namespace required for enum schema " + nspace);
+            CodeNamespace codens = addNamespace(nspace);
+
+            codens.Types.Add(ctd);
+
+            // Create callback abstract class
+            ctd = new CodeTypeDeclaration(protocolNameMangled + "Callback");
+            ctd.TypeAttributes = TypeAttributes.Abstract | TypeAttributes.Public;
+            ctd.IsClass = true;
+            ctd.BaseTypes.Add(protocolNameMangled);
+
+            // Need to override
+            
+
+
+            AddProtocolDocumentation(protocol, ctd);
+
+            AddMethods(protocol, true, ctd);
+
+            codens.Types.Add(ctd);
+        }
+
+        private static CodeMemberMethod CreateRequestMethod()
+        {
+            var requestMethod = new CodeMemberMethod();
+            requestMethod.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+            requestMethod.Name = "Request";
+            requestMethod.ReturnType = new CodeTypeReference(typeof (void));
+            {
+                var requestor = new CodeParameterDeclarationExpression(typeof (Avro.Specific.ICallbackRequestor),
+                                                                       "requestor");
+                requestMethod.Parameters.Add(requestor);
+
+                var messageName = new CodeParameterDeclarationExpression(typeof (string), "messageName");
+                requestMethod.Parameters.Add(messageName);
+
+                var args = new CodeParameterDeclarationExpression(typeof (object[]), "args");
+                requestMethod.Parameters.Add(args);
+
+                var callback = new CodeParameterDeclarationExpression(typeof (object), "callback");
+                requestMethod.Parameters.Add(callback);
+            }
+            return requestMethod;
+        }
+
+        private static void AddMethods(Protocol protocol, bool generateCallback, CodeTypeDeclaration ctd)
+        {
+            foreach (var e in protocol.Messages)
+            {
+                var name = e.Key;
+                var message = e.Value;
+                var response = message.Response;
+
+                if (generateCallback && message.Oneway.GetValueOrDefault())
+                    continue;
+
+                var messageMember = new CodeMemberMethod();
+                messageMember.Name = CodeGenUtil.Instance.Mangle(name);
+                messageMember.Attributes = MemberAttributes.Public | MemberAttributes.Abstract;
+
+                if (message.Doc!= null && message.Doc.Trim() != string.Empty)
+                    messageMember.Comments.Add(new CodeCommentStatement(message.Doc));
+
+                if (message.Oneway.GetValueOrDefault() || generateCallback)
+                {
+                    messageMember.ReturnType = new CodeTypeReference(typeof (void));
+                }
+                else
+                {
+                    bool ignored = false;
+                    string type = getType(response, false, ref ignored);
+
+                    messageMember.ReturnType = new CodeTypeReference(type);
+                }
+
+                foreach (Field field in message.Request.Fields)
+                {
+                    bool ignored = false;
+                    string type = getType(field.Schema, false, ref ignored);
+
+                    string fieldName = CodeGenUtil.Instance.Mangle(field.Name);
+                    var parameter = new CodeParameterDeclarationExpression(type, fieldName);
+                    messageMember.Parameters.Add(parameter);
+                }
+
+                if (generateCallback)
+                {
+                    bool unused = false;
+                    var type = getType(response, false, ref unused);
+                    var parameter = new CodeParameterDeclarationExpression("Avro.IO.ICallback<" + type + ">",
+                                                                           "callback");
+                    messageMember.Parameters.Add(parameter);
+                }
+
+
+                ctd.Members.Add(messageMember);
+            }
+        }
+
+        private void AddProtocolDocumentation(Protocol protocol, CodeTypeDeclaration ctd)
+        {
+            // Add interface documentation
+            if (protocol.Doc != null && protocol.Doc.Trim() != string.Empty)
+            {
+                var interfaceDoc = createDocComment(protocol.Doc);
+                if (interfaceDoc != null)
+                    ctd.Comments.Add(interfaceDoc);
+            }
+        }
+
         /// <summary>
         /// Creates a class declaration
         /// </summary>
@@ -330,14 +517,17 @@ namespace Avro
             RecordSchema recordSchema = schema as RecordSchema;
             if (null == recordSchema) throw new CodeGenException("Unable to cast schema into a record");
 
+            bool isError = recordSchema.Tag == Schema.Type.Error;
+
             // declare the class
             var ctd = new CodeTypeDeclaration(CodeGenUtil.Instance.Mangle(recordSchema.Name));
-            ctd.BaseTypes.Add("ISpecificRecord");
+            ctd.BaseTypes.Add(isError ? "SpecificException" : "ISpecificRecord");
+
             ctd.Attributes = MemberAttributes.Public;
             ctd.IsClass = true;
             ctd.IsPartial = true;
 
-            createSchemaField(schema, ctd, false);
+            createSchemaField(schema, ctd, isError);
 
             // declare Get() to be used by the Writer classes
             var cmmGet = new CodeMemberMethod();
@@ -356,6 +546,12 @@ namespace Avro
             cmmPut.Parameters.Add(new CodeParameterDeclarationExpression("System.Object", "fieldValue"));
             var putFieldStmt = new StringBuilder("switch (fieldPos)\n\t\t\t{\n");
 
+            if (isError)
+            {
+                cmmGet.Attributes |= MemberAttributes.Override;
+                cmmPut.Attributes |= MemberAttributes.Override;
+            }
+
             foreach (Field field in recordSchema.Fields)
             {
                 // Determine type of field

Modified: avro/trunk/lang/csharp/src/apache/main/File/DataFileReader.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/File/DataFileReader.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/File/DataFileReader.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/File/DataFileReader.cs Tue Aug 20 19:13:39 2013
@@ -123,7 +123,7 @@ namespace Avro.File
             {
                 return _header.MetaData[key];
             }
-            catch (KeyNotFoundException knfe)
+            catch (KeyNotFoundException)
             {
                 return null; 
             }
@@ -183,7 +183,7 @@ namespace Avro.File
                         _stream.Position = _stream.Position - (DataFileConstants.SyncSize - 1);
                 } while (!done);
             }
-            catch (Exception e) { } // could not find .. default to EOF
+            catch (Exception) { } // could not find .. default to EOF
 
             _blockStart = _stream.Position;
         }

Modified: avro/trunk/lang/csharp/src/apache/main/Generic/GenericReader.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Generic/GenericReader.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Generic/GenericReader.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Generic/GenericReader.cs Tue Aug 20 19:13:39 2013
@@ -177,6 +177,7 @@ namespace Avro.Generic
                     return Read<string>(writerSchema.Tag, readerSchema, d.ReadString);
                 case Schema.Type.Bytes:
                     return Read<byte[]>(writerSchema.Tag, readerSchema, d.ReadBytes);
+                case Schema.Type.Error:
                 case Schema.Type.Record:
                     return ReadRecord(reuse, (RecordSchema)writerSchema, readerSchema, d);
                 case Schema.Type.Enumeration:

Modified: avro/trunk/lang/csharp/src/apache/main/Generic/GenericWriter.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Generic/GenericWriter.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Generic/GenericWriter.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Generic/GenericWriter.cs Tue Aug 20 19:13:39 2013
@@ -114,6 +114,7 @@ namespace Avro.Generic
                     Write<byte[]>(value, schema.Tag, encoder.WriteBytes);
                     break;
                 case Schema.Type.Record:
+                case Schema.Type.Error:
                     WriteRecord(schema as RecordSchema, value, encoder);
                     break;
                 case Schema.Type.Enumeration:

Modified: avro/trunk/lang/csharp/src/apache/main/IO/BinaryEncoder.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/IO/BinaryEncoder.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/IO/BinaryEncoder.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/IO/BinaryEncoder.cs Tue Aug 20 19:13:39 2013
@@ -186,5 +186,10 @@ namespace Avro.IO
         {
             Stream.WriteByte(b);
         }
+
+        public void Flush()
+        {
+            Stream.Flush();
+        }
     }
 }

Added: avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,76 @@
+/**
+ * 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.IO;
+
+namespace Avro.IO
+{
+    public class ByteBufferInputStream : InputStream
+    {
+        private readonly IList<MemoryStream> _buffers;
+        private int _currentBuffer;
+        
+        public ByteBufferInputStream(IList<MemoryStream> buffers)
+        {
+            _buffers = buffers;
+        }
+
+        public override int Read(byte[] b, int off, int len)
+        {
+            if (len == 0) return 0;
+            MemoryStream buffer = GetNextNonEmptyBuffer();
+            long remaining = buffer.Length - buffer.Position;
+            if (len > remaining)
+            {
+                int remainingCheck = buffer.Read(b, off, (int) remaining);
+
+                if(remainingCheck != remaining)
+                    throw new InvalidDataException(string.Format("remainingCheck [{0}] and remaining[{1}] are different.",
+                        remainingCheck, remaining));
+                return (int)remaining;
+            }
+
+            int lenCheck = buffer.Read(b, off, len);
+
+            if (lenCheck != len)
+                throw new InvalidDataException(string.Format("lenCheck [{0}] and len[{1}] are different.",
+                                                             lenCheck, len));
+
+            return len;
+        }
+
+        private MemoryStream GetNextNonEmptyBuffer()
+        {
+            while (_currentBuffer < _buffers.Count)
+            {
+                MemoryStream buffer = _buffers[_currentBuffer];
+                if (buffer.Position < buffer.Length)
+                    return buffer;
+
+                _currentBuffer++;
+            }
+            throw new EndOfStreamException();
+        }
+
+        public override long Length
+        {
+            get { throw new NotSupportedException(); }
+        }
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferOutputStream.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferOutputStream.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferOutputStream.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/IO/ByteBufferOutputStream.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,118 @@
+/**
+ * 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.Collections.Generic;
+using System.IO;
+//using System.Linq;
+
+namespace Avro.IO
+{
+    public class ByteBufferOutputStream : OutputStream
+    {
+        public const int BUFFER_SIZE = 8192;
+
+        public ByteBufferOutputStream()
+        {
+            Reset();
+        }
+
+        private void Reset()
+        {
+            _buffers = new List<MemoryStream> {CreateBuffer()};
+        }
+
+        private List<MemoryStream> _buffers;
+
+        private static MemoryStream CreateBuffer()
+        {
+            return new MemoryStream(new byte[BUFFER_SIZE], 0, BUFFER_SIZE, true, true);
+        }
+
+        public void Prepend(List<MemoryStream> lists)
+        {
+            foreach (var stream in lists)
+            {
+                stream.Position = stream.Length;
+            }
+
+            _buffers.InsertRange(0, lists);
+        }
+
+        public void Append(List<MemoryStream> lists)
+        {
+            foreach (var stream in lists)
+            {
+                stream.Position = stream.Length;
+            }
+
+            _buffers.AddRange(lists);
+        }
+
+        public override void Write(byte[] b, int off, int len)
+        {
+            var buffer = _buffers[_buffers.Count -1];
+            var remaining = (int) (buffer.Length - buffer.Position);
+            while (len > remaining)
+            {
+                buffer.Write(b, off, remaining);
+                len -= remaining;
+                off += remaining;
+
+                buffer = CreateBuffer();
+                _buffers.Add(buffer);
+
+                remaining = (int) buffer.Length;
+            }
+
+            buffer.Write(b, off, len);
+        }
+
+        public List<MemoryStream> GetBufferList()
+        {
+            List<MemoryStream> result = _buffers;
+            
+            Reset();
+
+            foreach (MemoryStream b in result)
+            {
+                // Flip()
+                b.SetLength(b.Position);
+                b.Position = 0;
+            }
+
+            return result;
+        }
+
+        public override long Length
+        {
+            get
+            {
+                long sum = 0;
+                foreach (var buffer in _buffers)
+                {
+                    sum += buffer.Length;
+                }
+
+                return sum;
+            }
+        }
+
+        public override void Flush()
+        {
+        }
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/main/IO/ICallback.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/IO/ICallback.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/IO/ICallback.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/IO/ICallback.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,37 @@
+/**
+ * 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;
+
+namespace Avro.IO
+{
+    public interface ICallback<in T> 
+    {
+        /**
+         * Receives a callback result.
+         * @param result the result returned in the callback.
+         */
+        void HandleResult(T result);
+
+        /**
+         * Receives an error.
+         * @param error the error returned in the callback.
+         */
+        void HandleException(Exception exception);
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/main/IO/InputStream.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/IO/InputStream.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/IO/InputStream.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/IO/InputStream.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,48 @@
+using System;
+using System.IO;
+
+namespace Avro.IO
+{
+    public abstract class InputStream : Stream
+    {
+        public override void Flush()
+        {
+        }
+
+        public override long Seek(long offset, SeekOrigin origin)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override void SetLength(long value)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override void Write(byte[] buffer, int offset, int count)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override bool CanRead
+        {
+            get { return true; }
+        }
+
+        public override bool CanSeek
+        {
+            get { return false; }
+        }
+
+        public override bool CanWrite
+        {
+            get { return false; }
+        }
+
+        public override long Position
+        {
+            get { throw new NotSupportedException(); }
+            set { throw new NotSupportedException(); }
+        }
+    }
+}
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/main/IO/OutputStream.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/IO/OutputStream.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/IO/OutputStream.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/IO/OutputStream.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,44 @@
+using System;
+using System.IO;
+
+namespace Avro.IO
+{
+    public abstract class OutputStream : Stream
+    {
+        public override bool CanWrite
+        {
+            get { return true; }
+        }
+
+        public override bool CanRead
+        {
+            get { return false; }
+        }
+
+        public override bool CanSeek
+        {
+            get { return false; }
+        }
+
+        public override long Position
+        {
+            get { throw new NotSupportedException(); }
+            set { throw new NotSupportedException(); }
+        }
+
+        public override int Read(byte[] buffer, int offset, int count)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override long Seek(long offset, SeekOrigin origin)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override void SetLength(long value)
+        {
+            throw new NotSupportedException();
+        }
+    }
+}
\ No newline at end of file

Modified: avro/trunk/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Properties/AssemblyInfo.cs Tue Aug 20 19:13:39 2013
@@ -15,39 +15,19 @@
  * 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;
 
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
 [assembly: AssemblyTitle("Avro")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("Apache")]
 [assembly: AssemblyProduct("Avro")]
-[assembly: AssemblyCopyright("Copyright © Apache 2010")]
+[assembly: AssemblyCopyright("Copyright © Apache 2013")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("6984e56e-b67f-44c1-9aaf-0483c7589642")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
+[assembly: Guid("152D7B83-9A97-45F3-B4B3-A367AFC090C4")]
 [assembly: AssemblyVersion("0.9.0.0")]
-[assembly: AssemblyFileVersion("0.9.0.0")]
+[assembly: AssemblyFileVersion("0.9.0.0")]
\ No newline at end of file

Modified: avro/trunk/lang/csharp/src/apache/main/Protocol/Message.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Protocol/Message.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Protocol/Message.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Protocol/Message.cs Tue Aug 20 19:13:39 2013
@@ -56,6 +56,11 @@ namespace Avro
         public bool? Oneway { get; set; }
 
         /// <summary>
+        /// Explicitly defined protocol errors plus system added "string" error
+        /// </summary>
+        public UnionSchema SupportedErrors { get; set; }
+
+        /// <summary>
         /// Constructor for Message class
         /// </summary>
         /// <param name="name">name property</param>
@@ -72,6 +77,23 @@ namespace Avro
             this.Name = name;
             this.Doc = doc;
             this.Oneway = oneway;
+
+            if (error != null && error.CanRead(Schema.Parse("[\"string\"]")))
+            {
+                this.SupportedErrors = error;
+            }
+            else
+            {
+                this.SupportedErrors = (UnionSchema) Schema.Parse("[\"string\"]");
+
+                if (error != null)
+                {
+                    for (int i = 0; i < error.Schemas.Count; ++i)
+                    {
+                        this.SupportedErrors.Schemas.Add(error.Schemas[i]);
+                    }
+                }
+            }
         }
 
         /// <summary>

Modified: avro/trunk/lang/csharp/src/apache/main/Schema/MapSchema.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Schema/MapSchema.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Schema/MapSchema.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Schema/MapSchema.cs Tue Aug 20 19:13:39 2013
@@ -32,6 +32,11 @@ namespace Avro
         /// </summary>
         public Schema ValueSchema { get; set; }
 
+        public static MapSchema CreateMap(Schema type)
+        {
+            return new MapSchema(type,null);
+        }
+
         /// <summary>
         /// Static function to return new instance of map schema
         /// </summary>

Modified: avro/trunk/lang/csharp/src/apache/main/Schema/RecordSchema.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Schema/RecordSchema.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Schema/RecordSchema.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Schema/RecordSchema.cs Tue Aug 20 19:13:39 2013
@@ -266,7 +266,8 @@ namespace Avro
         /// <returns>true if this and writer schema are compatible based on the AVRO specification, false otherwise</returns>
         public override bool CanRead(Schema writerSchema)
         {
-            if (writerSchema.Tag != Type.Record) return false;
+            if ((writerSchema.Tag != Type.Record) && (writerSchema.Tag != Type.Error)) return false;
+
             RecordSchema that = writerSchema as RecordSchema;
             return protect(() => true, () =>
             {

Modified: avro/trunk/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Specific/ObjectCreator.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Specific/ObjectCreator.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Specific/ObjectCreator.cs Tue Aug 20 19:13:39 2013
@@ -39,6 +39,11 @@ namespace Avro.Specific
         /// </summary>
         private Type GenericListType = typeof(List<>);
 
+        /// <summary>
+        /// Static generic nullable type used for creating new nullable instances
+        /// </summary>
+        private Type GenericNullableType = typeof(Nullable<>);
+        
         private readonly Assembly execAssembly;
         private readonly Assembly entryAssembly;
         private readonly bool diffAssembly;
@@ -104,18 +109,17 @@ namespace Avro.Specific
         }
 
         /// <summary>
-        /// Gets the type of the specified type name
+        /// Find the type with the given name
         /// </summary>
-        /// <param name="name">name of the object to get type of</param>
-        /// <param name="schemaType">schema type for the object</param>
-        /// <returns>Type</returns>
-        public Type GetType(string name, Schema.Type schemaType)
+        /// <param name="name">the object type to locate</param>
+        /// <param name="throwError">whether or not to throw an error if the type wasn't found</param>
+        /// <returns>the object type, or <c>null</c> if not found</returns>
+        private Type FindType(string name,bool throwError) 
         {
             Type type;
 
             // Modify provided type to ensure it can be discovered.
             // This is mainly for Generics, and Nullables.
-
             name = name.Replace("Nullable", "Nullable`1");
             name = name.Replace("IList", "System.Collections.Generic.IList`1");
             name = name.Replace("<", "[");
@@ -138,22 +142,130 @@ namespace Avro.Specific
                 Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                 foreach (Assembly assembly in assemblies)
                 {
+                    // Fix for Mono 3.0.10
+                    if (assembly.FullName.StartsWith("MonoDevelop.NUnit"))
+                        continue;
+
                     types = assembly.GetTypes();
 
                     // Change the search to look for Types by both NAME and FULLNAME
                     foreach (Type t in types)
                     {
                         if (name == t.Name || name == t.FullName) type = t;
-
                     }
-
                     
                     if (type != null)
                         break;
                 }
             }
-            if (type == null)
+
+            if (null == type && throwError)
+            {
                 throw new AvroException("Unable to find type " + name + " in all loaded assemblies");
+            }
+
+            return type;
+        }
+
+
+        /// <summary>
+        /// Gets the type for the specified schema
+        /// </summary>
+        /// <param name="schema"></param>
+        /// <returns></returns>
+        public Type GetType(Schema schema)
+        {
+            switch(schema.Tag) {
+            case Schema.Type.Null:
+                break;
+            case Schema.Type.Boolean:
+                return typeof(bool);
+            case Schema.Type.Int:
+                return typeof(int);
+            case Schema.Type.Long:
+                return typeof(long);
+            case Schema.Type.Float:
+                return typeof(float);
+            case Schema.Type.Double:
+                return typeof(double);
+            case Schema.Type.Bytes:
+                return typeof(byte[]); 
+            case Schema.Type.String:
+                return typeof(string);
+            case Schema.Type.Union:
+                {
+                    UnionSchema unSchema = schema as UnionSchema;
+                    if (null != unSchema && unSchema.Count==2)
+                    {
+                        Schema s1 = unSchema.Schemas[0];
+                        Schema s2 = unSchema.Schemas[1];
+
+                        // Nullable ?
+                        Type itemType = null;
+                        if (s1.Tag == Schema.Type.Null)
+                        {
+                            itemType = GetType(s2);
+                        }
+                        else if (s2.Tag == Schema.Type.Null)
+                        {
+                            itemType = GetType(s1);
+                        }
+
+                        if (null != itemType ) 
+                        {
+                            if (itemType.IsValueType && !itemType.IsEnum)
+                            {
+                                try
+                                {
+                                    largs[0] = itemType;
+                                    return GenericNullableType.MakeGenericType(largs);
+                                }
+                                catch (Exception) { }
+                            }
+                            
+                            return itemType;
+                        }
+                    }
+
+                    return typeof(object);
+                }
+            case Schema.Type.Array: {
+                ArraySchema arrSchema = schema as ArraySchema;
+                Type itemSchema = GetType(arrSchema.ItemSchema);
+
+                largs[0] = itemSchema;
+                return GenericListType.MakeGenericType(largs); }
+            case Schema.Type.Map: {
+                MapSchema mapSchema = schema as MapSchema;
+                Type itemSchema = GetType(mapSchema.ValueSchema);
+
+                margs[1] = itemSchema;
+                return GenericMapType.MakeGenericType(margs); }
+            case Schema.Type.Enumeration:
+            case Schema.Type.Record:
+            case Schema.Type.Fixed:
+            case Schema.Type.Error: {
+                // Should all be named types
+                var named = schema as NamedSchema;
+                if(null!=named) {
+                    return FindType(named.Fullname,true);
+                }
+                break; }
+            }
+
+            // Fallback
+            return FindType(schema.Name,true);
+        }
+
+        /// <summary>
+        /// Gets the type of the specified type name
+        /// </summary>
+        /// <param name="name">name of the object to get type of</param>
+        /// <param name="schemaType">schema type for the object</param>
+        /// <returns>Type</returns>
+        public Type GetType(string name, Schema.Type schemaType)
+        {
+            Type type = FindType(name, true);
 
             if (schemaType == Schema.Type.Map)
             {

Added: avro/trunk/lang/csharp/src/apache/main/Specific/SpecificException.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Specific/SpecificException.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Specific/SpecificException.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/Specific/SpecificException.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,29 @@
+/**
+ * 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;
+
+namespace Avro.Specific
+{
+    public abstract class SpecificException : Exception, ISpecificRecord
+    {
+        public abstract Schema Schema { get; }
+        public abstract object Get(int fieldPos);
+        public abstract void Put(int fieldPos, object fieldValue);
+    }
+}
\ No newline at end of file

Modified: avro/trunk/lang/csharp/src/apache/main/Specific/SpecificFixed.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Specific/SpecificFixed.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Specific/SpecificFixed.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Specific/SpecificFixed.cs Tue Aug 20 19:13:39 2013
@@ -30,5 +30,39 @@ namespace Avro.Specific
     {
         public SpecificFixed(uint size) : base(size) { }
         public abstract new Schema Schema { get; }
+
+        protected bool Equals(SpecificFixed obj)
+        {
+            if (this == obj) return true;
+            if (obj != null && obj is SpecificFixed)
+            {
+                SpecificFixed that = obj as SpecificFixed;
+                if (that.Schema.Equals(this.Schema))
+                {
+                    for (int i = 0; i < value.Length; i++) if (this.value[i] != that.Value[i]) return false;
+                    return true;
+                }
+            }
+            return false;
+
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj)) return false;
+            if (ReferenceEquals(this, obj)) return true;
+            if (obj.GetType() != this.GetType()) return false;
+            return Equals((SpecificFixed) obj);
+        }
+
+        public override int GetHashCode()
+        {
+            int result = Schema.GetHashCode();
+            foreach (byte b in value)
+            {
+                result += 23 * b;
+            }
+            return result;
+        }
     }
 }

Added: avro/trunk/lang/csharp/src/apache/main/Specific/SpecificProtocol.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Specific/SpecificProtocol.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Specific/SpecificProtocol.cs (added)
+++ avro/trunk/lang/csharp/src/apache/main/Specific/SpecificProtocol.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,31 @@
+/**
+ * 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.
+ */
+namespace Avro.Specific
+{
+    public interface ISpecificProtocol
+    {
+        Protocol Protocol { get; }
+        void Request(ICallbackRequestor requestor, string messageName, object[] args, object callback);
+    }
+
+    public interface ICallbackRequestor
+    {
+        void Request<T>(string messageName, object[] args, object callback);
+    }
+
+}
\ No newline at end of file

Modified: avro/trunk/lang/csharp/src/apache/main/Specific/SpecificReader.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Specific/SpecificReader.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Specific/SpecificReader.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Specific/SpecificReader.cs Tue Aug 20 19:13:39 2013
@@ -107,6 +107,9 @@ namespace Avro.Specific
         {
             RecordSchema rs = (RecordSchema)readerSchema;
 
+            if (rs.Name == null)
+                return base.ReadRecord(reuse, writerSchema, readerSchema, dec);
+
             ISpecificRecord rec = (reuse != null ? reuse : ObjectCreator.Instance.New(rs.Fullname, Schema.Type.Record)) as ISpecificRecord;
             object obj;
             foreach (Field wf in writerSchema)

Modified: avro/trunk/lang/csharp/src/apache/main/Specific/SpecificWriter.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/main/Specific/SpecificWriter.cs?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/main/Specific/SpecificWriter.cs (original)
+++ avro/trunk/lang/csharp/src/apache/main/Specific/SpecificWriter.cs Tue Aug 20 19:13:39 2013
@@ -193,6 +193,7 @@ namespace Avro.Specific
                     return obj is byte[];
                 case Schema.Type.String:
                     return obj is string;
+                case Schema.Type.Error:
                 case Schema.Type.Record:
                     return obj is ISpecificRecord && 
                            (((obj as ISpecificRecord).Schema) as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);

Propchange: avro/trunk/lang/csharp/src/apache/msbuild/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Aug 20 19:13:39 2013
@@ -0,0 +1 @@
+obj

Added: avro/trunk/lang/csharp/src/apache/msbuild/Avro.msbuild.csproj
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/msbuild/Avro.msbuild.csproj?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/msbuild/Avro.msbuild.csproj (added)
+++ avro/trunk/lang/csharp/src/apache/msbuild/Avro.msbuild.csproj Tue Aug 20 19:13:39 2013
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{AEB22F94-4ECF-4008-B159-389B3F05D54B}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Avro.msbuild</RootNamespace>
+    <AssemblyName>Avro.msbuild</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\build\msbuild\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\build\msbuild\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Build.Framework" />
+    <Reference Include="Microsoft.Build.Tasks.v3.5" />
+    <Reference Include="Microsoft.Build.Utilities.v3.5" />
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AvroBuilldTask.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\main\Avro.main.csproj">
+      <Project>{A0A5CA3C-F58C-4D07-98B0-2C7B62AB20F0}</Project>
+      <Name>Avro.main</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

Added: avro/trunk/lang/csharp/src/apache/msbuild/AvroBuilldTask.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/msbuild/AvroBuilldTask.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/msbuild/AvroBuilldTask.cs (added)
+++ avro/trunk/lang/csharp/src/apache/msbuild/AvroBuilldTask.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,67 @@
+/**
+ * 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 Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+namespace Avro.msbuild
+{
+    public class AvroBuildTask : Task
+    {
+        public override bool Execute()
+        {
+            var codegen = new CodeGen();
+            if (SchemaFiles != null)
+            {
+                foreach (var schemaFile in SchemaFiles)
+                {
+                    var schema = Schema.Parse(System.IO.File.ReadAllText(schemaFile.ItemSpec));
+                    codegen.AddSchema(schema);
+                }
+            }
+            if (ProtocolFiles != null)
+            {
+                foreach (var protocolFile in ProtocolFiles)
+                {
+                    var protocol = Protocol.Parse(System.IO.File.ReadAllText(protocolFile.ItemSpec));
+                    codegen.AddProtocol(protocol);
+                }
+            }
+
+            var generateCode = codegen.GenerateCode();
+            var namespaces = generateCode.Namespaces;
+            for (var i = namespaces.Count - 1; i >= 0; i--)
+            {
+                var types = namespaces[i].Types;
+                for (var j = types.Count - 1; j >= 0; j--)
+                {
+                    Log.LogMessage("Generating {0}.{1}", namespaces[i].Name, types[j].Name);
+                }
+            }
+
+            codegen.WriteTypes(OutDir.ItemSpec);
+            return true;
+        }
+
+        public ITaskItem[] SchemaFiles { get; set; }
+        public ITaskItem[] ProtocolFiles { get; set; }
+
+        [Required]
+        public ITaskItem OutDir { get; set; }
+    }
+}

Added: avro/trunk/lang/csharp/src/apache/msbuild/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/msbuild/Properties/AssemblyInfo.cs?rev=1515933&view=auto
==============================================================================
--- avro/trunk/lang/csharp/src/apache/msbuild/Properties/AssemblyInfo.cs (added)
+++ avro/trunk/lang/csharp/src/apache/msbuild/Properties/AssemblyInfo.cs Tue Aug 20 19:13:39 2013
@@ -0,0 +1,33 @@
+/**
+ * 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.InteropServices;
+
+[assembly: AssemblyTitle("Avro.msbuild")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache")]
+[assembly: AssemblyProduct("Avro.msbuild")]
+[assembly: AssemblyCopyright("Copyright © Apache 2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: ComVisible(false)]
+[assembly: Guid("A7982FA5-F369-457F-894E-4F90262E4638")]
+[assembly: AssemblyVersion("0.9.0.0")]
+[assembly: AssemblyFileVersion("0.9.0.0")]
\ No newline at end of file

Modified: avro/trunk/lang/csharp/src/apache/test/Avro.test.csproj
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/test/Avro.test.csproj?rev=1515933&r1=1515932&r2=1515933&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/test/Avro.test.csproj (original)
+++ avro/trunk/lang/csharp/src/apache/test/Avro.test.csproj Tue Aug 20 19:13:39 2013
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -69,6 +69,10 @@
     <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\..\lang\csharp\lib\main\Castle.Core.dll</HintPath>
+    </Reference>
     <Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\..\lib\test\nunit.framework.dll</HintPath>
@@ -85,6 +89,30 @@
     <Compile Include="File\FileTests.cs" />
     <Compile Include="Generic\GenericTests.cs" />
     <Compile Include="IO\BinaryCodecTests.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\All.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllCallback.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllEnum.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllTestRecord.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllTestRecordPartial.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\FixedTest.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Kind.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Mail.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\MailCallback.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\MD5.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Message.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Simple.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\SimpleCallback.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestError.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecord.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecordExtensions.cs" />
+    <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecordWithUnion.cs" />
+    <Compile Include="Ipc\LocalTransceiverTest.cs" />
+    <Compile Include="Ipc\MailResponder.cs" />
+    <Compile Include="Ipc\SerializationTest.cs" />
+    <Compile Include="Ipc\SocketServerConcurrentExecutionTest.cs" />
+    <Compile Include="Ipc\SocketServerTest.cs" />
+    <Compile Include="Ipc\SocketServerWithCallbacksTest.cs" />
+    <Compile Include="Ipc\SocketTransceiverWhenServerStopsTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Protocol\ProtocolTest.cs" />
     <Compile Include="Schema\AliasTest.cs" />
@@ -95,6 +123,10 @@
     <Compile Include="Utils\CaseFinderTests.cs" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\ipc\Avro.ipc.csproj">
+      <Project>{3b05043a-dc6c-49b6-85bf-9ab055d0b414}</Project>
+      <Name>Avro.ipc</Name>
+    </ProjectReference>
     <ProjectReference Include="..\main\Avro.main.csproj">
       <Project>{A0A5CA3C-F58C-4D07-98B0-2C7B62AB20F0}</Project>
       <Name>Avro.main</Name>
@@ -117,6 +149,11 @@
       <Install>true</Install>
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="..\..\..\..\..\share\test\schemas\mail.avpr">
+      <Link>Ipc\mail.avpr</Link>
+    </EmbeddedResource>
+  </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
@@ -126,4 +163,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file



Mime
View raw message