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

How can i disable injector in debug mode, debug very trouble with injected class. #104

Closed
kargencW opened this issue Sep 20, 2019 · 4 comments
Assignees
Milestone

Comments

@kargencW
Copy link

kargencW commented Sep 20, 2019

Add MSBuild option to disable aspect injector entirely.

@pamidur
Copy link
Owner

pamidur commented Sep 20, 2019

Hi, for now there is no way to disable injections entirely. And this would be good enhancement!

For now you can disable on per injections basis or per aspect bassis:

    [Aspect(Scope.Global)]
// Disable all [Log] injections
#if !DEBUG
    [Injection(typeof(Log))]
#endif
    class Log : Attribute
    {
        [Advice(Kind.Before)]
        public void LogCall([Argument(Source.Name)] string name)
        {
            Console.WriteLine($"Calling {name}");
        }
    }
     
    class Program
    {
// Disable only this particular injection
#if !DEBUG
        [Log]
#endif
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }

@pamidur pamidur added this to the 2.3 milestone Sep 20, 2019
@pamidur pamidur self-assigned this Sep 20, 2019
@kargencW
Copy link
Author

kargencW commented Oct 1, 2019

thank you very much

@kargencW kargencW closed this as completed Oct 1, 2019
@pamidur
Copy link
Owner

pamidur commented Oct 1, 2019

I'll reopen this issue so I can track improvement of this feature: being able to disable AI completely

@pamidur
Copy link
Owner

pamidur commented Oct 4, 2019

you can now use

  <PropertyGroup>
    <AspectInjectorEnabled>false</AspectInjectorEnabled>
  </PropertyGroup>

to completely disable AI for specific configurations

released in 2.2.2

@pamidur pamidur modified the milestones: 2.3, 2.2.2 Oct 4, 2019
@pamidur pamidur closed this as completed Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants