You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
if (aNext is null)
{
throw new ArgumentNullException(nameof(aNext));
}
with:
Guard.Argument(aNext, nameof(aNext)).NotNull();
But I get the following message:
CA1062 In externally visible method 'Task MyBehavior<TRequest, TResponse>.Handle(TRequest aRequest, CancellationToken aCancellationToken, RequestHandlerDelegate aNext)', validate parameter 'aNext' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code econdition asserting non-null argument.
It's late at night so maybe I'm just sleepy and don't understand?
The text was updated successfully, but these errors were encountered:
The actual method you pass aNext is Argument, you then pass the initialized ArgumentInfo<T> object to NotNull. So using "Argument" instead of "NotNull" may work. It would, however, consider every guard as a null guard, making the analysis somewhat less useful.
I'm not sure how I can statically prove to FxCop that the argument can't be null if the NotNull method returns (instead of throwing) on my end. Using Code Contracts may have worked but it's dead for some time now. I for one really wish it had taken off, I probably wouldn't develop Guard at the first place :/
I believe using C# 8's nullable reference types are the official way to go now. I understand it may not be feasible for you to just move your whole project to C# 8, so the best compromise I can think of is to use dotnet_code_quality.null_check_validation_methods = Argument if it works.
I'm open to suggestions and as always, thank you for using Guard.
I replace the following:
with:
But I get the following message:
CA1062 In externally visible method 'Task MyBehavior<TRequest, TResponse>.Handle(TRequest aRequest, CancellationToken aCancellationToken, RequestHandlerDelegate aNext)', validate parameter 'aNext' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code econdition asserting non-null argument.
It's late at night so maybe I'm just sleepy and don't understand?
The text was updated successfully, but these errors were encountered: