Skip to content

Commit 57bbe02

Browse files
authored
Merge pull request #393 from calumgrant/cs/extractor/dynamic-type-name
C#: Minor extractor fixes
2 parents 536f3f3 + 9eed758 commit 57bbe02

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

change-notes/1.19/analysis-csharp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
## Changes to code extraction
2424

2525
* Arguments passed using `in` are now extracted.
26+
* Fix a bug where the `dynamic` type name was not extracted correctly in certain circumstances.
2627

2728
## Changes to QL libraries
2829

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static Expression Create(ExpressionNodeInfo info)
4343
{
4444
case SymbolKind.TypeParameter:
4545
case SymbolKind.NamedType:
46+
case SymbolKind.DynamicType:
4647
return TypeAccess.Create(info);
4748

4849
case SymbolKind.Property:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ class PropertyFactory : ICachedEntityFactory<IPropertySymbol, Property>
114114
public Property Create(Context cx, IPropertySymbol init) => new Property(cx, init);
115115
}
116116

117-
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
117+
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.PushesLabel;
118118
}
119119
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,24 @@ void F()
119119
new Point { x=1, y=2 };
120120
}
121121
}
122+
123+
class DynamicType
124+
{
125+
void F()
126+
{
127+
dynamic t = (dynamic)null;
128+
}
129+
}
130+
131+
class LocalVariableTags
132+
{
133+
Func<int, int> F = x => { int y=x; return y; };
134+
135+
private static Func<object, string, object> _getter => (o, n) =>
136+
{
137+
object x = o;
138+
return x;
139+
};
140+
}
141+
142+
// semmle-extractor-options: /r:System.Dynamic.Runtime.dll

csharp/ql/test/library-tests/regressions/TypeMentions.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@
5252
| Program.cs:114:16:114:19 | Nullable<Int32> |
5353
| Program.cs:117:5:117:8 | Void |
5454
| Program.cs:119:13:119:17 | Point |
55+
| Program.cs:125:5:125:8 | Void |
56+
| Program.cs:127:9:127:15 | dynamic |
57+
| Program.cs:127:22:127:28 | dynamic |
58+
| Program.cs:133:5:133:8 | Func<Int32,Int32> |
59+
| Program.cs:133:10:133:12 | Int32 |
60+
| Program.cs:133:15:133:17 | Int32 |
61+
| Program.cs:133:31:133:33 | Int32 |
62+
| Program.cs:135:20:135:23 | Func<Object,String,Object> |
63+
| Program.cs:135:25:135:30 | Object |
64+
| Program.cs:135:33:135:38 | String |
65+
| Program.cs:135:41:135:46 | Object |
66+
| Program.cs:137:10:137:15 | Object |

0 commit comments

Comments
 (0)