Skip to content

Commit

Permalink
Prevent Code Analysis to warn about "unused parameters" for operator …
Browse files Browse the repository at this point in the history
…weaving instruction (#105)
  • Loading branch information
BrunoJuchli authored and SimonCropp committed Aug 29, 2019
1 parent 43958cf commit 6f5a26f
Show file tree
Hide file tree
Showing 55 changed files with 224 additions and 106 deletions.
4 changes: 2 additions & 2 deletions AssemblyToProcess/ClassWithGenericBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class ClassWithGenericBase :
{
public int Prop { get; set; }

public static bool operator ==(ClassWithGenericBase left, ClassWithGenericBase right) => Operator.Weave();
public static bool operator !=(ClassWithGenericBase left, ClassWithGenericBase right) => Operator.Weave();
public static bool operator ==(ClassWithGenericBase left, ClassWithGenericBase right) => Operator.Weave(left, right);
public static bool operator !=(ClassWithGenericBase left, ClassWithGenericBase right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ClassWithGenericProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public class ClassWithGenericProperty
{
public GenericDependency<int> Prop { get; set; }

public static bool operator ==(ClassWithGenericProperty left, ClassWithGenericProperty right) => Operator.Weave();
public static bool operator !=(ClassWithGenericProperty left, ClassWithGenericProperty right) => Operator.Weave();
public static bool operator ==(ClassWithGenericProperty left, ClassWithGenericProperty right) => Operator.Weave(left, right);
public static bool operator !=(ClassWithGenericProperty left, ClassWithGenericProperty right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ClassWithIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public int this[int index]
set => X = index;
}

public static bool operator ==(ClassWithIndexer left, ClassWithIndexer right) => Operator.Weave();
public static bool operator !=(ClassWithIndexer left, ClassWithIndexer right) => Operator.Weave();
public static bool operator ==(ClassWithIndexer left, ClassWithIndexer right) => Operator.Weave(left, right);
public static bool operator !=(ClassWithIndexer left, ClassWithIndexer right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ClassWithNullable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class ClassWithNullable
{
public DateTime? NullableDate { get; set; }

public static bool operator ==(ClassWithNullable left, ClassWithNullable right) => Operator.Weave();
public static bool operator !=(ClassWithNullable left, ClassWithNullable right) => Operator.Weave();
public static bool operator ==(ClassWithNullable left, ClassWithNullable right) => Operator.Weave(left, right);
public static bool operator !=(ClassWithNullable left, ClassWithNullable right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ClassWithStaticProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class ClassWithStaticProperties

public static char V { get; set; }

public static bool operator ==(ClassWithStaticProperties left, ClassWithStaticProperties right) => Operator.Weave();
public static bool operator !=(ClassWithStaticProperties left, ClassWithStaticProperties right) => Operator.Weave();
public static bool operator ==(ClassWithStaticProperties left, ClassWithStaticProperties right) => Operator.Weave(left, right);
public static bool operator !=(ClassWithStaticProperties left, ClassWithStaticProperties right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/CustomEquals/CustomEquals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ int CustomGetHashCode()
return 42;
}

public static bool operator ==(CustomEquals left, CustomEquals right) => Operator.Weave();
public static bool operator !=(CustomEquals left, CustomEquals right) => Operator.Weave();
public static bool operator ==(CustomEquals left, CustomEquals right) => Operator.Weave(left, right);
public static bool operator !=(CustomEquals left, CustomEquals right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/CustomEquals/CustomGenericEquals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ int CustomGetHashCode()
return 42;
}

public static bool operator ==(CustomGenericEquals<T> left, CustomGenericEquals<T> right) => Operator.Weave();
public static bool operator !=(CustomGenericEquals<T> left, CustomGenericEquals<T> right) => Operator.Weave();
public static bool operator ==(CustomGenericEquals<T> left, CustomGenericEquals<T> right) => Operator.Weave(left, right);
public static bool operator !=(CustomGenericEquals<T> left, CustomGenericEquals<T> right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/CustomEquals/CustomGetHashCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ int CustomGetHashCodeMethod()
return 42;
}

public static bool operator ==(CustomGetHashCode left, CustomGetHashCode right) => Operator.Weave();
public static bool operator !=(CustomGetHashCode left, CustomGetHashCode right) => Operator.Weave();
public static bool operator ==(CustomGetHashCode left, CustomGetHashCode right) => Operator.Weave(left, right);
public static bool operator !=(CustomGetHashCode left, CustomGetHashCode right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/CustomEquals/CustomStructEquals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ int CustomGetHashCode()
return 42;
}

public static bool operator ==(CustomStructEquals left, CustomStructEquals right) => Operator.Weave();
public static bool operator !=(CustomStructEquals left, CustomStructEquals right) => Operator.Weave();
public static bool operator ==(CustomStructEquals left, CustomStructEquals right) => Operator.Weave(left, right);
public static bool operator !=(CustomStructEquals left, CustomStructEquals right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/EmptyClass.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Equals]
public class EmptyClass
{
public static bool operator ==(EmptyClass left, EmptyClass right) => Operator.Weave();
public static bool operator !=(EmptyClass left, EmptyClass right) => Operator.Weave();
public static bool operator ==(EmptyClass left, EmptyClass right) => Operator.Weave(left, right);
public static bool operator !=(EmptyClass left, EmptyClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/Enums/EnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public EnumClass(int normalEnum, int flagsEnum)
FlagsEnum = (FlagsEnum)flagsEnum;
}

public static bool operator ==(EnumClass left, EnumClass right) => Operator.Weave();
public static bool operator !=(EnumClass left, EnumClass right) => Operator.Weave();
public static bool operator ==(EnumClass left, EnumClass right) => Operator.Weave(left, right);
public static bool operator !=(EnumClass left, EnumClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/EqualsOrSubtypeClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public class EqualsOrSubtypeClass
{
public int A { get; set; }

public static bool operator ==(EqualsOrSubtypeClass left, EqualsOrSubtypeClass right) => Operator.Weave();
public static bool operator !=(EqualsOrSubtypeClass left, EqualsOrSubtypeClass right) => Operator.Weave();
public static bool operator ==(EqualsOrSubtypeClass left, EqualsOrSubtypeClass right) => Operator.Weave(left, right);
public static bool operator !=(EqualsOrSubtypeClass left, EqualsOrSubtypeClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ExactlyOfTypeClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public class ExactlyOfTypeClass
{
public int A { get; set; }

public static bool operator ==(ExactlyOfTypeClass left, ExactlyOfTypeClass right) => Operator.Weave();
public static bool operator !=(ExactlyOfTypeClass left, ExactlyOfTypeClass right) => Operator.Weave();
public static bool operator ==(ExactlyOfTypeClass left, ExactlyOfTypeClass right) => Operator.Weave(left, right);
public static bool operator !=(ExactlyOfTypeClass left, ExactlyOfTypeClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ExactlyTheSameTypeAsThisClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class ExactlyTheSameTypeAsThisClass
{
public int A { get; set; }

public static bool operator ==(ExactlyTheSameTypeAsThisClass left, ExactlyTheSameTypeAsThisClass right) => Operator.Weave();
public static bool operator !=(ExactlyTheSameTypeAsThisClass left, ExactlyTheSameTypeAsThisClass right) => Operator.Weave();
public static bool operator ==(ExactlyTheSameTypeAsThisClass left, ExactlyTheSameTypeAsThisClass right) => Operator.Weave(left, right);
public static bool operator !=(ExactlyTheSameTypeAsThisClass left, ExactlyTheSameTypeAsThisClass right) => Operator.Weave(left, right);
}

public class ExactlyTheSameTypeAsThisSubClass : ExactlyTheSameTypeAsThisClass
Expand Down
4 changes: 2 additions & 2 deletions AssemblyToProcess/GenericClass/GenericClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public int A

public IEnumerable<T> B { get; set; }

public static bool operator ==(GenericClass<T> left, GenericClass<T> right) => Operator.Weave();
public static bool operator !=(GenericClass<T> left, GenericClass<T> right) => Operator.Weave();
public static bool operator ==(GenericClass<T> left, GenericClass<T> right) => Operator.Weave(left, right);
public static bool operator !=(GenericClass<T> left, GenericClass<T> right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GenericClass/GenericClassBaseClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public abstract class GenericClassBaseClass
{
public int C { get; set; }

public static bool operator ==(GenericClassBaseClass left, GenericClassBaseClass right) => Operator.Weave();
public static bool operator !=(GenericClassBaseClass left, GenericClassBaseClass right) => Operator.Weave();
public static bool operator ==(GenericClassBaseClass left, GenericClassBaseClass right) => Operator.Weave(left, right);
public static bool operator !=(GenericClassBaseClass left, GenericClassBaseClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GenericClass/GenericClassNormalClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class GenericClassNormalClass :
{
public int D { get; set; }

public static bool operator ==(GenericClassNormalClass left, GenericClassNormalClass right) => Operator.Weave();
public static bool operator !=(GenericClassNormalClass left, GenericClassNormalClass right) => Operator.Weave();
public static bool operator ==(GenericClassNormalClass left, GenericClassNormalClass right) => Operator.Weave(left, right);
public static bool operator !=(GenericClassNormalClass left, GenericClassNormalClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GenericClass/GenericProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ static bool Z(T a, T b)
return Equals(a, b);
}

public static bool operator ==(GenericProperty<T> left, GenericProperty<T> right) => Operator.Weave();
public static bool operator !=(GenericProperty<T> left, GenericProperty<T> right) => Operator.Weave();
public static bool operator ==(GenericProperty<T> left, GenericProperty<T> right) => Operator.Weave(left, right);
public static bool operator !=(GenericProperty<T> left, GenericProperty<T> right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GenericClass/WithGenericParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class WithGenericParameter<T> :
{
public int X { get; set; }

public static bool operator ==(WithGenericParameter<T> left, WithGenericParameter<T> right) => Operator.Weave();
public static bool operator !=(WithGenericParameter<T> left, WithGenericParameter<T> right) => Operator.Weave();
public static bool operator ==(WithGenericParameter<T> left, WithGenericParameter<T> right) => Operator.Weave(left, right);
public static bool operator !=(WithGenericParameter<T> left, WithGenericParameter<T> right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GenericClass/WithoutGenericParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class WithoutGenericParameter :
{
public int Z { get; set; }

public static bool operator ==(WithoutGenericParameter left, WithoutGenericParameter right) => Operator.Weave();
public static bool operator !=(WithoutGenericParameter left, WithoutGenericParameter right) => Operator.Weave();
public static bool operator ==(WithoutGenericParameter left, WithoutGenericParameter right) => Operator.Weave(left, right);
public static bool operator !=(WithoutGenericParameter left, WithoutGenericParameter right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GuidClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class GuidClass
{
public Guid Key { get; set; }

public static bool operator ==(GuidClass left, GuidClass right) => Operator.Weave();
public static bool operator !=(GuidClass left, GuidClass right) => Operator.Weave();
public static bool operator ==(GuidClass left, GuidClass right) => Operator.Weave(left, right);
public static bool operator !=(GuidClass left, GuidClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/GuidError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
public class ReferenceObject :
NameObject
{
public static bool operator ==(ReferenceObject left, ReferenceObject right) => Operator.Weave();
public static bool operator !=(ReferenceObject left, ReferenceObject right) => Operator.Weave();
public static bool operator ==(ReferenceObject left, ReferenceObject right) => Operator.Weave(left, right);
public static bool operator !=(ReferenceObject left, ReferenceObject right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/IgnoreBaseClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class IgnoreBaseClass :
{
public int B { get; set; }

public static bool operator ==(IgnoreBaseClass left, IgnoreBaseClass right) => Operator.Weave();
public static bool operator !=(IgnoreBaseClass left, IgnoreBaseClass right) => Operator.Weave();
public static bool operator ==(IgnoreBaseClass left, IgnoreBaseClass right) => Operator.Weave(left, right);
public static bool operator !=(IgnoreBaseClass left, IgnoreBaseClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/IgnoredPropertiesClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public class IgnoredPropertiesClass
[IgnoreDuringEquals]
public int Y { get; set; }

public static bool operator ==(IgnoredPropertiesClass left, IgnoredPropertiesClass right) => Operator.Weave();
public static bool operator !=(IgnoredPropertiesClass left, IgnoredPropertiesClass right) => Operator.Weave();
public static bool operator ==(IgnoredPropertiesClass left, IgnoredPropertiesClass right) => Operator.Weave(left, right);
public static bool operator !=(IgnoredPropertiesClass left, IgnoredPropertiesClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/InheritedClass/BaseClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public class BaseClass
{
public int A { get; set; }

public static bool operator ==(BaseClass left, BaseClass right) => Operator.Weave();
public static bool operator !=(BaseClass left, BaseClass right) => Operator.Weave();
public static bool operator ==(BaseClass left, BaseClass right) => Operator.Weave(left, right);
public static bool operator !=(BaseClass left, BaseClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/InheritedClass/InheritedClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class InheritedClass :
{
public int B { get; set; }

public static bool operator ==(InheritedClass left, InheritedClass right) => Operator.Weave();
public static bool operator !=(InheritedClass left, InheritedClass right) => Operator.Weave();
public static bool operator ==(InheritedClass left, InheritedClass right) => Operator.Weave(left, right);
public static bool operator !=(InheritedClass left, InheritedClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/InheritedIgnoredPropertiesClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
public class InheritedIgnoredPropertiesClass :
IgnoredPropertiesClass
{
public static bool operator ==(InheritedIgnoredPropertiesClass left, InheritedIgnoredPropertiesClass right) => Operator.Weave();
public static bool operator !=(InheritedIgnoredPropertiesClass left, InheritedIgnoredPropertiesClass right) => Operator.Weave();
public static bool operator ==(InheritedIgnoredPropertiesClass left, InheritedIgnoredPropertiesClass right) => Operator.Weave(left, right);
public static bool operator !=(InheritedIgnoredPropertiesClass left, InheritedIgnoredPropertiesClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/IntArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ public class IntArray
{
public int[] Collection { get; set; }

public static bool operator ==(IntArray left, IntArray right) => Operator.Weave();
public static bool operator !=(IntArray left, IntArray right) => Operator.Weave();
public static bool operator ==(IntArray left, IntArray right) => Operator.Weave(left, right);
public static bool operator !=(IntArray left, IntArray right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/IntCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class IntCollection

public IEnumerable<int> Collection { get; set; }

public static bool operator ==(IntCollection left, IntCollection right) => Operator.Weave();
public static bool operator !=(IntCollection left, IntCollection right) => Operator.Weave();
public static bool operator ==(IntCollection left, IntCollection right) => Operator.Weave(left, right);
public static bool operator !=(IntCollection left, IntCollection right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/NestedClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class NestedClass

public NormalClass D { get; set; }

public static bool operator ==(NestedClass left, NestedClass right) => Operator.Weave();
public static bool operator !=(NestedClass left, NestedClass right) => Operator.Weave();
public static bool operator ==(NestedClass left, NestedClass right) => Operator.Weave(left, right);
public static bool operator !=(NestedClass left, NestedClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/NormalClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class NormalClass

public char V { get; set; }

public static bool operator ==(NormalClass left, NormalClass right) => Operator.Weave();
public static bool operator !=(NormalClass left, NormalClass right) => Operator.Weave();
public static bool operator ==(NormalClass left, NormalClass right) => Operator.Weave(left, right);
public static bool operator !=(NormalClass left, NormalClass right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/ObjectCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class ObjectCollection
{
public IEnumerable<object> Collection { get; set; }

public static bool operator ==(ObjectCollection left, ObjectCollection right) => Operator.Weave();
public static bool operator !=(ObjectCollection left, ObjectCollection right) => Operator.Weave();
public static bool operator ==(ObjectCollection left, ObjectCollection right) => Operator.Weave(left, right);
public static bool operator !=(ObjectCollection left, ObjectCollection right) => Operator.Weave(left, right);
}
4 changes: 2 additions & 2 deletions AssemblyToProcess/OnlyIntCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class OnlyIntCollection
{
public IEnumerable<int> Collection { get; set; }

public static bool operator ==(OnlyIntCollection left, OnlyIntCollection right) => Operator.Weave();
public static bool operator !=(OnlyIntCollection left, OnlyIntCollection right) => Operator.Weave();
public static bool operator ==(OnlyIntCollection left, OnlyIntCollection right) => Operator.Weave(left, right);
public static bool operator !=(OnlyIntCollection left, OnlyIntCollection right) => Operator.Weave(left, right);
}
6 changes: 3 additions & 3 deletions AssemblyToProcess/OnlyOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public override bool Equals(object obj)
return Value == 1 && second.Value == 2;
}

public static bool operator ==(OnlyOperator left, OnlyOperator right) => Operator.Weave();
public static bool operator !=(OnlyOperator left, OnlyOperator right) => Operator.Weave();
public static bool operator ==(OnlyOperator left, OnlyOperator right) => Operator.Weave(left, right);
public static bool operator !=(OnlyOperator left, OnlyOperator right) => Operator.Weave(left, right);
}

/// Reproducing https://github.com/Fody/Equals/issues/99
Expand All @@ -35,4 +35,4 @@ public bool CompareNormalClassForInequality()

return left != right;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Equals(DoNotAddEquals = true, DoNotAddGetHashCode = true)]
public class OnlyOperatorUsingWeavingInstructionOverloadingWithParameters
{
public int Value { get; set; }

public override bool Equals(object obj)
{
if (!(obj is OnlyOperatorUsingWeavingInstructionOverloadingWithParameters second))
{
return false;
}

return Value == 1 && second.Value == 2;
}

public static bool operator ==(OnlyOperatorUsingWeavingInstructionOverloadingWithParameters left, OnlyOperatorUsingWeavingInstructionOverloadingWithParameters right) => Operator.Weave(left, right);
public static bool operator !=(OnlyOperatorUsingWeavingInstructionOverloadingWithParameters left, OnlyOperatorUsingWeavingInstructionOverloadingWithParameters right) => Operator.Weave(left, right);
}
Loading

0 comments on commit 6f5a26f

Please sign in to comment.