improve mockability of generated code
jeffMSFT opened this issue · 1 comments
jeffMSFT commented
The code generator emits a lot of boilerplate that could be captured in a base interface, and thus simplify the task of mocking a collection proxy. For example,
public interface IItemCollection : ProxyExtensions.IReadOnlyQueryableSetBase<Models.IItem>
{
Models.IItemFetcher GetById(System.Guid id);
Task<ProxyExtensions.IPagedCollection<Models.IItem>> ExecuteAsync();
Task AddItemAsync(Models.IItem item, System.Boolean deferSaveChanges = false);
Models.IItemFetcher this[System.Guid id] { get; }
}
...could become
// unique to my model
public partial interface IItemCollection : IEntityCollection<Models.IItem>
{
Models.IEntityFetcher<Models.IItem> GetById(System.Guid id);
}
// shared by all entity definitions, perhaps in ProxyExtensions assembly
public interface IEntityCollection<T> : ProxyExtensions.IReadOnlyQueryableSetBase<T>
{
Task<ProxyExtensions.IPagedCollection<T>> ExecuteAsync();
Task AddItemAsync(T item, System.Boolean deferSaveChanges = false);
Models.IEntityFetcher<T> this[System.Guid id] { get; }
}
public interface IEntityFetcher<TSource>
{
Task<T> ExecuteAsync();
T Expand<TTarget>(System.Linq.Expressions.Expression<System.Func<TSource, TTarget>> navigationPropertyAccessor);
}
Is the team amenable to this kind of refactoring?
MIchaelMainer commented
@jeffMSFT Thank you for the issue. Yes, we may be open to this at some point in the future. We just aren't in a position right now to take pull requests and review them.