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}"); } } } }
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); }
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); }
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); }
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); }
private string GetRelativeFileContents(string relativePath) { var path = BaselineHelper.GetAbsolutePathRelativeToRepoRoot(relativePath); return(File.ReadAllText(path)); }