All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.csharp.S3898.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

Why is this an issue?

If you’re using a struct, it is likely because you’re interested in performance. But by failing to implement IEquatable<T> you’re loosing performance when comparisons are made because without IEquatable<T>, boxing and reflection are used to make comparisons.

Noncompliant code example

struct MyStruct  // Noncompliant
{
    public int Value { get; set; }
}

Compliant solution

struct MyStruct : IEquatable<MyStruct>
{
    public int Value { get; set; }

    public bool Equals(MyStruct other)
    {
        // ...
    }
}

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy