-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16576 from hvitved/csharp/static-field-side-effect
C#: Add support for flow through side-effects on static fields
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
csharp/ql/lib/change-notes/2024-05-23-static-field-side-effect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: majorAnalysis | ||
--- | ||
* Added support for data flow through side-effects on static fields. For example, when a static field containing an array is updated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
public class K | ||
{ | ||
static string[] Strings = new string[10]; | ||
|
||
private void M1() | ||
{ | ||
var o = Source<string>(1); | ||
Strings[0] = o; | ||
} | ||
|
||
private void M2() | ||
{ | ||
Sink(Strings[0]); // $ hasValueFlow=1 | ||
} | ||
|
||
public static void Sink(object o) { } | ||
|
||
static T Source<T>(object source) => throw null; | ||
} |