Create extended-nameof-scope.md

This commit is contained in:
Julien Couvreur 2019-12-27 12:09:04 -08:00 committed by GitHub
parent 1cff098408
commit ce3319a984
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,26 @@
# Extended `nameof` scope
## Summary
Allow `nameof(parameter)` inside an attribute on a method or parameter.
For example:
- `[MyAttribute(nameof(parameter))] void M(int parameter) { }`
- `[MyAttribute(nameof(TParameter))] void M<TParameter>() { }`
- `void M(int parameter, [MyAttribute(nameof(parameter))] int other) { }`
## Motivation
Attributes like `NotNullWhen` or `CallerExpression` need to refer to parameters, but those parameters are currently not in scope.
## Detailed design
TODO
[Method parameters](https://github.com/dotnet/csharplang/blob/master/spec/classes.md#method-parameters)
[Simple names](https://github.com/dotnet/csharplang/blob/master/spec/expressions.md#simple-names)
[Scopes](https://github.com/dotnet/csharplang/blob/master/spec/basic-concepts.md#scopes)
## Related spec sections
- [Corresponding parameters](https://github.com/dotnet/csharplang/blob/master/spec/expressions.md#corresponding-parameters)