Skip to content

Duplicate Member Generation #232

@JasonBock

Description

@JasonBock

To reproduce:

using Rocks;
#nullable enable
			
public abstract class ValueComparer
{
	public abstract object? Snapshot(object? instance);
}

public class ValueComparer<T>
	: ValueComparer
{
	public override object? Snapshot(object? instance) => null;

	public virtual T Snapshot(T instance) => default;
}

public class GeometryValueComparer<TGeometry>
	: ValueComparer<TGeometry> { }

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

This will create multiple diagnostics:

error CS8603: Possible null reference return.

error CS0462: The inherited members 'ValueComparer<T>.Snapshot(object?)' and 'ValueComparer<T>.Snapshot(T)' have the same signature in type 'CreateExpectationsOfGeometryValueComparerOfobjectExtensions.RockGeometryValueComparerOfobject', so they cannot be overridden

error CS8604: Possible null reference argument for parameter 'instance' in 'object ValueComparer<object>.Snapshot(object instance)'.

error CS0111: Type 'CreateExpectationsOfGeometryValueComparerOfobjectExtensions.RockGeometryValueComparerOfobject' already defines a member called 'Snapshot' with the same parameter types

error CS0462: The inherited members 'ValueComparer<T>.Snapshot(object?)' and 'ValueComparer<T>.Snapshot(T)' have the same signature in type 'CreateExpectationsOfGeometryValueComparerOfobjectExtensions.RockGeometryValueComparerOfobject', so they cannot be overridden
    
error CS0111: Type 'MethodExpectationsOfGeometryValueComparerOfobjectExtensions' already defines a member called 'Snapshot' with the same parameter types

The main ones are CS0462 and CS0111, though CS8604 should be addressed as well.

This was discovered on Microsoft.EntityFrameworkCore.ChangeTracking.GeometryValueComparer<>.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions