pinker
pinker

Reputation: 1293

Data Flow Analysis in Roslyn

I have the following code in C#:

public class X : IX
{
   public void E(IX d)
   {
        Data dt = new Data();
        dt.Name = ViewState["a"];
        Count(dt);
   }
}

And I am using Roslyn to do a few tests concerning data flow analysis. So, I am passing the first statement (Data dt = new Data()) to analyze the data flow and I would like to get as result that there is a flow from the first until third statement.

Is it possible to do this in Rosyln? Get a path that shows the influencing path?

thanks

Upvotes: 4

Views: 1502

Answers (1)

Kevin Pilch
Kevin Pilch

Reputation: 11615

Take a look at SemanticModel.AnalyzeDataflow. It can tell you what variables are read/written/captured/etc in a particular selection.

Upvotes: 4

Related Questions