pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
745 stars 112 forks source link

error AI_ERR0: Processing failure: System.Exception: Cannot resolve generic parameter #97

Closed LaborJos closed 4 years ago

LaborJos commented 5 years ago

Exception Message

29>  AspectInjector: Found 0 aspects, 262 injections
29>AspectInjector : error AI_ERR0: Processing failure: System.Exception: Cannot resolve generic parameter
29>     at FluentIL.Extensions.GenericProcessingExtension.ResolveGenericType(MemberReference member, TypeReference param)
29>     at System.Linq.Enumerable.SelectIListIterator`2.ToArray()
29>     at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
29>     at FluentIL.Extensions.GenericProcessingExtension.ParametrizeGenericInstance(MemberReference member, GenericInstanceType generic)
29>     at FluentIL.Extensions.GenericProcessingExtension.MakeCallReference(MemberReference member, FieldReference reference)
29>     at FluentIL.TypeMembers.Load(Cut cut, FieldReference field)
29>     at AspectInjector.Core.Extensions.FluentExtensions.LoadAspect(Cut cut, AspectDefinition aspect, MethodDefinition method, PointCut accessor)
29>     at AspectInjector.Core.Extensions.FluentExtensions.LoadAspect(Cut cut, AspectDefinition aspect)
29>     at AspectInjector.Core.Advice.Weavers.Processes.AdviceAroundProcess.<Execute>b__5_0(Cut e)
29>     at FluentIL.Cut.Here(PointCut pc)
29>     at FluentIL.MethodEditor.Instead(MethodBody body, PointCut action)
29>     at AspectInjector.Core.Processor.PatchAssembly(AssemblyDefinition assembly, Boolean optimize, Boolean verbose)
29>     at FluentIL.PatcherBase.Process(String assemblyFile, IAssemblyResolver resolver, Boolean optimize, Boolean verbose)
29>     at AspectInjector.Compiler.Execute(String filename, IReadOnlyList`1 references, Boolean optimize, Boolean verbose). Please submit an issue to https://github.com/pamidur/aspect-injector
29>AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors.

Code

namespace VM.ViewModels.Base
{
    using VM.Managed;
    using VM.ViewModels.Attributes;
    using VM.ViewModels.Pre;

    public class VariableViewModel : ExpressionViewModel<Variable>
    {
        public VariableViewModel(Identifier id, IDocumentViewModel parentDocument)
            : base(id, parentDocument)
        {
        }

        [AspectAttribute(nameof(Source))]
        public double Value { get; set; }
    }
}

Generic parameters are not used. However, the above error occurs.

pamidur commented 5 years ago

Hi, Wow, this is new generic-related bug. I thought they were fixed long ago. Thanks for the report. I'll be looking at it soon.

LaborJos commented 5 years ago

Hi, Wow, this is new generic-related bug. I thought they were fixed long ago. Thanks for the report. I'll be looking at it soon.

@pamidur I have confirmed that no errors occur in VS 2019.

pamidur commented 5 years ago

Thank you for checking. I'm going to look into this bug as soon I return from vacation. Sorry for the delay.

pamidur commented 5 years ago

I'm still working on it at this bug seem to be deeper than I thought. So it take time to fix it. Until then the workaround would be to used Scope.Global for your aspects

ColmBhandal commented 5 years ago

Thanks for this amazing tool. We are using Scope Global for now. We would make good use of the ability to do per instance for generic classes also!

pamidur commented 4 years ago

Blocked by https://github.com/jbevain/cecil/issues/639

pamidur commented 4 years ago

Fixed in https://github.com/pamidur/aspect-injector/releases/tag/2.2.7 @ColmBhandal you should be able to use Scope PerInstance now Sorry for such a long delay, the issue drills down to how (not obvious) mono.cecil works sometimes.

ColmBhandal commented 4 years ago

Thanks!

On Sat, 18 Jan 2020, 22:22 Oleksandr Hulyi, notifications@github.com wrote:

Fixed in https://github.com/pamidur/aspect-injector/releases/tag/2.2.7 @ColmBhandal https://github.com/ColmBhandal you should be able to use Scope PerInstance now Sorry for such a long delay, the issue drills down to how (not obvious) mono.cecil works sometimes.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pamidur/aspect-injector/issues/97?email_source=notifications&email_token=ADMQGKLQ3ZLWGYOCM7NHV7LQ6N6LJA5CNFSM4IAOF4NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJKDIBQ#issuecomment-575943686, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMQGKK3DS5YNC4XQ7P275DQ6N6LJANCNFSM4IAOF4NA .