forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request github#12060 from michaelnebel/csharp11/nameof
C# 11: Nameof on attribute declarations.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
public class MyAttributeTestClass | ||
{ | ||
public class MyAttribute : Attribute | ||
{ | ||
public readonly string S; | ||
public MyAttribute(string s) => S = s; | ||
} | ||
|
||
[MyAttribute(nameof(T))] | ||
public void M1<T>(string x) { } | ||
|
||
[return: MyAttribute(nameof(y))] | ||
public string M2(string y) => y; | ||
|
||
public object M3([MyAttribute(nameof(z))] string z) => z; | ||
|
||
public object M4<S>([MyAttribute(nameof(S))] string z) => z; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
| NameofScope.cs:11:18:11:26 | nameof(...) | [My(...)] | T | | ||
| NameofScope.cs:14:26:14:34 | nameof(...) | [return: My(...)] | y | | ||
| NameofScope.cs:17:35:17:43 | nameof(...) | [My(...)] | z | | ||
| NameofScope.cs:19:38:19:46 | nameof(...) | [My(...)] | S | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import csharp | ||
|
||
query predicate nameof(NameOfExpr e, string parent, string v) { | ||
e.getFile().getStem() = "NameofScope" and | ||
e.getParent().toString() = parent and | ||
v = e.getValue() | ||
} |