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

C# ArgumentListSyntax类代码示例

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

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



ArgumentListSyntax类属于命名空间,在下文中一共展示了ArgumentListSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:30,代码来源:MethodParameterLookup.cs


示例2: CreateInvocationExpression

 public static InvocationExpressionSyntax CreateInvocationExpression(ExpressionSyntax sourceExpression, SimpleNameSyntax methodName, ArgumentListSyntax argumentList) =>
     SyntaxFactory.InvocationExpression(
         SyntaxFactory.MemberAccessExpression(
         SyntaxKind.SimpleMemberAccessExpression,
         sourceExpression,
         methodName),
         argumentList);
开发者ID:JeanLLopes,项目名称:code-cracker,代码行数:7,代码来源:CallExtensionMethodAsExtensionCodeFixProvider.cs


示例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;
        }
开发者ID:jakobehn,项目名称:sonarlint-vs,代码行数:25,代码来源:MethodParameterLookup.cs


示例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());
        }
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:27,代码来源:Intrinsics.cs


示例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;
		}
开发者ID:cincuranet,项目名称:ConfigureAwaitChecker,代码行数:8,代码来源:Checker.cs


示例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;
     });
 }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:8,代码来源:ReferenceEqualsOnValueType.cs


示例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}";
 }
开发者ID:jarlrasm,项目名称:PhilTheCartographer,代码行数:9,代码来源:FillConstrutorRefactoring.cs


示例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));
        }
开发者ID:jarlrasm,项目名称:PhilTheCartographer,代码行数:13,代码来源:FillConstrutorRefactoring.cs


示例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)));
            }
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:46,代码来源:InvocationResolvesToOverrideWithParams.cs


示例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);
     }
 }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:20,代码来源:MethodChecker.cs


示例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;
        }
开发者ID:yonglehou,项目名称:PSharp,代码行数:28,代码来源:MethodSummaryResolver.cs


示例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;
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:17,代码来源:InsecureHashAlgorithm.cs


示例16: MatchArguments

        private static bool MatchArguments(ParameterListSyntax parameters, ArgumentListSyntax arguments)
        {
            if (arguments.Arguments.Count != parameters.Parameters.Count) return false;

            var paramNameList = parameters.Parameters.Select(p => p.Identifier.Text);
            var argNameList = arguments.Arguments
                .Where(a => a.Expression is IdentifierNameSyntax)
                .Select(a => (a.Expression as IdentifierNameSyntax).Identifier.Text);

            return paramNameList.SequenceEqual(argNameList);
        }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:11,代码来源:ConvertLambdaExpressionToMethodGroupAnalyzer.cs


示例17: createInvocation

        private static SyntaxNode createInvocation(string call, ArgumentListSyntax args)
        {
            //td: use cases
            //switch (call)
            //{
            //    case "c":
            //        call = "RR.c";
            //        break;
            //}

            return CSharp.InvocationExpression(CSharp.ParseExpression("RR." + call), args);
        }
开发者ID:mpmedia,项目名称:Excess,代码行数:12,代码来源:Extension.cs


示例18: VisitArgumentList

 public virtual void VisitArgumentList(ArgumentListSyntax node)
 {
     DefaultVisit(node);
 }
开发者ID:pminiszewski,项目名称:HlslTools,代码行数:4,代码来源:SyntaxVisitor.cs


示例19: GetArguments

 private List<object> GetArguments(ArgumentListSyntax argumentList)
 {
     return argumentList.Arguments
         .Select(a => a.Expression)
         .Select(l => l == null ? null : context.SemanticModel.GetConstantValue(l).Value)
         .ToList();
 }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:7,代码来源:MethodChecker.cs


示例20: ArgumentsMatchParameters

        private static bool ArgumentsMatchParameters(ArgumentListSyntax argumentList, List<INamedTypeSymbol> argumentTypes,
            IMethodSymbol possibleOtherMethod, SemanticModel semanticModel)
        {
            var matchedParameters = new List<IParameterSymbol>();
            for (int i = 0; i < argumentList.Arguments.Count; i++)
            {
                var argument = argumentList.Arguments[i];
                var argumentType = argumentTypes[i];
                IParameterSymbol parameter;
                if (!MethodParameterLookup.TryGetParameterSymbol(argument, argumentList, possibleOtherMethod, out parameter))
                {
                    return false;
                }

                if (argumentType == null)
                {
                    if (!parameter.Type.IsReferenceType)
                    {
                        return false;
                    }
                }
                else
                {
                    var conversion = semanticModel.ClassifyConversion(argument.Expression, parameter.Type);
                    if (!conversion.IsImplicit)
                    {
                        return false;
                    }
                }

                matchedParameters.Add(parameter);
            }

            var nonMatchedParameters = possibleOtherMethod.Parameters.Except(matchedParameters);
            return nonMatchedParameters.All(p => p.HasExplicitDefaultValue);
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:36,代码来源:InvocationResolvesToOverrideWithParams.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ArgumentType类代码示例发布时间:2022-05-24
下一篇:
C# ArgumentList类代码示例发布时间: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