本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.Kind方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclarationSyntax.Kind方法的具体用法?C# TypeDeclarationSyntax.Kind怎么用?C# TypeDeclarationSyntax.Kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax
的用法示例。
在下文中一共展示了TypeDeclarationSyntax.Kind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMetricKind
private static TypeMetricKind GetMetricKind(TypeDeclarationSyntax type)
{
switch (type.Kind())
{
case SyntaxKind.ClassDeclaration:
return TypeMetricKind.Class;
case SyntaxKind.StructDeclaration:
return TypeMetricKind.Struct;
case SyntaxKind.InterfaceDeclaration:
return TypeMetricKind.Interface;
default:
return TypeMetricKind.Unknown;
}
}
示例2: ReplaceModifiers
// This code was copied from the Roslyn code base (and slightly modified). It can be removed if
// TypeDeclarationSyntaxExtensions.WithModifiers is made public (Roslyn issue #2186)
private static TypeDeclarationSyntax ReplaceModifiers(TypeDeclarationSyntax node, SyntaxTokenList modifiers)
{
switch (node.Kind())
{
case SyntaxKind.ClassDeclaration:
return ((ClassDeclarationSyntax)node).WithModifiers(modifiers);
case SyntaxKind.InterfaceDeclaration:
return ((InterfaceDeclarationSyntax)node).WithModifiers(modifiers);
case SyntaxKind.StructDeclaration:
return ((StructDeclarationSyntax)node).WithModifiers(modifiers);
}
return node;
}
示例3: ClassifyUpdate
private void ClassifyUpdate(TypeDeclarationSyntax oldNode, TypeDeclarationSyntax newNode)
{
if (oldNode.Kind() != newNode.Kind())
{
ReportError(RudeEditKind.TypeKindUpdate);
return;
}
if (!SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers))
{
ReportError(RudeEditKind.ModifiersUpdate);
return;
}
if (!SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier))
{
ReportError(RudeEditKind.Renamed);
return;
}
Debug.Assert(!SyntaxFactory.AreEquivalent(oldNode.BaseList, newNode.BaseList));
ReportError(RudeEditKind.BaseTypeOrInterfaceUpdate);
}
示例4: ReplaceKeyword
// This code was copied from the Roslyn code base (and slightly modified). It can be removed if
// TypeDeclarationSyntaxExtensions.WithModifiers is made public (Roslyn issue #2186)
private static TypeDeclarationSyntax ReplaceKeyword(TypeDeclarationSyntax node, SyntaxToken keyword)
{
switch (node.Kind())
{
case SyntaxKind.ClassDeclaration:
return ((ClassDeclarationSyntax)node).WithKeyword(keyword);
case SyntaxKind.InterfaceDeclaration:
return ((InterfaceDeclarationSyntax)node).WithKeyword(keyword);
case SyntaxKind.StructDeclaration:
return ((StructDeclarationSyntax)node).WithKeyword(keyword);
}
return node;
}
示例5: 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(TypeDeclarationSyntax syntax)
{
return GetSourceTypeMember(syntax.Identifier.ValueText, syntax.Arity, syntax.Kind(), syntax);
}