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/09/29 12:35:17 UTC

[avro] branch branch-1.9 updated (05d8e1a -> bbec939)

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

blachniet pushed a change to branch branch-1.9
in repository https://gitbox.apache.org/repos/asf/avro.git.


    from 05d8e1a  AVRO-2550: Update Travis CI scripts to use Yetus 0.10
     new 1439952  AVRO-2454: Fix CA1034 - Nested types should not be visible
     new f58a506  AVRO-2454: Fix SA1600 - Elements should be documented
     new 5f6daa9  AVRO-2454: Fix CA1052 - Static holder types should be Static or NotInheritable
     new 2f85a47  AVRO-2454: Fix CA1063 - Implement IDisposable correctly
     new f2776a7  AVRO-2454: Ignore CA1303 - Do not pass literals as localized parameters
     new 38d9159  AVRO-2454: Fix CA1305 - Specify IFormatProvider
     new 861e93e  AVRO-2454: Ignore SA1116 and SA1117 - Parameters on separate lines
     new c9d6eed  AVRO-2454: Fix SA1119 - StatementMustNotUseUnnecessaryParenthesis
     new 94df7f9  AVRO-2454: Fix CA1307 - Specify StringComparison
     new 4c75f07  AVRO-2454: Fix CA1507 - Use nameof in place of string
     new 18f8107  AVRO-2454: Fix SA1604 - ElementDocumentationMustHaveSummary
     new 44b335e  AVRO-2454: Fix SA1606 - ElementDocumentationMustHaveSummaryText
     new f5cfefe  AVRO-2454: Fix SA1610 - PropertyDocumentationMustHaveValueText
     new ea06118  AVRO-2454: Fix SA1611 - ElementParametersMustBeDocumented
     new 408bd2c  AVRO-2454: Fix CA1715 - Identifiers should have correct prefix
     new 549f9a9  AVRO-2454: Fix CA1724 - Type names should not match namespaces
     new bbec939  AVRO-2454: Fix CA1721 - Property names should not match get methods

The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 lang/csharp/Avro.ruleset                           | 28 +++++++------------
 lang/csharp/src/apache/main/CodeGen/CodeGen.cs     | 13 ++++-----
 .../src/apache/main/File/DataFileConstants.cs      |  3 +++
 lang/csharp/src/apache/main/File/DataFileReader.cs | 31 +++++++++++++++++-----
 lang/csharp/src/apache/main/File/DataFileWriter.cs | 14 +++++++++-
 lang/csharp/src/apache/main/File/DeflateCodec.cs   |  2 +-
 lang/csharp/src/apache/main/File/NullCodec.cs      |  2 +-
 lang/csharp/src/apache/main/Generic/DatumReader.cs |  2 ++
 lang/csharp/src/apache/main/Generic/DatumWriter.cs |  2 ++
 .../src/apache/main/Generic/GenericDatumReader.cs  | 11 +++++---
 .../src/apache/main/Generic/GenericDatumWriter.cs  |  4 +--
 lang/csharp/src/apache/main/Generic/GenericEnum.cs |  4 ++-
 .../src/apache/main/Generic/GenericReader.cs       |  4 +--
 .../src/apache/main/Generic/GenericWriter.cs       | 12 ++++-----
 .../apache/main/Generic/PreresolvingDatumReader.cs |  1 +
 .../apache/main/Generic/PreresolvingDatumWriter.cs | 10 +++----
 lang/csharp/src/apache/main/GlobalSuppressions.cs  |  3 +++
 lang/csharp/src/apache/main/IO/BinaryEncoder.cs    |  2 +-
 .../src/apache/main/IO/ByteBufferInputStream.cs    |  8 +++---
 lang/csharp/src/apache/main/IO/Decoder.cs          |  2 ++
 lang/csharp/src/apache/main/IO/Encoder.cs          |  2 ++
 lang/csharp/src/apache/main/Protocol/Message.cs    |  4 +--
 lang/csharp/src/apache/main/Protocol/Protocol.cs   | 18 +++++++------
 lang/csharp/src/apache/main/Schema/ArraySchema.cs  |  2 +-
 lang/csharp/src/apache/main/Schema/EnumSchema.cs   |  9 ++++++-
 lang/csharp/src/apache/main/Schema/Field.cs        |  4 +--
 lang/csharp/src/apache/main/Schema/FixedSchema.cs  |  2 +-
 lang/csharp/src/apache/main/Schema/JsonHelper.cs   |  8 +++---
 lang/csharp/src/apache/main/Schema/MapSchema.cs    |  2 +-
 .../src/apache/main/Schema/PrimitiveSchema.cs      |  7 ++++-
 lang/csharp/src/apache/main/Schema/Property.cs     | 10 ++++---
 lang/csharp/src/apache/main/Schema/RecordSchema.cs |  4 +--
 lang/csharp/src/apache/main/Schema/Schema.cs       | 11 ++++----
 .../src/apache/main/Schema/SchemaNormalization.cs  |  9 ++++---
 lang/csharp/src/apache/main/Schema/UnionSchema.cs  |  2 +-
 .../src/apache/main/Specific/ObjectCreator.cs      |  4 +++
 .../apache/main/Specific/SpecificDatumReader.cs    |  2 +-
 .../apache/main/Specific/SpecificDatumWriter.cs    |  4 +--
 .../src/apache/main/Specific/SpecificWriter.cs     |  4 +--
 lang/csharp/stylecop.json                          |  7 ++++-
 40 files changed, 174 insertions(+), 99 deletions(-)


[avro] 17/17: AVRO-2454: Fix CA1721 - Property names should not match get methods

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bbec9394c1dce0d5109fed632069502b12f24594
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 21:48:26 2019 -0400

    AVRO-2454: Fix CA1721 - Property names should not match get methods
    
    (cherry picked from commit 2dd342921cc7264a54cd66c00528381a167230f9)
---
 lang/csharp/Avro.ruleset                          | 1 -
 lang/csharp/src/apache/main/GlobalSuppressions.cs | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index f40f63a..1c53123 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -29,7 +29,6 @@
     <Rule Id="CA1710" Action="Info" />
     <Rule Id="CA1716" Action="Info" />
     <Rule Id="CA1720" Action="Info" />
-    <Rule Id="CA1721" Action="Info" />
     <Rule Id="CA1801" Action="Info" />
     <Rule Id="CA1819" Action="Info" />
     <Rule Id="CA1820" Action="Info" />
diff --git a/lang/csharp/src/apache/main/GlobalSuppressions.cs b/lang/csharp/src/apache/main/GlobalSuppressions.cs
index 8bb0e31..4fafb70 100644
--- a/lang/csharp/src/apache/main/GlobalSuppressions.cs
+++ b/lang/csharp/src/apache/main/GlobalSuppressions.cs
@@ -40,4 +40,6 @@
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065:Do not raise exceptions in unexpected locations", Justification = "Maintain public API", Scope = "member", Target = "~P:Avro.Protocol.MD5")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Maintain public API", Scope = "member", Target = "~M:Avro.Schema.GetTypeString(Avro.Schema.Type)~System.String")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Maintain public API", Scope = "member", Target = "~P:Avro.UnnamedSchema.Name")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721:Property names should not match get methods", Justification = "Maintain public API", Scope = "member", Target = "~M:Avro.NamedSchema.GetName(Newtonsoft.Json.Linq.JToken,System.String)~Avro.SchemaName")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721:Property names should not match get methods", Justification = "Maintain public API", Scope = "member", Target = "~P:Avro.NamedSchema.Name")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Reviewed", Scope = "type", Target = "~T:Avro.Schema")]


[avro] 16/17: AVRO-2454: Fix CA1724 - Type names should not match namespaces

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 549f9a997454300f39a1c11a32d44ca61b1e9acd
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 21:37:00 2019 -0400

    AVRO-2454: Fix CA1724 - Type names should not match namespaces
    
    (cherry picked from commit 85016374897e776c54d7e8cfe022f60b1d4e9550)
---
 lang/csharp/Avro.ruleset                          | 1 -
 lang/csharp/src/apache/main/GlobalSuppressions.cs | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 4900e32..f40f63a 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -30,7 +30,6 @@
     <Rule Id="CA1716" Action="Info" />
     <Rule Id="CA1720" Action="Info" />
     <Rule Id="CA1721" Action="Info" />
-    <Rule Id="CA1724" Action="Info" />
     <Rule Id="CA1801" Action="Info" />
     <Rule Id="CA1819" Action="Info" />
     <Rule Id="CA1820" Action="Info" />
diff --git a/lang/csharp/src/apache/main/GlobalSuppressions.cs b/lang/csharp/src/apache/main/GlobalSuppressions.cs
index c73afa0..8bb0e31 100644
--- a/lang/csharp/src/apache/main/GlobalSuppressions.cs
+++ b/lang/csharp/src/apache/main/GlobalSuppressions.cs
@@ -40,3 +40,4 @@
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1065:Do not raise exceptions in unexpected locations", Justification = "Maintain public API", Scope = "member", Target = "~P:Avro.Protocol.MD5")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Maintain public API", Scope = "member", Target = "~M:Avro.Schema.GetTypeString(Avro.Schema.Type)~System.String")]
 [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Maintain public API", Scope = "member", Target = "~P:Avro.UnnamedSchema.Name")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Reviewed", Scope = "type", Target = "~T:Avro.Schema")]


[avro] 06/17: AVRO-2454: Fix CA1305 - Specify IFormatProvider

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 38d91595381b46ea765451ac2c13742021dc3007
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:47:10 2019 -0400

    AVRO-2454: Fix CA1305 - Specify IFormatProvider
    
    (cherry picked from commit 539d746274a01011cffe6a863d7373d3a38d4c78)
---
 lang/csharp/Avro.ruleset                                |  1 -
 lang/csharp/src/apache/main/CodeGen/CodeGen.cs          | 11 ++++++-----
 lang/csharp/src/apache/main/File/DataFileReader.cs      | 17 +++++++++++------
 lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs |  8 +++++---
 .../src/apache/main/Schema/SchemaNormalization.cs       |  9 ++++++---
 5 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index e3a8405..79f3a94 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -25,7 +25,6 @@
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
     <Rule Id="CA1062" Action="Info" />
-    <Rule Id="CA1305" Action="Info" />
     <Rule Id="CA1307" Action="Info" />
     <Rule Id="CA1507" Action="Info" />
     <Rule Id="CA1707" Action="Info" />
diff --git a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
index c3d1ef3..be33321 100644
--- a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
+++ b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
@@ -16,14 +16,14 @@
  * limitations under the License.
  */
 using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
 using System.Collections.Generic;
-using System.Linq;
+using System.Globalization;
+using System.IO;
 using System.Reflection;
 using System.Text;
-using System.CodeDom;
-using System.CodeDom.Compiler;
 using Microsoft.CSharp;
-using System.IO;
 
 namespace Avro
 {
@@ -836,7 +836,8 @@ namespace Avro
         /// <returns>CodeCommentStatement object</returns>
         protected virtual CodeCommentStatement createDocComment(string comment)
         {
-            string text = string.Format("<summary>\r\n {0}\r\n </summary>", comment);
+            string text = string.Format(CultureInfo.InvariantCulture,
+                "<summary>\r\n {0}\r\n </summary>", comment);
             return new CodeCommentStatement(text, true);
         }
 
diff --git a/lang/csharp/src/apache/main/File/DataFileReader.cs b/lang/csharp/src/apache/main/File/DataFileReader.cs
index e93d8b1..784bf10 100644
--- a/lang/csharp/src/apache/main/File/DataFileReader.cs
+++ b/lang/csharp/src/apache/main/File/DataFileReader.cs
@@ -17,8 +17,9 @@
  */
 using System;
 using System.Collections.Generic;
-using System.Linq;
+using System.Globalization;
 using System.IO;
+using System.Linq;
 using Avro.Generic;
 using Avro.IO;
 using Avro.Specific;
@@ -165,7 +166,7 @@ namespace Avro.File
         /// <inheritdoc/>
         public long GetMetaLong(string key)
         {
-            return long.Parse(GetMetaString(key));
+            return long.Parse(GetMetaString(key), CultureInfo.InvariantCulture);
         }
 
         /// <inheritdoc/>
@@ -182,7 +183,8 @@ namespace Avro.File
             }
             catch (Exception e)
             {
-                throw new AvroRuntimeException(string.Format("Error fetching meta data for key: {0}", key), e);
+                throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture,
+                    "Error fetching meta data for key: {0}", key), e);
             }
         }
 
@@ -285,7 +287,8 @@ namespace Avro.File
             }
             catch (Exception e)
             {
-                throw new AvroRuntimeException(string.Format("Error fetching next object from block: {0}", e));
+                throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture,
+                    "Error fetching next object from block: {0}", e));
             }
         }
 
@@ -402,7 +405,8 @@ namespace Avro.File
             }
             catch (Exception e)
             {
-                throw new AvroRuntimeException(string.Format("Error fetching next object from block: {0}", e));
+                throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture,
+                    "Error fetching next object from block: {0}", e));
             }
         }
 
@@ -471,7 +475,8 @@ namespace Avro.File
             }
             catch (Exception e)
             {
-                throw new AvroRuntimeException(string.Format("Error ascertaining if data has next block: {0}", e), e);
+                throw new AvroRuntimeException(string.Format(CultureInfo.InvariantCulture,
+                    "Error ascertaining if data has next block: {0}", e), e);
             }
         }
 
diff --git a/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs b/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs
index 6725cf7..b077bfd 100644
--- a/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs
+++ b/lang/csharp/src/apache/main/IO/ByteBufferInputStream.cs
@@ -17,6 +17,7 @@
  */
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.IO;
 
 namespace Avro.IO
@@ -50,7 +51,8 @@ namespace Avro.IO
                 int remainingCheck = buffer.Read(b, off, (int) remaining);
 
                 if(remainingCheck != remaining)
-                    throw new InvalidDataException(string.Format("remainingCheck [{0}] and remaining[{1}] are different.",
+                    throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture,
+                        "remainingCheck [{0}] and remaining[{1}] are different.",
                         remainingCheck, remaining));
                 return (int)remaining;
             }
@@ -58,8 +60,8 @@ namespace Avro.IO
             int lenCheck = buffer.Read(b, off, len);
 
             if (lenCheck != len)
-                throw new InvalidDataException(string.Format("lenCheck [{0}] and len[{1}] are different.",
-                                                             lenCheck, len));
+                throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture,
+                    "lenCheck [{0}] and len[{1}] are different.", lenCheck, len));
 
             return len;
         }
diff --git a/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs b/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs
index c7ea9d6..eb7a4b4 100644
--- a/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs
+++ b/lang/csharp/src/apache/main/Schema/SchemaNormalization.cs
@@ -16,9 +16,10 @@
  * limitations under the License.
  */
 
+using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.Text;
-using System;
 
 namespace Avro
 {
@@ -99,7 +100,8 @@ namespace Avro
                     var sha256 = System.Security.Cryptography.SHA256.Create();
                     return sha256.ComputeHash(data);
                 default:
-                    throw new ArgumentException(string.Format("Unsupported fingerprint computation algorithm ({0})", fpName));
+                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
+                        "Unsupported fingerprint computation algorithm ({0})", fpName));
             }
         }
 
@@ -214,7 +216,8 @@ namespace Avro
                     else if (st == Schema.Type.Fixed)
                     {
                         FixedSchema fixedSchema = s as FixedSchema;
-                        o.Append(",\"size\":").Append(fixedSchema.Size.ToString());
+                        o.Append(",\"size\":")
+                            .Append(fixedSchema.Size.ToString(CultureInfo.InvariantCulture));
                     }
                     else  // st == Schema.Type.Record
                     {


[avro] 14/17: AVRO-2454: Fix SA1611 - ElementParametersMustBeDocumented

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ea0611800b6001492c4ce2de48633905f1241a50
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 15:31:33 2019 -0400

    AVRO-2454: Fix SA1611 - ElementParametersMustBeDocumented
    
    (cherry picked from commit 2641b45e2d61d718fd3301cf380ea829f2c0ae6a)
---
 lang/csharp/Avro.ruleset                                       | 1 -
 lang/csharp/src/apache/main/Generic/PreresolvingDatumReader.cs | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index a624c32..00e630d 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -133,7 +133,6 @@
     <Rule Id="SA1516" Action="Info" />
     <Rule Id="SA1519" Action="Info" />
     <Rule Id="SA1520" Action="Info" />
-    <Rule Id="SA1611" Action="Info" />
     <Rule Id="SA1614" Action="Info" />
     <Rule Id="SA1615" Action="Info" />
     <Rule Id="SA1616" Action="Info" />
diff --git a/lang/csharp/src/apache/main/Generic/PreresolvingDatumReader.cs b/lang/csharp/src/apache/main/Generic/PreresolvingDatumReader.cs
index b963618..8b0cffa 100644
--- a/lang/csharp/src/apache/main/Generic/PreresolvingDatumReader.cs
+++ b/lang/csharp/src/apache/main/Generic/PreresolvingDatumReader.cs
@@ -507,6 +507,7 @@ namespace Avro.Generic
         /// the Specific and Generic implementations. Used to avoid retrieving the existing
         /// value if it's not reusable.
         /// </summary>
+        /// <param name="tag">Schema type to test for reusability.</param>
         protected virtual bool IsReusable(Schema.Type tag)
         {
             return true;


[avro] 10/17: AVRO-2454: Fix CA1507 - Use nameof in place of string

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4c75f0765f3b0d9bf97d41a32893915fb632f66b
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 14:27:29 2019 -0400

    AVRO-2454: Fix CA1507 - Use nameof in place of string
    
    (cherry picked from commit 0e1073e98b4323fd85af1826a72ca12d5eabc1d2)
---
 lang/csharp/Avro.ruleset                           | 1 -
 lang/csharp/src/apache/main/CodeGen/CodeGen.cs     | 2 +-
 lang/csharp/src/apache/main/Protocol/Message.cs    | 2 +-
 lang/csharp/src/apache/main/Protocol/Protocol.cs   | 6 +++---
 lang/csharp/src/apache/main/Schema/ArraySchema.cs  | 2 +-
 lang/csharp/src/apache/main/Schema/Field.cs        | 2 +-
 lang/csharp/src/apache/main/Schema/FixedSchema.cs  | 2 +-
 lang/csharp/src/apache/main/Schema/JsonHelper.cs   | 8 ++++----
 lang/csharp/src/apache/main/Schema/MapSchema.cs    | 2 +-
 lang/csharp/src/apache/main/Schema/RecordSchema.cs | 2 +-
 lang/csharp/src/apache/main/Schema/Schema.cs       | 2 +-
 lang/csharp/src/apache/main/Schema/UnionSchema.cs  | 2 +-
 12 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 1f12d7f..0931157 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -25,7 +25,6 @@
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
     <Rule Id="CA1062" Action="Info" />
-    <Rule Id="CA1507" Action="Info" />
     <Rule Id="CA1707" Action="Info" />
     <Rule Id="CA1710" Action="Info" />
     <Rule Id="CA1715" Action="Info" />
diff --git a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
index be33321..40c7256 100644
--- a/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
+++ b/lang/csharp/src/apache/main/CodeGen/CodeGen.cs
@@ -105,7 +105,7 @@ namespace Avro
         protected virtual CodeNamespace addNamespace(string name)
         {
             if (string.IsNullOrEmpty(name))
-                throw new ArgumentNullException("name", "name cannot be null.");
+                throw new ArgumentNullException(nameof(name), "name cannot be null.");
 
             CodeNamespace ns = null;
 
diff --git a/lang/csharp/src/apache/main/Protocol/Message.cs b/lang/csharp/src/apache/main/Protocol/Message.cs
index 34edd0a..5e455ef 100644
--- a/lang/csharp/src/apache/main/Protocol/Message.cs
+++ b/lang/csharp/src/apache/main/Protocol/Message.cs
@@ -75,7 +75,7 @@ namespace Avro
         /// </param>
         public Message(string name, string doc, RecordSchema request, Schema response, UnionSchema error, bool? oneway)
         {
-            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "name cannot be null.");
+            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "name cannot be null.");
             this.Request = request;
             this.Response = response;
             this.Error = error;
diff --git a/lang/csharp/src/apache/main/Protocol/Protocol.cs b/lang/csharp/src/apache/main/Protocol/Protocol.cs
index 2665823..cd4e0cc 100644
--- a/lang/csharp/src/apache/main/Protocol/Protocol.cs
+++ b/lang/csharp/src/apache/main/Protocol/Protocol.cs
@@ -86,9 +86,9 @@ namespace Avro
                         string doc, IEnumerable<Schema> types,
                         IDictionary<string,Message> messages)
         {
-            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "name cannot be null.");
-            if (null == types) throw new ArgumentNullException("types", "types cannot be null.");
-            if (null == messages) throw new ArgumentNullException("messages", "messages cannot be null.");
+            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "name cannot be null.");
+            if (null == types) throw new ArgumentNullException(nameof(types), "types cannot be null.");
+            if (null == messages) throw new ArgumentNullException(nameof(messages), "messages cannot be null.");
 
             this.Name = name;
             this.Namespace = space;
diff --git a/lang/csharp/src/apache/main/Schema/ArraySchema.cs b/lang/csharp/src/apache/main/Schema/ArraySchema.cs
index 0976ed7..5b4e6a4 100644
--- a/lang/csharp/src/apache/main/Schema/ArraySchema.cs
+++ b/lang/csharp/src/apache/main/Schema/ArraySchema.cs
@@ -54,7 +54,7 @@ namespace Avro
         /// <param name="props">dictionary that provides access to custom properties</param>
         private ArraySchema(Schema items, PropertyMap props) : base(Type.Array, props)
         {
-            if (null == items) throw new ArgumentNullException("items");
+            if (null == items) throw new ArgumentNullException(nameof(items));
             this.ItemSchema = items;
         }
 
diff --git a/lang/csharp/src/apache/main/Schema/Field.cs b/lang/csharp/src/apache/main/Schema/Field.cs
index 1d5bedb..026b5b2 100644
--- a/lang/csharp/src/apache/main/Schema/Field.cs
+++ b/lang/csharp/src/apache/main/Schema/Field.cs
@@ -124,7 +124,7 @@ namespace Avro
         internal Field(Schema schema, string name, IList<string> aliases, int pos, string doc,
                         JToken defaultValue, SortOrder sortorder, PropertyMap props)
         {
-            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "name cannot be null.");
+            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name), "name cannot be null.");
             if (null == schema) throw new ArgumentNullException("type", "type cannot be null.");
             this.Schema = schema;
             this.Name = name;
diff --git a/lang/csharp/src/apache/main/Schema/FixedSchema.cs b/lang/csharp/src/apache/main/Schema/FixedSchema.cs
index 098e32c..b16c1ff 100644
--- a/lang/csharp/src/apache/main/Schema/FixedSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/FixedSchema.cs
@@ -69,7 +69,7 @@ namespace Avro
                             : base(Type.Fixed, name, aliases, props, names, doc)
         {
             if (null == name.Name) throw new SchemaParseException("name cannot be null for fixed schema.");
-            if (size <= 0) throw new ArgumentOutOfRangeException("size", "size must be greater than zero.");
+            if (size <= 0) throw new ArgumentOutOfRangeException(nameof(size), "size must be greater than zero.");
             this.Size = size;
         }
 
diff --git a/lang/csharp/src/apache/main/Schema/JsonHelper.cs b/lang/csharp/src/apache/main/Schema/JsonHelper.cs
index 7cbea49..87887f5 100644
--- a/lang/csharp/src/apache/main/Schema/JsonHelper.cs
+++ b/lang/csharp/src/apache/main/Schema/JsonHelper.cs
@@ -34,8 +34,8 @@ namespace Avro
         /// <returns>property value if property exists, null if property doesn't exist in the JSON object</returns>
         public static string GetOptionalString(JToken jtok, string field)
         {
-            if (null == jtok) throw new ArgumentNullException("jtok", "jtok cannot be null.");
-            if (string.IsNullOrEmpty(field)) throw new ArgumentNullException("field", $"field cannot be null at '{jtok.Path}'");
+            if (null == jtok) throw new ArgumentNullException(nameof(jtok), "jtok cannot be null.");
+            if (string.IsNullOrEmpty(field)) throw new ArgumentNullException(nameof(field), $"field cannot be null at '{jtok.Path}'");
 
             JToken child = jtok[field];
             if (null == child) return null;
@@ -85,8 +85,8 @@ namespace Avro
         /// <returns>null if property doesn't exist, otherise returns property boolean value</returns>
         public static bool? GetOptionalBoolean(JToken jtok, string field)
         {
-            if (null == jtok) throw new ArgumentNullException("jtok", "jtok cannot be null.");
-            if (string.IsNullOrEmpty(field)) throw new ArgumentNullException("field", $"field cannot be null at '{jtok.Path}'");
+            if (null == jtok) throw new ArgumentNullException(nameof(jtok), "jtok cannot be null.");
+            if (string.IsNullOrEmpty(field)) throw new ArgumentNullException(nameof(field), $"field cannot be null at '{jtok.Path}'");
 
             JToken child = jtok[field];
             if (null == child) return null;
diff --git a/lang/csharp/src/apache/main/Schema/MapSchema.cs b/lang/csharp/src/apache/main/Schema/MapSchema.cs
index e50b04e..54bc05a 100644
--- a/lang/csharp/src/apache/main/Schema/MapSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/MapSchema.cs
@@ -71,7 +71,7 @@ namespace Avro
         /// <param name="props">dictionary that provides access to custom properties</param>
         private MapSchema(Schema valueSchema, PropertyMap props) : base(Type.Map, props)
         {
-            if (null == valueSchema) throw new ArgumentNullException("valueSchema", "valueSchema cannot be null.");
+            if (null == valueSchema) throw new ArgumentNullException(nameof(valueSchema), "valueSchema cannot be null.");
             this.ValueSchema = valueSchema;
         }
 
diff --git a/lang/csharp/src/apache/main/Schema/RecordSchema.cs b/lang/csharp/src/apache/main/Schema/RecordSchema.cs
index c485f5d..6f01d0c 100644
--- a/lang/csharp/src/apache/main/Schema/RecordSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/RecordSchema.cs
@@ -178,7 +178,7 @@ namespace Avro
         {
             get
             {
-                if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name");
+                if (string.IsNullOrEmpty(name)) throw new ArgumentNullException(nameof(name));
                 Field field;
                 return fieldLookup.TryGetValue(name, out field) ? field : null;
             }
diff --git a/lang/csharp/src/apache/main/Schema/Schema.cs b/lang/csharp/src/apache/main/Schema/Schema.cs
index 046151d..aba4e72 100644
--- a/lang/csharp/src/apache/main/Schema/Schema.cs
+++ b/lang/csharp/src/apache/main/Schema/Schema.cs
@@ -206,7 +206,7 @@ namespace Avro
         /// <returns>new Schema object</returns>
         public static Schema Parse(string json)
         {
-            if (string.IsNullOrEmpty(json)) throw new ArgumentNullException("json", "json cannot be null.");
+            if (string.IsNullOrEmpty(json)) throw new ArgumentNullException(nameof(json), "json cannot be null.");
             return Parse(json.Trim(), new SchemaNames(), null); // standalone schema, so no enclosing namespace
         }
 
diff --git a/lang/csharp/src/apache/main/Schema/UnionSchema.cs b/lang/csharp/src/apache/main/Schema/UnionSchema.cs
index e3a0fe1..0ffb5e0 100644
--- a/lang/csharp/src/apache/main/Schema/UnionSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/UnionSchema.cs
@@ -75,7 +75,7 @@ namespace Avro
         private UnionSchema(List<Schema> schemas, PropertyMap props) : base(Type.Union, props)
         {
             if (schemas == null)
-                throw new ArgumentNullException("schemas");
+                throw new ArgumentNullException(nameof(schemas));
             this.Schemas = schemas;
         }
 


[avro] 01/17: AVRO-2454: Fix CA1034 - Nested types should not be visible

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1439952c679b7c3288f482ff85764a4bb957d3d0
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 09:45:59 2019 -0400

    AVRO-2454: Fix CA1034 - Nested types should not be visible
    
    (cherry picked from commit a1d9b1a64c5c5ca273e5f6dfcf6015a7d1e0cc8f)
---
 lang/csharp/Avro.ruleset                              | 1 -
 lang/csharp/src/apache/main/Specific/ObjectCreator.cs | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index e5a3983..2a101e2 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -21,7 +21,6 @@
     AVRO-2454: We need to evaluate each of these rules to determine whether we should enforce them.
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
-    <Rule Id="CA1034" Action="Info" />
     <Rule Id="CA1052" Action="Info" />
     <Rule Id="CA1062" Action="Info" />
     <Rule Id="CA1063" Action="Info" />
diff --git a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
index 5c876e5..fe3f6ee 100644
--- a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
+++ b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
@@ -74,6 +74,7 @@ namespace Avro.Specific
         }
 
 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
+#pragma warning disable CA1034 // Nested types should not be visible
         /// <summary>
         /// Obsolete: This will be removed from the public API in a future version.
         /// </summary>
@@ -116,6 +117,7 @@ namespace Avro.Specific
                 return !left.Equals(right);
             }
         }
+#pragma warning restore CA1034 // Nested types should not be visible
 #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
 
         /// <summary>


[avro] 05/17: AVRO-2454: Ignore CA1303 - Do not pass literals as localized parameters

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f2776a75472722a1b4ec067bbae82ce49355cec6
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:37:18 2019 -0400

    AVRO-2454: Ignore CA1303 - Do not pass literals as localized parameters
    
    (cherry picked from commit 5d3ad3e179c31a444b51bc2f6556448eb5ad3408)
---
 lang/csharp/Avro.ruleset | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index e883235..e3a8405 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -17,12 +17,14 @@
 -->
 <RuleSet Name="New Rule Set" Description=" " ToolsVersion="16.0">
   <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
+    <!-- CA1303: Do not pass literals as localized parameters -->
+    <Rule Id="CA1303" Action="None" />
+
     <!--
     AVRO-2454: We need to evaluate each of these rules to determine whether we should enforce them.
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
     <Rule Id="CA1062" Action="Info" />
-    <Rule Id="CA1303" Action="Info" />
     <Rule Id="CA1305" Action="Info" />
     <Rule Id="CA1307" Action="Info" />
     <Rule Id="CA1507" Action="Info" />


[avro] 03/17: AVRO-2454: Fix CA1052 - Static holder types should be Static or NotInheritable

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5f6daa933eaee1b6a422cd2cf1add02b2e7dff9b
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:25:37 2019 -0400

    AVRO-2454: Fix CA1052 - Static holder types should be Static or NotInheritable
    
    (cherry picked from commit 770acd5a5f2de734eb7a6e51ae18ed254b2828f8)
---
 lang/csharp/Avro.ruleset                              | 1 -
 lang/csharp/src/apache/main/File/DataFileConstants.cs | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 446f4a4..3dfafe0 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -21,7 +21,6 @@
     AVRO-2454: We need to evaluate each of these rules to determine whether we should enforce them.
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
-    <Rule Id="CA1052" Action="Info" />
     <Rule Id="CA1062" Action="Info" />
     <Rule Id="CA1063" Action="Info" />
     <Rule Id="CA1303" Action="Info" />
diff --git a/lang/csharp/src/apache/main/File/DataFileConstants.cs b/lang/csharp/src/apache/main/File/DataFileConstants.cs
index 10fe24f..27b034e 100644
--- a/lang/csharp/src/apache/main/File/DataFileConstants.cs
+++ b/lang/csharp/src/apache/main/File/DataFileConstants.cs
@@ -21,6 +21,9 @@ namespace Avro.File
     /// <summary>
     /// Constants used in data files.
     /// </summary>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Design",
+        "CA1052:Static holder types should be Static or NotInheritable",
+        Justification = "Maintain public API")]
     public class DataFileConstants
     {
         /// <summary>


[avro] 12/17: AVRO-2454: Fix SA1606 - ElementDocumentationMustHaveSummaryText

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 44b335e68bd25684e27142798b62b8063f160c1f
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 15:25:32 2019 -0400

    AVRO-2454: Fix SA1606 - ElementDocumentationMustHaveSummaryText
    
    (cherry picked from commit 2e93877491ef385455183cf9a430b54227945858)
---
 lang/csharp/Avro.ruleset | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 9298422..221d03c 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -133,7 +133,6 @@
     <Rule Id="SA1516" Action="Info" />
     <Rule Id="SA1519" Action="Info" />
     <Rule Id="SA1520" Action="Info" />
-    <Rule Id="SA1606" Action="Info" />
     <Rule Id="SA1610" Action="Info" />
     <Rule Id="SA1611" Action="Info" />
     <Rule Id="SA1614" Action="Info" />


[avro] 07/17: AVRO-2454: Ignore SA1116 and SA1117 - Parameters on separate lines

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 861e93ea54c11730f43ee80fc1b433580ee748a1
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:50:52 2019 -0400

    AVRO-2454: Ignore SA1116 and SA1117 - Parameters on separate lines
    
    (cherry picked from commit 33418a3955cac1c00b6c2ee31b3fc4929a54d996)
---
 lang/csharp/Avro.ruleset | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 79f3a94..7029d96 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -51,6 +51,12 @@
     <!-- PrefixLocalCallsWithThis -->
     <Rule Id="SA1101" Action="None" />
 
+    <!-- SplitParametersMustStartOnLineAfterDeclaration -->
+    <Rule Id="SA1116" Action="None" />
+
+    <!-- ParametersMustBeOnSameLineOrSeparateLines -->
+    <Rule Id="SA1117" Action="None" />
+
     <!--
     Element Ordering Rules
     https://google.github.io/styleguide/javaguide.html#s3.4.2-ordering-class-contents
@@ -89,8 +95,6 @@
     <Rule Id="SA1106" Action="Info" />
     <Rule Id="SA1107" Action="Info" />
     <Rule Id="SA1108" Action="Info" />
-    <Rule Id="SA1116" Action="Info" />
-    <Rule Id="SA1117" Action="Info" />
     <Rule Id="SA1119" Action="Info" />
     <Rule Id="SA1121" Action="Info" />
     <Rule Id="SA1122" Action="Info" />


[avro] 08/17: AVRO-2454: Fix SA1119 - StatementMustNotUseUnnecessaryParenthesis

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c9d6eeda052591ebecb378514a04a7a68d79398a
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:56:35 2019 -0400

    AVRO-2454: Fix SA1119 - StatementMustNotUseUnnecessaryParenthesis
    
    (cherry picked from commit ded1087822b590ac5106cf58bef51c8476653743)
---
 lang/csharp/Avro.ruleset                                       | 1 -
 lang/csharp/src/apache/main/File/DataFileReader.cs             | 2 +-
 lang/csharp/src/apache/main/File/DeflateCodec.cs               | 2 +-
 lang/csharp/src/apache/main/File/NullCodec.cs                  | 2 +-
 lang/csharp/src/apache/main/Generic/GenericDatumReader.cs      | 2 +-
 lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs      | 4 ++--
 lang/csharp/src/apache/main/Generic/GenericWriter.cs           | 4 ++--
 lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs | 2 +-
 lang/csharp/src/apache/main/IO/BinaryEncoder.cs                | 2 +-
 lang/csharp/src/apache/main/Protocol/Protocol.cs               | 6 +++---
 lang/csharp/src/apache/main/Schema/Field.cs                    | 2 +-
 lang/csharp/src/apache/main/Schema/RecordSchema.cs             | 2 +-
 lang/csharp/src/apache/main/Schema/Schema.cs                   | 2 +-
 lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs    | 2 +-
 lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs    | 4 ++--
 lang/csharp/src/apache/main/Specific/SpecificWriter.cs         | 4 ++--
 16 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 7029d96..329a5fc 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -95,7 +95,6 @@
     <Rule Id="SA1106" Action="Info" />
     <Rule Id="SA1107" Action="Info" />
     <Rule Id="SA1108" Action="Info" />
-    <Rule Id="SA1119" Action="Info" />
     <Rule Id="SA1121" Action="Info" />
     <Rule Id="SA1122" Action="Info" />
     <Rule Id="SA1128" Action="Info" />
diff --git a/lang/csharp/src/apache/main/File/DataFileReader.cs b/lang/csharp/src/apache/main/File/DataFileReader.cs
index 784bf10..d1f8452 100644
--- a/lang/csharp/src/apache/main/File/DataFileReader.cs
+++ b/lang/csharp/src/apache/main/File/DataFileReader.cs
@@ -239,7 +239,7 @@ namespace Avro.File
         /// <inheritdoc/>
         public bool PastSync(long position)
         {
-            return ((_blockStart >= position + DataFileConstants.SyncSize) || (_blockStart >= _stream.Length));
+            return (_blockStart >= position + DataFileConstants.SyncSize) || (_blockStart >= _stream.Length);
         }
 
         /// <inheritdoc/>
diff --git a/lang/csharp/src/apache/main/File/DeflateCodec.cs b/lang/csharp/src/apache/main/File/DeflateCodec.cs
index 77f9ee8..7ee1ade 100644
--- a/lang/csharp/src/apache/main/File/DeflateCodec.cs
+++ b/lang/csharp/src/apache/main/File/DeflateCodec.cs
@@ -76,7 +76,7 @@ namespace Avro.File
         {
             if (this == other)
                 return true;
-            return (this.GetType().Name == other.GetType().Name);
+            return this.GetType().Name == other.GetType().Name;
         }
 
         /// <inheritdoc/>
diff --git a/lang/csharp/src/apache/main/File/NullCodec.cs b/lang/csharp/src/apache/main/File/NullCodec.cs
index 873047d..875f679 100644
--- a/lang/csharp/src/apache/main/File/NullCodec.cs
+++ b/lang/csharp/src/apache/main/File/NullCodec.cs
@@ -52,7 +52,7 @@ namespace Avro.File
         {
             if (this == other)
                 return true;
-            return (this.GetType().Name == other.GetType().Name);
+            return this.GetType().Name == other.GetType().Name;
         }
 
         /// <inheritdoc/>
diff --git a/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs b/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
index 199453a..1edb765 100644
--- a/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
@@ -210,7 +210,7 @@ namespace Avro.Generic
 
             public void AddElements(object mapObj, int elements, ReadItem itemReader, Decoder decoder, bool reuse)
             {
-                var map = ((IDictionary<string, object>)mapObj);
+                var map = (IDictionary<string, object>)mapObj;
                 for (int i = 0; i < elements; i++)
                 {
                     var key = decoder.ReadString();
diff --git a/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs b/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs
index 94100bf..e7d1138 100644
--- a/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs
@@ -49,7 +49,7 @@ namespace Avro.Generic
         /// <inheritdoc/>
         protected override void EnsureRecordObject( RecordSchema recordSchema, object value )
         {
-            if( value == null || !( value is GenericRecord ) || !( ( value as GenericRecord ).Schema.Equals( recordSchema ) ) )
+            if( value == null || !( value is GenericRecord ) || ! ( value as GenericRecord ).Schema.Equals( recordSchema )  )
             {
                 throw TypeMismatch( value, "record", "GenericRecord" );
             }
@@ -66,7 +66,7 @@ namespace Avro.Generic
         {
             return (v,e) =>
                        {
-                            if( v == null || !(v is GenericEnum) || !((v as GenericEnum).Schema.Equals(es)))
+                            if( v == null || !(v is GenericEnum) || !(v as GenericEnum).Schema.Equals(es))
                                 throw TypeMismatch(v, "enum", "GenericEnum");
                             e.WriteEnum(es.Ordinal((v as GenericEnum ).Value));
                        };
diff --git a/lang/csharp/src/apache/main/Generic/GenericWriter.cs b/lang/csharp/src/apache/main/Generic/GenericWriter.cs
index 7a08b68..f2fb24a 100644
--- a/lang/csharp/src/apache/main/Generic/GenericWriter.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericWriter.cs
@@ -222,7 +222,7 @@ namespace Avro.Generic
         /// <param name="value">Ensure this object is a record</param>
         protected virtual void EnsureRecordObject(RecordSchema s, object value)
         {
-            if (value == null || !(value is GenericRecord) || !((value as GenericRecord).Schema.Equals(s)))
+            if (value == null || !(value is GenericRecord) || !(value as GenericRecord).Schema.Equals(s))
             {
                 throw TypeMismatch(value, "record", "GenericRecord");
             }
@@ -251,7 +251,7 @@ namespace Avro.Generic
         /// <param name="encoder">Encoder for serialization</param>
         protected virtual void WriteEnum(EnumSchema es, object value, Encoder encoder)
         {
-            if (value == null || !(value is GenericEnum) || !((value as GenericEnum).Schema.Equals(es)))
+            if (value == null || !(value is GenericEnum) || !(value as GenericEnum).Schema.Equals(es))
                 throw TypeMismatch(value, "enum", "GenericEnum");
             encoder.WriteEnum(es.Ordinal((value as GenericEnum).Value));
         }
diff --git a/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs b/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs
index 247a9ae..7b52721 100644
--- a/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs
+++ b/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs
@@ -445,7 +445,7 @@ namespace Avro.Generic
             /// <inheritdoc/>
             public void WriteMapValues(object map, WriteItem valueWriter, Encoder encoder)
             {
-                foreach (DictionaryEntry entry in ((IDictionary)map))
+                foreach (DictionaryEntry entry in (IDictionary)map)
                 {
                     encoder.StartItem();
                     encoder.WriteString(entry.Key.ToString());
diff --git a/lang/csharp/src/apache/main/IO/BinaryEncoder.cs b/lang/csharp/src/apache/main/IO/BinaryEncoder.cs
index 5a2b409..f09a7a6 100644
--- a/lang/csharp/src/apache/main/IO/BinaryEncoder.cs
+++ b/lang/csharp/src/apache/main/IO/BinaryEncoder.cs
@@ -106,7 +106,7 @@ namespace Avro.IO
         {
             long bits = BitConverter.DoubleToInt64Bits(value);
 
-            writeByte((byte)((bits) & 0xFF));
+            writeByte((byte)(bits & 0xFF));
             writeByte((byte)((bits >> 8) & 0xFF));
             writeByte((byte)((bits >> 16) & 0xFF));
             writeByte((byte)((bits >> 24) & 0xFF));
diff --git a/lang/csharp/src/apache/main/Protocol/Protocol.cs b/lang/csharp/src/apache/main/Protocol/Protocol.cs
index 94fa51c..51c672c 100644
--- a/lang/csharp/src/apache/main/Protocol/Protocol.cs
+++ b/lang/csharp/src/apache/main/Protocol/Protocol.cs
@@ -165,9 +165,9 @@ namespace Avro
             {
                 using (Newtonsoft.Json.JsonTextWriter writer = new Newtonsoft.Json.JsonTextWriter(sw))
                 {
-                    #if(DEBUG)
+#if DEBUG
                     writer.Formatting = Newtonsoft.Json.Formatting.Indented;
-                    #endif
+#endif
 
                     WriteJson(writer, new SchemaNames());
                     writer.Flush();
@@ -291,7 +291,7 @@ namespace Avro
         {
             int hash = Messages.Count;
             foreach (KeyValuePair<string, Message> pair in Messages)
-                hash += (pair.Key.GetHashCode() + pair.Value.GetHashCode());
+                hash += pair.Key.GetHashCode() + pair.Value.GetHashCode();
             return hash;
         }
     }
diff --git a/lang/csharp/src/apache/main/Schema/Field.cs b/lang/csharp/src/apache/main/Schema/Field.cs
index eef8d20..1d5bedb 100644
--- a/lang/csharp/src/apache/main/Schema/Field.cs
+++ b/lang/csharp/src/apache/main/Schema/Field.cs
@@ -213,7 +213,7 @@ namespace Avro
         {
             if (null == this.Props) return null;
             string v;
-            return (this.Props.TryGetValue(key, out v)) ? v : null;
+            return this.Props.TryGetValue(key, out v) ? v : null;
         }
 
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Schema/RecordSchema.cs b/lang/csharp/src/apache/main/Schema/RecordSchema.cs
index 3c6010b..c485f5d 100644
--- a/lang/csharp/src/apache/main/Schema/RecordSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/RecordSchema.cs
@@ -180,7 +180,7 @@ namespace Avro
             {
                 if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name");
                 Field field;
-                return (fieldLookup.TryGetValue(name, out field)) ? field : null;
+                return fieldLookup.TryGetValue(name, out field) ? field : null;
             }
         }
 
diff --git a/lang/csharp/src/apache/main/Schema/Schema.cs b/lang/csharp/src/apache/main/Schema/Schema.cs
index db0cb66..fe0729a 100644
--- a/lang/csharp/src/apache/main/Schema/Schema.cs
+++ b/lang/csharp/src/apache/main/Schema/Schema.cs
@@ -327,7 +327,7 @@ namespace Avro
         {
             if (null == this.Props) return null;
             string v;
-            return (this.Props.TryGetValue(key, out v)) ? v : null;
+            return this.Props.TryGetValue(key, out v) ? v : null;
         }
 
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs b/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs
index 2b98229..6de1b2e 100644
--- a/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs
+++ b/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs
@@ -227,7 +227,7 @@ namespace Avro.Specific
 
             public void AddElements(object mapObj, int elements, ReadItem itemReader, Decoder decoder, bool reuse)
             {
-                var map = ((IDictionary)mapObj);
+                var map = (IDictionary)mapObj;
                 for (int i = 0; i < elements; i++)
                 {
                     var key = decoder.ReadString();
diff --git a/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs b/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs
index f41849a..ebf1121 100644
--- a/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs
+++ b/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs
@@ -137,7 +137,7 @@ namespace Avro.Specific
                 case Schema.Type.Error:
                 case Schema.Type.Record:
                     return obj is ISpecificRecord &&
-                           (((obj as ISpecificRecord).Schema) as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
+                           ((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
                 case Schema.Type.Enumeration:
                     return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString());
                 case Schema.Type.Array:
@@ -148,7 +148,7 @@ namespace Avro.Specific
                     return false;   // Union directly within another union not allowed!
                 case Schema.Type.Fixed:
                     return obj is SpecificFixed &&
-                           (((obj as SpecificFixed).Schema) as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName);
+                           ((obj as SpecificFixed).Schema as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName);
                 default:
                     throw new AvroException("Unknown schema type: " + sc.Tag);
             }
diff --git a/lang/csharp/src/apache/main/Specific/SpecificWriter.cs b/lang/csharp/src/apache/main/Specific/SpecificWriter.cs
index 50fe46e..89f256b 100644
--- a/lang/csharp/src/apache/main/Specific/SpecificWriter.cs
+++ b/lang/csharp/src/apache/main/Specific/SpecificWriter.cs
@@ -207,7 +207,7 @@ namespace Avro.Specific
                 case Schema.Type.Error:
                 case Schema.Type.Record:
                     return obj is ISpecificRecord &&
-                           (((obj as ISpecificRecord).Schema) as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
+                           ((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName);
                 case Schema.Type.Enumeration:
                     return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString());
                 case Schema.Type.Array:
@@ -218,7 +218,7 @@ namespace Avro.Specific
                     return false;   // Union directly within another union not allowed!
                 case Schema.Type.Fixed:
                     return obj is SpecificFixed &&
-                           (((obj as SpecificFixed).Schema) as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName);
+                           ((obj as SpecificFixed).Schema as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName);
                 default:
                     throw new AvroException("Unknown schema type: " + sc.Tag);
             }


[avro] 09/17: AVRO-2454: Fix CA1307 - Specify StringComparison

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 94df7f9233a69defdfa34b19e065c4f45911b7ea
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 12:08:52 2019 -0400

    AVRO-2454: Fix CA1307 - Specify StringComparison
    
    (cherry picked from commit e6479eae59aa9d83d6effc7284e5a3821c5e8c14)
---
 lang/csharp/Avro.ruleset                              |  1 -
 lang/csharp/src/apache/main/File/DataFileWriter.cs    |  2 +-
 lang/csharp/src/apache/main/Generic/GenericEnum.cs    |  4 +++-
 lang/csharp/src/apache/main/Protocol/Message.cs       |  2 +-
 lang/csharp/src/apache/main/Protocol/Protocol.cs      |  6 ++++--
 lang/csharp/src/apache/main/Schema/EnumSchema.cs      |  9 ++++++++-
 lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs |  7 ++++++-
 lang/csharp/src/apache/main/Schema/Property.cs        | 10 +++++++---
 lang/csharp/src/apache/main/Schema/Schema.cs          |  7 ++++---
 9 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 329a5fc..1f12d7f 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -25,7 +25,6 @@
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
     <Rule Id="CA1062" Action="Info" />
-    <Rule Id="CA1307" Action="Info" />
     <Rule Id="CA1507" Action="Info" />
     <Rule Id="CA1707" Action="Info" />
     <Rule Id="CA1710" Action="Info" />
diff --git a/lang/csharp/src/apache/main/File/DataFileWriter.cs b/lang/csharp/src/apache/main/File/DataFileWriter.cs
index 897ef6e..234f205 100644
--- a/lang/csharp/src/apache/main/File/DataFileWriter.cs
+++ b/lang/csharp/src/apache/main/File/DataFileWriter.cs
@@ -107,7 +107,7 @@ namespace Avro.File
         /// <inheritdoc/>
         public bool IsReservedMeta(string key)
         {
-            return key.StartsWith(DataFileConstants.MetaDataReserved);
+            return key.StartsWith(DataFileConstants.MetaDataReserved, StringComparison.Ordinal);
         }
 
         /// <inheritdoc/>
diff --git a/lang/csharp/src/apache/main/Generic/GenericEnum.cs b/lang/csharp/src/apache/main/Generic/GenericEnum.cs
index d80ecff..1e81304 100644
--- a/lang/csharp/src/apache/main/Generic/GenericEnum.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericEnum.cs
@@ -57,7 +57,9 @@ namespace Avro.Generic
         public override bool Equals(object obj)
         {
             if (obj == this) return true;
-            return (obj != null && obj is GenericEnum) ? Value.Equals((obj as GenericEnum).Value) : false;
+            return (obj != null && obj is GenericEnum)
+                ? Value.Equals((obj as GenericEnum).Value, System.StringComparison.Ordinal)
+                : false;
         }
 
         /// <inheritdoc/>
diff --git a/lang/csharp/src/apache/main/Protocol/Message.cs b/lang/csharp/src/apache/main/Protocol/Message.cs
index 9df50ec..34edd0a 100644
--- a/lang/csharp/src/apache/main/Protocol/Message.cs
+++ b/lang/csharp/src/apache/main/Protocol/Message.cs
@@ -186,7 +186,7 @@ namespace Avro
           if (!(obj is Message)) return false;
 
           Message that = obj as Message;
-          return this.Name.Equals(that.Name) &&
+          return this.Name.Equals(that.Name, StringComparison.Ordinal) &&
                  this.Request.Equals(that.Request) &&
                  areEqual(this.Response, that.Response) &&
                  areEqual(this.Error, that.Error);
diff --git a/lang/csharp/src/apache/main/Protocol/Protocol.cs b/lang/csharp/src/apache/main/Protocol/Protocol.cs
index 51c672c..2665823 100644
--- a/lang/csharp/src/apache/main/Protocol/Protocol.cs
+++ b/lang/csharp/src/apache/main/Protocol/Protocol.cs
@@ -222,8 +222,10 @@ namespace Avro
 
             Protocol that = obj as Protocol;
 
-            return this.Name.Equals(that.Name) && this.Namespace.Equals(that.Namespace) &&
-                    TypesEquals(that.Types) && MessagesEquals(that.Messages);
+            return this.Name.Equals(that.Name, StringComparison.Ordinal)
+                && this.Namespace.Equals(that.Namespace, StringComparison.Ordinal)
+                && TypesEquals(that.Types)
+                && MessagesEquals(that.Messages);
         }
 
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Schema/EnumSchema.cs b/lang/csharp/src/apache/main/Schema/EnumSchema.cs
index 4344e41..f5b72e0 100644
--- a/lang/csharp/src/apache/main/Schema/EnumSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/EnumSchema.cs
@@ -178,7 +178,14 @@ namespace Avro
                 EnumSchema that = obj as EnumSchema;
                 if (SchemaName.Equals(that.SchemaName) && Count == that.Count)
                 {
-                    for (int i = 0; i < Count; i++) if (!Symbols[i].Equals(that.Symbols[i])) return false;
+                    for (int i = 0; i < Count; i++)
+                    {
+                        if (!Symbols[i].Equals(that.Symbols[i], StringComparison.Ordinal))
+                        {
+                            return false;
+                        }
+                    }
+
                     return areEqual(that.Props, this.Props);
                 }
             }
diff --git a/lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs b/lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs
index 703519c..13485d1 100644
--- a/lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs
+++ b/lang/csharp/src/apache/main/Schema/PrimitiveSchema.cs
@@ -45,7 +45,12 @@ namespace Avro
         public static PrimitiveSchema NewInstance(string type, PropertyMap props = null)
         {
             const string q = "\"";
-            if (type.StartsWith(q) && type.EndsWith(q)) type = type.Substring(1, type.Length - 2);
+            if (type.StartsWith(q, StringComparison.Ordinal)
+                && type.EndsWith(q, StringComparison.Ordinal))
+            {
+                type = type.Substring(1, type.Length - 2);
+            }
+
             switch (type)
             {
                 case "null":
diff --git a/lang/csharp/src/apache/main/Schema/Property.cs b/lang/csharp/src/apache/main/Schema/Property.cs
index 50ca739..8ffd6bf 100644
--- a/lang/csharp/src/apache/main/Schema/Property.cs
+++ b/lang/csharp/src/apache/main/Schema/Property.cs
@@ -15,9 +15,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+using System;
 using System.Collections.Generic;
-using Newtonsoft.Json.Linq;
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 
 namespace Avro
 {
@@ -61,7 +62,10 @@ namespace Avro
             string oldValue;
             if (TryGetValue(key, out oldValue))
             {
-                if (!oldValue.Equals(value)) throw new AvroException("Property cannot be overwritten: " + key);
+                if (!oldValue.Equals(value, StringComparison.Ordinal))
+                {
+                    throw new AvroException("Property cannot be overwritten: " + key);
+                }
             }
             else
                 Add(key, value);
@@ -100,7 +104,7 @@ namespace Avro
                 {
                     if (!that.ContainsKey(pair.Key))
                         return false;
-                    if (!pair.Value.Equals(that[pair.Key]))
+                    if (!pair.Value.Equals(that[pair.Key], StringComparison.Ordinal))
                         return false;
                 }
                 return true;
diff --git a/lang/csharp/src/apache/main/Schema/Schema.cs b/lang/csharp/src/apache/main/Schema/Schema.cs
index fe0729a..046151d 100644
--- a/lang/csharp/src/apache/main/Schema/Schema.cs
+++ b/lang/csharp/src/apache/main/Schema/Schema.cs
@@ -183,9 +183,9 @@ namespace Avro
                 {
                     string type = (string)jtype;
 
-                    if (type.Equals("array"))
+                    if (type.Equals("array", StringComparison.Ordinal))
                         return ArraySchema.NewInstance(jtok, props, names, encspace);
-                    if (type.Equals("map"))
+                    if (type.Equals("map", StringComparison.Ordinal))
                         return MapSchema.NewInstance(jtok, props, names, encspace);
 
                     Schema schema = PrimitiveSchema.NewInstance((string)type, props);
@@ -224,7 +224,8 @@ namespace Avro
 
             try
             {
-                bool IsArray = json.StartsWith("[") && json.EndsWith("]");
+                bool IsArray = json.StartsWith("[", StringComparison.Ordinal)
+                    && json.EndsWith("]", StringComparison.Ordinal);
                 JContainer j = IsArray ? (JContainer)JArray.Parse(json) : (JContainer)JObject.Parse(json);
 
                 return ParseJson(j, names, encspace);


[avro] 04/17: AVRO-2454: Fix CA1063 - Implement IDisposable correctly

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2f85a47e2a084f8db7f5914108859f4f2530598e
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:32:49 2019 -0400

    AVRO-2454: Fix CA1063 - Implement IDisposable correctly
    
    (cherry picked from commit 61e56249baa8aeb63ac4ce990ac595189e7282b4)
---
 lang/csharp/Avro.ruleset                           |  2 --
 lang/csharp/src/apache/main/File/DataFileReader.cs | 12 ++++++++++++
 lang/csharp/src/apache/main/File/DataFileWriter.cs | 12 ++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 3dfafe0..e883235 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -22,7 +22,6 @@
     We disabled these rules initially to get the code analyzers installed in the project.
     -->
     <Rule Id="CA1062" Action="Info" />
-    <Rule Id="CA1063" Action="Info" />
     <Rule Id="CA1303" Action="Info" />
     <Rule Id="CA1305" Action="Info" />
     <Rule Id="CA1307" Action="Info" />
@@ -35,7 +34,6 @@
     <Rule Id="CA1721" Action="Info" />
     <Rule Id="CA1724" Action="Info" />
     <Rule Id="CA1801" Action="Info" />
-    <Rule Id="CA1816" Action="Info" />
     <Rule Id="CA1819" Action="Info" />
     <Rule Id="CA1820" Action="Info" />
     <Rule Id="CA1822" Action="Info" />
diff --git a/lang/csharp/src/apache/main/File/DataFileReader.cs b/lang/csharp/src/apache/main/File/DataFileReader.cs
index 61156fc..e93d8b1 100644
--- a/lang/csharp/src/apache/main/File/DataFileReader.cs
+++ b/lang/csharp/src/apache/main/File/DataFileReader.cs
@@ -300,6 +300,18 @@ namespace Avro.File
         /// <inheritdoc/>
         public void Dispose()
         {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Releases resources associated with this <see cref="DataFileReader{T}"/>.
+        /// </summary>
+        /// <param name="disposing">
+        /// True if called from <see cref="Dispose()"/>; false otherwise.
+        /// </param>
+        protected virtual void Dispose(bool disposing)
+        {
             _stream.Close();
         }
 
diff --git a/lang/csharp/src/apache/main/File/DataFileWriter.cs b/lang/csharp/src/apache/main/File/DataFileWriter.cs
index fc666cf..897ef6e 100644
--- a/lang/csharp/src/apache/main/File/DataFileWriter.cs
+++ b/lang/csharp/src/apache/main/File/DataFileWriter.cs
@@ -327,6 +327,18 @@ namespace Avro.File
         /// <inheritdoc/>
         public void Dispose()
         {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Releases resources associated with this <see cref="DataFileWriter{T}"/>.
+        /// </summary>
+        /// <param name="disposing">
+        /// True if called from <see cref="Dispose()"/>; false otherwise.
+        /// </param>
+        protected virtual void Dispose(bool disposing)
+        {
             Close();
         }
     }


[avro] 15/17: AVRO-2454: Fix CA1715 - Identifiers should have correct prefix

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 408bd2c34ea93b8d497792c7a2852fb7033454c0
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 21:00:26 2019 -0400

    AVRO-2454: Fix CA1715 - Identifiers should have correct prefix
    
    (cherry picked from commit 2014d7d6f86ad0a48f801ef152dbc88ef208f620)
---
 lang/csharp/Avro.ruleset                                       | 1 -
 lang/csharp/src/apache/main/Generic/DatumReader.cs             | 2 ++
 lang/csharp/src/apache/main/Generic/DatumWriter.cs             | 2 ++
 lang/csharp/src/apache/main/Generic/GenericReader.cs           | 4 ++--
 lang/csharp/src/apache/main/Generic/GenericWriter.cs           | 8 ++++----
 lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs | 8 ++++----
 lang/csharp/src/apache/main/IO/Decoder.cs                      | 2 ++
 lang/csharp/src/apache/main/IO/Encoder.cs                      | 2 ++
 8 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 00e630d..4900e32 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -27,7 +27,6 @@
     <Rule Id="CA1062" Action="Info" />
     <Rule Id="CA1707" Action="Info" />
     <Rule Id="CA1710" Action="Info" />
-    <Rule Id="CA1715" Action="Info" />
     <Rule Id="CA1716" Action="Info" />
     <Rule Id="CA1720" Action="Info" />
     <Rule Id="CA1721" Action="Info" />
diff --git a/lang/csharp/src/apache/main/Generic/DatumReader.cs b/lang/csharp/src/apache/main/Generic/DatumReader.cs
index e1f4213..a8a2bbc 100644
--- a/lang/csharp/src/apache/main/Generic/DatumReader.cs
+++ b/lang/csharp/src/apache/main/Generic/DatumReader.cs
@@ -23,6 +23,8 @@ namespace Avro.Generic
     /// Defines the interface for an object that reads data of a schema.
     /// </summary>
     /// <typeparam name="T">Type of the in-memory data representation.</typeparam>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming",
+        "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")]
     public interface DatumReader<T>
     {
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Generic/DatumWriter.cs b/lang/csharp/src/apache/main/Generic/DatumWriter.cs
index dcf7993..be68365 100644
--- a/lang/csharp/src/apache/main/Generic/DatumWriter.cs
+++ b/lang/csharp/src/apache/main/Generic/DatumWriter.cs
@@ -23,6 +23,8 @@ namespace Avro.Generic
     /// Defines the interface for an object that writes data of a schema.
     /// </summary>
     /// <typeparam name="T">Type of the in-memory data representation.</typeparam>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming",
+        "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")]
     public interface DatumWriter<T>
     {
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Generic/GenericReader.cs b/lang/csharp/src/apache/main/Generic/GenericReader.cs
index 9c1a25e..b6813fa 100644
--- a/lang/csharp/src/apache/main/Generic/GenericReader.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericReader.cs
@@ -246,12 +246,12 @@ namespace Avro.Generic
         /// <summary>
         /// A generic function to read primitive types
         /// </summary>
-        /// <typeparam name="S">The .NET type to read</typeparam>
+        /// <typeparam name="T">The .NET type to read</typeparam>
         /// <param name="tag">The Avro type tag for the object on the stream</param>
         /// <param name="readerSchema">A schema compatible to the Avro type</param>
         /// <param name="reader">A function that can read the avro type from the stream</param>
         /// <returns>The primitive type just read</returns>
-        protected S Read<S>(Schema.Type tag, Schema readerSchema, Reader<S> reader)
+        protected T Read<T>(Schema.Type tag, Schema readerSchema, Reader<T> reader)
         {
             return reader();
         }
diff --git a/lang/csharp/src/apache/main/Generic/GenericWriter.cs b/lang/csharp/src/apache/main/Generic/GenericWriter.cs
index f2fb24a..5f439bb 100644
--- a/lang/csharp/src/apache/main/Generic/GenericWriter.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericWriter.cs
@@ -179,14 +179,14 @@ namespace Avro.Generic
         /// <summary>
         /// A generic method to serialize primitive Avro types.
         /// </summary>
-        /// <typeparam name="S">Type of the C# type to be serialized</typeparam>
+        /// <typeparam name="T">Type of the C# type to be serialized</typeparam>
         /// <param name="value">The value to be serialized</param>
         /// <param name="tag">The schema type tag</param>
         /// <param name="writer">The writer which should be used to write the given type.</param>
-        protected virtual void Write<S>(object value, Schema.Type tag, Writer<S> writer)
+        protected virtual void Write<T>(object value, Schema.Type tag, Writer<T> writer)
         {
-            if (!(value is S)) throw TypeMismatch(value, tag.ToString(), typeof(S).ToString());
-            writer((S)value);
+            if (!(value is T)) throw TypeMismatch(value, tag.ToString(), typeof(T).ToString());
+            writer((T)value);
         }
 
         /// <summary>
diff --git a/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs b/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs
index 7b52721..e4e96d3 100644
--- a/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs
+++ b/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs
@@ -117,14 +117,14 @@ namespace Avro.Generic
         /// <summary>
         /// A generic method to serialize primitive Avro types.
         /// </summary>
-        /// <typeparam name="S">Type of the C# type to be serialized</typeparam>
+        /// <typeparam name="TValue">Type of the C# type to be serialized</typeparam>
         /// <param name="value">The value to be serialized</param>
         /// <param name="tag">The schema type tag</param>
         /// <param name="writer">The writer which should be used to write the given type.</param>
-        protected void Write<S>(object value, Schema.Type tag, Writer<S> writer)
+        protected void Write<TValue>(object value, Schema.Type tag, Writer<TValue> writer)
         {
-            if (!(value is S)) throw TypeMismatch(value, tag.ToString(), typeof(S).ToString());
-            writer((S)value);
+            if (!(value is TValue)) throw TypeMismatch(value, tag.ToString(), typeof(TValue).ToString());
+            writer((TValue)value);
         }
 
 
diff --git a/lang/csharp/src/apache/main/IO/Decoder.cs b/lang/csharp/src/apache/main/IO/Decoder.cs
index 573a8dd..536c1e9 100644
--- a/lang/csharp/src/apache/main/IO/Decoder.cs
+++ b/lang/csharp/src/apache/main/IO/Decoder.cs
@@ -22,6 +22,8 @@ namespace Avro.IO
     /// Decoder is used to decode Avro data on a stream. There are methods to read the Avro types on the stream. There are also
     /// methods to skip items, which are usually more efficient than reading, on the stream.
     /// </summary>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming",
+        "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")]
     public interface Decoder
     {
         /// <summary>
diff --git a/lang/csharp/src/apache/main/IO/Encoder.cs b/lang/csharp/src/apache/main/IO/Encoder.cs
index e04f3eb..24d7381 100644
--- a/lang/csharp/src/apache/main/IO/Encoder.cs
+++ b/lang/csharp/src/apache/main/IO/Encoder.cs
@@ -22,6 +22,8 @@ namespace Avro.IO
     /// Defines the interface for a class that provies low-level support for serializing Avro
     /// values.
     /// </summary>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming",
+        "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")]
     public interface Encoder
     {
         /// <summary>


[avro] 02/17: AVRO-2454: Fix SA1600 - Elements should be documented

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f58a506f3d6f4a261523a1a1ce5873375589dbb8
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 11:23:08 2019 -0400

    AVRO-2454: Fix SA1600 - Elements should be documented
    
    (cherry picked from commit 21698b9baa331e0f2506acb4c1b5408c1b84f071)
---
 lang/csharp/Avro.ruleset                              | 1 -
 lang/csharp/src/apache/main/Specific/ObjectCreator.cs | 2 ++
 lang/csharp/stylecop.json                             | 7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 2a101e2..446f4a4 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -134,7 +134,6 @@
     <Rule Id="SA1516" Action="Info" />
     <Rule Id="SA1519" Action="Info" />
     <Rule Id="SA1520" Action="Info" />
-    <Rule Id="SA1600" Action="Info" />
     <Rule Id="SA1604" Action="Info" />
     <Rule Id="SA1606" Action="Info" />
     <Rule Id="SA1610" Action="Info" />
diff --git a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
index fe3f6ee..00a7f36 100644
--- a/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
+++ b/lang/csharp/src/apache/main/Specific/ObjectCreator.cs
@@ -75,6 +75,7 @@ namespace Avro.Specific
 
 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
 #pragma warning disable CA1034 // Nested types should not be visible
+#pragma warning disable SA1600 // Elements should be documented
         /// <summary>
         /// Obsolete: This will be removed from the public API in a future version.
         /// </summary>
@@ -117,6 +118,7 @@ namespace Avro.Specific
                 return !left.Equals(right);
             }
         }
+#pragma warning restore SA1600 // Elements should be documented
 #pragma warning restore CA1034 // Nested types should not be visible
 #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
 
diff --git a/lang/csharp/stylecop.json b/lang/csharp/stylecop.json
index 82e8819..8925591 100644
--- a/lang/csharp/stylecop.json
+++ b/lang/csharp/stylecop.json
@@ -3,7 +3,12 @@
   "settings": {
     "documentationRules": {
       "companyName": "Apache Software Foundation (ASF)",
-      "fileNamingConvention": "stylecop"
+      "fileNamingConvention": "stylecop",
+      "documentInterfaces": false,
+      "documentExposedElements": true,
+      "documentInternalElements": false,
+      "documentPrivateElements": false,
+      "documentPrivateFields": false
     },
     "indentation": {
       "indentationSize": 4,


[avro] 11/17: AVRO-2454: Fix SA1604 - ElementDocumentationMustHaveSummary

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 18f8107968c0699516d9a77653f397b5ad1680a1
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 15:22:05 2019 -0400

    AVRO-2454: Fix SA1604 - ElementDocumentationMustHaveSummary
    
    (cherry picked from commit 5b7fcf6d9a628e768410a369fd7773b46378052c)
---
 lang/csharp/Avro.ruleset                                  | 1 -
 lang/csharp/src/apache/main/Generic/GenericDatumReader.cs | 9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 0931157..9298422 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -133,7 +133,6 @@
     <Rule Id="SA1516" Action="Info" />
     <Rule Id="SA1519" Action="Info" />
     <Rule Id="SA1520" Action="Info" />
-    <Rule Id="SA1604" Action="Info" />
     <Rule Id="SA1606" Action="Info" />
     <Rule Id="SA1610" Action="Info" />
     <Rule Id="SA1611" Action="Info" />
diff --git a/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs b/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
index 1edb765..da33afd 100644
--- a/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
+++ b/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs
@@ -21,8 +21,13 @@ using Avro.IO;
 
 namespace Avro.Generic
 {
-    /// PreresolvingDatumReader for reading data to GenericRecord classes or primitives.
-    /// <see cref="PreresolvingDatumReader{T}">For more information about performance considerations for choosing this implementation</see>
+    /// <summary>
+    /// <see cref="PreresolvingDatumReader{T}"/> for reading data to <see cref="GenericRecord"/>
+    /// classes or primitives.
+    /// <see cref="PreresolvingDatumReader{T}">For more information about performance considerations
+    /// for choosing this implementation</see>.
+    /// </summary>
+    /// <typeparam name="T">Type to deserialize data into.</typeparam>
     public class GenericDatumReader<T> : PreresolvingDatumReader<T>
     {
         /// <summary>


[avro] 13/17: AVRO-2454: Fix SA1610 - PropertyDocumentationMustHaveValueText

Posted by bl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f5cfefeb440cf56a42bdce80740b2e0b7aa0f2f5
Author: Brian Lachniet <bl...@gmail.com>
AuthorDate: Sun Aug 18 15:27:54 2019 -0400

    AVRO-2454: Fix SA1610 - PropertyDocumentationMustHaveValueText
    
    (cherry picked from commit eef00d72cc172896980e515bee1a84fa3a29aa3a)
---
 lang/csharp/Avro.ruleset | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset
index 221d03c..a624c32 100644
--- a/lang/csharp/Avro.ruleset
+++ b/lang/csharp/Avro.ruleset
@@ -133,7 +133,6 @@
     <Rule Id="SA1516" Action="Info" />
     <Rule Id="SA1519" Action="Info" />
     <Rule Id="SA1520" Action="Info" />
-    <Rule Id="SA1610" Action="Info" />
     <Rule Id="SA1611" Action="Info" />
     <Rule Id="SA1614" Action="Info" />
     <Rule Id="SA1615" Action="Info" />