GuardClauses
GuardClauses copied to clipboard
Would be nice including [NoEnumeration] attribute
Guard.Against.Null There is [NoEnumeration] attribute for the input used in the method. Resharper siglalizes possibility of multiple enumeration eventhough the underlying method doesn't enumerate.
- .NET SDK Version: .net5 Steps to Reproduce:
This is fixed now in 3.3.0 - can you confirm? https://www.nuget.org/packages/Ardalis.GuardClauses/3.3.0
Unfortunately it is not working. But I have no idea why. When I define an extension method with JetBrainsNoEnumeration that all it does is calling underlying Guard.Against.Null I don't see multiple enumeration warning.


I'm not sure why that isn't working but I don't know that it's a problem in GuardClauses library.
From JetBrains documentation/blog, these attributes are designed to not be included in the final compiled assembly - by default.
You can read a full blog about it here.
If I understood correctly, in order to fix this issue you have the following options:
- Include the source code of the attributes. Resharper has a tool that copies the code to the clipboard, so we can easily create the class;
- Define the JETBRAINS_ANNOTATIONS symbol.
I believe the decision should be made by you. But, I don't mind help fixing this issue.
Ok, I reviewed the article and it seems like the right approach for me is to include the source of the annotation/attribute in my library so there's no dependency on any third party packages, and to mark it internal. The library shows how to get the required source code but I don't have the tooling to do so. So, if someone wants to either add the source to this conversation or make a PR with it added to this repo, that would help move this issue toward completion.
Olá @tiagojsrios I am considering to try out your suggestion for fixing this issue. Are you fine with it or you prefer to try out yourself? Regards