Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve mockability of generated code #137

Open
jeffMSFT opened this issue May 22, 2018 · 1 comment
Open

improve mockability of generated code #137

jeffMSFT opened this issue May 22, 2018 · 1 comment

Comments

@jeffMSFT
Copy link

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
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants