GuardClauses icon indicating copy to clipboard operation
GuardClauses copied to clipboard

Would be nice including [NoEnumeration] attribute

Open kubaak opened this issue 4 years ago • 6 comments

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:

kubaak avatar Oct 29 '21 13:10 kubaak

This is fixed now in 3.3.0 - can you confirm? https://www.nuget.org/packages/Ardalis.GuardClauses/3.3.0

ardalis avatar Oct 30 '21 19:10 ardalis

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.

image image

image

kubaak avatar Nov 01 '21 06:11 kubaak

I'm not sure why that isn't working but I don't know that it's a problem in GuardClauses library.

ardalis avatar Jan 18 '22 20:01 ardalis

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.

tiagojsrios avatar Jan 29 '22 14:01 tiagojsrios

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.

ardalis avatar Aug 01 '23 18:08 ardalis

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

pedroduarte0 avatar Oct 15 '23 10:10 pedroduarte0