I have a non-generic class with a generic method. Generic type on this method defines output type and can't be inferred from usage so I have to explicitly provide generic type. Sometimes this type is passed on from generic caller's method type parameter, but in one instance I have to explicitly provide it myself.
The problem is when I call my explicitly provided generic type method call it seems that it doesn't get executed and returns a completely irrelevant type. I can't debug into this call and get invalid results. But it doesn't break execution which is especially strange. When the same method is called from elsewhere where generic type is passed on from caller's generic method type, everything seems to work as per definition.
I'm completely lost what's going on.
My method definition in the interface (and is implemented later in the class):
TRecord Update<TRecord>(int recordId, int? categoryId, string categoryName, string title)
where TRecord : Record;
My Record
class is non-abstract and and there's only one type that inherits from it:
public class Record : ProtectedEntity
{
...
}
public class RelatedRecord<T> : Record
{
public IList<T> Related { get; private set; }
...
}
I'm calling my method doing this:
var record = myRepo.Update<Record>(...);
When execution gets to this line I hit F11 to debug into it, but execution just jumps to the next sentence. When I check my record
variable it's not of type Record
but rather System.String
, having the value of parameter categoryName
. This means that something does get executed but it's definitely not the body of my generic method.
The strange thing is that everywhere else the same call works as expected.
How can this be explained and what am I doing wrong?