I have the following class and I am trying to create an interface for this.
However when I try refactor in VS2010. I get a message that: Could not
extract interface. The type does not contain any members that could be
extracted to an interface.
Is this related to my defining the class and/or method as static? What I
do need is to be able to get this data without having to create an instance
so that’s why I made it all static.
public static class DataSourceService
{
public static IEnumerable<DataSource> GetDataSources()
{
return new[]
{
new DataSource { Value = "0001", Text = "Development" },
new DataSource { Value = "0002", Text = "Production" }
};
}
}
You cannot have a static class with an interface, that’s why the refactor tool cannot extract one. You would need to turn it into an instance class with instance members in order to extract an interface.