Please do not focus on the poor overall design I am dealing with a C#, EF-driven API where the original programmers programmed everything synchronously which caused extremely poor performance. I converted everything to async 1:1, which created some design pattern issues.
One of the problems is that all mapper classes inherited directly from an interface, something like:
Interface IConvertThings<T,S>()
{
public Task<T> ConvertTo(S object);
public Task<T> ConvertFrom(T object);
}
A problem we were facing already was that we had multiple duplication of code where one of these would not have a value (i.e. you could ConvertTo but not ConvertFrom or vice versa). To resolve this, I created an abstract class for all of the other objects involved to inherit from:
public abstract class AConvertThings<T,S> : IConvertThings<T,S>
{
public Task<T> ConvertTo(S object) { throw new NotImplementedException(); }
public Task<S> ConvertFrom(T object) { throw new NotImplementedException(); }
}
Conversion classes all now inherit from AConvertThings. The intent was that if a method wasn't defined in the conversion class (with "new" to hide the original), the AConvertThings method we be called and report the error and let the developer know they've called an incomplete method on that Converter (as some only are supposed to go one way).
The problem I'm experiencing is that even with the new keyword on the inheriting classes, the AConvertThings class is being called at runtime, throwing the error when the inheriting classes have a fully complete stack.
public async new Task<TYPE> ConvertTo(OTHERTYPE object)
What am I overlooking?