本文整理汇总了C#中IParameterSymbol类的典型用法代码示例。如果您正苦于以下问题:C# IParameterSymbol类的具体用法?C# IParameterSymbol怎么用?C# IParameterSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParameterSymbol类属于命名空间,在下文中一共展示了IParameterSymbol类的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: CreateArgument
private static SyntaxNode CreateArgument(
this ISyntaxFactoryService factory,
IParameterSymbol parameter)
{
return factory.CreateArgument(nameOpt: null, refKind: parameter.RefKind,
expression: factory.CreateIdentifierName(parameter.Name));
}
开发者ID:riversky,项目名称:roslyn,代码行数:7,代码来源:ICodeDefinitionFactoryExtensions.cs
示例3: ParameterConfiguration
public ParameterConfiguration(IParameterSymbol thisParameter, List<IParameterSymbol> parametersWithoutDefaultValues, List<IParameterSymbol> remainingEditableParameters, IParameterSymbol paramsParameter)
{
ThisParameter = thisParameter;
ParametersWithoutDefaultValues = parametersWithoutDefaultValues;
RemainingEditableParameters = remainingEditableParameters;
ParamsParameter = paramsParameter;
}
开发者ID:mjheitland,项目名称:TableTweaker,代码行数:7,代码来源:ParameterConfiguration.cs
示例4: GetDefaultValueClause
private static EqualsValueClauseSyntax GetDefaultValueClause(IParameterSymbol symbol)
{
if (symbol.HasExplicitDefaultValue)
{
return GetDefaultValueClauseCore(symbol.ExplicitDefaultValue, symbol.Type);
}
return null;
}
开发者ID:dotnet,项目名称:docfx,代码行数:8,代码来源:CSYamlModelGenerator.cs
示例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;
}
开发者ID:romerod,项目名称:FactoryGenerator,代码行数:17,代码来源:ParameterSymbolBuilderService.cs
示例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;
}
开发者ID:romerod,项目名称:FactoryGenerator,代码行数:23,代码来源:ParameterSymbolBuilderService.cs
示例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));
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:13,代码来源:AbstractCSharpSignatureHelpProvider.cs
示例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));
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:ParameterGenerator.cs
示例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;
}
开发者ID:romerod,项目名称:FactoryGenerator,代码行数:59,代码来源:MethodsBuilderService.cs
示例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)
{
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:23,代码来源:CodeGenerationConversionSymbol.cs
示例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);
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:5,代码来源:DefineAccessorsForAttributeArguments.cs
示例15: CreateArgument
private static SyntaxNode CreateArgument(
this SyntaxGenerator factory,
IParameterSymbol parameter)
{
return factory.Argument(parameter.RefKind, factory.IdentifierName(parameter.Name));
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:6,代码来源:ICodeDefinitionFactoryExtensions.cs
示例16: IsSameParameter
private static bool IsSameParameter(IParameterSymbol parameterSymbol, IEnumerable<ParameterSyntax> parameters)
{
var parametersFromSymbol = parameterSymbol.Locations.Select(l => l.FindToken().AncestorAndSelf<ParameterSyntax>());
if (parameters.Any(p => parametersFromSymbol.Any(p2 => p == p2)))
{
return true;
}
return false;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:10,代码来源:AddOutOrRefCodeAction.cs
示例17: GetParameterModifiers
private static IEnumerable<SyntaxToken> GetParameterModifiers(IParameterSymbol parameter, bool isThisParameter)
{
if (isThisParameter)
{
yield return SyntaxFactory.Token(SyntaxKind.ThisKeyword);
}
switch (parameter.RefKind)
{
case RefKind.None:
break;
case RefKind.Ref:
yield return SyntaxFactory.Token(SyntaxKind.RefKeyword);
break;
case RefKind.Out:
yield return SyntaxFactory.Token(SyntaxKind.OutKeyword);
break;
default:
break;
}
if (parameter.IsParams)
{
yield return SyntaxFactory.Token(SyntaxKind.ParamsKeyword);
}
}
开发者ID:dotnet,项目名称:docfx,代码行数:24,代码来源:CSYamlModelGenerator.cs
示例18: GetParameter
private static ParameterSyntax GetParameter(IParameterSymbol p, IFilterVisitor filterVisitor, bool isThisParameter = false)
{
return SyntaxFactory.Parameter(
GetAttributes(p, filterVisitor, true),
SyntaxFactory.TokenList(GetParameterModifiers(p, isThisParameter)),
GetTypeSyntax(p.Type),
SyntaxFactory.Identifier(p.Name),
GetDefaultValueClause(p));
}
开发者ID:dotnet,项目名称:docfx,代码行数:9,代码来源:CSYamlModelGenerator.cs
示例19: GenerateEqualsValueClauseWorker
private static ExpressionSyntax GenerateEqualsValueClauseWorker(
IParameterSymbol parameter,
object value)
{
return ExpressionGenerator.GenerateExpression(parameter.Type, value, canUseFieldReference: true);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:6,代码来源:ParameterGenerator.cs
示例20: AddDescriptionForParameterAsync
private async Task AddDescriptionForParameterAsync(IParameterSymbol symbol)
{
if (symbol.IsOptional)
{
var initializerParts = await GetInitializerSourcePartsAsync(symbol).ConfigureAwait(false);
if (!initializerParts.IsDefaultOrEmpty)
{
var parts = ToMinimalDisplayParts(symbol, MinimallyQualifiedFormat).ToList();
parts.AddRange(Space());
parts.AddRange(Punctuation("="));
parts.AddRange(Space());
parts.AddRange(initializerParts);
AddToGroup(SymbolDescriptionGroups.MainDescription,
Description(FeaturesResources.parameter), parts);
return;
}
}
AddToGroup(SymbolDescriptionGroups.MainDescription,
Description(FeaturesResources.parameter),
ToMinimalDisplayParts(symbol, MinimallyQualifiedFormatWithConstants));
}
开发者ID:jkotas,项目名称:roslyn,代码行数:24,代码来源:AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs
注:本文中的IParameterSymbol类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论