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


C# ExpressionStatementSyntax.ToString方法代码示例

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


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

示例1: RewriteStatement

        /// <summary>
        /// Rewrites the raise statement.
        /// </summary>
        /// <param name="node">ExpressionStatementSyntax</param>
        /// <returns>SyntaxNode</returns>
        private SyntaxNode RewriteStatement(ExpressionStatementSyntax node)
        {
            var text = "{ " + node.ToString() + "return; }";
            var rewritten = SyntaxFactory.ParseStatement(text);
            rewritten = rewritten.WithTriviaFrom(node);

            return rewritten;
        }
开发者ID:yonglehou,项目名称:PSharp,代码行数:13,代码来源:RaiseRewriter.cs

示例2: AssignMethodReturnToReceiverAsync

        private async Task<Document> AssignMethodReturnToReceiverAsync(CodeFixContext context, Document document, ExpressionStatementSyntax statement, string receiverName, CancellationToken c)
        {
            var rValueExpr = statement.ToString();
            var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);
            var memberAccess = root.FindNode(context.Span)?.FirstAncestorOrSelf<MemberAccessExpressionSyntax>();

            var declaration = SyntaxFactory
                .ParseStatement($"{receiverName} = {rValueExpr}");

            var formattedDeclaration = declaration.WithTriviaFrom(statement);
            // Replace the old statement with the block:
            var newRoot = root.ReplaceNode((SyntaxNode)statement, formattedDeclaration);

            var newDocument = document.WithSyntaxRoot(newRoot);
            return newDocument;

        }
开发者ID:Winsto,项目名称:MVA-Roslyn,代码行数:17,代码来源:PureMethodsFixer.cs

示例3: VisitExpressionStatement

 public override void VisitExpressionStatement(ExpressionStatementSyntax node)
 {
     // TODO: Don't just emit the expression as-is. Need to process the nodes of the expression
     Emit(node.ToString());
 }
开发者ID:benlaan,项目名称:cs2ts,代码行数:5,代码来源:Transpiler.cs

示例4: AssignMethodReturnToNewVariable

        private async Task<Document> AssignMethodReturnToNewVariable(Document document, ExpressionStatementSyntax statement, CancellationToken c)
        {
            var rValueExpr = statement.ToString();
            var semanticModel = await document.GetSemanticModelAsync();
            var newVariable = FindAvailableVariableName("returnValue",
                statement, semanticModel);

            var declaration = SyntaxFactory.ParseStatement($"var {newVariable} = {rValueExpr}");

            var formattedDeclaration = declaration.WithTriviaFrom(statement);
            // Replace the old statement with the block:
            var root = await document.GetSyntaxRootAsync();
            var newRoot = root.ReplaceNode((SyntaxNode)statement, formattedDeclaration);

            var newDocument = document.WithSyntaxRoot(newRoot);
            return newDocument;

        }
开发者ID:Winsto,项目名称:MVA-Roslyn,代码行数:18,代码来源:PureMethodsFixer.cs

示例5: VisitExpressionStatement

 public override void VisitExpressionStatement(ExpressionStatementSyntax node)
 {
     _2JS.AppendLine(node.ToString());
     base.VisitExpressionStatement(node);
 }
开发者ID:ghostnguyen,项目名称:daccf960-44f9-4f95-91c4-b1aba37effe1,代码行数:5,代码来源:Syntax2Str.cs


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