You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several months ago, I reported #1175 and I think this may be related because it again involves subtyping with the use of the "new" keyword.
I have an interface (IRepository<T>) that defines a property (Foo Foo { get; set;}), and then a derived interface (IRepository<T, TK>) that redefines that property (Foo<T>). Next, I have a Service<T> class which takes a IRepository<T> in its constructor and sets its own Foo property from the repository property, then a derived Service<T, TK> class which takes a IRepository<T, TK> in its constructor and passes it to the base.
When creating a new instance of the Service<T, TK> class using a mocked IRepository<T, TK>, the Foo property is null, presumably the setter in the base class constructor uses the base interface's property definition, which is of type Foo and not Foo<T>.
Several months ago, I reported #1175 and I think this may be related because it again involves subtyping with the use of the "new" keyword.
I have an interface (
IRepository<T>
) that defines a property (Foo Foo { get; set;}
), and then a derived interface (IRepository<T, TK>
) that redefines that property (Foo<T>
). Next, I have aService<T>
class which takes aIRepository<T>
in its constructor and sets its ownFoo
property from the repository property, then a derivedService<T, TK>
class which takes aIRepository<T, TK>
in its constructor and passes it to the base.When creating a new instance of the
Service<T, TK>
class using a mockedIRepository<T, TK>
, theFoo
property is null, presumably the setter in the base class constructor uses the base interface's property definition, which is of typeFoo
and notFoo<T>
.Here is a fiddle that demonstrates the issue: https://dotnetfiddle.net/SDY3JZ
When using actual concrete classes, this all works fine, it's just the mock that has problems.
Thanks.
The text was updated successfully, but these errors were encountered: