本文整理汇总了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);
}
示例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);
}
示例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";
}
示例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";
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}