コード例 #1
0
 public static Task <Document> RefactorAsync(
     Document document,
     LockStatementSyntax lockStatement,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(IntroduceFieldToLockOnRefactoring.RefactorAsync(document, lockStatement, cancellationToken));
 }
 public static async Task <Document> RefactorAsync(
     Document document,
     LockStatementSyntax lockStatement,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await IntroduceFieldToLockOnRefactoring.RefactorAsync(document, lockStatement, cancellationToken).ConfigureAwait(false));
 }
コード例 #3
0
        public static void ComputeRefactorings(RefactoringContext context, LockStatementSyntax lockStatement)
        {
            if (context.IsRefactoringEnabled(RefactoringIdentifiers.IntroduceFieldToLockOn))
            {
                ExpressionSyntax expression = lockStatement.Expression;

                if (expression != null)
                {
                    if (expression.IsMissing || expression.IsKind(SyntaxKind.ThisExpression))
                    {
                        if (context.Span.IsContainedInSpanOrBetweenSpans(expression))
                        {
                            context.RegisterRefactoring(
                                "Introduce field to lock on",
                                cancellationToken => IntroduceFieldToLockOnRefactoring.RefactorAsync(context.Document, lockStatement, cancellationToken));
                        }
                    }
                }
            }
        }