本文整理汇总了C#中Binder.ValidateParameterNameConflicts方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.ValidateParameterNameConflicts方法的具体用法?C# Binder.ValidateParameterNameConflicts怎么用?C# Binder.ValidateParameterNameConflicts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Binder
的用法示例。
在下文中一共展示了Binder.ValidateParameterNameConflicts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeParameters
public static ImmutableArray<ParameterSymbol> MakeParameters(
Binder binder,
Symbol owner,
BaseParameterListSyntax syntax,
bool allowRefOrOut,
out SyntaxToken arglistToken,
DiagnosticBag diagnostics)
{
arglistToken = default(SyntaxToken);
int parameterIndex = 0;
int firstDefault = -1;
var builder = ArrayBuilder<ParameterSymbol>.GetInstance();
ImmutableArray<ParameterSymbol> parameters;
foreach (var parameterSyntax in syntax.Parameters)
{
SyntaxToken outKeyword;
SyntaxToken refKeyword;
SyntaxToken paramsKeyword;
SyntaxToken thisKeyword;
var refKind = GetModifiers(parameterSyntax.Modifiers, out outKeyword, out refKeyword, out paramsKeyword, out thisKeyword);
if (parameterSyntax.IsArgList)
{
arglistToken = parameterSyntax.Identifier;
// The native compiler produces "Expected type" here, in the parser. Roslyn produces
// the somewhat more informative "arglist not valid" error.
if (paramsKeyword.Kind() != SyntaxKind.None || outKeyword.Kind() != SyntaxKind.None ||
refKeyword.Kind() != SyntaxKind.None || thisKeyword.Kind() != SyntaxKind.None)
{
// CS1669: __arglist is not valid in this context
diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, arglistToken.GetLocation());
}
continue;
}
if (parameterSyntax.Default != null && firstDefault == -1)
{
firstDefault = parameterIndex;
}
Debug.Assert(parameterSyntax.Type != null);
var parameterType = binder.BindType(parameterSyntax.Type, diagnostics);
if (!allowRefOrOut && (refKind != RefKind.None))
{
var outOrRefKeyword = (outKeyword.Kind() != SyntaxKind.None) ? outKeyword : refKeyword;
Debug.Assert(outOrRefKeyword.Kind() != SyntaxKind.None);
// error CS0631: ref and out are not valid in this context
diagnostics.Add(ErrorCode.ERR_IllegalRefParam, outOrRefKeyword.GetLocation());
}
var parameter = SourceParameterSymbol.Create(
binder,
owner,
parameterType,
parameterSyntax,
refKind,
parameterSyntax.Identifier,
parameterIndex,
(paramsKeyword.Kind() != SyntaxKind.None),
parameterIndex == 0 && thisKeyword.Kind() != SyntaxKind.None,
diagnostics);
ReportParameterErrors(owner, parameterSyntax, parameter, firstDefault, diagnostics);
builder.Add(parameter);
++parameterIndex;
}
parameters = builder.ToImmutableAndFree();
var methodOwner = owner as MethodSymbol;
var typeParameters = (object)methodOwner != null ?
methodOwner.TypeParameters :
default(ImmutableArray<TypeParameterSymbol>);
binder.ValidateParameterNameConflicts(typeParameters, parameters, diagnostics);
return parameters;
}