ardalis / GuardClauses

A simple package with guard clause extensions.
MIT License
3.06k stars 270 forks source link

Would be nice including [NoEnumeration] attribute #148

Open kubaak opened 2 years ago

kubaak commented 2 years ago

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.

1. 2.

ardalis commented 2 years ago

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

kubaak commented 2 years ago

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

ardalis commented 2 years ago

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

tiagojsrios commented 2 years ago

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:

I believe the decision should be made by you. But, I don't mind help fixing this issue.

ardalis commented 1 year ago

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.

pedroduarte0 commented 1 year ago

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