Skip to content

Duplication With Overriding Methods #251

@JasonBock

Description

@JasonBock

To reproduce:

var code =
	"""
	using Rocks;
	using System;

	#nullable enable

	public class Criterion<T> : IEquatable<T>
	{
		public override int GetHashCode() => base.GetHashCode();
		public override bool Equals(object? obj) => base.Equals(obj);
		public bool Equals(T? other) => true;
	}

	public static class Test
	{
		public static void Generate()
		{
			var rock = Rock.Create<Criterion<object>>();
		}
	}
	""";

Errors:

error CS0462: The inherited members 'Criterion<T>.Equals(object?)' and 'Criterion<T>.Equals(T?)' have the same signature in type 'CreateExpectationsOfCriterionOfobjectExtensions.RockCriterionOfobject', so they cannot be overridden

This was found in AutoFixture.Kernel.Criterion<>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions