private static void HasTargetFrameworkAndImplicitUsings(
        bool throwIf,
        ILogger logger,
        DirectoryInfo projectPath,
        string targetFramework)
    {
        var foundDirectoryBuildPropsFilesWithImplicitUsings = DirectoryBuildPropsHelper.SearchAllForElement(
            projectPath,
            "ImplicitUsings",
            "enable",
            SearchOption.TopDirectoryOnly,
            StringComparison.OrdinalIgnoreCase);

        if (!foundDirectoryBuildPropsFilesWithImplicitUsings.Any())
        {
            return;
        }

        var foundFiles = DotnetCsProjHelper.SearchAllForElement(
            projectPath,
            "TargetFramework",
            targetFramework);

        if (!foundFiles.Any())
        {
            return;
        }

        var sb     = new StringBuilder();
        var header = $"TargetFramework '{targetFramework}' in .csproj can causes build errors when /Directory.Build.Props has ImplicitUsings enabled, please manually upgrade the following files:";

        if (throwIf)
        {
            sb.AppendLine(header);
        }
        else
        {
            logger.LogWarning(header);
        }

        foreach (var fileFullName in foundFiles.Select(x => x.FullName))
        {
            if (throwIf)
            {
                sb.AppendLine(5, fileFullName);
            }
            else
            {
                logger.LogWarning($"     {fileFullName}");
            }
        }

        if (throwIf)
        {
            throw new DataException(sb.ToString());
        }
    }
    private static void HasEnableNetAnalyzers(
        bool throwIf,
        ILogger logger,
        DirectoryInfo projectPath,
        SupportedProjectTargetType projectTarget)
    {
        var foundFiles = DotnetCsProjHelper.SearchAllForElement(
            projectPath,
            "EnableNETAnalyzers",
            "true",
            SearchOption.AllDirectories,
            StringComparison.OrdinalIgnoreCase);

        if (!foundFiles.Any())
        {
            return;
        }

        var sb     = new StringBuilder();
        var header = $"EnableNETAnalyzers in .csproj causes build errors when /Directory.Build.Props has projectTarget '{projectTarget}', please remove the element from the following files:";

        if (throwIf)
        {
            sb.AppendLine(header);
        }
        else
        {
            logger.LogWarning(header);
        }

        foreach (var fileFullName in foundFiles.Select(x => x.FullName))
        {
            if (throwIf)
            {
                sb.AppendLine(5, fileFullName);
            }
            else
            {
                logger.LogWarning($"     {fileFullName}");
            }
        }

        if (throwIf)
        {
            throw new DataException(sb.ToString());
        }
    }