当前位置: 首页>>代码示例>>C#>>正文


C# TypeSyntax.ToString方法代码示例

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


在下文中一共展示了TypeSyntax.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: GetFieldVariableName

        public static string GetFieldVariableName(TypeSyntax type, bool underscore)
        {
            var name = type.ToString();
            if (name.StartsWith("I"))
                name = name.Substring(1);

            var firstChara = name[0];
            if (Char.IsUpper(firstChara))
            {
                name = firstChara.ToString().ToLower() + name.Substring(1);
            }
            else
            {
                name += 1;
            }

            return name;
        }
开发者ID:OsvaldoJ,项目名称:orchardizer,代码行数:18,代码来源:RoslynExtensions.cs

示例4: ResolveLType

 private static string ResolveLType(TypeSyntax node)
 {
     var gensyn = node as GenericNameSyntax;
     if (null != gensyn) return gensyn.Identifier.ToString();
     else return node.ToString();
 }
开发者ID:thomas13335,项目名称:wpf2html5,代码行数:6,代码来源:CSharpToJScriptConverter.cs

示例5: BindCrefParameterOrReturnType

        /// <remarks>
        /// Keep in sync with <see cref="M:SemanticModel.GetSpeculativelyBoundExpression()"/>.
        /// </remarks>
        private TypeSymbol BindCrefParameterOrReturnType(TypeSyntax typeSyntax, MemberCrefSyntax memberCrefSyntax, DiagnosticBag diagnostics)
        {
            DiagnosticBag unusedDiagnostics = DiagnosticBag.GetInstance(); // Examined, but not reported.

            // After much deliberation, we eventually decided to suppress lookup of inherited members within
            // crefs, in order to match dev11's behavior (Changeset #829014).  Unfortunately, it turns out
            // that dev11 does not suppress these members when performing lookup within parameter and return
            // types, within crefs (DevDiv #586815, #598371).
            Debug.Assert(InCrefButNotParameterOrReturnType);
            Binder parameterOrReturnTypeBinder = this.WithAdditionalFlags(BinderFlags.CrefParameterOrReturnType);

            // It would be nice to pull this binder out of the factory so we wouldn't have to worry about them getting out
            // of sync, but this code is also used for included crefs, which don't have BinderFactories.
            // As a compromise, we'll assert that the binding locations match in scenarios where we can go through the factory.
            Debug.Assert(!this.Compilation.ContainsSyntaxTree(typeSyntax.SyntaxTree) ||
                this.Compilation.GetBinderFactory(typeSyntax.SyntaxTree).GetBinder(typeSyntax).Flags ==
                (parameterOrReturnTypeBinder.Flags & ~BinderFlags.SemanticModel));

            TypeSymbol type = parameterOrReturnTypeBinder.BindType(typeSyntax, unusedDiagnostics);

            if (unusedDiagnostics.HasAnyErrors())
            {
                if (HasNonObsoleteError(unusedDiagnostics))
                {
                    ErrorCode code = typeSyntax.Parent.Kind == SyntaxKind.ConversionOperatorMemberCref
                        ? ErrorCode.WRN_BadXMLRefReturnType
                        : ErrorCode.WRN_BadXMLRefParamType;
                    CrefSyntax crefSyntax = GetRootCrefSyntax(memberCrefSyntax);
                    diagnostics.Add(code, typeSyntax.Location, typeSyntax.ToString(), crefSyntax.ToString());
                }
            }
            else
            {
                Debug.Assert(type.TypeKind != TypeKind.Error || typeSyntax.ContainsDiagnostics || !typeSyntax.SyntaxTree.ReportDocumentationCommentDiagnostics(), "Why wasn't there a diagnostic?");
            }

            unusedDiagnostics.Free();

            return type;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:43,代码来源:Binder_Crefs.cs

示例6: GetTypeScriptEquivalentType

        private static string GetTypeScriptEquivalentType(TypeSyntax field)
        {
            var type = "";
            switch (field.ToString().ToLower())
            {
                case "int":
                case "float":
                case "small":
                case "bigint":
                    type = "number";
                    break;
                default:
                    type = field.ToString();
                    break;
            }

            return type;
        }
开发者ID:TrabacchinLuigi,项目名称:RoslynExporter,代码行数:18,代码来源:CodeRefactoringProvider.cs

示例7: GetMappedType

        private string GetMappedType(TypeSyntax type)
        {
            if (type.ToString() == "void")
                return "void";

            if (type.ToString().EndsWith("Exception"))
                return type.ToString();

            return type.ToString().StartsWith("int") ? "number" : "string";
        }
开发者ID:benlaan,项目名称:cs2ts,代码行数:10,代码来源:Transpiler.cs

示例8: BuildVariableDeclaration

 // The "target = new Class1()" portion of "Class1 target = new Class1();"
 private VariableDeclarationSyntax BuildVariableDeclaration(TypeSyntax variableType, string variableName)
 {
     return SyntaxFactory.VariableDeclaration(variableType,
             SyntaxFactory.SingletonSeparatedList<VariableDeclaratorSyntax>(
                 SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier(SyntaxFactory.TriviaList(), variableName, SyntaxFactory.TriviaList(SyntaxFactory.Space)))
                     .WithInitializer(
                         SyntaxFactory.EqualsValueClause(
                             SyntaxFactory.ObjectCreationExpression(SyntaxFactory.IdentifierName(variableType.ToString()))
                             .WithNewKeyword(SyntaxFactory.Token(SyntaxFactory.TriviaList(SyntaxFactory.Space), SyntaxKind.NewKeyword, SyntaxFactory.TriviaList(SyntaxFactory.Space)))
                             .WithArgumentList(SyntaxFactory.ArgumentList())
                         )
                     )
             )
     );
 }
开发者ID:tategriffin,项目名称:Cartographer,代码行数:16,代码来源:FirstParameterToReturnTypeClassMapper.cs

示例9: GetName

 private string GetName(TypeSyntax name)
 {
     return (name as SimpleNameSyntax).Identifier.ToString() ?? name.ToString();
 }
开发者ID:nukefusion,项目名称:StyleCopAnalyzers,代码行数:4,代码来源:StandardTextDiagnosticBase.cs

示例10: GetFullReturnType

        private string GetFullReturnType(TypeSyntax returnType)
        {
            var fullReturnType = returnType.ToString();
            var node = returnType.DescendantNodes().OfType<IdentifierNameSyntax>().FirstOrDefault();
            Document cl = null;

            var systemTypes = new List<string>()
            {
                "Guid",
                "Guid?"
            };

            if (node != null && systemTypes.All(x => x != node.Identifier.ToString() && x != returnType.ToString()))
            {
                var nameSpace = SymbolFinder.FindDeclarationsAsync(_project, node.Identifier.ValueText, ignoreCase: false).Result.Last().ContainingNamespace.ToString();

                fullReturnType = fullReturnType.Replace(node.Identifier.ToString(), nameSpace + "." + node.Identifier);
            }

            return fullReturnType;
        }
开发者ID:yumapos,项目名称:Yumapos-WCF-Generator,代码行数:21,代码来源:WCFGenerator.cs

示例11: TypeInspector

 public TypeInspector(TypeSyntax typeSyntax)
 {
     ShortName = typeSyntax.ToString();
 }
开发者ID:cdsalmons,项目名称:OrleansTemplates,代码行数:4,代码来源:TypeInspector.cs


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