Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would be nice including [NoEnumeration] attribute #148

Open
kubaak opened this issue Oct 29, 2021 · 6 comments
Open

Would be nice including [NoEnumeration] attribute #148

kubaak opened this issue Oct 29, 2021 · 6 comments

Comments

@kubaak
Copy link

kubaak commented Oct 29, 2021

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:
@ardalis
Copy link
Owner

ardalis commented Oct 30, 2021

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

@kubaak
Copy link
Author

kubaak commented Nov 1, 2021

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
Copy link
Owner

ardalis commented Jan 18, 2022

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

@tiagojsrios
Copy link
Contributor

tiagojsrios commented Jan 29, 2022

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.

@ardalis
Copy link
Owner

ardalis commented Aug 1, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants