Skip to content

Commit 8eeded5

Browse files
committed
C#: Handle nameof(A.B) where A.B is a nested namespace.
1 parent c8ffbf3 commit 8eeded5

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/MemberAccess.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ static Expression Create(ExpressionNodeInfo info, ExpressionSyntax expression, S
9292
case SymbolKind.Event:
9393
kind = ExprKind.EVENT_ACCESS;
9494
break;
95+
case SymbolKind.Namespace:
96+
kind = ExprKind.NAMESPACE_ACCESS;
97+
break;
9598
default:
9699
info.Context.ModelError(info.Node, "Unhandled symbol for member access");
97100
kind = ExprKind.UNKNOWN;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
| Program.cs:62:17:62:35 | nameof(...) | Program.cs:62:24:62:34 | access to method MethodGroup |
22
| Program.cs:63:13:63:50 | nameof(...) | Program.cs:63:20:63:49 | access to method MethodGroup |
33
| Program.cs:169:16:169:29 | nameof(...) | Program.cs:169:23:169:28 | access to namespace System |
4+
| Program.cs:169:33:169:62 | nameof(...) | Program.cs:169:40:169:61 | access to namespace Tasks |

csharp/ql/test/library-tests/regressions/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ unsafe class ArrayTypesTest
166166

167167
class NameofNamespace
168168
{
169-
string s = nameof(System);
169+
string s = nameof(System) + nameof(System.Threading.Tasks);
170170
}
171171

172172
class UsingDiscard

0 commit comments

Comments
 (0)