Reputation: 349
I have read that Roslyn does not provide a native CFG implementation, nor a public inter- or intra-data-flow analysis. However that was a source based on Roslyn RC2 which is probably really old. Is it still the case today?
I am trying to do taint analysis, i.e. I should be able to trace a variable after it has been passed through functions or assigned to other variables.
Any help will be appreciated! Thanks!
Upvotes: 3
Views: 1201
Reputation: 1856
Meanwhile there seems to be a public API for getting a control flow graph (in preview status so far). I could not find any further documentation.
Source code: http://sourceroslyn.io/#Microsoft.CodeAnalysis/Operations/ControlFlowGraph.cs
Example usage in the unit tests: http://sourceroslyn.io/#Roslyn.Test.Utilities/Compilation/ControlFlowGraphVerifier.cs
GitHub issue: https://github.com/dotnet/roslyn/issues/24104
Upvotes: 2
Reputation: 19031
Roslyn as of 1.2 only has limited built-in data flow analysis to understand the variables being used in a set of spans in a single method. That's used for the "extract method" refactoring to see what variables need to be moved. Otherwise, you're still on your own if you want to do something bigger.
Upvotes: 4