Ejemplo n.º 1
0
        public static async Task <bool> VerifySyntaxEquivalenceAsync(
            Document oldDocument,
            Document newDocument,
            SyntaxFactsService syntaxFacts,
            CancellationToken cancellationToken = default)
        {
            if (!string.Equals(
                    (await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false)).NormalizeWhitespace("", false).ToFullString(),
                    (await oldDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false)).NormalizeWhitespace("", false).ToFullString(),
                    StringComparison.Ordinal))
            {
                WriteLine($"Syntax roots with normalized white-space are not equivalent '{oldDocument.FilePath}'", ConsoleColor.Magenta);
                return(false);
            }

            if (!syntaxFacts.AreEquivalent(
                    await newDocument.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false),
                    await oldDocument.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false)))
            {
                WriteLine($"Syntax trees are not equivalent '{oldDocument.FilePath}'", ConsoleColor.Magenta);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        internal bool IsSupportedProject(Project project)
        {
            if (SyntaxFactsService.IsSupportedLanguage(project.Language) &&
                (Language == null || Language == project.Language))
            {
                return((ProjectNames.Count > 0)
                    ? ProjectNames.Contains(project.Name)
                    : !IgnoredProjectNames.Contains(project.Name));
            }

            return(false);
        }