Skip to content

Commit

Permalink
Remove JetBrains Annotations (#236)
Browse files Browse the repository at this point in the history
* Upgrade packages to latest and fix unit tests

* Remove all JetBrains annotations

* Lint solution using dotnet format with existing .editorconfig file
  • Loading branch information
Coop56 committed Oct 7, 2022
1 parent f930574 commit 2d576e0
Show file tree
Hide file tree
Showing 40 changed files with 3,068 additions and 3,118 deletions.
6 changes: 2 additions & 4 deletions src/GuardClauses/Guard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using JetBrainsNotNullAttribute = JetBrains.Annotations.NotNullAttribute;

namespace Ardalis.GuardClauses
namespace Ardalis.GuardClauses
{
/// <summary>
/// Simple interface to provide a generic mechanism to build guard clause extension methods from.
Expand All @@ -18,7 +16,7 @@ public class Guard : IGuardClause
/// <summary>
/// An entry point to a set of Guard Clauses.
/// </summary>
[JetBrainsNotNull] public static IGuardClause Against { get; } = new Guard();
public static IGuardClause Against { get; } = new Guard();

private Guard() { }
}
Expand Down
3 changes: 1 addition & 2 deletions src/GuardClauses/GuardAgainstExpressionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using JetBrainsNotNullAttribute = JetBrains.Annotations.NotNullAttribute;

namespace Ardalis.GuardClauses
{
Expand All @@ -15,7 +14,7 @@ public static partial class GuardClauseExtensions
/// <param name="message"></param>
/// <returns><paramref name="input"/> if the <paramref name="func"/> evaluates to true </returns>
/// <exception cref="ArgumentException"></exception>
public static T AgainstExpression<T>([JetBrainsNotNull] this IGuardClause guardClause, [JetBrainsNotNull] Func<T, bool> func, T input, string message) where T : struct
public static T AgainstExpression<T>(this IGuardClause guardClause, Func<T, bool> func, T input, string message) where T : struct
{
if (!func(input))
{
Expand Down
13 changes: 5 additions & 8 deletions src/GuardClauses/GuardAgainstInvalidFormatExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Text.RegularExpressions;
using JetBrainsInvokerParameterNameAttribute = JetBrains.Annotations.InvokerParameterNameAttribute;
using JetBrainsNotNullAttribute = JetBrains.Annotations.NotNullAttribute;
using JetBrainsRegexPattern = JetBrains.Annotations.RegexPatternAttribute;

namespace Ardalis.GuardClauses
{
Expand All @@ -18,10 +15,10 @@ public static partial class GuardClauseExtensions
/// <param name="message">Optional. Custom error message</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static string InvalidFormat([JetBrainsNotNull] this IGuardClause guardClause,
[JetBrainsNotNull] string input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
[JetBrainsNotNull][JetBrainsRegexPattern] string regexPattern,
public static string InvalidFormat(this IGuardClause guardClause,
string input,
string parameterName,
string regexPattern,
string? message = null)
{
var m = Regex.Match(input, regexPattern);
Expand All @@ -44,7 +41,7 @@ public static string InvalidFormat([JetBrainsNotNull] this IGuardClause guardCla
/// <typeparam name="T"></typeparam>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static T InvalidInput<T>([JetBrainsNotNull] this IGuardClause guardClause, [JetBrainsNotNull] T input, [JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName, Func<T, bool> predicate, string? message = null)
public static T InvalidInput<T>(this IGuardClause guardClause, T input, string parameterName, Func<T, bool> predicate, string? message = null)
{
if (!predicate(input))
{
Expand Down
142 changes: 70 additions & 72 deletions src/GuardClauses/GuardAgainstNegativeExtensions.cs

Large diffs are not rendered by default.

35 changes: 16 additions & 19 deletions src/GuardClauses/GuardAgainstNotFoundExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using JetBrainsInvokerParameterNameAttribute = JetBrains.Annotations.InvokerParameterNameAttribute;
using JetBrainsNoEnumerationAttribute = JetBrains.Annotations.NoEnumerationAttribute;
using JetBrainsNotNullAttribute = JetBrains.Annotations.NotNullAttribute;

namespace Ardalis.GuardClauses
{
Expand All @@ -19,15 +16,15 @@ public static partial class GuardClauseExtensions
/// <returns><paramref name="input" /> if the value is not null.</returns>
/// <exception cref="NotFoundException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static T NotFound<T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] string key,
[NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName)
public static T NotFound<T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] string key,
[NotNull][ValidatedNotNull] T input,
string parameterName)
#else
public static T NotFound<T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] string key,
[NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][CallerArgumentExpression("input")] string? parameterName = null)
public static T NotFound<T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] string key,
[NotNull][ValidatedNotNull] T input,
[CallerArgumentExpression("input")] string? parameterName = null)
#endif
{
guardClause.NullOrEmpty(key, nameof(key));
Expand All @@ -52,15 +49,15 @@ public static T NotFound<T>([JetBrainsNotNull] this IGuardClause guardClause,
/// <returns><paramref name="input" /> if the value is not null.</returns>
/// <exception cref="NotFoundException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static T NotFound<TKey, T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] TKey key,
[NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName) where TKey : struct
public static T NotFound<TKey, T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] TKey key,
[NotNull][ValidatedNotNull] T input,
string parameterName) where TKey : struct
#else
public static T NotFound<TKey, T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] TKey key,
[NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null) where TKey : struct
public static T NotFound<TKey, T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] TKey key,
[NotNull][ValidatedNotNull]T input,
[CallerArgumentExpression("input")] string? parameterName = null) where TKey : struct
#endif
{
guardClause.Null(key, nameof(key));
Expand Down
91 changes: 44 additions & 47 deletions src/GuardClauses/GuardAgainstNullExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using JetBrainsInvokerParameterNameAttribute = JetBrains.Annotations.InvokerParameterNameAttribute;
using JetBrainsNoEnumerationAttribute = JetBrains.Annotations.NoEnumerationAttribute;
using JetBrainsNotNullAttribute = JetBrains.Annotations.NotNullAttribute;

namespace Ardalis.GuardClauses
{
Expand All @@ -27,14 +24,14 @@ public static partial class GuardClauseExtensions
/// <param name="message">Optional. Custom error message</param>
/// <returns><paramref name="input" /> if the value is not null.</returns>
#if NETSTANDARD || NETFRAMEWORK
public static T Null<T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
public static T Null<T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] T input,
string parameterName,
string? message = null)
#else
public static T Null<T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
public static T Null<T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull]T input,
[CallerArgumentExpression("input")] string? parameterName = null,
string? message = null)
#endif
{
Expand Down Expand Up @@ -62,14 +59,14 @@ public static T Null<T>([JetBrainsNotNull] this IGuardClause guardClause,
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static string NullOrEmpty([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] string? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
public static string NullOrEmpty(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] string? input,
string parameterName,
string? message = null)
#else
public static string NullOrEmpty([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] string? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
public static string NullOrEmpty(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] string? input,
[CallerArgumentExpression("input")] string? parameterName = null,
string? message = null)
#endif
{
Expand All @@ -94,14 +91,14 @@ public static string NullOrEmpty([JetBrainsNotNull] this IGuardClause guardClaus
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static Guid NullOrEmpty([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] Guid? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
public static Guid NullOrEmpty(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] Guid? input,
string parameterName,
string? message = null)
#else
public static Guid NullOrEmpty([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] Guid? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
public static Guid NullOrEmpty(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] Guid? input,
[CallerArgumentExpression("input")] string? parameterName = null,
string? message = null)
#endif
{
Expand All @@ -126,14 +123,14 @@ public static Guid NullOrEmpty([JetBrainsNotNull] this IGuardClause guardClause,
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static IEnumerable<T> NullOrEmpty<T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] IEnumerable<T>? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
public static IEnumerable<T> NullOrEmpty<T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] IEnumerable<T>? input,
string parameterName,
string? message = null)
#else
public static IEnumerable<T> NullOrEmpty<T>([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] IEnumerable<T>? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
public static IEnumerable<T> NullOrEmpty<T>(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] IEnumerable<T>? input,
[CallerArgumentExpression("input")] string? parameterName = null,
string? message = null)
#endif
{
Expand All @@ -158,14 +155,14 @@ public static IEnumerable<T> NullOrEmpty<T>([JetBrainsNotNull] this IGuardClause
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static string NullOrWhiteSpace([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] string? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
public static string NullOrWhiteSpace(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] string? input,
string parameterName,
string? message = null)
#else
public static string NullOrWhiteSpace([JetBrainsNotNull] this IGuardClause guardClause,
[NotNull, JetBrainsNotNull][ValidatedNotNull] string? input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
public static string NullOrWhiteSpace(this IGuardClause guardClause,
[NotNull][ValidatedNotNull] string? input,
[CallerArgumentExpression("input")] string? parameterName = null,
string? message = null)
#endif
{
Expand All @@ -188,14 +185,14 @@ public static string NullOrWhiteSpace([JetBrainsNotNull] this IGuardClause guard
/// <returns><paramref name="input" /> if the value is not default for that type.</returns>
/// <exception cref="ArgumentException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static T Default<T>([JetBrainsNotNull] this IGuardClause guardClause,
[AllowNull, NotNull, JetBrainsNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
public static T Default<T>(this IGuardClause guardClause,
[AllowNull, NotNull] T input,
string parameterName,
string? message = null)
#else
public static T Default<T>([JetBrainsNotNull] this IGuardClause guardClause,
[AllowNull, NotNull, JetBrainsNotNull][JetBrainsNoEnumeration] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
public static T Default<T>(this IGuardClause guardClause,
[AllowNull, NotNull]T input,
[CallerArgumentExpression("input")] string? parameterName = null,
string? message = null)
#endif
{
Expand All @@ -222,16 +219,16 @@ public static T Default<T>([JetBrainsNotNull] this IGuardClause guardClause,
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentNullException"></exception>
#if NETSTANDARD || NETFRAMEWORK
public static T NullOrInvalidInput<T>([JetBrainsNotNull] this IGuardClause guardClause,
[JetBrainsNotNull] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
Func<T, bool> predicate,
public static T NullOrInvalidInput<T>(this IGuardClause guardClause,
T input,
string parameterName,
Func<T, bool> predicate,
string? message = null)
#else
public static T NullOrInvalidInput<T>([JetBrainsNotNull] this IGuardClause guardClause,
[JetBrainsNotNull] T input,
[JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
Func<T, bool> predicate,
public static T NullOrInvalidInput<T>(this IGuardClause guardClause,
T input,
string parameterName,
Func<T, bool> predicate,
string? message = null)
#endif
{
Expand Down
Loading

0 comments on commit 2d576e0

Please sign in to comment.