本文整理汇总了C#中ArgumentListSyntax类的典型用法代码示例。如果您正苦于以下问题:C# ArgumentListSyntax类的具体用法?C# ArgumentListSyntax怎么用?C# ArgumentListSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArgumentListSyntax类属于命名空间,在下文中一共展示了ArgumentListSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetParameterSymbol
public static bool TryGetParameterSymbol(ArgumentSyntax argument, ArgumentListSyntax argumentList,
IMethodSymbol method, out IParameterSymbol parameter)
{
parameter = null;
if (!argumentList.Arguments.Contains(argument) ||
method == null ||
method.IsVararg)
{
return false;
}
if (argument.NameColon != null)
{
parameter = method.Parameters
.FirstOrDefault(symbol => symbol.Name == argument.NameColon.Name.Identifier.ValueText);
return parameter != null;
}
var argumentIndex = argumentList.Arguments.IndexOf(argument);
var parameterIndex = argumentIndex;
if (parameterIndex >= method.Parameters.Length)
{
var lastParameter = method.Parameters.Last();
parameter = lastParameter.IsParams ? lastParameter : null;
return parameter != null;
}
parameter = method.Parameters[parameterIndex];
return true;
}
示例2: CreateInvocationExpression
public static InvocationExpressionSyntax CreateInvocationExpression(ExpressionSyntax sourceExpression, SimpleNameSyntax methodName, ArgumentListSyntax argumentList) =>
SyntaxFactory.InvocationExpression(
SyntaxFactory.MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
sourceExpression,
methodName),
argumentList);
示例3: GetParameterSymbol
public static IParameterSymbol GetParameterSymbol(ArgumentSyntax argument, ArgumentListSyntax argumentList, IMethodSymbol method)
{
if (!argumentList.Arguments.Contains(argument) ||
method == null)
{
return null;
}
if (argument.NameColon != null)
{
return method.Parameters
.FirstOrDefault(symbol => symbol.Name == argument.NameColon.Name.Identifier.ValueText);
}
var argumentIndex = argumentList.Arguments.IndexOf(argument);
var parameterIndex = argumentIndex;
if (parameterIndex >= method.Parameters.Length)
{
var p = method.Parameters.Last();
return p.IsParams ? p : null;
}
var parameter = method.Parameters[parameterIndex];
return parameter;
}
示例4: WithConstructorInitializerLocalsBinder
public WithConstructorInitializerLocalsBinder(Binder enclosing, ArgumentListSyntax initializerArgumentList)
: base(enclosing, enclosing.Flags)
{
Debug.Assert(initializerArgumentList != null);
this.scope = initializerArgumentList;
this.initializerArgumentList = initializerArgumentList;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:WithConstructorInitializerLocalsBinder.cs
示例5: Resolve
public override FlatOperand Resolve(ExpressionSyntax expression, ArgumentListSyntax argumentList, TypeInfo result_type, SymbolInfo si, FlatOperand into_lvalue, Function function, List<FlatStatement> instructions)
{
FlatOperand fop_subject;
if (expression is IdentifierNameSyntax)
{
// typeof this
fop_subject = FlatOperand.ThisRef(FlatValue.FromType(result_type.ConvertedType));
}
else if (expression is MemberAccessExpressionSyntax)
{
MemberAccessExpressionSyntax meas = (MemberAccessExpressionSyntax)expression;
fop_subject = function.ResolveExpression(meas.Expression, null, instructions);
}
else
{
throw new NotImplementedException("GetMetaTable on expression type " + expression.GetType().ToString());
}
if (into_lvalue == null)
{
FlatOperand fop_register = function.AllocateRegister("");
into_lvalue = fop_register.GetLValue(function, instructions);
}
instructions.Add(FlatStatement.GETMETATABLE(into_lvalue, fop_subject));
return into_lvalue.AsRValue(FlatValue.Table());
}
示例6: HasFalseArgument
public static bool HasFalseArgument(ArgumentListSyntax argumentList)
{
if (argumentList.Arguments.Count != 1)
return false;
if (!argumentList.Arguments[0].Expression.IsKind(SyntaxKind.FalseLiteralExpression))
return false;
return true;
}
示例7: AnyArgumentIsValueType
private static bool AnyArgumentIsValueType(ArgumentListSyntax argumentList, SemanticModel semanticModel)
{
return argumentList.Arguments.Any(argument =>
{
var type = semanticModel.GetTypeInfo(argument.Expression).Type;
return type != null && type.IsValueType;
});
}
示例8: FixConstructor
public FixConstructor(IMethodSymbol constructor, ArgumentListSyntax node, string sourcename, SemanticModel semanticModel, Document document)
{
this.constructor = constructor;
this.node = node;
this.sourcename = sourcename;
this.semanticModel = semanticModel;
this.document = document;
Title = $"Fill constructor from {sourcename}";
}
示例9: CollapseParameters
private async Task<Document> CollapseParameters(Document document, ArgumentListSyntax argumentListNode, CancellationToken cancellationToken)
{
ArgumentListSyntax updatedParameterList = SyntaxFactory.ArgumentList(argumentListNode.OpenParenToken,
SyntaxFactory.SeparatedList(argumentListNode.Arguments
.Select(argument => argument.WithoutLeadingTrivia().WithoutTrailingTrivia()).ToList()),
argumentListNode.CloseParenToken);
SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken);
var newRoot = root.ReplaceNode(argumentListNode, updatedParameterList);
return await Formatter.FormatAsync(document.WithSyntaxRoot(newRoot), updatedParameterList.FullSpan);
}
开发者ID:marketinvoice,项目名称:MarketInvoice.CodeAnalysis,代码行数:12,代码来源:BreakArgumentsApartRefactoringProvider.cs
示例10: ReportForUnimplemented
private static void ReportForUnimplemented(CodeRefactoringContext context, IMethodSymbol constructor, SemanticModel semanticModel, ArgumentListSyntax node, TypeInfo typeSymbol)
{
var unimplemntedParameters = constructor.Parameters.Skip(node.Arguments.Count);
var typesymbols = semanticModel.GetTypeSymbols(node, typeSymbol);
var symbols = typesymbols.Where(x => ImplementsSomethingFor(x.TypeSymbol, unimplemntedParameters))
.Distinct();
foreach(var symbol in symbols)
context.RegisterRefactoring(
new FixConstructor(constructor, node, symbol.Name, semanticModel, context.Document));
}
示例11: CheckCall
private static void CheckCall(SyntaxNode node, ArgumentListSyntax argumentList, SyntaxNodeAnalysisContext context)
{
var invokedMethodSymbol = context.SemanticModel.GetSymbolInfo(node).Symbol as IMethodSymbol;
if (invokedMethodSymbol == null ||
!invokedMethodSymbol.Parameters.Any() ||
!invokedMethodSymbol.Parameters.Last().IsParams ||
argumentList == null)
{
return;
}
if (IsInvocationWithExplicitArray(argumentList, invokedMethodSymbol, context.SemanticModel))
{
return;
}
var argumentTypes = argumentList.Arguments
.Select(arg => context.SemanticModel.GetTypeInfo(arg.Expression).Type)
.ToList();
if (argumentTypes.Any(type => type is IErrorTypeSymbol))
{
return;
}
var possibleOtherMethods = invokedMethodSymbol.ContainingType.GetMembers(invokedMethodSymbol.Name)
.OfType<IMethodSymbol>()
.Where(m => !m.IsVararg)
.Where(m => m.MethodKind == invokedMethodSymbol.MethodKind)
.Where(m => !invokedMethodSymbol.Equals(m))
.Where(m => m.Parameters.Any() && !m.Parameters.Last().IsParams);
var otherMethod = possibleOtherMethods.FirstOrDefault(possibleOtherMethod =>
ArgumentsMatchParameters(
argumentList,
argumentTypes.Select(t => t as INamedTypeSymbol).ToList(),
possibleOtherMethod,
context.SemanticModel));
if (otherMethod != null)
{
context.ReportDiagnostic(Diagnostic.Create(
Rule,
node.GetLocation(),
otherMethod.ToMinimalDisplayString(context.SemanticModel, node.SpanStart)));
}
}
示例12: Execute
private void Execute(MethodInformation methodInformation, List<object> arguments, ArgumentListSyntax argumentList)
{
if (!argumentList.Arguments.Any())
{
return;
}
try
{
methodInformation.MethodAction.Invoke(arguments);
}
catch (Exception ex)
{
while (ex.InnerException != null)
{
ex = ex.InnerException;
}
var diag = Diagnostic.Create(diagnosticDescriptor, argumentList.Arguments[methodInformation.ArgumentIndex].GetLocation(), ex.Message);
context.ReportDiagnostic(diag);
}
}
示例13: GetCandidateParameterTypes
/// <summary>
/// Returns the candidate parameter types from the
/// specified argument list.
/// </summary>
/// <param name="argumentList">ArgumentListSyntax</param>
/// <param name="node">IDataFlowNode</param>
/// <returns>ITypeSymbols</returns>
private static IDictionary<int, ISet<ITypeSymbol>> GetCandidateParameterTypes(
ArgumentListSyntax argumentList, IDataFlowNode node)
{
var candidateTypes = new Dictionary<int, ISet<ITypeSymbol>>();
if (argumentList == null)
{
return candidateTypes;
}
for (int idx = 0; idx < argumentList.Arguments.Count; idx++)
{
var argSymbol = node.Summary.SemanticModel.GetSymbolInfo(
argumentList.Arguments[idx].Expression).Symbol;
if (argSymbol != null)
{
candidateTypes.Add(idx, node.DataFlowInfo.GetCandidateTypesOfSymbol(argSymbol));
}
}
return candidateTypes;
}
示例14: BreakParametersApart
private async Task<Document> BreakParametersApart(Document document, ArgumentListSyntax argumentListNode, CancellationToken cancellationToken)
{
if (argumentListNode.Arguments.Count < 2)
return document;
ArgumentSyntax firstParameter = argumentListNode.Arguments.First();
List<ArgumentSyntax> updatedParameters = new List<ArgumentSyntax>();
updatedParameters.Add(firstParameter.WithoutLeadingTrivia().WithoutTrailingTrivia());
foreach (ArgumentSyntax parameter in argumentListNode.Arguments.Skip(1).ToList())
updatedParameters.Add(parameter
.WithoutTrailingTrivia()
.WithLeadingTrivia(SyntaxFactory.EndOfLine("\r\n"), GetIndentTrivia(argumentListNode)));
ArgumentListSyntax updatedParameterList = SyntaxFactory.ArgumentList(argumentListNode.OpenParenToken,
SyntaxFactory.SeparatedList(updatedParameters),
argumentListNode.CloseParenToken);
SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken);
var newRoot = root.ReplaceNode(argumentListNode, updatedParameterList);
return document.WithSyntaxRoot(newRoot);
}
开发者ID:marketinvoice,项目名称:MarketInvoice.CodeAnalysis,代码行数:23,代码来源:BreakArgumentsApartRefactoringProvider.cs
示例15: TryGetAlgorithmName
private static bool TryGetAlgorithmName(ArgumentListSyntax argumentList, out string algorithmName)
{
if (argumentList == null ||
argumentList.Arguments.Count == 0 ||
!argumentList.Arguments.First().Expression.IsKind(SyntaxKind.StringLiteralExpression))
{
algorithmName = null;
return false;
}
var algorithmNameCandidate = ((LiteralExpressionSyntax)argumentList.Arguments.First().Expression).Token.ValueText;
algorithmName = InsecureHashAlgorithmTypeNames.Values
.FirstOrDefault(alg =>
algorithmNameCandidate.StartsWith(alg, System.StringComparison.InvariantCulture));
return algorithmName != null;
}