C#: Change reporting location of partial methods

This commit is contained in:
Tamas Vajk
2024-08-21 15:13:14 +02:00
parent 6103749188
commit 7c4733e88f
6 changed files with 11 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ namespace Semmle.Extraction.CSharp.Entities
public override Microsoft.CodeAnalysis.Location ReportingLocation =>
IsCompilerGeneratedDelegate()
? Symbol.ContainingType.GetSymbolLocation()
: Symbol.GetSymbolLocation();
: BodyDeclaringSymbol.GetSymbolLocation();
public override bool NeedsPopulation => base.NeedsPopulation || IsCompilerGeneratedDelegate();

View File

@@ -1,6 +1,6 @@
| Partial.cs:3:18:3:39 | PartialMethodWithBody1 | true |
| Partial.cs:4:18:4:42 | PartialMethodWithoutBody1 | true |
| Partial.cs:5:17:5:23 | Method2 | false |
| Partial.cs:10:18:10:39 | PartialMethodWithBody1 | true |
| Partial.cs:11:17:11:23 | Method3 | false |
| Partial.cs:16:18:16:42 | PartialMethodWithoutBody2 | true |
| Partial.cs:17:17:17:23 | Method4 | false |

View File

@@ -1,6 +1,6 @@
| Partial.cs:1:15:1:26 | TwoPartClass |
| Partial.cs:3:18:3:39 | PartialMethodWithBody1 |
| Partial.cs:4:18:4:42 | PartialMethodWithoutBody1 |
| Partial.cs:8:15:8:26 | TwoPartClass |
| Partial.cs:10:18:10:39 | PartialMethodWithBody1 |
| Partial.cs:14:15:14:33 | OnePartPartialClass |
| Partial.cs:16:18:16:42 | PartialMethodWithoutBody2 |

View File

@@ -1,10 +1,10 @@
| Partial.cs:1:15:1:26 | TwoPartClass | Partial.cs:3:18:3:39 | PartialMethodWithBody1 |
| Partial.cs:1:15:1:26 | TwoPartClass | Partial.cs:4:18:4:42 | PartialMethodWithoutBody1 |
| Partial.cs:1:15:1:26 | TwoPartClass | Partial.cs:5:17:5:23 | Method2 |
| Partial.cs:1:15:1:26 | TwoPartClass | Partial.cs:10:18:10:39 | PartialMethodWithBody1 |
| Partial.cs:1:15:1:26 | TwoPartClass | Partial.cs:11:17:11:23 | Method3 |
| Partial.cs:8:15:8:26 | TwoPartClass | Partial.cs:3:18:3:39 | PartialMethodWithBody1 |
| Partial.cs:8:15:8:26 | TwoPartClass | Partial.cs:4:18:4:42 | PartialMethodWithoutBody1 |
| Partial.cs:8:15:8:26 | TwoPartClass | Partial.cs:5:17:5:23 | Method2 |
| Partial.cs:8:15:8:26 | TwoPartClass | Partial.cs:10:18:10:39 | PartialMethodWithBody1 |
| Partial.cs:8:15:8:26 | TwoPartClass | Partial.cs:11:17:11:23 | Method3 |
| Partial.cs:14:15:14:33 | OnePartPartialClass | Partial.cs:16:18:16:42 | PartialMethodWithoutBody2 |
| Partial.cs:14:15:14:33 | OnePartPartialClass | Partial.cs:17:17:17:23 | Method4 |

View File

@@ -1,3 +1,3 @@
| Partial.cs:3:18:3:39 | PartialMethodWithBody1 | true |
| Partial.cs:4:18:4:42 | PartialMethodWithoutBody1 | false |
| Partial.cs:10:18:10:39 | PartialMethodWithBody1 | true |
| Partial.cs:16:18:16:42 | PartialMethodWithoutBody2 | false |

View File

@@ -1,13 +1,13 @@
Partial.cs:
# 1| [Class] TwoPartClass
# 3| 5: [Method] PartialMethodWithBody1
# 3| -1: [TypeMention] Void
# 10| 4: [BlockStmt] {...}
# 4| 6: [Method] PartialMethodWithoutBody1
# 4| 5: [Method] PartialMethodWithoutBody1
# 4| -1: [TypeMention] Void
# 5| 7: [Method] Method2
# 5| 6: [Method] Method2
# 5| -1: [TypeMention] Void
# 5| 4: [BlockStmt] {...}
# 10| 7: [Method] PartialMethodWithBody1
# 3| -1: [TypeMention] Void
# 10| 4: [BlockStmt] {...}
# 11| 8: [Method] Method3
# 11| -1: [TypeMention] Void
# 11| 4: [BlockStmt] {...}