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/04 00:22:37 UTC

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

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

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

    AVRO-2454: Fix CA1063 - Implement IDisposable correctly
---
 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();
         }
     }