-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Handle some BMN garbage types. #18894
Changes from all commits
5551aeb
9af170f
c2b835d
e835d8b
fc5a49e
3b764b0
d5ee93d
5c931fa
fb3ce46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ public class ExtractionContext | |
public ExtractorMode Mode { get; } | ||
public string OutputPath { get; } | ||
public IEnumerable<CompilationInfo> CompilationInfos { get; } | ||
public bool IsStandalone => Mode.HasFlag(ExtractorMode.Standalone); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need a public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it the value itself is written to trap outside this file (it is written to |
||
public bool IsBinaryLog => Mode.HasFlag(ExtractorMode.BinaryLog); | ||
|
||
/// <summary> | ||
/// Creates a new extractor instance for one compilation unit. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Broken type without a name. | ||
public class { } | ||
|
||
// Legal declaration, but we want don't want to use it. | ||
public class var { } | ||
|
||
public class C | ||
{ | ||
public string Prop { get; set; } | ||
} | ||
|
||
|
||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
C x1 = new C(); | ||
string y1 = x1.Prop; | ||
|
||
var x2 = new C(); // Has type `var` as this overrides the implicitly typed keyword `var`. | ||
var y2 = x2.Prop; // Unknown type as `x2` has type `var`. | ||
|
||
C2 x3 = new C2(); // Unknown type. | ||
var y3 = x3.Prop; // Unknown property of unknown type. | ||
|
||
string s = x1.Prop + x3.Prop; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
| BrokenTypes.cs:2:14:2:13 | call to constructor Object | object | ObjectType | | ||
| BrokenTypes.cs:5:14:5:16 | call to constructor Object | object | ObjectType | | ||
| BrokenTypes.cs:7:14:7:14 | call to constructor Object | object | ObjectType | | ||
| BrokenTypes.cs:13:14:13:20 | call to constructor Object | object | ObjectType | | ||
| BrokenTypes.cs:17:11:17:12 | access to local variable x1 | C | Class | | ||
| BrokenTypes.cs:17:11:17:22 | C x1 = ... | C | Class | | ||
| BrokenTypes.cs:17:16:17:22 | object creation of type C | C | Class | | ||
| BrokenTypes.cs:18:16:18:17 | access to local variable y1 | string | StringType | | ||
| BrokenTypes.cs:18:16:18:27 | String y1 = ... | string | StringType | | ||
| BrokenTypes.cs:18:21:18:22 | access to local variable x1 | C | Class | | ||
| BrokenTypes.cs:18:21:18:27 | access to property Prop | string | StringType | | ||
| BrokenTypes.cs:20:13:20:14 | access to local variable x2 | var | UnknownType | | ||
| BrokenTypes.cs:20:13:20:24 | var x2 = ... | var | UnknownType | | ||
| BrokenTypes.cs:20:18:20:24 | (...) ... | var | UnknownType | | ||
| BrokenTypes.cs:20:18:20:24 | object creation of type C | C | Class | | ||
| BrokenTypes.cs:21:13:21:14 | access to local variable y2 | var | UnknownType | | ||
| BrokenTypes.cs:21:13:21:24 | var y2 = ... | var | UnknownType | | ||
| BrokenTypes.cs:21:18:21:19 | access to local variable x2 | var | UnknownType | | ||
| BrokenTypes.cs:21:18:21:24 | (...) ... | var | UnknownType | | ||
| BrokenTypes.cs:21:18:21:24 | access to property (unknown) | | UnknownType | | ||
| BrokenTypes.cs:23:12:23:13 | access to local variable x3 | <unknown type> | UnknownType | | ||
| BrokenTypes.cs:23:12:23:24 | <unknown type> x3 = ... | <unknown type> | UnknownType | | ||
| BrokenTypes.cs:23:17:23:24 | object creation of type <unknown type> | <unknown type> | UnknownType | | ||
| BrokenTypes.cs:24:13:24:14 | access to local variable y3 | var | UnknownType | | ||
| BrokenTypes.cs:24:13:24:24 | var y3 = ... | var | UnknownType | | ||
| BrokenTypes.cs:24:18:24:19 | access to local variable x3 | <unknown type> | UnknownType | | ||
| BrokenTypes.cs:24:18:24:24 | (...) ... | var | UnknownType | | ||
| BrokenTypes.cs:24:18:24:24 | access to property (unknown) | | UnknownType | | ||
| BrokenTypes.cs:26:16:26:16 | access to local variable s | string | StringType | | ||
| BrokenTypes.cs:26:16:26:36 | String s = ... | string | StringType | | ||
| BrokenTypes.cs:26:20:26:21 | access to local variable x1 | C | Class | | ||
| BrokenTypes.cs:26:20:26:26 | access to property Prop | string | StringType | | ||
| BrokenTypes.cs:26:20:26:36 | (...) ... | string | StringType | | ||
| BrokenTypes.cs:26:20:26:36 | ... + ... | | UnknownType | | ||
| BrokenTypes.cs:26:30:26:31 | access to local variable x3 | <unknown type> | UnknownType | | ||
| BrokenTypes.cs:26:30:26:36 | access to property (unknown) | | UnknownType | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import csharp | ||
|
||
from Expr e, Type t | ||
where e.fromSource() and t = e.getType() | ||
select e, t.toStringWithTypes(), t.getAPrimaryQlClass() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
semmle-extractor-options: --standalone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, that this is not semantically equivalent! But the original code looks like a mistake.