public void RemoveAllSpamComments() { CreateDummyAppDataPostsDirectory(); var remover = new CommentRemover(Directory.GetCurrentDirectory(), IgnoreLog); var allPosts = remover.GetAllPosts(RemoveWordsAndViaWebservice); remover.RemoveAllSpamComments(allPosts); }
public void HandleWebserviceCrashesInContainsSpam() { CreateDummyAppDataPostsDirectory(); var remover = new CommentRemover(Directory.GetCurrentDirectory(), IgnoreLog); var allPosts = remover.GetAllPosts(RemoveWordsAndViaWebservice); remover.TryToRemoveSpamComment(allPosts, null, allPosts[0], 0); }
public void RemoveUnapprovedComments() { CreateDummyAppDataPostsDirectory(); var remover = new CommentRemover(Directory.GetCurrentDirectory(), IgnoreLog); var firstPost = remover.GetAllPosts(RemoveChoices.Unapproved)[0]; firstPost.Save(); firstPost = remover.GetAllPosts(RemoveChoices.All)[0]; Assert.AreEqual(firstPost.Comments.Count, 0); }
public TomeStream GetStream(string testFileName) { string path = Path.Combine(Config.TomePath, testFileName); string[] tome = File.ReadAllLines(path); string[] tomeNoComments = CommentRemover.RemoveComments(tome); TomeStream stream = new TomeStream(tomeNoComments); return(stream); }
public static TNode RemoveComments <TNode>(TNode node, TextSpan span, CommentFilter comments) where TNode : SyntaxNode { if (node == null) { throw new ArgumentNullException(nameof(node)); } var remover = new CommentRemover(node, comments, span); return((TNode)remover.Visit(node)); }
public void RemoveComments_Removes_End_Of_Line_Comments(string input, string expected) { // arrange var commentRemover = new CommentRemover(); // act string cleanedLine = commentRemover.RemoveComments(input); // assert Assert.AreEqual(expected, cleanedLine); }
public static async Task <Document> RemoveAllCommentsExceptXmlCommentsAsync( Document document, CancellationToken cancellationToken) { SyntaxNode oldRoot = await document.GetSyntaxRootAsync(cancellationToken); CompilationUnitSyntax newRoot = CommentRemover.RemoveFrom((CompilationUnitSyntax)oldRoot, keepXmlComment: true) .WithAdditionalAnnotations(Formatter.Annotation); return(document.WithSyntaxRoot(newRoot)); }
public void RemoveSpamCommentsInFirstPost() { CreateDummyAppDataPostsDirectory(); var remover = new CommentRemover(Directory.GetCurrentDirectory(), IgnoreLog); var firstPost = remover.GetAllPosts(RemoveWordsAndViaWebservice)[0]; Assert.AreEqual(firstPost.Comments.Count, 1); foreach (var comment in firstPost.Comments) if (comment.ContainsSpam()) comment.Remove(); firstPost.Save(); firstPost = remover.GetAllPosts(RemoveChoices.All)[0]; Assert.AreEqual(firstPost.Comments.Count, 0); }
/// <summary> /// Simple method to minify CSS content using a few regular expressions. This will throw an exception for null input. /// </summary> private string MinifyCSS(string content) { if (content == null) { throw new ArgumentNullException("content"); } content = content.Trim(); if (content == "") { return(""); } content = CommentRemover.Replace(content += "/**/", ""); // Ensure that any unclosed comments are handled content = HashSurroundingWhitespaceRemover.Replace(content, "#"); content = ExtraneousWhitespaceRemover.Replace(content, ""); content = DuplicateWhitespaceRemover.Replace(content, " "); content = DelimiterWhitespaceRemover.Replace(content, "$1"); content = content.Replace(";}", "}"); content = UnitWhitespaceRemover.Replace(content, "$1"); return(content); }
private static string Execute(string input) { var sut = new CommentRemover(); return(sut.Process(input)); }
public static TNode RemoveComments <TNode>(TNode node, CommentRemoveOptions removeOptions, TextSpan span) where TNode : SyntaxNode { return(CommentRemover.RemoveComments(node, removeOptions, span)); }
static void Main(string[] args) { if (args.Length < 1) { throw new Exception("No source file provided."); } IPreprocessor whitespaceRemover = new WhitespaceRemover(); IPreprocessor commentRemover = new CommentRemover(); IPreprocessor labelSymbolPreprocessor = new LabelSymbolPreprocessor(); IPreprocessor emptyLineRemover = new EmptyLineRemover(); IPreprocessor predefinedSymbolPreprocessor = new PredefinedSymbolPreprocessor(); IPreprocessor variableSymbolPreprocessor = new VariableSymbolPreprocessor(); IEnumerable<IPreprocessor> preprocessors = new[] { commentRemover, whitespaceRemover, labelSymbolPreprocessor, emptyLineRemover, predefinedSymbolPreprocessor, variableSymbolPreprocessor }; IDestinationsParser destinationsParser = new DestinationsParser(); IComputationOptionsParser computationOptionsParser = new ComputationOptionsParser(); IJumpConditionsParser jumpConditionsParser = new JumpConditionsParser(); IInstructionParser addressingInstructionParser = new AddressingInstructionParser(); IInstructionParser computeInstructionParser = new ComputeInstructionParser(destinationsParser, computationOptionsParser, jumpConditionsParser); IEnumerable<IInstructionParser> instructionParsers = new[] { addressingInstructionParser, computeInstructionParser }; IParser parser = new Parser(instructionParsers); IDictionary<Type, IInstructionTranslator> translators = new Dictionary<Type, IInstructionTranslator>() { { typeof(AddressingInstruction), new AddressingInstructionTranslator() }, { typeof(ComputeInstruction), new ComputeInstructionTranslator() } }; ITranslator translator = new Translator(translators); IAssembler assembler = new Assembler(preprocessors, parser, translator); for (int i = 0; i < args.Length; i++) { var lines = File.ReadAllLines(args[i]); Result<List<string>> assemblyResult = assembler.Assemble(lines); if (assemblyResult.Error != null) { Console.WriteLine($"Error: {assemblyResult.Error}"); } File.WriteAllLines(Path.ChangeExtension(args[i], ".hack"), assemblyResult.Value); Console.WriteLine($"Successfully assembled {Path.GetFileName(args[i])}."); } }
private void StartClick(object sender, RoutedEventArgs e) { try { var remover = new CommentRemover(BasePath.Text, UpdateUI); var choices = GetChoices(); var daysForRemovingUnapprovedComments = (int)Days.Value; if (workerThread != null) workerThread.Abort(); workerThread = new Thread(new ThreadStart(delegate { var posts = remover.GetAllPosts(choices, daysForRemovingUnapprovedComments); remover.RemoveAllSpamComments(posts); workerThread = null; })); workerThread.Start(); } catch (Exception ex) { MessageBox.Show("Unable to start comment remover: " + ex.Message, "BlogEngine.net Spam Comment Remover"); } }
public static TNode RemoveComment <TNode>(TNode node, CommentRemoveOptions removeOptions, TextSpan span) where TNode : SyntaxNode { CommentRemover remover = CommentRemover.Create(node, removeOptions, span); return((TNode)remover.Visit(node)); }