public void AddComment_Prepends_Leading_Text_To_First_Node() { var statements = _statementCollection.AddComment(TestStatementCommentShort); var firstStatement = statements.First(); var lastStatement = statements.Last(); Assert.AreEqual(TestCommentText, firstStatement.GetLeadingTrivia().Single().ToFullString()); Assert.IsEmpty(firstStatement.GetTrailingTrivia()); Assert.IsEmpty(lastStatement.GetLeadingTrivia()); Assert.IsEmpty(lastStatement.GetTrailingTrivia()); }
private async Task InsertRequestPipelineMiddlewareRegistrations() { try { var pipelineAdditions = await _taskManager.ManagedRun(_taskId, (token) => _lifecycleManager.GetMiddlewarePipelineAdditions(token)); _configureMethodStatements = _configureMethodStatements.Concat(pipelineAdditions); } catch (OperationCanceledException e) { LogHelper.LogError(e, string.Format( Constants.CaneledServiceCallLogTemplate, Rules.Config.Constants.WebFormsErrorTag, GetType().Name, typeof(LifecycleManagerService).Name, GetMiddlewarePipelineAdditionsLogCall)); var failureComment = string.Format(Constants.OperationFailedCommentTemplate, ConfigureRequestPipelineOperation); if (!_configureMethodStatements.Any()) { // If we don't have any extra statements for configure() add a blank // one to attach our comment to _configureMethodStatements = _configureMethodStatements.Append(CodeSyntaxHelper.GetBlankLine().AddComment(failureComment, isLeading: false)); } else { _configureMethodStatements = _configureMethodStatements.AddComment(failureComment, isLeading: false); } } }
public static IEnumerable <SyntaxType> AddComment <SyntaxType>( this IEnumerable <SyntaxType> nodeSet, string commentText, int lineCharacterSoftLimit = Constants.DefaultCommentLineCharacterLimit, bool isLeading = true) where SyntaxType : SyntaxNode { return(nodeSet.AddComment(CommentWordWrap(commentText, lineCharacterSoftLimit), isLeading)); }