I'm trying to fix this issue https://github.com/dotnet-security-guard/roslyn-security-guard/issues/60 Affected file is https://github.com/dotnet-security-guard/roslyn-security-guard/blob/master/RoslynSecurityGuard/Analyzers/CsrfTokenAnalyzer.cs
There is DiagnosticAnalyzer
implemented and the logic in VisitMethods(SyntaxNodeAnalysisContext ctx)
method is not correct for API method. So that I want to add such check to that method to exclude all the controller methods which return ViewResult
instance as API method will not return a view.
Can you suggest me how can I traverse a C# (and VB) method body and find if a body contains any statement which returns ViewResult instance?