Esempio n. 1
0
        public void ResXAndDesignerFilesShouldBeConsistentAndNotCauseUnnecessaryMergeConflicts()
        {
            List <string> resxFiles = new();

            foreach (string file in System.IO.Directory.GetFiles(BaselineHelper.GetAbsolutePathRelativeToRepoRoot(""), "*.resx", SearchOption.AllDirectories))
            {
                resxFiles.Add(file);
            }
            resxFiles.Should().HaveCountGreaterThan(2, "There should be at least 3 resx files found in the project");

            foreach (string resXRelativePath in resxFiles)
            {
                using (new AssertionScope(resXRelativePath))
                {
                    AssertDoesNotContainTabs(resXRelativePath, GetRelativeFileContents(resXRelativePath));
                }

                string designerRelativePath = Path.ChangeExtension(resXRelativePath, ".Designer.cs");
                using (new AssertionScope(designerRelativePath))
                {
                    string designerFileContents = GetRelativeFileContents(designerRelativePath);
                    AssertDoesNotContainTabs(designerFileContents, designerFileContents);

                    if (designerFileContents.Contains("get\n"))
                    {
                        throw new Exception($"{designerRelativePath} should be formatted with this style:\n\n  get\n  {{\n\nand not this style:\n\n  get {{\n\n{Info}");
                    }
                }
            }
        }
Esempio n. 2
0
    private void WriteTarballFileList(string?tarballPath, string outputFileName, bool isPortable)
    {
        if (!File.Exists(tarballPath))
        {
            throw new InvalidOperationException($"Tarball path '{tarballPath}' does not exist.");
        }

        string fileListing = ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"tf {tarballPath}", OutputHelper);

        fileListing = BaselineHelper.RemoveRids(fileListing, isPortable);
        IEnumerable <string> files = fileListing.Split(Environment.NewLine).OrderBy(path => path);

        File.WriteAllLines(outputFileName, files);
    }
Esempio n. 3
0
    public void CompareMsftToSb()
    {
        const string msftFileListingFileName = "msftSdkFiles.txt";
        const string sbFileListingFileName   = "sbSdkFiles.txt";

        WriteTarballFileList(Config.MsftSdkTarballPath, msftFileListingFileName, isPortable: true);
        WriteTarballFileList(Config.SdkTarballPath, sbFileListingFileName, isPortable: false);

        string diff = BaselineHelper.DiffFiles(msftFileListingFileName, sbFileListingFileName, OutputHelper);

        diff = BaselineHelper.RemoveVersions(diff);
        diff = RemoveDiffMarkers(diff);
        BaselineHelper.CompareContents("MsftToSbSdk.diff", diff, OutputHelper, Config.WarnOnSdkContentDiffs);
    }
Esempio n. 4
0
    public void CompareMsftToSb()
    {
        const string msftFileListingFileName = "msftSdkFiles.txt";
        const string sbFileListingFileName   = "sbSdkFiles.txt";

        WriteTarballFileList(Config.MsftSdkTarballPath, msftFileListingFileName);
        WriteTarballFileList(Config.SdkTarballPath, sbFileListingFileName);

        string diff = BaselineHelper.DiffFiles(msftFileListingFileName, sbFileListingFileName, OutputHelper);

        diff = RemoveVersionedPaths(diff);
        diff = RemoveDiffMarkers(diff);
        diff = RemoveRids(diff);
        BaselineHelper.CompareContents("MsftToSbSdk.diff", diff, OutputHelper);
    }
Esempio n. 5
0
    public void FormatProject()
    {
        string unformattedCsFilePath = Path.Combine(BaselineHelper.GetAssetsDirectory(), UnformattedFileName);

        string projectDirectory = DotNetHelper.ExecuteNew("console", nameof(FormatProject), "C#");

        string projectFilePath = Path.Combine(projectDirectory, nameof(FormatProject) + ".csproj");
        string testFilePath    = Path.Combine(projectDirectory, TestFileName);

        File.Copy(unformattedCsFilePath, testFilePath);

        DotNetHelper.ExecuteCmd($"format {projectFilePath}");

        BaselineHelper.CompareFiles(ExpectedFormattedFileName, testFilePath, OutputHelper);
    }
Esempio n. 6
0
        private string GetRelativeFileContents(string relativePath)
        {
            var path = BaselineHelper.GetAbsolutePathRelativeToRepoRoot(relativePath);

            return(File.ReadAllText(path));
        }