• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MemberAccessExpressionSyntax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CanFix

        /// <summary>
        /// Determines if a MemberAccessExpressionSyntax can be fixed by our codefix
        /// </summary>
        public static bool CanFix(MemberAccessExpressionSyntax memberAccessExpression)
        {
            // Verify if it is a call to one of the methods we can fix
            if (!MethodNamesToRefactor.Contains(memberAccessExpression.Name.ToString())) return false;

            // The parent should be an InvocationExpressionSyntax
            var defaultIfNullexpression = memberAccessExpression.Parent as InvocationExpressionSyntax;

            // There should be one argument, the lambda expression
            if (defaultIfNullexpression?.ArgumentList.Arguments.Count != 1) return false;

            var lambda = GetLambdaFromFirstArgument(defaultIfNullexpression);
            if (lambda == null) return false;

            // Check if the Lambas body starts with a AccessExpression of the parameter
            return GetLeftMostAccessExpression(lambda) != null;
        }
开发者ID:FrankBakkerNl,项目名称:DefaultIfNullAnalyser,代码行数:20,代码来源:DefaulIfNullExpressionHelper.cs


示例17: ImportNeededNamespace

 private static CompilationUnitSyntax ImportNeededNamespace(CompilationUnitSyntax root, SemanticModel semanticModel, MemberAccessExpressionSyntax callerMethod)
 {
     var symbolInfo = semanticModel.GetSymbolInfo(callerMethod.Name);
     var methodSymbol = symbolInfo.Symbol as IMethodSymbol;
     if (methodSymbol == null) return root;
     var namespaceDisplayString = methodSymbol.ContainingNamespace.ToDisplayString();
     var hasNamespaceImported = root
         .DescendantNodes()
         .OfType<UsingDirectiveSyntax>()
         .Select(s => s.Name.ToString())
         .Any(n => n == namespaceDisplayString);
     if (!hasNamespaceImported)
     {
         var namespaceQualifiedName = methodSymbol.ContainingNamespace.ToNameSyntax();
         root = root.AddUsings(SyntaxFactory.UsingDirective(namespaceQualifiedName));
     }
     return root;
 }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:18,代码来源:CallExtensionMethodAsExtensionCodeFixProvider.cs


示例18: LookupMethodSymbol

        public static IMethodSymbol LookupMethodSymbol(this SemanticModel model, MemberAccessExpressionSyntax memberAccess)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (memberAccess == null) throw new ArgumentNullException("memberAccess");

            var expression = memberAccess;

            Logger.Trace("Looking up symbol for: {0}", expression);

            var symbol = model.GetSymbolInfo(expression).Symbol;

            var methodSymbol = symbol as IMethodSymbol;
            if (methodSymbol != null)
            {
                NumMethodSymbolLookups++;
                return methodSymbol;
            }

            throw new MethodSymbolMissingException(memberAccess);
        }
开发者ID:modulexcite,项目名称:CSharpAnalyzer,代码行数:20,代码来源:SemanticModelExtensions.cs


示例19: VisitMemberAccessExpression

        public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
        {
            SyntaxNode r_node = node;

            if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) && node.ToString() == "ById.OnLeft")
            {
                var p = node.HasParent<ArgumentSyntax, ArgumentListSyntax, InvocationExpressionSyntax, EqualsValueClauseSyntax, VariableDeclaratorSyntax>();
                if (p == null)
                {

                }
                else
                {
                    var byId = SyntaxFactory.ParseExpression("\"#" + p.Identifier.Text + "\"");
                    //var argById = SyntaxFactory.Argument(byId);
                    r_node = byId;
                }
            }

            return r_node;
        }
开发者ID:ghostnguyen,项目名称:daccf960-44f9-4f95-91c4-b1aba37effe1,代码行数:21,代码来源:SyntaxTrans_ById.cs


示例20: InitializeBodyInfo

 public InitializeBodyInfo(InvocationExpressionSyntax invocationExpr = null, MemberAccessExpressionSyntax memberExpr = null)
 {
     InvocationExpr = invocationExpr;
     MemberExpr = memberExpr;
 }
开发者ID:maggiemsft,项目名称:roslyn-analyzers,代码行数:5,代码来源:DiagnosticAnalyzer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MemberAccessor类代码示例发布时间:2022-05-24
下一篇:
C# Member类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap