当前位置: 首页>>代码示例>>C#>>正文


C# ExpressionSyntax.SkipParens方法代码示例

本文整理汇总了C#中ExpressionSyntax.SkipParens方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionSyntax.SkipParens方法的具体用法?C# ExpressionSyntax.SkipParens怎么用?C# ExpressionSyntax.SkipParens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExpressionSyntax的用法示例。


在下文中一共展示了ExpressionSyntax.SkipParens方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnpackNullableValueAccess

 internal static ExpressionSyntax UnpackNullableValueAccess(SemanticModel semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken)
 {
     var expr = expression.SkipParens();
     if (!expr.IsKind(SyntaxKind.SimpleMemberAccessExpression))
         return expression;
     var info = semanticModel.GetTypeInfo(((MemberAccessExpressionSyntax)expr).Expression, cancellationToken);
     if (!info.ConvertedType.IsNullableType())
         return expression;
     return ((MemberAccessExpressionSyntax)expr).Expression;
 }
开发者ID:yeaicc,项目名称:RefactoringEssentials,代码行数:10,代码来源:ConvertConditionalTernaryToNullCoalescingAnalyzer.cs

示例2: AnalyzeBinaryExpression

 static ExpressionSyntax AnalyzeBinaryExpression(ExpressionSyntax node)
 {
     var bOp = node.SkipParens() as BinaryExpressionSyntax;
     if (bOp == null)
         return null;
     if (bOp.IsKind(SyntaxKind.NotEqualsExpression) || bOp.IsKind(SyntaxKind.EqualsExpression))
     {
         if (bOp.Left != null && bOp.Left.SkipParens().IsKind(SyntaxKind.NullLiteralExpression))
             return bOp.Right;
         if (bOp.Right != null && bOp.Right.SkipParens().IsKind(SyntaxKind.NullLiteralExpression))
             return bOp.Left;
     }
     return null;
 }
开发者ID:yeaicc,项目名称:RefactoringEssentials,代码行数:14,代码来源:ConvertConditionalTernaryToNullCoalescingAnalyzer.cs

示例3: CheckNullComparison

        static bool CheckNullComparison(SyntaxNodeAnalysisContext nodeContext, BinaryExpressionSyntax binaryOperatorExpression, ExpressionSyntax right, ExpressionSyntax nullNode, ref Diagnostic diagnostic)
        {
            if (!binaryOperatorExpression.IsKind(SyntaxKind.EqualsExpression) && !binaryOperatorExpression.IsKind(SyntaxKind.NotEqualsExpression))
                return false;
            // note null == null is checked by similiar expression comparison.
            var expr = right.SkipParens();

            var rr = nodeContext.SemanticModel.GetTypeInfo(expr);
            if (rr.Type == null)
                return false;
            var returnType = rr.Type;
            if (returnType != null && returnType.IsValueType && !returnType.IsPointerType())
            {
                // nullable check
                if (returnType.IsNullableType())
                    return false;

                var conversion = nodeContext.SemanticModel.GetConversion(nullNode);
                if (conversion.IsUserDefined)
                    return false;
                // check for user operators
                foreach (IMethodSymbol op in returnType.GetMembers().OfType<IMethodSymbol>().Where(m => m.MethodKind == MethodKind.UserDefinedOperator && m.Parameters.Length == 2))
                {
                    if (op.Parameters[0].Type.IsReferenceType == false && op.Parameters[1].Type.IsReferenceType == false)
                        continue;
                    if (binaryOperatorExpression.IsKind(SyntaxKind.EqualsExpression) && op.Name == "op_Equality")
                        return false;
                    if (binaryOperatorExpression.IsKind(SyntaxKind.NotEqualsExpression) && op.Name == "op_Inequality")
                        return false;
                }
                diagnostic = Diagnostic.Create(
                    descriptor,
                    binaryOperatorExpression.GetLocation(),
                    !binaryOperatorExpression.IsKind(SyntaxKind.EqualsExpression) ? "true" : "false"
                );
                return true;
            }
            return false;
        }
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:39,代码来源:ConditionIsAlwaysTrueOrFalseAnalyzer.cs

示例4: AreConditionsEqual

 public static bool AreConditionsEqual(ExpressionSyntax cond1, ExpressionSyntax cond2)
 {
     if (cond1 == null || cond2 == null)
         return false;
     return cond1.SkipParens().IsEquivalentTo(cond2.SkipParens(), true);
 }
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:6,代码来源:CSharpUtil.cs

示例5: ExtractLambda

        static bool ExtractLambda(ArgumentSyntax argument, out ParameterSyntax parameter, out ExpressionSyntax body)
        {
            if (argument.Expression is SimpleLambdaExpressionSyntax)
            {
                var simple = (SimpleLambdaExpressionSyntax)argument.Expression;
                parameter = simple.Parameter;
                body = simple.Body as ExpressionSyntax;
                if (body == null)
                    return false;
                body = body.SkipParens();
                return true;
            }

            parameter = null;
            body = null;
            return false;
        }
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:17,代码来源:ReplaceWithOfTypeAnalyzer.cs


注:本文中的ExpressionSyntax.SkipParens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。