Skip to content

Renaming could fail when implementing multiple interfaces with members of the same name #252

@wmjordan

Description

@wmjordan

Recently I found that the renamer reported failed to rename quite a few members in some complicated projects.

After some tracing, I found that the cause was that there were two interfaces which had a same member name, and two classes happened to implement both interfaces individually. When I removed the IName from one class, no warning any more.

You can reproduce the error with the following classes or the following assembly.
sample.zip

	public interface IName { string Name { get; } }
	public interface IOperator {
		string Name { get; }
		void Operate();
	}
	public interface IWorker : IName, IC
	{

	}
	public interface IC {
		void C(string x);
	}
	sealed class Operator : IC, IOperator, IName {
		public string Name { get; set; }

		public void C(string x) {
			throw new NotImplementedException();
		}

		void IOperator.Operate() {
			throw new NotImplementedException();
		}
	}
	class Worker
	{
		public void C(string x) {
			throw new NotImplementedException();
		}
	}
	sealed class Manager : Worker, IWorker, IOperator
	{
		public string Name { get; }

		public void Operate() {
			throw new NotImplementedException();
		}
	}

The warning message:

 [WARN] Failed to rename all targeted members, because the references are blocking each other.
Remaining definitions: 
• Original Name: ConsoleApp1.Manager::Name; Name Hash: 7FD14884
• Original Name: ConsoleApp1.Operator::get_Name; Name Hash: 80656335
• Original Name: ConsoleApp1.Manager::get_Name; Name Hash: 29F5020F
• Original Name: ConsoleApp1.Operator::Name; Name Hash: DC8BAEA4
• Original Name: ConsoleApp1.IName::get_Name; Name Hash: CC986802
• Original Name: ConsoleApp1.IOperator::get_Name; Name Hash: 47B3E33D
• Original Name: ConsoleApp1.IOperator::Name; Name Hash: 1112CB76
• Original Name: ConsoleApp1.IName::Name; Name Hash: 7B5602B1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions