本文整理汇总了C#中IParameterSymbol类的典型用法代码示例。如果您正苦于以下问题:C# IParameterSymbol类的具体用法?C# IParameterSymbol怎么用?C# IParameterSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParameterSymbol类属于命名空间,在下文中一共展示了IParameterSymbol类的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: CreateArgument
private static SyntaxNode CreateArgument(
this ISyntaxFactoryService factory,
IParameterSymbol parameter)
{
return factory.CreateArgument(nameOpt: null, refKind: parameter.RefKind,
expression: factory.CreateIdentifierName(parameter.Name));
}
示例3: ParameterConfiguration
public ParameterConfiguration(IParameterSymbol thisParameter, List<IParameterSymbol> parametersWithoutDefaultValues, List<IParameterSymbol> remainingEditableParameters, IParameterSymbol paramsParameter)
{
ThisParameter = thisParameter;
ParametersWithoutDefaultValues = parametersWithoutDefaultValues;
RemainingEditableParameters = remainingEditableParameters;
ParamsParameter = paramsParameter;
}
示例4: GetDefaultValueClause
private static EqualsValueClauseSyntax GetDefaultValueClause(IParameterSymbol symbol)
{
if (symbol.HasExplicitDefaultValue)
{
return GetDefaultValueClauseCore(symbol.ExplicitDefaultValue, symbol.Type);
}
return null;
}
示例5: BuildAttributes
/// <summary>
/// Builds attributes of the <paramref name="parameterSymbol"/>.
/// </summary>
/// <param name="parameterSymbol">
/// The parameter attributes that you want as string.
/// </param>
/// <returns>
/// Attributes of the <paramref name="parameterSymbol"/> as string.
/// </returns>
public string BuildAttributes(IParameterSymbol parameterSymbol)
{
var attributes = parameterSymbol.GetAttributes();
return attributes.Any()
? string.Format("[{0}]", string.Join(",", attributes.Select(x => x.ToString())))
: string.Empty;
}
示例6: CreateParameterSyntax
static ParameterSyntax CreateParameterSyntax(SemanticModel model, SyntaxNode node, IParameterSymbol p)
{
return SyntaxFactory.Parameter(
SyntaxFactory.List<AttributeListSyntax>(),
SyntaxFactory.TokenList(),
SyntaxFactory.ParseTypeName(p.Type.ToMinimalDisplayString(model, node.SpanStart)),
SyntaxFactory.Identifier(p.Name),
null
);
}
开发者ID:Kavignon,项目名称:RefactoringEssentials,代码行数:10,代码来源:ConvertMethodGroupToAnonymousMethodCodeRefactoringProvider.cs
示例7: CreateParameterSyntax
static ParameterSyntax CreateParameterSyntax(SemanticModel model, SyntaxNode node, IParameterSymbol p)
{
return SyntaxFactory.Parameter(
SyntaxFactory.List<AttributeListSyntax>(),
SyntaxFactory.TokenList(),
null,
SyntaxFactory.Identifier(p.Name),
null
);
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:10,代码来源:ConvertMethodGroupToLambdaCodeRefactoringProvider.cs
示例8: BuildArgumentType
/// <summary>
/// Builds the type as string of the <paramref name="parameterSymbol"/>.
/// </summary>
/// <param name="parameterSymbol">
/// The parameter type that you want as string.
/// </param>
/// <param name="isShort">
/// Expects to have a short type.
/// </param>
/// <returns>
/// The type of the <paramref name="parameterSymbol" /> as <see cref="string"/>.
/// </returns>
public string BuildArgumentType(IParameterSymbol parameterSymbol,
bool isShort)
{
if (!isShort)
{
return parameterSymbol.Type.ToString();
}
var shortType = CleanFullType(parameterSymbol);
return shortType;
}
示例9: HasNotNullContract
static bool HasNotNullContract(SemanticModel semanticModel, IParameterSymbol parameterSymbol, BlockSyntax bodyStatement)
{
foreach (var expressions in bodyStatement.DescendantNodes().OfType<ExpressionStatementSyntax>())
{
var identifiers = expressions.DescendantNodes().OfType<IdentifierNameSyntax>();
if (Enumerable.SequenceEqual(identifiers.Select(i => i.Identifier.Text), new List<string>() { "Contract", "Requires", parameterSymbol.Name }))
{
return true;
}
}
return false;
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:13,代码来源:ContractRequiresNotNullCodeRefactoringProvider.cs
示例10: Convert
protected static SignatureHelpParameter Convert(
IParameterSymbol parameter,
SemanticModel semanticModel,
int position,
IDocumentationCommentFormattingService formatter,
CancellationToken cancellationToken)
{
return new SignatureHelpParameter(
parameter.Name,
parameter.IsOptional,
parameter.GetDocumentationPartsFactory(semanticModel, position, formatter),
parameter.ToMinimalDisplayParts(semanticModel, position));
}
示例11: GetParameter
internal static ParameterSyntax GetParameter(IParameterSymbol p, CodeGenerationOptions options, bool isExplicit, bool isFirstParam, bool seenOptional)
{
var reusableSyntax = GetReuseableSyntaxNodeForSymbol<ParameterSyntax>(p, options);
if (reusableSyntax != null)
{
return reusableSyntax;
}
return SyntaxFactory.Parameter(p.Name.ToIdentifierToken())
.WithAttributeLists(GenerateAttributes(p, isExplicit, options))
.WithModifiers(GenerateModifiers(p, isFirstParam))
.WithType(p.Type.GenerateTypeSyntax())
.WithDefault(GenerateEqualsValueClause(p, isExplicit, seenOptional));
}
示例12: Build
/// <summary>
/// Builds models representing methods of the factories.
/// </summary>
/// <param name="concreteClassSymbol">
/// Represents the concrete class.
/// </param>
/// <param name="fields">
/// Fields available in the factory.
/// </param>
/// <param name="injectedParameters">
/// The injected parameters in the factory.
/// </param>
/// <param name="factoryMethods">
/// The factory methods retrieved with Roslyn.
/// </param>
/// <param name="factoryInterfaceName">
/// The interface name of the factory.
/// </param>
/// <returns>
/// Models representing the factory methods.
/// </returns>
public IEnumerable<Method> Build(INamedTypeSymbol concreteClassSymbol,
IEnumerable<Field> fields,
IParameterSymbol[] injectedParameters,
IMethodSymbol[] factoryMethods,
string factoryInterfaceName)
{
if (!factoryMethods.Any())
{
return Enumerable.Empty<Method>();
}
fields = fields as Field[] ?? fields.ToArray();
var methods = new List<Method>();
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var factoryMethod in factoryMethods)
{
var constructor = GetConstructorFromFactoryMethod(factoryMethod, concreteClassSymbol);
var factoryMethodParameters = factoryMethod.Parameters;
var arguments = this.argumentsBuilderService.BuildMethodArgument(factoryMethodParameters)
.ToArray();
var constructorArguments = this.BuildConstructorParameters(constructor, arguments, fields, injectedParameters, factoryInterfaceName);
var genericArguments = this.genericTypeBuilderService.Build(factoryMethod.TypeParameters);
if (this.writeXmlDoc)
{
var xmlComments = BuildXmlDoc(factoryMethod);
methods.Add(new Method("Create", factoryMethod.ReturnType.ToString(), concreteClassSymbol.ToString(), arguments, constructorArguments, genericArguments, xmlComments));
}
else
{
methods.Add(new Method("Create", factoryMethod.ReturnType.ToString(), concreteClassSymbol.ToString(), arguments, constructorArguments, genericArguments, string.Empty));
}
}
return methods;
}
示例13: CodeGenerationConversionSymbol
public CodeGenerationConversionSymbol(
INamedTypeSymbol containingType,
IList<AttributeData> attributes,
Accessibility declaredAccessibility,
DeclarationModifiers modifiers,
ITypeSymbol toType,
IParameterSymbol fromType,
bool isImplicit,
IList<AttributeData> toTypeAttributes) :
base(containingType,
attributes,
declaredAccessibility,
modifiers,
returnType: toType,
explicitInterfaceSymbolOpt: null,
name: isImplicit ?
WellKnownMemberNames.ImplicitConversionName :
WellKnownMemberNames.ExplicitConversionName,
typeParameters: SpecializedCollections.EmptyList<ITypeParameterSymbol>(),
parameters: new List<IParameterSymbol>(SpecializedCollections.SingletonEnumerable(fromType)),
returnTypeAttributes: toTypeAttributes)
{
}
示例14: GetIncreaseVisibilityDiagnostic
private static Diagnostic GetIncreaseVisibilityDiagnostic(IParameterSymbol parameter, IPropertySymbol property)
{
// If '{0}' is the property accessor for positional argument '{1}', make it public.
return property.GetMethod.Locations.CreateDiagnostic(IncreaseVisibilityRule, new Dictionary<string, string> { { "case", MakePublicCase } }.ToImmutableDictionary(), property.Name, parameter.Name);
}
示例15: CreateArgument
private static SyntaxNode CreateArgument(
this SyntaxGenerator factory,
IParameterSymbol parameter)
{
return factory.Argument(parameter.RefKind, factory.IdentifierName(parameter.Name));
}