MethodImplAttribute doesn't work with BeDecoratedWith
See original GitHub issueVersion: 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:
- [breaking] add capacity of finding the Implementation Flags to current
BeDecoratedWith
method - [non-braking] add a new assertion like
BeDecoratedWithImplementationFlags
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dennisdoomen
BeDecoratedWith
itself won’t be breaking, rather a fix. HoweverThatAreDecoratedWith
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 accessMethodImplAttributes
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?Thanks for another contribution @melchiork . They are very appreciated.