dotnetcore/AspectCore-Framework

和Scrutor一起使用的問題

Opened this issue · 2 comments

你好,想要请教一下
我在.net core专案中
使用Scutor套件做装饰者模式的DI
套用之后
就无法被AspectCore的属性拦截生成Proxy的class
想问你们有遇到过类似的问题吗
谢谢
專案連結 https://github.com/frank58246/AOE_Test
未命名
未命名1 1
未命名1
未命名2

I have the same issue as frank mentioned.

In addition, if you try to use DynamicProxyServiceProviderFactory with services.Decorate<>() method that is provided by Scrutor like so:

image

You'll be getting the following exception:

Unhandled exception. System.NotImplementedException: The method or operation is not implemented.
   at System.Reflection.MemberInfo.GetCustomAttributesData()
   at System.Reflection.MemberInfo.get_CustomAttributes()
   at AspectCore.Extensions.Reflection.MemberReflector`1..ctor(TMemberInfo reflectionInfo)
   at AspectCore.Extensions.Reflection.TypeReflector..ctor(TypeInfo typeInfo)
   at AspectCore.Extensions.Reflection.TypeReflector.<>c.<Create>b__0_0(TypeInfo info)
   at AspectCore.Extensions.Reflection.ReflectorCacheUtils`2.<>c__DisplayClass1_0.<GetOrAdd>b__0(TMemberInfo k)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at AspectCore.Extensions.Reflection.TypeReflector.Create(TypeInfo typeInfo)
   at AspectCore.Extensions.Reflection.ReflectorExtensions.GetReflector(TypeInfo typeInfo)
   at AspectCore.DynamicProxy.ReflectionUtils.IsNonAspect(TypeInfo typeInfo)
   at AspectCore.Extensions.DependencyInjection.ServiceValidator.TryValidate(ServiceDescriptor descriptor, Type& implementationType)
   at AspectCore.Extensions.DependencyInjection.ServiceCollectionBuildExtensions.WeaveDynamicProxyService(IServiceCollection services)
   at AspectCore.Extensions.DependencyInjection.ServiceCollectionBuildExtensions.BuildDynamicProxyProvider(IServiceCollection services)
   at AspectCore.Extensions.DependencyInjection.DynamicProxyServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
   at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()
   at Program.<Main>$(String[] args) in /Volumes/Projects/RND/VisualStudio/Demo/AOPDemo/Program.cs:line 24

Debug output:
image

I also encounter the same error, and this issue continues to occur until now. services.Decorate<>()
'System.NotImplementedException: 'The method or operation is not implemented.'