static bool ValidateContractAccess(MemberAccessExpressionSyntax access, string method, string genericTypeName) { if (access == null) { return(false); } var className = access.Expression.GetRightmostName() as SimpleNameSyntax; if (className == null || className.Identifier.ValueText != "Contract") { return(false); } var ensures = access.GetRightmostName() as SimpleNameSyntax; if (ensures == null || ensures.Identifier.ValueText != method) { return(false); } if (genericTypeName != null) { var generic = ensures as GenericNameSyntax; if (generic == null || generic.Arity != 1) { return(false); } var typeName = generic.TypeArgumentList.Arguments[0].GetRightmostName() as SimpleNameSyntax; if (typeName == null || typeName.Identifier.ValueText != genericTypeName) { return(false); } } return(true); }