-
-
Notifications
You must be signed in to change notification settings - Fork 279
Description
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.