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


C# MemberAccessExpressionSyntax类代码示例

本文整理汇总了C#中MemberAccessExpressionSyntax的典型用法代码示例。如果您正苦于以下问题:C# MemberAccessExpressionSyntax类的具体用法?C# MemberAccessExpressionSyntax怎么用?C# MemberAccessExpressionSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RemoveCall

 private static SyntaxNode RemoveCall(SyntaxNode root,
     InvocationExpressionSyntax castInvocation, MemberAccessExpressionSyntax memberAccess)
 {
     return castInvocation != null
         ? RemoveExtensionMethodCall(root, castInvocation)
         : RemoveStaticMemberCall(root, memberAccess);
 }
开发者ID:jakobehn,项目名称:sonarlint-vs,代码行数:7,代码来源:RedundantCastCodeFixProvider.cs

示例2: ShouldUseTap

        public bool ShouldUseTap(MemberAccessExpressionSyntax memberAccessExpression)
        {
            if (memberAccessExpression.IsWrappedInAwaitExpression() || memberAccessExpression.IsWrappedInLock())
            {
                return false;
            }

            var identifierName = memberAccessExpression.Name as IdentifierNameSyntax;
            if (identifierName?.Identifier.ValueText != nameof(Task<int>.Result))
            {
                return false;
            }

            var lambdaExpression = memberAccessExpression.FirstAncestorOrSelf<LambdaExpressionSyntax>();
            if (lambdaExpression == null)
            {
                var methodDeclaration = memberAccessExpression.FirstAncestorOrSelf<MethodDeclarationSyntax>();
                if (methodDeclaration == null || methodDeclaration.HasOutOrRefParameters())
                {
                    return false;
                }
            }

            var symbol = FindSymbol(memberAccessExpression.Expression);
            if (symbol == null)
            {
                return false;
            }
            var taskSymbol = semanticModel.Compilation.GetTypeByMetadataName(typeof(Task).FullName);
            var taskOfTSymbol = semanticModel.Compilation.GetTypeByMetadataName(typeof(Task).FullName + "`1");

            return symbol.IsGenericType ?
                symbol.ConstructedFrom.Equals(taskOfTSymbol) :
                symbol.Equals(taskSymbol);
        }
开发者ID:hvanbakel,项目名称:Asyncify-CSharp,代码行数:35,代码来源:VariableAccessChecker.cs

示例3: VisitMemberAccessExpression

 public override void VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
 {
     base.VisitMemberAccessExpression(node);
     if (node.Parent is MemberAccessExpressionSyntax || node.Parent is InvocationExpressionSyntax)
         return;
     if (node.Expression.IsKind(SyntaxKind.ThisExpression))
         Check(node);
 }
开发者ID:Kavignon,项目名称:RefactoringEssentials,代码行数:8,代码来源:DoNotCallOverridableMethodsInConstructorAnalyzer.cs

示例4: ToStaticMethodInvocation

        static SyntaxNode ToStaticMethodInvocation(SemanticModel model, InvocationExpressionSyntax invocation, MemberAccessExpressionSyntax memberAccess, SymbolInfo invocationRR)
        {
            var newArgumentList = invocation.ArgumentList.Arguments.ToList();
            newArgumentList.Insert(0, SyntaxFactory.Argument(memberAccess.Expression.WithoutLeadingTrivia()));

            var newTarget = memberAccess.WithExpression(SyntaxFactory.ParseTypeName(invocationRR.Symbol.ContainingType.ToMinimalDisplayString(model, memberAccess.SpanStart)));
            return SyntaxFactory.InvocationExpression(newTarget, SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList<ArgumentSyntax>(newArgumentList)));
        }
开发者ID:Kavignon,项目名称:RefactoringEssentials,代码行数:8,代码来源:InvokeAsStaticMethodCodeRefactoringProvider.cs

示例5: IsInvocationOfApply

        private static bool IsInvocationOfApply(MemberAccessExpressionSyntax memberAccessSyntax, string bindingSetIdentifierString)
        {
            var identifierName = memberAccessSyntax.Expression as IdentifierNameSyntax;

            if (identifierName?.Identifier.ValueText != bindingSetIdentifierString) return false;

            return memberAccessSyntax.Name.Identifier.ValueText == "Apply";
        }
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:8,代码来源:ApplyMustBeCalledWhenUsingFluentBindingSetAnalyzer.cs

示例6: IsInvocationOfBind

        private static bool IsInvocationOfBind(MemberAccessExpressionSyntax memberAccessSyntax, string bindingSetIdentifierString)
        {
            var identifierName = GetIdentifierRecursive(memberAccessSyntax);

            if (identifierName?.Identifier.ValueText != bindingSetIdentifierString) return false;

            return memberAccessSyntax.Name.Identifier.ValueText == "Bind";
        }
开发者ID:MvvmCross,项目名称:MvvmCross,代码行数:8,代码来源:ApplyMustBeCalledWhenUsingFluentBindingSetCodeFix.cs

示例7: VisitMemberAccessExpression

        public override void VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
        {
            // Dong Xie: node.Name.GetText() 
            if (node.Name.GetText().ToString() != PublishKeyword) return;

            PublicationCalls.Add(node);
            Publications.Add(node.Ancestors().OfType<InvocationExpressionSyntax>().Last());
        }
开发者ID:jjrdk,项目名称:CqrsMessagingTools,代码行数:8,代码来源:MilSyntaxWalker.cs

示例8: FixStringToCharInvocation

 public void FixStringToCharInvocation(MemberAccessExpressionSyntax toCharArrayInvocation, Diagnostic diagnostic, CodeFixContext context, SyntaxNode root)
 {
     context.RegisterCodeFix(CodeActionFactory.Create(toCharArrayInvocation.Span, diagnostic.Severity, "Remove redundant 'string.ToCharArray()' call",
     token =>
     {
         var newRoot = root.ReplaceNode(toCharArrayInvocation.Parent, toCharArrayInvocation.Expression
             .WithAdditionalAnnotations(Formatter.Annotation));
         return Task.FromResult(context.Document.WithSyntaxRoot(newRoot));
     }), diagnostic);
 }
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:10,代码来源:RedundantStringToCharArrayCallCodeFixProvider.cs

示例9: IsPrivateField

        private bool IsPrivateField(MemberAccessExpressionSyntax memberSyntax, SemanticModel model, CancellationToken token)
        {
            var symbolInfo = model.GetSymbolInfo(memberSyntax, token);
            if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Field)
            {
                var field = (IFieldSymbol)symbolInfo.Symbol;
                return field.DeclaredAccessibility == Accessibility.Private;
            }

            return false;
        }
开发者ID:michaelcfanning,项目名称:codeformatter,代码行数:11,代码来源:ExplicitThisAnalyzer.cs

示例10: InsertAsyncCall

        private async Task<Document> InsertAsyncCall(Document document, MemberAccessExpressionSyntax memberAccess, CancellationToken cancellationToken)
        {
            var name = memberAccess.Name.Identifier.ValueText;
            ExpressionSyntax oldNode, newNode, newMemberAccess;
            switch (name)
            {
                case "WaitAny":
                    newMemberAccess = memberAccess.WithName((SimpleNameSyntax)SyntaxFactory.ParseName("WhenAny"));
                    break;
                case "WaitAll":
                    newMemberAccess = memberAccess.WithName((SimpleNameSyntax)SyntaxFactory.ParseName("WhenAny"));
                    break;
                case "Wait":
                    newMemberAccess = memberAccess.Expression;
                    break;
                case "Result":
                    newMemberAccess = memberAccess.Expression;
                    break;
                case "Sleep":
                    newMemberAccess = SyntaxFactory.ParseExpression("Task.Delay");
                    break;
                default:
                    newMemberAccess = memberAccess.WithName((SimpleNameSyntax)SyntaxFactory.ParseName(memberAccess.Name.Identifier.ValueText + "Async"));
                    break;
            }

            var invoc = memberAccess.Parent as InvocationExpressionSyntax;
            // WaitAny, WaitAll, Wait, Sleep, XyzAsync etc.
            if (invoc != null)
            {
                oldNode = invoc;
                newNode = name == "Wait" ? newMemberAccess : invoc.WithExpression(newMemberAccess);
            }
            // t.Result
            else
            {
                oldNode = memberAccess;
                newNode = newMemberAccess;
            }

            newNode = SyntaxFactory.AwaitExpression(newNode)
                .WithAdditionalAnnotations(Formatter.Annotation)
                .WithLeadingTrivia(memberAccess.GetLeadingTrivia())
                .WithTrailingTrivia(memberAccess.GetTrailingTrivia());

            if (oldNode.Parent.Kind() == SyntaxKind.SimpleMemberAccessExpression)
            {
                newNode = SyntaxFactory.ParenthesizedExpression(newNode);
            }

            var root = await document.GetSyntaxRootAsync().ConfigureAwait(false);
            var newRoot = root.ReplaceNode(oldNode, newNode);
            return document.WithSyntaxRoot(newRoot);
        }
开发者ID:modulexcite,项目名称:AsyncFixer,代码行数:54,代码来源:LongRunningFixer.cs

示例11: CouldBeAnAssert

 static bool CouldBeAnAssert(MemberAccessExpressionSyntax memberAccess)
 {
     for (var i = 0; i < NUnitAssertMethods.All.Count; i++)
     {
         if (NUnitAssertMethods.All[i].CouldBeEqualto(memberAccess))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:vbfox,项目名称:NFluentConversion,代码行数:11,代码来源:ReplaceNUnitAnalyzer.cs

示例12: MemberAccessExpressionTranslation

        public MemberAccessExpressionTranslation(MemberAccessExpressionSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
        {
            Expression = syntax.Expression.Get<ExpressionTranslation>(this);
            Name = syntax.Name.Get<SimpleNameTranslation>(this);

            var simpleName = Name as SimpleNameTranslation;

            if (simpleName != null)
            {
                simpleName.DetectApplyThis = false;
            }
        }
开发者ID:asthomas,项目名称:TypescriptSyntaxPaste,代码行数:12,代码来源:MemberAccessExpressionTranslation.cs

示例13: VisitMemberAccessExpression

            public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
            {
                node = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node);
                var name = node.Name.Identifier.ValueText;
                if (node.Expression != null &&
                    node.Expression.Kind() == SyntaxKind.ThisExpression &&
                    IsPrivateField(node))
                {
                    _addedAnnotations = true;
                    return node.WithAdditionalAnnotations(Simplifier.Annotation);
                }

                return node;
            }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-codeformatter-dotnet,代码行数:14,代码来源:ExplicitThisRule.cs

示例14: IsPrivateField

            private bool IsPrivateField(MemberAccessExpressionSyntax memberSyntax)
            {
                if (_semanticModel == null)
                {
                    _semanticModel = _document.GetSemanticModelAsync(_cancellationToken).Result;
                }

                var symbolInfo = _semanticModel.GetSymbolInfo(memberSyntax, _cancellationToken);
                if (symbolInfo.Symbol != null && symbolInfo.Symbol.Kind == SymbolKind.Field)
                {
                    var field = (IFieldSymbol)symbolInfo.Symbol;
                    return field.DeclaredAccessibility == Accessibility.Private;
                }

                return false;
            }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-codeformatter-dotnet,代码行数:16,代码来源:ExplicitThisRule.cs

示例15: VisitMemberAccessExpression

            public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
            {
                bool oldAlwaysSimplify = this.alwaysSimplify;
                if (!this.alwaysSimplify)
                {
                    this.alwaysSimplify = node.HasAnnotation(Simplifier.Annotation);
                }

                var result = SimplifyExpression(
                    node,
                    newNode: base.VisitMemberAccessExpression(node),
                    simplifier: SimplifyName);

                this.alwaysSimplify = oldAlwaysSimplify;

                return result;
            }
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:CSharpNameReducer.Rewriter.cs


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