• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Syntax.TypeSyntax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax的典型用法代码示例。如果您正苦于以下问题:C# TypeSyntax类的具体用法?C# TypeSyntax怎么用?C# TypeSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeSyntax类属于Microsoft.CodeAnalysis.CSharp.Syntax命名空间,在下文中一共展示了TypeSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetAllReferencedTypes

		private static IEnumerable<TypeSyntax> GetAllReferencedTypes(TypeSyntax type, SyntaxNodeAnalysisContext context)
		{
			if (type == null)
				throw new ArgumentNullException(nameof(type));

			// The "all referenced types" set will be the current type and any generic type parameters that it has (and any generic type parameters that
			// they might have)..
			yield return type;

			// .. so, if this type doesn't have any type parameters then we're done here..
			// If this isn't 
			var genericTypeIfApplicable = type as GenericNameSyntax;
			if (genericTypeIfApplicable == null)
				yield break;

			// .. alternatively, if the type has the Bridge [IgnoreGeneric] attribute on it then we don't need to worry about the type parameters since
			// there won't be references to them at runtime
			var typeSymbolInfo = context.SemanticModel.GetSymbolInfo(type);
			if ((typeSymbolInfo.Symbol != null) && typeSymbolInfo.Symbol.GetAttributes().Any(attribute => IsBridgeClass(attribute.AttributeClass, "IgnoreGenericAttribute")))
				yield break;

			foreach (var typeParameter in genericTypeIfApplicable.TypeArgumentList.Arguments)
			{
				foreach (var typeRelatedToTypeParameter in GetAllReferencedTypes(typeParameter, context))
					yield return typeRelatedToTypeParameter;
			}
		}
开发者ID:ProductiveRage,项目名称:Bridge.React,代码行数:27,代码来源:ReactElementAnalyser.cs


示例2: GetTrackerClassName

        public static string GetTrackerClassName(TypeSyntax type)
        {
            // NOTE: it's naive approach because we don't know semantic type information here.
            var genericType = type as GenericNameSyntax;
            if (genericType == null)
            {
                if (type.ToString().StartsWith("Trackable"))
                {
                    return $"TrackablePocoTracker<I{type.ToString().Substring(9)}>";
                }
            }
            else if (CodeAnalaysisExtensions.CompareTypeName(genericType.Identifier.ToString(),
                                                             "TrackableData.TrackableDictionary"))
            {
                return $"TrackableDictionaryTracker{genericType.TypeArgumentList}";
            }
            else if (CodeAnalaysisExtensions.CompareTypeName(genericType.Identifier.ToString(),
                                                             "TrackableData.TrackableSet"))
            {
                return $"TrackableSetTracker{genericType.TypeArgumentList}";
            }
            else if (CodeAnalaysisExtensions.CompareTypeName(genericType.Identifier.ToString(),
                                                             "TrackableData.TrackableList"))
            {
                return $"TrackableListTracker{genericType.TypeArgumentList}";
            }

            throw new Exception("Cannot resolve tracker class of " + type);
        }
开发者ID:SaladLab,项目名称:TrackableData,代码行数:29,代码来源:Utility.cs


示例3: AddTypeParameters

 private void AddTypeParameters(TypeSyntax typeSyntax, MultiDictionary<string, TypeParameterSymbol> map)
 {
     switch (typeSyntax.Kind())
     {
         case SyntaxKind.AliasQualifiedName:
             AddTypeParameters(((AliasQualifiedNameSyntax)typeSyntax).Name, map);
             break;
         case SyntaxKind.QualifiedName:
             // NOTE: Dev11 does not warn about duplication, it just matches parameter types to the
             // *last* type parameter with the same name.  That's why we're iterating backwards.
             QualifiedNameSyntax qualifiedNameSyntax = (QualifiedNameSyntax)typeSyntax;
             AddTypeParameters(qualifiedNameSyntax.Right, map);
             AddTypeParameters(qualifiedNameSyntax.Left, map);
             break;
         case SyntaxKind.GenericName:
             AddTypeParameters((GenericNameSyntax)typeSyntax, map);
             break;
         case SyntaxKind.IdentifierName:
         case SyntaxKind.PredefinedType:
             break;
         default:
             Debug.Assert(false, "Unexpected type syntax kind " + typeSyntax.Kind());
             break;
     }
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:25,代码来源:WithCrefTypeParametersBinder.cs


示例4: IsTrackableType

 public static bool IsTrackableType(TypeSyntax type)
 {
     // NOTE: it's naive approach because we don't know semantic type information here.
     var parts = type.ToString().Split('.');
     var typeName = parts[parts.Length - 1];
     return typeName.StartsWith("Trackable");
 }
开发者ID:SaladLab,项目名称:TrackableData,代码行数:7,代码来源:Utility.cs


示例5: HandleDeclaration

        private static void HandleDeclaration(SyntaxNodeAnalysisContext context, TypeSyntax returnType)
        {
            var predefinedType = returnType as PredefinedTypeSyntax;

            if (predefinedType != null && predefinedType.Keyword.IsKind(SyntaxKind.VoidKeyword))
            {
                // There is no return value
                return;
            }

            var documentationStructure = context.Node.GetDocumentationCommentTriviaSyntax();

            if (documentationStructure == null)
            {
                return;
            }

            if (documentationStructure.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null)
            {
                // Don't report if the documentation is inherited.
                return;
            }

            if (documentationStructure.Content.GetFirstXmlElement(XmlCommentHelper.ReturnsXmlTag) == null)
            {
                context.ReportDiagnostic(Diagnostic.Create(Descriptor, returnType.GetLocation()));
            }
        }
开发者ID:robinsedlaczek,项目名称:StyleCopAnalyzers,代码行数:28,代码来源:SA1615ElementReturnValueMustBeDocumented.cs


示例6: MethodDeclaration

 public static MethodDeclarationSyntax MethodDeclaration(
     SyntaxList<AttributeListSyntax> attributeLists,
     SyntaxTokenList modifiers,
     TypeSyntax returnType,
     ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier,
     SyntaxToken identifier,
     TypeParameterListSyntax typeParameterList,
     ParameterListSyntax parameterList,
     SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses,
     BlockSyntax body,
     SyntaxToken semicolonToken)
 {
     return SyntaxFactory.MethodDeclaration(
         attributeLists,
         modifiers,
         default(SyntaxToken),
         returnType,
         explicitInterfaceSpecifier,
         identifier,
         typeParameterList,
         parameterList,
         constraintClauses,
         body,
         default(ArrowExpressionClauseSyntax),
         semicolonToken);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:26,代码来源:MethodDeclarationSyntax.cs


示例7: TryAnalyzeVariableDeclaration

        protected override bool TryAnalyzeVariableDeclaration(TypeSyntax typeName, SemanticModel semanticModel, OptionSet optionSet, CancellationToken cancellationToken, out TextSpan issueSpan)
        {
            issueSpan = default(TextSpan);

            // If it is currently not var, explicit typing exists, return. 
            // this also takes care of cases where var is mapped to a named type via an alias or a class declaration.
            if (!typeName.IsTypeInferred(semanticModel))
            {
                return false;
            }

            if (typeName.Parent.IsKind(SyntaxKind.VariableDeclaration) &&
                typeName.Parent.Parent.IsKind(SyntaxKind.LocalDeclarationStatement, SyntaxKind.ForStatement, SyntaxKind.UsingStatement))
            {
                // check assignment for variable declarations.
                var variable = ((VariableDeclarationSyntax)typeName.Parent).Variables.First();
                if (!AssignmentSupportsStylePreference(variable.Identifier, typeName, variable.Initializer, semanticModel, optionSet, cancellationToken))
                {
                    return false;
                }
            }

            issueSpan = typeName.Span;
            return true;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:25,代码来源:CSharpUseExplicitTypeDiagnosticAnalyzer.cs


示例8: BuildDeclaration

        public MethodDeclarationSyntax BuildDeclaration(TypeSyntax returnType, string name, IEnumerable<ParameterSyntax> paramsInfo)
        {
            MethodDeclarationSyntax mDecl = SF.MethodDeclaration (returnType, name);
            mDecl = mDecl.AddModifiers (SF.Token (SyntaxKind.PublicKeyword));
            mDecl = mDecl.AddParameterListParameters (paramsInfo.ToArray ());

            return mDecl;
        }
开发者ID:newky2k,项目名称:sample-translator,代码行数:8,代码来源:MethodBuilder.cs


示例9: MakeForeachLocal

 public static SourceLocalSymbol MakeForeachLocal(
     MethodSymbol containingMethod,
     ForEachLoopBinder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     ExpressionSyntax collection)
 {
     return new SourceLocalSymbol(containingMethod, binder, typeSyntax, identifierToken, null, collection, LocalDeclarationKind.ForEach);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:9,代码来源:SourceLocalSymbol.cs


示例10: FurnaceTypeWriter

        public FurnaceTypeWriter(string baseClassFullName)
        {
            GuardBaseClass(baseClassFullName);
            var typeIndex = baseClassFullName.LastIndexOf('.') + 1;
            _typeName = baseClassFullName.Substring(typeIndex);
            _typeNamespace = baseClassFullName.Substring(0, typeIndex - 1);

            _baseTypeSyntax = SyntaxFactory.ParseTypeName(baseClassFullName);
        }
开发者ID:laurentkempe,项目名称:Furnace,代码行数:9,代码来源:FurnaceTypeWriter.cs


示例11: PerformAction

 internal static Document PerformAction(Document document, SyntaxNode root, TypeSyntax type)
 {
     var newRoot = root.ReplaceNode((SyntaxNode)
         type,
         SyntaxFactory.IdentifierName("var")
         .WithLeadingTrivia(type.GetLeadingTrivia())
         .WithTrailingTrivia(type.GetTrailingTrivia())
     );
     return document.WithSyntaxRoot(newRoot);
 }
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:10,代码来源:ReplaceExplicitTypeWithVarCodeRefactoringProvider.cs


示例12: CreateAutoProperty

        internal static PropertyDeclarationSyntax CreateAutoProperty(TypeSyntax type, string identifier, SyntaxList<AccessorDeclarationSyntax> accessors, SyntaxKind? accessibility)
        {
            var newProperty = SyntaxFactory.PropertyDeclaration(type, identifier)
                .WithAccessorList(SyntaxFactory.AccessorList(accessors));

            if (accessibility.HasValue)
                newProperty = newProperty.WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(accessibility.Value)));

            return newProperty.WithAdditionalAnnotations(Formatter.Annotation);
        }
开发者ID:ceddlyburge,项目名称:RefactoringEssentials,代码行数:10,代码来源:Manipulations.cs


示例13: MakeLocal

 public static SourceLocalSymbol MakeLocal(
     Symbol containingSymbol,
     Binder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     LocalDeclarationKind declarationKind)
 {
     Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
     return new SourceLocalSymbol(containingSymbol, binder, typeSyntax, identifierToken, declarationKind);
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:10,代码来源:SourceLocalSymbol.cs


示例14: PerformAction

 static Document PerformAction(Document document, SemanticModel model, SyntaxNode root, ITypeSymbol type, TypeSyntax typeSyntax)
 {
     var newRoot = root.ReplaceNode((SyntaxNode)
         typeSyntax,
         SyntaxFactory.ParseTypeName(type.ToMinimalDisplayString(model, typeSyntax.SpanStart))
         .WithLeadingTrivia(typeSyntax.GetLeadingTrivia())
         .WithTrailingTrivia(typeSyntax.GetTrailingTrivia())
     );
     return document.WithSyntaxRoot(newRoot);
 }
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:10,代码来源:ReplaceVarWithExplicitTypeCodeRefactoringProvider.cs


示例15: QueryUnboundLambdaState

 public QueryUnboundLambdaState(UnboundLambda unbound, Binder binder, RangeVariableMap rangeVariableMap, ImmutableArray<RangeVariableSymbol> parameters, ExpressionSyntax body, TypeSyntax castTypeSyntax, TypeSymbol castType)
     : this(unbound, binder, rangeVariableMap, parameters, (LambdaSymbol lambdaSymbol, ExecutableCodeBinder lambdaBodyBinder, DiagnosticBag diagnostics) =>
 {
     BoundExpression expression = lambdaBodyBinder.BindValue(body, diagnostics, BindValueKind.RValue);
     Debug.Assert((object)castType != null);
     Debug.Assert(castTypeSyntax != null);
     // We transform the expression from "expr" to "expr.Cast<castTypeOpt>()".
     expression = lambdaBodyBinder.MakeQueryInvocation(body, expression, "Cast", castTypeSyntax, castType, diagnostics);
     return lambdaBodyBinder.WrapExpressionLambdaBody(expression, body, diagnostics);
 })
 { }
开发者ID:riversky,项目名称:roslyn,代码行数:11,代码来源:Binder.QueryUnboundLambdaState.cs


示例16: HoistVariable

 protected SyntaxNode HoistVariable(CSharpSyntaxNode node, ref SyntaxToken identifier, TypeSyntax type)
 {
     if (hoistedVariables.ContainsKey(identifier.ToString()))
     {
         var newName = GenerateNewName(identifier);
         var newIdentifier = SyntaxFactory.Identifier(newName);
         identifier = newIdentifier;
     }
     hoistedVariables[identifier.ToString()] = type;
     return node;
 }
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:11,代码来源:StateGenerator.cs


示例17: MakePossibleOutVarLocalWithoutInitializer

 public static SourceLocalSymbol MakePossibleOutVarLocalWithoutInitializer(
     Symbol containingSymbol,
     Binder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     CSharpSyntaxNode scopeSegmentRoot,
     LocalDeclarationKind declarationKind)
 {
     Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
     return new PossibleOutVarLocalWithoutInitializer(containingSymbol, binder, typeSyntax, identifierToken, scopeSegmentRoot, declarationKind);
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs


示例18: MakeLocal

 public static SourceLocalSymbol MakeLocal(
     MethodSymbol containingMethod,
     Binder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     EqualsValueClauseSyntax initializer,
     LocalDeclarationKind declarationKind)
 {
     Debug.Assert(declarationKind != LocalDeclarationKind.ForEach);
     return new SourceLocalSymbol(containingMethod, binder, typeSyntax, identifierToken, initializer, null, declarationKind);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs


示例19: MakeLocalWithInitializer

 public static SourceLocalSymbol MakeLocalWithInitializer(
     Symbol containingSymbol,
     Binder binder,
     TypeSyntax typeSyntax,
     SyntaxToken identifierToken,
     EqualsValueClauseSyntax initializer,
     LocalDeclarationKind declarationKind)
 {
     Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
     return new LocalWithInitializer(containingSymbol, binder, typeSyntax, identifierToken, initializer, declarationKind);
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs


示例20: FilterType

		protected void FilterType(TypeSyntax syntax)
		{
			if (syntax.IsKind(SyntaxKind.PredefinedType))
			{
				var symbolInfo = SemanticModel.GetSymbolInfo(syntax);
				if ((symbolInfo.Symbol != null) && (symbolInfo.Symbol.Kind == SymbolKind.NamedType))
				{
					var symbol = (ITypeSymbol)symbolInfo.Symbol;
					FilterTypeSymbol(symbol);
				}
			}
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:12,代码来源:ClassCouplingAnalyzerBase.cs



注:本文中的Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Syntax.VariableDeclarationSyntax类代码示例发布时间:2022-05-26
下一篇:
C# Syntax.TypeDeclarationSyntax类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap