I have created the following object to walk my constructor:
internal class ConstructorWalker : CSharpSyntaxWalker
{
private string className = String.Empty;
private readonly SemanticModel semanticModel;
private readonly Action<string> callback;
public ConstructorWalker(Document document, Action<string> callback)
{
this.semanticModel = document.GetSemanticModelAsync().Result;
this.callback = callback;
}
public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
{
var typeToMatch = typeof(Dictionary<string, Func<GenericMobileRequest, Result<object>, Task>>);
var parameters = node.ParameterList;
foreach (var param in parameters.ChildNodes()) {
//This does not work... .Symbol is null
var paramType = ((IParameterSymbol)semanticModel.GetSymbolInfo(param).Symbol).Type;
if(paramType == typeToMatch) {
//PROFIT!!!
}
}
How can I determine the type of the parameter so I can ensure it is of the type I am interested in?