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


C# IdentifierNameSyntax.ToString方法代码示例

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


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

示例1: RewriteExpression

        /// <summary>
        /// Rewrites the expression with a field access expression.
        /// </summary>
        /// <param name="node">IdentifierNameSyntax</param>
        /// <returns>SyntaxNode</returns>
        private SyntaxNode RewriteExpression(IdentifierNameSyntax node)
        {
            SyntaxNode rewritten = node;

            if (!base.IsInStateScope(rewritten) ||
                !(base.IsMachineField(rewritten) || base.IsMachineMethod(rewritten)))
            {
                return rewritten;
            }

            if (!(rewritten.Parent is MemberAccessExpressionSyntax) &&
                !(rewritten.Parent is ObjectCreationExpressionSyntax) &&
                !(rewritten.Parent is TypeOfExpressionSyntax))
            {
                var text = "this." + node.ToString();

                rewritten = SyntaxFactory.ParseExpression(text);
                rewritten = rewritten.WithTriviaFrom(node);
            }

            if ((rewritten.Parent is MemberAccessExpressionSyntax) &&
                (rewritten.Parent as MemberAccessExpressionSyntax).Expression is IdentifierNameSyntax &&
                ((rewritten.Parent as MemberAccessExpressionSyntax).Expression as IdentifierNameSyntax).
                IsEquivalentTo(node))
            {
                var text = "this." + node.ToString();

                rewritten = SyntaxFactory.ParseExpression(text);
                rewritten = rewritten.WithTriviaFrom(node);
            }

            return rewritten;
        }
开发者ID:jerickmsft,项目名称:PSharp,代码行数:38,代码来源:FieldAccessRewriter.cs

示例2: RewriteExpression

        /// <summary>
        /// Rewrites the expression with a field access expression.
        /// </summary>
        /// <param name="node">IdentifierNameSyntax</param>
        /// <returns>SyntaxNode</returns>
        private SyntaxNode RewriteExpression(IdentifierNameSyntax node)
        {
            SyntaxNode rewritten = node;

            if (!base.IsInStateScope(rewritten) ||
                !(base.IsMachineField(rewritten) || base.IsMachineMethod(rewritten)))
            {
                return rewritten;
            }

            if (rewritten.Parent is ArgumentSyntax &&
                rewritten.Parent.Parent is ArgumentListSyntax &&
                rewritten.Parent.Parent.Parent is InvocationExpressionSyntax)
            {
                var invocation = rewritten.Parent.Parent.Parent as InvocationExpressionSyntax;
                if (invocation.Expression is IdentifierNameSyntax &&
                    (invocation.Expression as IdentifierNameSyntax).Identifier.ValueText.Equals("nameof") &&
                    invocation.ArgumentList.Arguments.Count == 1)
                {
                    return rewritten;
                }
            }

            if (!(rewritten.Parent is MemberAccessExpressionSyntax) &&
                !(rewritten.Parent is ObjectCreationExpressionSyntax) &&
                !(rewritten.Parent is TypeOfExpressionSyntax))
            {
                var text = "this." + node.ToString();

                rewritten = SyntaxFactory.ParseExpression(text);
                rewritten = rewritten.WithTriviaFrom(node);
            }

            if ((rewritten.Parent is MemberAccessExpressionSyntax) &&
                (rewritten.Parent as MemberAccessExpressionSyntax).Expression is IdentifierNameSyntax &&
                ((rewritten.Parent as MemberAccessExpressionSyntax).Expression as IdentifierNameSyntax).
                IsEquivalentTo(node))
            {
                var text = "this." + node.ToString();

                rewritten = SyntaxFactory.ParseExpression(text);
                rewritten = rewritten.WithTriviaFrom(node);
            }

            return rewritten;
        }
开发者ID:jerickmsft,项目名称:PSharp,代码行数:51,代码来源:FieldAccessRewriter.cs

示例3: ReplaceWrongDateTimeUsageWithNodaTimeEquivalent

 private async Task<Document> ReplaceWrongDateTimeUsageWithNodaTimeEquivalent(Document document, IdentifierNameSyntax node, CancellationToken cancellationToken) {
     string replacement = node.ToString() == "Today" ? "SystemClock.Instance.Now.InZone(DateTimeZoneProviders.Tzdb.GetSystemDefault()).Date"
                                                     : "SystemClock.Instance.Now";
     return await ApplyReplacement(document, node, cancellationToken, replacement, "NodaTime");
 }
开发者ID:vuder,项目名称:CodingStandardCodeAnalyzers,代码行数:5,代码来源:DateTimeClassUsageCodeAnalyzerCodeFixProvider.cs

示例4: VisitIdentifierName

 public override void VisitIdentifierName(IdentifierNameSyntax node)
 {
     VisitSymbol(node.ToString());
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-codeformatter-dotnet,代码行数:4,代码来源:PreprocessorSymbolTracker.cs

示例5: ReplaceWrongDateTimeUsageWithDateTimeOffset

 private async Task<Document> ReplaceWrongDateTimeUsageWithDateTimeOffset(Document document, IdentifierNameSyntax node, CancellationToken cancellationToken) {
     return await ApplyReplacement(document, node, cancellationToken, "DateTimeOffset.Now" + (node.ToString() == "Today" ? ".Date" : ""), "System");
 }
开发者ID:vuder,项目名称:CodingStandardCodeAnalyzers,代码行数:3,代码来源:DateTimeClassUsageCodeAnalyzerCodeFixProvider.cs


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