Repository navigation
Move shared dataflow value creation helpers out of HandleCallAction - #2757
Conversation
And clean up some usages of GetMethodParameterValue
tlakollo
left a comment
There was a problem hiding this comment.
In general looks good to me
jtschuster
left a comment
There was a problem hiding this comment.
Would it make more sense to put all of this into FlowAnnotations and make that a partial class? It looks like there are already a few duplicate methods in FlowAnnotations.cs on the linker side. LGTM otherwise.
- Move MethodRequiresDataFlowAnalysis to AnnotationContext
|
I was debating whether to use |
vitek-karas
left a comment
There was a problem hiding this comment.
Sorry for the late review - just one perf related comment.
| _owningSymbol = owningSymbol; | ||
| _operation = operation; | ||
| _diagnosticContext = diagnosticContext; | ||
| _annotations = new FlowAnnotations (); |
There was a problem hiding this comment.
This is relatively expensive - FlowAnnotations is a class, so this is a heap allocation - but it doesn't store anything. Also linker doesn't have this problem since it's using a "singleton" instance effectively. We should do the same in the analyzer (note that HandleCallAction is created very frequently - it should be allocation free if at all possible).
Same goes for the ReflectionAccessAnalyzer below - either make it a struct or share the instance between calls to this constructor.
…otnet/linker#2757) This builds on the work @jtschuster did in c2fff33 to share code for the annotation checks. I noticed that ReflectionMethodBodyScanner and HandleCallAction started accumulating these helpers for creating dataflow values from methods and I thought it would make sense for that to be handled as a separate concern, so I moved them out to a separate class and adjusted some of the callsites in ReflectionMethodBodyScanner to use the shared version. This was motivated in part by some of the factoring I am doing as a follow-up to 137b7b9, but isn't directly related. (While working on the follow-up, I came across a point where I needed to create a dataflow value in shared code from outside HandleCallAction, and there wasn't a very clean way to do this). Commit migrated from dotnet/linker@4418cce
This builds on the work @jtschuster did in c2fff33 to share code for the annotation checks.
I noticed that ReflectionMethodBodyScanner and HandleCallAction started accumulating these helpers for creating dataflow values from methods and I thought it would make sense for that to be handled as a separate concern, so I moved them out to a separate class and adjusted some of the callsites in ReflectionMethodBodyScanner to use the shared version.
This was motivated in part by some of the factoring I am doing as a follow-up to 137b7b9, but isn't directly related. (While working on the follow-up, I came across a point where I needed to create a dataflow value in shared code from outside HandleCallAction, and there wasn't a very clean way to do this).