Skip to content

Duplicate Members in Shims #231

@JasonBock

Description

@JasonBock

To reproduce:

using Rocks;
using System;
using System.Linq;
using System.Collections.Generic;

public interface IReadOnlyProperty 
{ 
	Type ClrType { get; }
}

public interface IProperty
	: IReadOnlyProperty { }

public interface IReadOnlyKey
{
	bool IsPrimaryKey() => true;

	IReadOnlyList<IReadOnlyProperty> Properties { get; }
}

public interface IKey
	: IReadOnlyKey
{
	Type GetKeyType() => Properties.Count > 1 ? typeof(object[]) : Properties.First().ClrType;
			
	new IReadOnlyList<IProperty> Properties { get; }
}

public interface IRuntimeKey 
	: IKey { }

public static class Test
{
	public static void Go() => Rock.Create<IRuntimeKey>();
}

Here's the resulting diagnostic:

error CS0102: The type 'CreateExpectationsOfIRuntimeKeyExtensions.RockIRuntimeKey.ShimIKey55018818661256234156060084750235742359064106137' already contains a definition for 'Properties'

I think the shim generation is generating shims for every member on the given type. Not entirely sure about it. But the shim ends up having definitions for both Properties properties.

This was found on multiple types in Microsoft.EntityFrameworkCore - this example was derived from Microsoft.EntityFrameworkCore.Metadata.Internal.IRuntimeKey.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions