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

ArgumentException: Could not find method overriding method with nested generics #297

Closed
BitWizJason opened this issue Aug 22, 2017 · 7 comments
Labels
Milestone

Comments

@BitWizJason
Copy link

BitWizJason commented Aug 22, 2017

Visual Studio Enterprise 2017 Version 15.2 (26430.16) Release
Target framework: .NET Framework 4.6.1
Castle.Core (3.3.0)

System.ArgumentException occurred
  HResult=0x80070057
  Message=Could not find method overriding System.Threading.Tasks.Task`1[System.Collections.Generic.List`1[TEntity]] GetAllCache[TEntity,TEntityPrimaryKey](Abp.Domain.Repositories.IRepository`2[TEntity,TEntityPrimaryKey], System.String, System.Linq.Expressions.Expression`1[System.Func`2[TEntity,System.Object]][]) on type DES.Employees.EmployeesAppService. This is most likely a bug. Please report it.
  Source=Castle.Core
  StackTrace:
   at Castle.DynamicProxy.Internal.InvocationHelper.ObtainMethod(MethodInfo proxiedMethod, Type type)
   at Castle.DynamicProxy.Internal.InvocationHelper.GetMethodOnType(Type type, MethodInfo proxiedMethod)
   at Castle.DynamicProxy.Internal.InheritanceInvocation.get_MethodInvocationTarget()
   at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Abp.Auditing.AuditingInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Abp.Runtime.Validation.Interception.ValidationInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.EmployeesAppServiceProxy.GetAllCache[TEntity,TEntityPrimaryKey](IRepository`2 repository, String cacheName, Expression`1[] entityIncludes)
   at DES.Shared.AbstractCrudDESAppServiceBase.<GetAll>d__4`4.MoveNext() in \DES\src\DES.Application\Shared\AbstractCrudDESAppServiceBase.cs:line 101
@BitWizJason
Copy link
Author

Method Base Class:

    public virtual async Task<List<TEntity>> GetAllCache<TEntity, TEntityPrimaryKey>(IRepository<TEntity, TEntityPrimaryKey> repository, [CallerMemberName] string cacheName = "", params Expression<Func<TEntity, object>>[] entityIncludes)
        where TEntity : Entity<TEntityPrimaryKey>
    {
        return await CacheManager
            .GetCache<string, List<TEntity>>(this.GetMethodCacheName(cacheName))
            .GetAsync(AllCacheKey, async () => await repository.GetAllIncluding(entityIncludes).ToListAsync().ConfigureAwait(false))
            .ConfigureAwait(false);
    }

Method implementing class:

    public override async Task<List<TEntity>> GetAllCache<TEntity, TEntityPrimaryKey>(IRepository<TEntity, TEntityPrimaryKey> repository, [CallerMemberName] string cacheName = "",
        params Expression<Func<TEntity, object>>[] entityIncludes)
    {
        if (entityIncludes == null)
        {
            return await base.GetAllCache(repository, cacheName, 
                entity => (entity as Employee).User);
        }

        return await base.GetAllCache(repository, cacheName, entityIncludes);
    }

@BitWizJason
Copy link
Author

Verified issue still occurs in Castle.Core (4.1.1)

@jonorossi
Copy link
Member

@BitWizJason could you please provide a runnable test case, it doesn't need to use NUnit just create a ProxyGenerator.

It would be great if you can reduce the test to what causes the problem, i.e. is it because its async, the generic parameters, the first actual parameter being a generic, the parameter with a default value, the parameter with [CallerMemberName], or the params parameter.

@BitWizJason
Copy link
Author

@jonorossi Will do!

BitWizJason added a commit to BitWizJason/Core that referenced this issue Sep 19, 2017
…generic as a return type are inherited and overriden. This is in reference to issue castleproject#297
BitWizJason added a commit to BitWizJason/Core that referenced this issue Sep 19, 2017
…ds with the base method when they contain a nested generic as the return type. References issue castleproject#297
@BitWizJason
Copy link
Author

@jonorossi I created a pull request with test cases and a potential fix #303

@jonorossi jonorossi added bug and removed needs-repro labels Sep 20, 2017
@jonorossi jonorossi changed the title ArgumentException: Could not find method overriding method ArgumentException: Could not find method overriding method with nested generics Sep 20, 2017
@jonorossi
Copy link
Member

Thanks @BitWizJason, merged.

@jonorossi jonorossi added this to the vNext milestone Sep 21, 2017
@backjacklao
Copy link

This issue still occurs in Castle.Core (4.4.1)

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

No branches or pull requests

3 participants