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.

MethodImplAttribute doesn't work with BeDecoratedWith

See original GitHub issue

Version: 5.1.2

When a method is decorated with MethodImplAttribute the assertion Should().BeDecoratedWith<MethodImplAttribute>() will not detect that and therefore produce a false negative. It’s because GetCustomAttributes method that is used behind the scenes will not get this attribute as per docs. The GetMethodImplementationFlags method has to be used. I can implement a patch for this, but I’m unsure which of two approaches would be better:

  1. [breaking] add capacity of finding the Implementation Flags to current BeDecoratedWith method
  2. [non-braking] add a new assertion like BeDecoratedWithImplementationFlags

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
melchiorkcommented, Feb 28, 2018

@dennisdoomen BeDecoratedWith itself won’t be breaking, rather a fix. However ThatAreDecoratedWith might lead to some changes in existing tests’ behavior. However it too can be considered a fix. So, this might not be breaking change after all. But the attributes itself is lost when compiling and in runtime we can only access MethodImplAttributes enum (docs). The attribute would have to be artificially “reconstructed” during assertion. Which can bring more problems. So probably the second approach would be more consistent with the framework itself. What do you think?

0reactions
jnyrupcommented, Mar 24, 2018

Thanks for another contribution @melchiork . They are very appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fluent Assertions PropertyInfo BeDecoratedWith
One possible answer is to wait a while and then get the latest version, as this issue seems to have been fixed recently...
Read more >
Add detail to transactions via XML (.NET)
New Relic .NET agent: Use an XML file to collect data from un-instrumented methods and to block instrumentation of methods you do not...
Read more >
C# Threads
Methods can be decorated with a MethodImpl attribute, synchronizing access much like a Win32 critical section. [MethodImpl (MethodImplOptions.Synchronized)]
Read more >
SafeHandle.cs source code in C# .NET - dotnetframework.org
Versioning; /* Problems addressed by the SafeHandle class: 1) Critical finalization ... In particular, any sub-methods you call should be decorated with a ......
Read more >
Interop in .NETMF - José Simões - WordPress.com
The stub methods must be implemented as extern and be decorated with the MethodImplAttribute attribute. Otherwise Visual Studio won't be ...
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