public override Location VisitSingleValueCaseClause([NotNull] ISingleValueCaseClauseOperation operation,
                                                                [CanBeNull] object argument)
            {
                var syntax = (SwitchLabelSyntax)operation.Syntax;

                return(syntax.Keyword.GetLocation());
            }
示例#2
0
 private bool ProcessAsField([NotNull] ISingleValueCaseClauseOperation caseClause)
 {
     if (caseClause.Value is IFieldReferenceOperation enumField)
     {
         caseClauseValues.Add(enumField.Field);
         return(true);
     }
     return(false);
 }
示例#3
0
            private bool ProcessAsLiteralSyntax([NotNull] SwitchAnalysisContext analysisContext,
                                                [NotNull] ISingleValueCaseClauseOperation caseClause)
            {
                if (caseClause.Value.Syntax is LiteralExpressionSyntax literalSyntax)
                {
                    if (ProcessLiteralSyntaxAsTrueKeyword(analysisContext, literalSyntax) ||
                        ProcessLiteralSyntaxAsFalseKeyword(analysisContext, literalSyntax) ||
                        ProcessLiteralSyntaxAsNullKeyword(literalSyntax))
                    {
                        return(true);
                    }
                }

                return(false);
            }
示例#4
0
            private bool ProcessAsConversion([NotNull] SwitchAnalysisContext analysisContext,
                                             [NotNull] ISingleValueCaseClauseOperation caseClause)
            {
                var conversion   = caseClause.Value as IConversionOperation;
                var memberSyntax = conversion?.Syntax as MemberAccessExpressionSyntax;

                IFieldSymbol field = analysisContext.GetFieldOrNull(memberSyntax);

                if (field != null)
                {
                    caseClauseValues.Add(field);
                    return(true);
                }

                return(false);
            }
示例#5
0
        public override void VisitSingleValueCaseClause(ISingleValueCaseClauseOperation operation)
        {
            Assert.Equal(OperationKind.CaseClause, operation.Kind);
            Assert.Equal(CaseKind.SingleValue, operation.CaseKind);

            // It is unexpected to have null operation.Value. The conditional logic is added
            // as a work around for https://github.com/dotnet/roslyn/issues/23795 and should be removed
            // once the issue is fixed
            if (operation.Value == null)
            {
                Assert.Equal(LanguageNames.VisualBasic, operation.Language);
                Assert.Empty(operation.Children);
            }
            else
            {
                AssertEx.Equal(new[] { operation.Value }, operation.Children);
            }
        }
示例#6
0
 public override IOperation VisitSingleValueCaseClause(ISingleValueCaseClauseOperation operation, object argument)
 {
     return(new SingleValueCaseClause(operation.Label, Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit));
 }
示例#7
0
 public virtual void VisitSingleValueCaseClause(ISingleValueCaseClauseOperation operation)
 {
     DefaultVisit(operation);
 }
示例#8
0
 public override void VisitSingleValueCaseClause([NotNull] ISingleValueCaseClauseOperation operation)
 {
     base.VisitSingleValueCaseClause(operation);
 }
示例#9
0
        public override void VisitSingleValueCaseClause(ISingleValueCaseClauseOperation operation)
        {
            var caseKind = operation.CaseKind;

            base.VisitSingleValueCaseClause(operation);
        }
示例#10
0
 public override bool VisitSingleValueCaseClause([NotNull] ISingleValueCaseClauseOperation operation1,
                                                 [CanBeNull] IOperation argument)
 {
     return(argument is ISingleValueCaseClauseOperation operation2 && AreBaseOperationsEqual(operation1, operation2) &&
            operation1.CaseKind == operation2.CaseKind);
 }
示例#11
0
 public override void VisitSingleValueCaseClause(ISingleValueCaseClauseOperation operation)
 {
     VisitCaseClauseOperation(operation);
     Assert.Equal(CaseKind.SingleValue, operation.CaseKind);
     AssertEx.Equal(new[] { operation.Value }, operation.Children);
 }