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

Unify method signatures among frameworks #337

Open
Ergamon opened this issue Feb 10, 2024 · 2 comments
Open

Unify method signatures among frameworks #337

Ergamon opened this issue Feb 10, 2024 · 2 comments

Comments

@Ergamon
Copy link
Contributor

Ergamon commented Feb 10, 2024

I am in the process of looking for a nice guard clause library using the newer feature of CallerArgumentExpressionAttribute.
It almost seemed I found it here. When I did my first tests on our current .NET 8 environment it looked perfect.

But today I started exchanging our old library with this one in one of our older solutions. Sadly for some reasons we cannot move this one away from .NET Framework. To my surprise suddenly all method signatures looked different.

My goal for our team is always to keep the differences among the solutions as small as possible. So a Guard Clause library working different is a no go.

Is there any particular reason why you are holding back this feature?

I mean all you have to do is add this to your project:

#if NETFRAMEWORK || NETSTANDARD2_0
namespace System.Runtime.CompilerServices
{
  [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
  internal sealed class CallerArgumentExpressionAttribute : Attribute
  {
    public CallerArgumentExpressionAttribute(string parameterName)
    {
      ParameterName = parameterName;
    }

    public string ParameterName { get; }
  }
}
#endif

and voila it works on older platforms.

@ardalis
Copy link
Owner

ardalis commented Feb 10, 2024

Sounds like a great idea! Are you looking to add a pull request?

@Ergamon
Copy link
Contributor Author

Ergamon commented Feb 10, 2024

Done. I created one.

If you accept it, there is then the question, if it is worth to have a special netstandard 2.1 version. As every .net version that can use 2.1 also can use 2.0. But I did not want to make more changes then necessary in a single pull request.

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

2 participants