Exemplo n.º 1
0
        public static void AddCastExpression(
            CodeFixContext context,
            Diagnostic diagnostic,
            ExpressionSyntax expression,
            ITypeSymbol destinationType,
            SemanticModel semanticModel)
        {
            CodeAction codeAction = CodeActionFactory.AddCastExpression(context.Document, expression, destinationType, semanticModel, equivalenceKey: EquivalenceKey.Create(diagnostic, CodeFixIdentifiers.AddCastExpression));

            context.RegisterCodeFix(codeAction, diagnostic);
        }
Exemplo n.º 2
0
        private static void RegisterAddCastExpressionRefactoring(
            RefactoringContext context,
            ExpressionSyntax expression,
            ITypeSymbol destinationType,
            SemanticModel semanticModel)
        {
            CodeAction codeAction = CodeActionFactory.AddCastExpression(
                context.Document,
                expression,
                destinationType,
                semanticModel,
                equivalenceKey: EquivalenceKey.Join(RefactoringIdentifiers.AddCastExpression, SymbolDisplay.ToDisplayString(destinationType)));

            context.RegisterRefactoring(codeAction);
        }