public ConstraintData GetConstraintData(SyntaxNode invocationExpression) { using (_constratintContext.Enter()) { Visit(invocationExpression); return(_constratintContext.Current); } }
public MethodDeclarationData GetMethodDeclarationData(MethodDeclarationSyntax node) { using (_methodDeclarationContext.Enter()) { Visit(node); return(_methodDeclarationContext.Current); } }
public ClassDeclarationData GetClassDeclarationData(ClassDeclarationSyntax node) { using (_classDeclarationContext.Enter()) { _classDeclarationContext.Current.ClassSymbol = _semanticModel.GetDeclaredSymbol(node); Visit(node); return(_classDeclarationContext.Current); } }
public AssertThatData GetAssertThatData(InvocationExpressionSyntax invocationExpression) { using (_assertThatContext.Enter()) { Visit(invocationExpression); var symbol = _semanticModel.GetSymbolInfo(invocationExpression).Symbol as IMethodSymbol; _assertThatContext.Current.InvocationMember = invocationExpression.Expression as MemberAccessExpressionSyntax; var isResolveConstraint = symbol.Parameters.FirstOrDefault(x => ResolveRecognizer.ResolveConstraint(x.Type)); var isFunc = ResolveRecognizer.ActualValueDelegate(symbol.Parameters.First().Type); var isAction = ResolveRecognizer.TestDelegate(symbol.Parameters.First().Type); if (isResolveConstraint is null) { return(null); } if (isFunc) { _assertThatContext.Current.Arguments.Add(SyntaxFactory.Argument( WrapInFunc(invocationExpression.ArgumentList.Arguments.First().Expression, symbol.TypeArguments.Select(x => x.Name)))); } else if (isAction) { _assertThatContext.Current.Arguments.Add(SyntaxFactory.Argument( WrapInAction(invocationExpression.ArgumentList.Arguments.First().Expression))); } else { _assertThatContext.Current.Arguments.Add(invocationExpression.ArgumentList.Arguments.First()); } var isResolveIndex = symbol.Parameters.IndexOf(isResolveConstraint); var constraintData = WalkConstraintExpression(invocationExpression.ArgumentList.Arguments[isResolveIndex].Expression); _assertThatContext.Current.AssertMethod = constraintData.ConstraintMode; _assertThatContext.Current.AssertMethodTypeArgument = constraintData.ConstraintGenericType; if (constraintData.ConstraintArgument != null) { _assertThatContext.Current.Arguments.Add(constraintData.ConstraintArgument); } return(_assertThatContext.Current); } }