本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax.GetParameterSymbol方法的典型用法代码示例。如果您正苦于以下问题:C# ArgumentSyntax.GetParameterSymbol方法的具体用法?C# ArgumentSyntax.GetParameterSymbol怎么用?C# ArgumentSyntax.GetParameterSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax
的用法示例。
在下文中一共展示了ArgumentSyntax.GetParameterSymbol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitArgument
/// <summary>
/// Normalizes the <paramref name="argument" />.
/// </summary>
public override SyntaxNode VisitArgument(ArgumentSyntax argument)
{
// Special case for array accesses, as Roslyn doesn't return a symbol for the argument
if (argument.Parent.Parent is ElementAccessExpressionSyntax)
{
var arrayExpression = ((ElementAccessExpressionSyntax)argument.Parent.Parent).Expression;
if (SemanticModel.GetTypeInfo(arrayExpression).Type.TypeKind == TypeKind.Array)
return base.VisitArgument(argument);
}
var parameterSymbol = argument.GetParameterSymbol(SemanticModel);
if (parameterSymbol.RefKind != RefKind.None)
return base.VisitArgument(argument);
var parameterType = DetermineType(parameterSymbol.Type);
if (parameterType == ExpressionType.Other)
return base.VisitArgument(argument);
return argument.WithExpression(ReplaceImplicitConversion(parameterType, argument.Expression));
}
示例2: VisitArgument
/// <summary>
/// Normalizes the <paramref name="argument" />.
/// </summary>
public override SyntaxNode VisitArgument(ArgumentSyntax argument)
{
// Special case for array accesses, as Roslyn doesn't return a symbol for the argument
if (argument.Parent.Parent is ElementAccessExpressionSyntax)
{
var arrayExpression = ((ElementAccessExpressionSyntax)argument.Parent.Parent).Expression;
var kind = SemanticModel.GetTypeInfo(arrayExpression).Type.TypeKind;
if (kind == TypeKind.Array || kind == TypeKind.Pointer)
return base.VisitArgument(argument);
}
var parameterSymbol = argument.GetParameterSymbol(SemanticModel);
if (parameterSymbol.RefKind != RefKind.None)
return base.VisitArgument(argument);
var arraySymbol = parameterSymbol.Type as IArrayTypeSymbol;
var isParamsFormula = arraySymbol != null && parameterSymbol.IsParams && IsFormulaType(arraySymbol.ElementType);
if (!isParamsFormula && !IsFormulaType(parameterSymbol.Type))
return base.VisitArgument(argument);
return argument.WithExpression(ReplaceImplicitConversion(argument.Expression));
}