本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.DelegateDeclarationSyntax类的典型用法代码示例。如果您正苦于以下问题:C# DelegateDeclarationSyntax类的具体用法?C# DelegateDeclarationSyntax怎么用?C# DelegateDeclarationSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DelegateDeclarationSyntax类属于Microsoft.CodeAnalysis.CSharp.Syntax命名空间,在下文中一共展示了DelegateDeclarationSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitDelegateDeclaration
public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
if (node == null)
return null;
var symbol = _semanticModel.GetDeclaredSymbol(node);
node = (DelegateDeclarationSyntax)base.VisitDelegateDeclaration(node);
if (!IsPrivateOrInternal(symbol.DeclaredAccessibility))
node = (DelegateDeclarationSyntax)ApplyDocComment(node, symbol.GetDocumentationCommentId());
return node;
}
示例2: SourceDelegateMethodSymbol
protected SourceDelegateMethodSymbol(
SourceMemberContainerTypeSymbol delegateType,
TypeSymbol returnType,
DelegateDeclarationSyntax syntax,
MethodKind methodKind,
DeclarationModifiers declarationModifiers)
: base(delegateType, syntax.GetReference(), bodySyntaxReferenceOpt: null, location: syntax.Identifier.GetLocation())
{
_returnType = returnType;
this.MakeFlags(methodKind, declarationModifiers, _returnType.SpecialType == SpecialType.System_Void, isExtensionMethod: false);
}
示例3: VisitDelegateDeclaration
/// <summary>
///
/// </summary>
/// <param name="node"></param>
public override sealed void VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
base.VisitDelegateDeclaration(node);
}
示例4: IsTaskReturningMethod
private static bool IsTaskReturningMethod(SemanticModel semanticModel, DelegateDeclarationSyntax delegateDeclarationSyntax, CancellationToken cancellationToken)
{
return IsTaskType(semanticModel, delegateDeclarationSyntax.ReturnType, cancellationToken);
}
示例5: GetDeclaredSymbol
/// <summary>
/// Given a delegate declaration, get the corresponding type symbol.
/// </summary>
/// <param name="declarationSyntax">The syntax node that declares a delegate.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The type symbol that was declared.</returns>
public override INamedTypeSymbol GetDeclaredSymbol(DelegateDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
CheckSyntaxNode(declarationSyntax);
return GetDeclaredType(declarationSyntax);
}
示例6: HandleDelegateDeclaration
private static SyntaxNode HandleDelegateDeclaration(DelegateDeclarationSyntax node)
{
SyntaxToken triviaToken = node.DelegateKeyword;
if (triviaToken.IsMissing)
{
return null;
}
SyntaxKind defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword;
SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref triviaToken, defaultVisibility);
return node
.WithDelegateKeyword(triviaToken)
.WithModifiers(modifiers)
.WithoutFormatting();
}
示例7: VisitDelegateDeclaration
public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
//Extend:Maybe add support depend on template, e.g. MS Ajax
return node;
}
示例8: CheckDelegateVariance
private static void CheckDelegateVariance(DelegateDeclarationSyntax declaration, SyntaxNodeAnalysisContext context)
{
var declaredSymbol = context.SemanticModel.GetDeclaredSymbol(declaration);
if (declaredSymbol == null)
{
return;
}
var returnType = context.SemanticModel.GetTypeInfo(declaration.ReturnType).Type;
if (returnType == null)
{
return;
}
var parameterSymbols = declaration.ParameterList == null
? ImmutableArray<IParameterSymbol>.Empty
: declaration.ParameterList.Parameters
.Select(p => context.SemanticModel.GetDeclaredSymbol(p))
.ToImmutableArray();
if (parameterSymbols.Any(parameter => parameter == null))
{
return;
}
foreach (var typeParameter in declaredSymbol.TypeParameters
.Where(typeParameter => typeParameter.Variance == VarianceKind.None))
{
var canBeIn = CheckTypeParameter(typeParameter, VarianceKind.In, declaredSymbol, returnType, parameterSymbols);
var canBeOut = CheckTypeParameter(typeParameter, VarianceKind.Out, declaredSymbol, returnType, parameterSymbols);
if (canBeIn ^ canBeOut)
{
ReportIssue(typeParameter, canBeIn ? VarianceKind.In : VarianceKind.Out, context);
}
}
}
示例9: IsInDelegateDeclaration
internal static bool IsInDelegateDeclaration(int position, DelegateDeclarationSyntax delegateDecl)
{
Debug.Assert(delegateDecl != null);
return IsBeforeToken(position, delegateDecl, delegateDecl.SemicolonToken);
}
示例10: CreateField
/// <summary>
/// Creates a field declaration that stores <paramref name="methodDelegate" />.
/// </summary>
/// <param name="methodDelegate">The delegate the field should be created for.</param>
private FieldDeclarationSyntax CreateField(DelegateDeclarationSyntax methodDelegate)
{
return SyntaxBuilder.Field(GetFieldName(), methodDelegate.Identifier.ValueText, Visibility.Private,
_browsableAttribute, _compilerGeneratedAttribute).AsSingleLine();
}
示例11: GetSourceTypeMember
/// <summary>
/// Get a source type symbol for the given declaration syntax.
/// </summary>
/// <returns>Null if there is no matching declaration.</returns>
internal SourceNamedTypeSymbol GetSourceTypeMember(DelegateDeclarationSyntax syntax)
{
return GetSourceTypeMember(syntax.Identifier.ValueText, syntax.Arity, syntax.Kind(), syntax);
}
示例12: GetDeclaredSymbol
/// <summary>
/// Given a delegate declaration, get the corresponding type symbol.
/// </summary>
/// <param name="declarationSyntax">The syntax node that declares a delegate.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The type symbol that was declared.</returns>
public override INamedTypeSymbol GetDeclaredSymbol(DelegateDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
using (Logger.LogBlock(FunctionId.CSharp_SemanticModel_GetDeclaredSymbol, message: this.SyntaxTree.FilePath, cancellationToken: cancellationToken))
{
CheckSyntaxNode(declarationSyntax);
return GetDeclaredType(declarationSyntax);
}
}
示例13: VisitDelegateDeclaration
public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
if (compilation != null)
{
var type = compilation.GetSemanticModel(node.SyntaxTree).GetDeclaredSymbol(node);
types.Add(type);
}
delegateDeclarations.Add(node);
base.VisitDelegateDeclaration(node);
}
示例14: VisitDelegateDeclaration
public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
LS2IL.TypeExtraInfo.ClassMetadataGenerator wasClass = CurrentClass;
INamedTypeSymbol s = Model.GetDeclaredSymbol(node);
//System.Console.WriteLine(s.GetFullyQualifiedName());
TypeExtraInfo tei = Chunk.AddTypeExtraInfo(s, Model, IsLibrary);
CurrentClass = tei.MetadataGenerator;
base.VisitDelegateDeclaration(node);
CurrentClass = wasClass;
}
示例15: VisitDelegateDeclaration
public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node)
{
CheckXmlDocForErrors(node, semanticModel.GetDeclaredSymbol(node));
}