Skip to content

Commit 369c456

Browse files
authored
Merge pull request github#2090 from hvitved/csharp/local-function-trap
C#: Use containing type instead of containing method in local function TRAP label
2 parents 6c87d75 + 8ba9414 commit 369c456

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/LocalFunction.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,11 @@ class LocalFunction : Method
1111
{
1212
}
1313

14-
Method ContainingMethod =>
15-
symbol.OriginalDefinition.ContainingSymbol is IMethodSymbol m
16-
? Method.Create(Context, m)
17-
: throw new InternalError(symbol, "Unable to determine local function's containing callable");
18-
1914
public override void WriteId(TextWriter trapFile)
2015
{
21-
trapFile.WriteSubId(ContainingMethod);
22-
trapFile.Write(".(");
16+
trapFile.WriteSubId(ContainingType);
17+
trapFile.Write(".");
2318
trapFile.WriteSubId(Location);
24-
trapFile.Write(')');
2519
if (symbol.IsGenericMethod && !IsSourceDeclaration)
2620
{
2721
trapFile.Write('<');

csharp/ql/test/library-tests/csharp7/CSharp7.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ int f8()
148148
return f9(1);
149149
}
150150

151-
{
151+
Action a = () => {
152152
int f9() => 0;
153-
}
153+
};
154154

155155
return f1(2);
156156
}

csharp/ql/test/library-tests/csharp7/LocalFunctions.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| CSharp7.cs:143:9:143:31 | f7 | f7 | Int32 | CSharp7.cs:130:5:156:5 | {...} | CSharp7.cs:143:9:143:31 | f7(...) | f7(int) |
66
| CSharp7.cs:145:9:149:9 | f8 | f8 | Int32 | CSharp7.cs:130:5:156:5 | {...} | CSharp7.cs:145:9:149:9 | f8(...) | f8() |
77
| CSharp7.cs:147:13:147:35 | f9 | f9 | Int32 | CSharp7.cs:146:9:149:9 | {...} | CSharp7.cs:147:13:147:35 | f9(...) | f9(int) |
8-
| CSharp7.cs:152:13:152:26 | f9 | f9 | Int32 | CSharp7.cs:151:9:153:9 | {...} | CSharp7.cs:152:13:152:26 | f9(...) | f9() |
8+
| CSharp7.cs:152:13:152:26 | f9 | f9 | Int32 | CSharp7.cs:151:26:153:9 | {...} | CSharp7.cs:152:13:152:26 | f9(...) | f9() |
99
| CSharp7.cs:160:9:160:24 | f | f | Int32 | CSharp7.cs:159:5:172:5 | {...} | CSharp7.cs:160:9:160:24 | f(...) | f() |
1010
| CSharp7.cs:160:9:160:24 | f | f | Int32 | CSharp7.cs:159:5:172:5 | {...} | CSharp7.cs:160:9:160:24 | f(...) | f() |
1111
| CSharp7.cs:161:9:161:25 | g | g | T | CSharp7.cs:159:5:172:5 | {...} | CSharp7.cs:161:9:161:25 | g(...) | g(T) |

csharp/ql/test/library-tests/csharp7/LocalVariables.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
| CSharp7.cs:123:16:123:18 | m13 | string |
3636
| CSharp7.cs:135:19:135:20 | f4 | Func<int> |
3737
| CSharp7.cs:139:24:139:25 | f5 | Func<int, int> |
38+
| CSharp7.cs:151:16:151:16 | a | Action |
3839
| CSharp7.cs:176:16:176:18 | src | string |
3940
| CSharp7.cs:181:13:181:17 | sink1 | string |
4041
| CSharp7.cs:182:13:182:17 | sink2 | string |

0 commit comments

Comments
 (0)