From 923ea8e6042db6eddbd727ee303adc54ae58f4b9 Mon Sep 17 00:00:00 2001 From: Kyle Schoonover Date: Tue, 3 May 2022 11:54:08 -0700 Subject: [PATCH] AVRO-3499 Remove unnecessary suppressions (#1656) --- .../src/apache/main/Generic/DatumWriter.cs | 3 +-- lang/csharp/src/apache/main/IO/Decoder.cs | 2 -- lang/csharp/src/apache/main/IO/Encoder.cs | 2 -- .../src/apache/main/Protocol/Message.cs | 8 +++--- .../src/apache/main/Protocol/Protocol.cs | 9 +++---- .../src/apache/main/Schema/EnumSchema.cs | 8 +++--- lang/csharp/src/apache/main/Schema/Field.cs | 14 ++-------- .../src/apache/main/Schema/SchemaName.cs | 27 +++++++++---------- 8 files changed, 27 insertions(+), 46 deletions(-) diff --git a/lang/csharp/src/apache/main/Generic/DatumWriter.cs b/lang/csharp/src/apache/main/Generic/DatumWriter.cs index be6836537a..0b732d9d76 100644 --- a/lang/csharp/src/apache/main/Generic/DatumWriter.cs +++ b/lang/csharp/src/apache/main/Generic/DatumWriter.cs @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + using Avro.IO; namespace Avro.Generic @@ -23,8 +24,6 @@ namespace Avro.Generic /// Defines the interface for an object that writes data of a schema. /// /// Type of the in-memory data representation. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", - "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")] public interface DatumWriter { /// diff --git a/lang/csharp/src/apache/main/IO/Decoder.cs b/lang/csharp/src/apache/main/IO/Decoder.cs index 6270a4177a..1476b0e1a5 100644 --- a/lang/csharp/src/apache/main/IO/Decoder.cs +++ b/lang/csharp/src/apache/main/IO/Decoder.cs @@ -22,8 +22,6 @@ 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. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", - "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")] public interface Decoder { /// diff --git a/lang/csharp/src/apache/main/IO/Encoder.cs b/lang/csharp/src/apache/main/IO/Encoder.cs index ee26a75120..84a2099a19 100644 --- a/lang/csharp/src/apache/main/IO/Encoder.cs +++ b/lang/csharp/src/apache/main/IO/Encoder.cs @@ -22,8 +22,6 @@ namespace Avro.IO /// Defines the interface for a class that provides low-level support for serializing Avro /// values. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", - "CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")] public interface Encoder { /// diff --git a/lang/csharp/src/apache/main/Protocol/Message.cs b/lang/csharp/src/apache/main/Protocol/Message.cs index 732438c937..19cc61c84f 100644 --- a/lang/csharp/src/apache/main/Protocol/Message.cs +++ b/lang/csharp/src/apache/main/Protocol/Message.cs @@ -198,12 +198,10 @@ public override bool Equals(Object obj) /// public override int GetHashCode() { -#pragma warning disable CA1307 // Specify StringComparison return Name.GetHashCode() + -#pragma warning restore CA1307 // Specify StringComparison - Request.GetHashCode() + - (Response == null ? 0 : Response.GetHashCode()) + - (Error == null ? 0 : Error.GetHashCode()); + Request.GetHashCode() + + (Response == null ? 0 : Response.GetHashCode()) + + (Error == null ? 0 : Error.GetHashCode()); } /// diff --git a/lang/csharp/src/apache/main/Protocol/Protocol.cs b/lang/csharp/src/apache/main/Protocol/Protocol.cs index 1f5b541060..94ae1268a0 100644 --- a/lang/csharp/src/apache/main/Protocol/Protocol.cs +++ b/lang/csharp/src/apache/main/Protocol/Protocol.cs @@ -269,10 +269,8 @@ private bool MessagesEquals(IDictionary that) /// public override int GetHashCode() { -#pragma warning disable CA1307 // Specify StringComparison return Name.GetHashCode() + Namespace.GetHashCode() + -#pragma warning restore CA1307 // Specify StringComparison - GetTypesHashCode() + GetMessagesHashCode(); + GetTypesHashCode() + GetMessagesHashCode(); } /// @@ -295,9 +293,10 @@ private int GetMessagesHashCode() { int hash = Messages.Count; foreach (KeyValuePair pair in Messages) -#pragma warning disable CA1307 // Specify StringComparison + { hash += pair.Key.GetHashCode() + pair.Value.GetHashCode(); -#pragma warning restore CA1307 // Specify StringComparison + } + return hash; } } diff --git a/lang/csharp/src/apache/main/Schema/EnumSchema.cs b/lang/csharp/src/apache/main/Schema/EnumSchema.cs index 295b73ebdc..225780310a 100644 --- a/lang/csharp/src/apache/main/Schema/EnumSchema.cs +++ b/lang/csharp/src/apache/main/Schema/EnumSchema.cs @@ -289,9 +289,11 @@ public override bool Equals(object obj) public override int GetHashCode() { int result = SchemaName.GetHashCode() + getHashCode(Props); -#pragma warning disable CA1307 // Specify StringComparison - foreach (string s in Symbols) result += 23 * s.GetHashCode(); -#pragma warning restore CA1307 // Specify StringComparison + foreach (string s in Symbols) + { + result += 23 * s.GetHashCode(); + } + return result; } diff --git a/lang/csharp/src/apache/main/Schema/Field.cs b/lang/csharp/src/apache/main/Schema/Field.cs index 0c3f7afcae..799f265b32 100644 --- a/lang/csharp/src/apache/main/Schema/Field.cs +++ b/lang/csharp/src/apache/main/Schema/Field.cs @@ -54,18 +54,10 @@ public enum SortOrder /// public readonly string Name; - /// - /// List of aliases for the field name - /// - [Obsolete("Use Aliases instead. This will be removed from the public API in a future version.")] - public readonly IList aliases; - -#pragma warning disable CS0618 // Type or member is obsolete /// /// List of aliases for the field name. /// - public IList Aliases => aliases; -#pragma warning restore CS0618 // Type or member is obsolete + public IList Aliases { get; private set; } /// /// Position of the field within its record. @@ -163,9 +155,7 @@ internal Field ChangePosition(int newPosition) Schema = schema ?? throw new ArgumentNullException("type", "type cannot be null."); Name = name; -#pragma warning disable CS0618 // Type or member is obsolete - this.aliases = aliases; -#pragma warning restore CS0618 // Type or member is obsolete + Aliases = aliases; Pos = pos; Documentation = doc; DefaultValue = defaultValue; diff --git a/lang/csharp/src/apache/main/Schema/SchemaName.cs b/lang/csharp/src/apache/main/Schema/SchemaName.cs index 11d22daa51..7716d7a55f 100644 --- a/lang/csharp/src/apache/main/Schema/SchemaName.cs +++ b/lang/csharp/src/apache/main/Schema/SchemaName.cs @@ -65,30 +65,29 @@ public class SchemaName /// namespace of the schema /// enclosing namespace of the schema /// documentation of the schema - public SchemaName(String name, String space, String encspace, String documentation) + public SchemaName(string name, string space, string encspace, string documentation) { if (name == null) { // anonymous - this.Name = this.Space = null; - this.EncSpace = encspace; // need to save enclosing namespace for anonymous types, so named types within the anonymous type can be resolved + Name = Space = null; + EncSpace = encspace; // need to save enclosing namespace for anonymous types, so named types within the anonymous type can be resolved } -#pragma warning disable CA1307 // Specify StringComparison else if (!name.Contains(".")) -#pragma warning restore CA1307 // Specify StringComparison { // unqualified name - this.Space = space; // use default space - this.Name = name; - this.EncSpace = encspace; + Space = space; // use default space + Name = name; + EncSpace = encspace; } else { string[] parts = name.Split('.'); - this.Space = string.Join(".", parts, 0, parts.Length - 1); - this.Name = parts[parts.Length - 1]; - this.EncSpace = encspace; + Space = string.Join(".", parts, 0, parts.Length - 1); + Name = parts[parts.Length - 1]; + EncSpace = encspace; } - this.Documentation = documentation; - fullName = string.IsNullOrEmpty(Namespace) ? this.Name : Namespace + "." + this.Name; + + Documentation = documentation; + fullName = string.IsNullOrEmpty(Namespace) ? Name : Namespace + "." + Name; } /// @@ -149,9 +148,7 @@ private static bool areEqual(object obj1, object obj2) /// public override int GetHashCode() { -#pragma warning disable CA1307 // Specify StringComparison return string.IsNullOrEmpty(Fullname) ? 0 : 29 * Fullname.GetHashCode(); -#pragma warning restore CA1307 // Specify StringComparison } }