Skip to content

Issue With Getters, Setters, Inheritance, and new #227

@JasonBock

Description

@JasonBock

Here's the example:

public interface IMessagePublishTopology
{
	bool Exclude { get; }
}

public interface IMessagePublishTopologyConfigurator :
	IMessagePublishTopology
{
	new bool Exclude { set; }
}

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

This is subtle, but...note that IMessagePublishTopologyConfigurator adds a setter for Exclude but also adds new. What Rocks ends up implementing is just the setter. VS and SharpLab says you should do it this way:

public class X
    : IMessagePublishTopologyConfigurator
{
    public bool Exclude { set => throw new NotImplementedException(); }

    bool IMessagePublishTopology.Exclude => throw new NotImplementedException();
}

This was found with MassTransit.IMessagePublishTopologyConfigurator.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions