VS2010 Implement Generic Interface expansion doesn't use specified type
- by TJB
Using the release version of Visual Studio 2010 I think there's a difference in the "Implement Interface" expansion from VS2008
If I speicify an interface and implement it in a class as so:
public interface IRepository<T> where T : IModel
{
T Get<T>(int id);
void Update<T>();
int Add<T>(T item);
}
public class MockRepository : IRepository<MockUser>
{
// ...
}
Then use the "Implement Interface" expansion and get this:
public class MockRepository : IRepository<MockUser>
{
public T Get<T>(int id)
{
throw new NotImplementedException();
}
public void Update<T>()
{
throw new NotImplementedException();
}
public int Add<T>(T item)
{
throw new NotImplementedException();
}
}
Instead of what I expected
public class MockRepository : IRepository<MockUser>
{
public MockUser Get<MockUser>(int id)
{
throw new NotImplementedException();
}
public void Update<MockUser>()
{
throw new NotImplementedException();
}
public int Add<MockUser>(MockUser item)
{
throw new NotImplementedException();
}
}
The IDE uses the type variable name from the generic interface definition T instead of the specified concrete type MockUser.
Is this a bug? Or is something new just for VS2010 / .Net 4.0?