You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by bl...@apache.org on 2019/11/17 14:38:01 UTC

[avro] branch master updated: AVRO-2617: Use consistent line endings in C# CodeGen (#701)

This is an automated email from the ASF dual-hosted git repository.

blachniet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new bda7d99  AVRO-2617: Use consistent line endings in C# CodeGen (#701)
bda7d99 is described below

commit bda7d995ff7cb3079285c169b23064309ecda8b1
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Nov 17 09:37:51 2019 -0500

    AVRO-2617: Use consistent line endings in C# CodeGen (#701)
---
 lang/csharp/src/apache/main/CodeGen/CodeGen.cs | 29 +++++++++++++++-----------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
index 10197a0..fe7791e 100644
--- a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
+++ b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
@@ -406,19 +406,20 @@ namespace Avro
 
             if (protocol.Messages.Count > 0)
             {
-                builder.Append("switch(messageName)\n\t\t\t{");
+                builder.AppendLine("switch(messageName)");
+                builder.Append("\t\t\t{");
 
                 foreach (var a in protocol.Messages)
                 {
-                    builder.Append("\n\t\t\t\tcase \"").Append(a.Key).Append("\":\n");
+                    builder.AppendLine().Append("\t\t\t\tcase \"").Append(a.Key).AppendLine("\":");
 
                     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");
+                           .AppendLine(">(messageName, args, callback);");
+                    builder.AppendLine("\t\t\t\tbreak;");
                 }
 
                 builder.Append("\t\t\t}");
@@ -575,7 +576,8 @@ namespace Avro
             cmmGet.Attributes = MemberAttributes.Public;
             cmmGet.ReturnType = new CodeTypeReference("System.Object");
             cmmGet.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "fieldPos"));
-            StringBuilder getFieldStmt = new StringBuilder("switch (fieldPos)\n\t\t\t{\n");
+            StringBuilder getFieldStmt = new StringBuilder("switch (fieldPos)")
+                .AppendLine().AppendLine("\t\t\t{");
 
             // declare Put() to be used by the Reader classes
             var cmmPut = new CodeMemberMethod();
@@ -584,7 +586,8 @@ namespace Avro
             cmmPut.ReturnType = new CodeTypeReference(typeof(void));
             cmmPut.Parameters.Add(new CodeParameterDeclarationExpression(typeof(int), "fieldPos"));
             cmmPut.Parameters.Add(new CodeParameterDeclarationExpression("System.Object", "fieldValue"));
-            var putFieldStmt = new StringBuilder("switch (fieldPos)\n\t\t\t{\n");
+            var putFieldStmt = new StringBuilder("switch (fieldPos)")
+                .AppendLine().AppendLine("\t\t\t{");
 
             if (isError)
             {
@@ -638,7 +641,7 @@ namespace Avro
                 getFieldStmt.Append(field.Pos);
                 getFieldStmt.Append(": return this.");
                 getFieldStmt.Append(mangledName);
-                getFieldStmt.Append(";\n");
+                getFieldStmt.AppendLine(";");
 
                 // add to Put()
                 putFieldStmt.Append("\t\t\tcase ");
@@ -656,24 +659,26 @@ namespace Avro
                     type = type.Remove(type.Length - 1);   // remove >
 
                     putFieldStmt.Append(type);
-                    putFieldStmt.Append(")fieldValue; break;\n");
+                    putFieldStmt.AppendLine(")fieldValue; break;");
                 }
                 else
                 {
                     putFieldStmt.Append(" = (");
                     putFieldStmt.Append(baseType);
-                    putFieldStmt.Append(")fieldValue; break;\n");
+                    putFieldStmt.AppendLine(")fieldValue; break;");
                 }
             }
 
             // end switch block for Get()
-            getFieldStmt.Append("\t\t\tdefault: throw new AvroRuntimeException(\"Bad index \" + fieldPos + \" in Get()\");\n\t\t\t}");
+            getFieldStmt.AppendLine("\t\t\tdefault: throw new AvroRuntimeException(\"Bad index \" + fieldPos + \" in Get()\");")
+                .Append("\t\t\t}");
             var cseGet = new CodeSnippetExpression(getFieldStmt.ToString());
             cmmGet.Statements.Add(cseGet);
             ctd.Members.Add(cmmGet);
 
             // end switch block for Put()
-            putFieldStmt.Append("\t\t\tdefault: throw new AvroRuntimeException(\"Bad index \" + fieldPos + \" in Put()\");\n\t\t\t}");
+            putFieldStmt.AppendLine("\t\t\tdefault: throw new AvroRuntimeException(\"Bad index \" + fieldPos + \" in Put()\");")
+                .Append("\t\t\t}");
             var csePut = new CodeSnippetExpression(putFieldStmt.ToString());
             cmmPut.Statements.Add(csePut);
             ctd.Members.Add(cmmPut);
@@ -837,7 +842,7 @@ namespace Avro
         protected virtual CodeCommentStatement createDocComment(string comment)
         {
             string text = string.Format(CultureInfo.InvariantCulture,
-                "<summary>\r\n {0}\r\n </summary>", comment);
+                "<summary>{1} {0}{1} </summary>", comment, Environment.NewLine);
             return new CodeCommentStatement(text, true);
         }