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

Use NotNull and CallerArgumentExpression attributes from .NET 6 to reduce messages parameters #30

Open
lsolano opened this issue May 12, 2022 · 0 comments

Comments

@lsolano
Copy link
Owner

lsolano commented May 12, 2022

Is your feature request related to a problem? Please describe.

Argument name:
The following pattern is a litter verbose:

public sealed class Foo
{
  //For EVERY call we need to add namof ...
  public Foo(Bar bar) => MyBar = Arguments.NotNull(bar, nameof(bar));
  
  public Bar MyBar { get; }
}

Reduce Compiler Warnings:
Do use [return: NotNull] and [NotNull] for methods return and parameters respectively.

public static class Arguments
{
  [DebuggerStepThrough]
  [return: NotNull] //Add this attribute for every method to tell the compiler that returned values wont be null. 
  public static TParamType OrException<TParamType>(
    //Add NotNull to all parameters to declare that will be not-null if the method returns
    [NotNull] TParamType? value, ...
}

Describe the solution you'd like
Do add the described Attributes to all public methods corresponding parameters.

Describe alternatives you've considered
None.

Additional context
Take advantage of .NET 6 new features.

lsolano added a commit that referenced this issue May 12, 2022
1. Declare new desing on README.md
2. Version bump (3.x to 4.0.0-alpha)
3. Add net6.0 target framework.
lsolano added a commit that referenced this issue May 12, 2022
1. Remove deprecated methods
2. Rename multiple methods
3. Split methods with optional messages (overloads) in two
    with more explicit names.

BREAKING CHANGE: Remove deprecated methods from Arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant