question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instance of advice attribute is created twice.

See original GitHub issue

Hi again 😃

Another issue from my side.

I’ve updated my project to use MrAdvice from v.2.0.16 to v2.8.5 and noticed strange thing - the actual advice attribute instance is created twice. To check this behavior just put some output log into advice attribute ctor and You’ll see this log twice. I declare advice this way:

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public class AdviceAsyncAttribute : Attribute, IMethodAsyncAdvice
{
	public AdviceAsyncAttribute()
	{
		Console.WriteLine("ctor AdviceAsyncAttribute");
	}

	public async Task Advise(MethodAsyncAdviceContext context)
	{
		Console.WriteLine("Before MethodAsync");
		await context.ProceedAsync();
		Console.WriteLine("After MethodAsync");
	}
}

This behavior is on Windows with .NET Framework.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
picrapcommented, Jan 27, 2020

Yes, there is no guarantee an attribute is created once (or twice). So if you want to store extra data related to instances, you can use introduced fields, they’re designed for it. More details at https://github.com/ArxOne/MrAdvice/wiki/IntroducingFields

1reaction
AlexanderButscommented, Apr 4, 2019

Sure, I’ll provide my example a little bit later 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring annotation AOP called twice
I annotate my spring boot controller some functions with a custom annotation for logging purpose. However, I find the before advice is executed ......
Read more >
Chapter 6. Aspect Oriented Programming with Spring
Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a...
Read more >
Stuck on borrowing the same variable twice? : r/rust
So I am trying to access an attribute in a vec of attributes, loop through those attributes, then call a mutable function in...
Read more >
pyqgis - QGIS plugin triggers function twice
I have a plugin with a function (triggered by a button) that selects a specific layer by name, then shows its attribute table....
Read more >
Common mistakes with React Testing Library
Advice: Avoid adding unnecessary or incorrect accessibility attributes. Not using @testing-library/user-event. Importance: medium // ❌ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found