-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Test plan for CallerArgumentExpressionAttribute #52745
Comments
There is already Overload resolution will currently pick It could be tweaked to prefer the other overload only because it has caller member attribute, but that will make the language inconsistent. Another solution I can think of (which I'm not sure if it's good) is introducing a new language feature, a special attribute I can't think of other use cases of such a new language feature, so I don't think it's a great idea to introduce a whole language feature just for this? (Is there some easier way I'm missing? 😄) |
Make |
Probably a breaking change unfortunately. |
Consider existing code with an obsolete overload:
Now the question is, can this possibly make the overload resolution to pick another method where it already compiles without any error? that is, it's not ambiguous and it's not resolved to the obsolete method. I'm leaning towards no, it can't but I'm not completely sure. |
|
TODO
|
Open questions:
|
Open questions were answered in https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-06-14.md. |
FYI |
Proposal: dotnet/csharplang#287 Test plan: #52745 Addresses part of LDM notes: https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-06-14.md
TODO: #54355 (comment) |
Updated the test plan in preparation for review this afternoon. I went through and checked off all the boxes I could find tests for. |
Is it available? public static string CheckLength(this string value, [CallerArgumentExpression("value")] string parameterName = Empty)
{
}
string name = "";
name.CheckLength() The |
@jerviscui Yes it's available and You'll need to have the latest Visual Studio 2022 preview to use the feature. |
@Youssef1313 Thank you very much! And I'm about to try VS 2022. |
Proposal: dotnet/csharplang#287
Spec: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-10.0/caller-argument-expression.md
General Concerns
Semantics
this
parameterthis
parameterOpen issues:
CallerArgumentExpression
toDebug.Assert
and have that new overload get picked?FYI @Youssef1313
The text was updated successfully, but these errors were encountered: