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

Improve S2259: Add support for [NotNull] #6083

Closed
martin-strecker-sonarsource opened this issue Sep 13, 2022 · 1 comment
Closed

Improve S2259: Add support for [NotNull] #6083

martin-strecker-sonarsource opened this issue Sep 13, 2022 · 1 comment
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues.
Milestone

Comments

@martin-strecker-sonarsource
Copy link
Contributor

martin-strecker-sonarsource commented Sep 13, 2022

Throw helpers can be annoated with [NotNull]. This behaves exactly like the already supported [ValidatedNotNullAttribute]. This enables support for ArgumentNullException.ThrowIfNull, the upcoming ArgumentException.ThrowIfNullOrEmpty and any custom annotated Guard classes.

Attribute targets are:

ValidatedNotNullAttribute

Unknown.

System.Diagnostics.CodeAnalysis.NotNull

  • AttributeTargets.Field
  • AttributeTargets.Parameter
  • AttributeTargets.Property
  • AttributeTargets.ReturnValue

JetBrains.Annotations.NotNull

  • AttributeTargets.Class
  • AttributeTargets.Method
  • AttributeTargets.Property
  • AttributeTargets.Field
  • AttributeTargets.Event
  • AttributeTargets.Interface
  • AttributeTargets.Parameter
  • AttributeTargets.Delegate
  • AttributeTargets.GenericParameter
@martin-strecker-sonarsource martin-strecker-sonarsource added Type: Improvement Area: CFG/SE CFG and SE related issues. Area: C# C# rules related issues. labels Sep 13, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource added this to the 8.45 milestone Sep 13, 2022
@martin-strecker-sonarsource
Copy link
Contributor Author

see also #5729

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues.
Projects
None yet
Development

No branches or pull requests

2 participants