Skip to content
Permalink
Browse files
AVRO-3499 Remove unnecessary suppressions (#1656)
  • Loading branch information
KyleSchoonover committed May 3, 2022
1 parent fda48f2 commit 923ea8e6042db6eddbd727ee303adc54ae58f4b9
Showing 8 changed files with 27 additions and 46 deletions.
@@ -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.
/// </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>
@@ -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.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming",
"CA1715:Identifiers should have correct prefix", Justification = "Maintain public API")]
public interface Decoder
{
/// <summary>
@@ -22,8 +22,6 @@ namespace Avro.IO
/// Defines the interface for a class that provides 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>
@@ -198,12 +198,10 @@ public override bool Equals(Object obj)
/// <returns></returns>
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());
}

/// <summary>
@@ -269,10 +269,8 @@ private bool MessagesEquals(IDictionary<string, Message> that)
/// <returns></returns>
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();
}

/// <summary>
@@ -295,9 +293,10 @@ private int GetMessagesHashCode()
{
int hash = Messages.Count;
foreach (KeyValuePair<string, Message> pair in Messages)
#pragma warning disable CA1307 // Specify StringComparison
{
hash += pair.Key.GetHashCode() + pair.Value.GetHashCode();
#pragma warning restore CA1307 // Specify StringComparison
}

return hash;
}
}
@@ -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;
}

@@ -54,18 +54,10 @@ public enum SortOrder
/// </summary>
public readonly string Name;

/// <summary>
/// List of aliases for the field name
/// </summary>
[Obsolete("Use Aliases instead. This will be removed from the public API in a future version.")]
public readonly IList<string> aliases;

#pragma warning disable CS0618 // Type or member is obsolete
/// <summary>
/// List of aliases for the field name.
/// </summary>
public IList<string> Aliases => aliases;
#pragma warning restore CS0618 // Type or member is obsolete
public IList<string> Aliases { get; private set; }

/// <summary>
/// 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;
@@ -65,30 +65,29 @@ public class SchemaName
/// <param name="space">namespace of the schema</param>
/// <param name="encspace">enclosing namespace of the schema</param>
/// <param name="documentation">documentation of the schema</param>
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;
}

/// <summary>
@@ -149,9 +148,7 @@ private static bool areEqual(object obj1, object obj2)
/// <inheritdoc/>
public override int GetHashCode()
{
#pragma warning disable CA1307 // Specify StringComparison
return string.IsNullOrEmpty(Fullname) ? 0 : 29 * Fullname.GetHashCode();
#pragma warning restore CA1307 // Specify StringComparison
}
}

0 comments on commit 923ea8e

Please sign in to comment.