Missing braces :)
diff --git a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
index f387f39..15e08e0 100644
--- a/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
+++ b/src/ProtocolBuffers.Serialization/JsonFormatWriter.cs
@@ -246,8 +246,10 @@
         {

             if (disposing)

             {

-                while(_counter.Count > 1)

+                while (_counter.Count > 1)

+                {

                     WriteMessageEnd();

+                }

             }

 

             base.Dispose(disposing);

diff --git a/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs b/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
index 79f403d..3c5cb3a 100644
--- a/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
+++ b/src/ProtocolBuffers.Serialization/XmlFormatWriter.cs
@@ -78,8 +78,10 @@
         {

             if (disposing)

             {

-                while(_messageOpenCount > 0)

+                while (_messageOpenCount > 0)

+                {

                     WriteMessageEnd();

+                }

 

                 _output.Close();

             }

@@ -163,7 +165,9 @@
         public override void WriteMessageEnd()

         {

             if (_messageOpenCount <= 0)

+            {

                 throw new InvalidOperationException();

+            }

 

             _output.WriteEndElement();

             _output.Flush();

diff --git a/src/ProtocolBuffers/CodedOutputStream.cs b/src/ProtocolBuffers/CodedOutputStream.cs
index 560719a..37c6038 100644
--- a/src/ProtocolBuffers/CodedOutputStream.cs
+++ b/src/ProtocolBuffers/CodedOutputStream.cs
@@ -131,7 +131,9 @@
             if (output != null)

             {

                 if (position > 0)

+                {

                     Flush();

+                }

                 output.Dispose();

             }

         }