public static Mailbox BuildTree(MatchedNameCollection folderPathCollection) { List<KeyValuePair<string[], Mailbox>> paths = BuildPathsList(folderPathCollection); IComparer<KeyValuePair<string[], Mailbox>> comparer = new PathComparer(); paths.Sort(comparer); return AssembleTree(paths); }
public AnalysesSidePanel(IDispatcher dispatcher, ITaskScheduler taskScheduler, IAnalysisStorage analysisStorage) { if (dispatcher == null) { throw new ArgumentNullException(nameof(dispatcher)); } if (taskScheduler == null) { throw new ArgumentNullException(nameof(taskScheduler)); } if (analysisStorage == null) { throw new ArgumentNullException(nameof(analysisStorage)); } _dispatcher = dispatcher; _taskScheduler = taskScheduler; _analysisStorage = analysisStorage; _pathComparer = new PathComparer(); _activeById = new Dictionary <AnalysisId, AnalysisViewModel>(); _active = new ObservableCollection <AnalysisViewModel>(); _available = new ObservableCollection <AnalysisTemplateViewModel>(); _availableSnapshotsByFileName = new Dictionary <string, AnalysisSnapshotItemViewModel>(); _availableSnapshots = new ObservableCollection <AnalysisSnapshotItemViewModel>(); UpdateTooltip(); PropertyChanged += OnPropertyChanged; }
private static AdvancedAlgorithms.TestResult VerifyLiftedAugmentingPath( UndirectedGraph <int, Edge <int> > g, List <Edge <int> > liftedAugmentingPath, List <Edge <int> > expectedAugmentingPath) { bool areEdgesInOriginalGraph = AreEdgesInOriginalGraph(g, liftedAugmentingPath); if (!areEdgesInOriginalGraph) { return(new AdvancedAlgorithms.TestResult(false, "Edges in lifted path do not belong to the graph")); } //Assert.IsTrue(areEdgesInOriginalGraph, "Edges in lifted path do not belong to the graph"); if (1 != liftedAugmentingPath.Count % 2) { return(new AdvancedAlgorithms.TestResult(false, "Lifted path has even number of edges")); } //Assert.AreEqual(1, liftedAugmentingPath.Count % 2, "Lifted path has even number of edges"); var pathComparer = new PathComparer(); if (!pathComparer.Equals(expectedAugmentingPath, liftedAugmentingPath)) { return(new AdvancedAlgorithms.TestResult(false, "Paths do not match")); } //Assert.IsTrue(pathComparer.Equals(expectedAugmentingPath, liftedAugmentingPath), "Paths do not match"); return(new AdvancedAlgorithms.TestResult(true, "")); }
public FakeFileSystemTree(IEnvironment environment) { if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (environment.WorkingDirectory == null) { throw new ArgumentException("Working directory not set."); } if (environment.WorkingDirectory.IsRelative) { throw new ArgumentException("Working directory cannot be relative."); } Comparer = new PathComparer(environment.Platform.IsUnix()); _root = new FakeDirectory(this, "/") { Exists = true }; _root.Create(); }
public void GetCommonDirectoryTest() { string path1, path2, expected, actual; path1 = @"C:\common\path\specific1\path1"; path2 = @"C:\common\path\specific2\path2"; expected = @"C:\common\path"; actual = _Path.GetCommonDirectory(path1, path2); Assert.IsTrue(PathComparer.IsEquivalent(expected, actual)); path1 = @"C:\common\path\specific1"; path2 = @"C:\common\path\specific2"; expected = @"C:\common\path"; actual = _Path.GetCommonDirectory(path1, path2); Assert.IsTrue(PathComparer.IsEquivalent(expected, actual)); path1 = @"C:\common\path\specific"; path2 = @"C:\common\path\specific"; expected = @"C:\common\path"; actual = _Path.GetCommonDirectory(path1, path2); Assert.IsTrue(PathComparer.IsEquivalent(expected, actual)); path1 = @"C:\no\common\path"; path2 = @"C:\cuz\im\different"; expected = @"C:\"; actual = _Path.GetCommonDirectory(path1, path2); Assert.IsTrue(PathComparer.IsEquivalent(expected, actual)); path1 = @"C:\no\common\path\specific"; path2 = @"D:\common\path\specific"; actual = _Path.GetCommonDirectory(path1, path2); Assert.IsNull(actual); }
public void Should_Return_Whether_Or_Not_The_Comparer_Is_Case_Sensitive(bool isCaseSensitive) { // Given, When var comparer = new PathComparer(isCaseSensitive); // Then Assert.Equal(isCaseSensitive, comparer.IsCaseSensitive); }
public void SameAssetInstancesIsConsideredEqual(bool isCaseSensitive) { // Given, When PathComparer comparer = new PathComparer(isCaseSensitive); FilePath path = new FilePath("shaders/basic.vert"); // Then Assert.True(comparer.Equals(path, path)); }
public void Same_Asset_Instances_Is_Considered_Equal(bool isCaseSensitive) { // Given, When var comparer = new PathComparer(isCaseSensitive); var path = new FilePath("shaders/basic.vert"); // Then Assert.True(comparer.Equals(path, path)); }
public void Different_Paths_Get_Different_Hash_Codes(bool isCaseSensitive) { // Given, When var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("shaders/basic.frag"); // Then Assert.NotEqual(comparer.GetHashCode(first), comparer.GetHashCode(second)); }
public void Same_Paths_But_Different_Casing_Get_Same_Hash_Code_Depending_On_Case_Sensitivity(bool isCaseSensitive, bool expected) { // Given, When var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("SHADERS/BASIC.VERT"); // Then Assert.Equal(expected, comparer.GetHashCode(first) == comparer.GetHashCode(second)); }
public void Same_Paths_Get_Same_Hash_Code(bool isCaseSensitive) { // Given, When var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("shaders/basic.vert"); // Then Assert.AreEqual(comparer.GetHashCode(first), comparer.GetHashCode(second)); }
public void Same_Paths_Are_Considered_Equal(bool isCaseSensitive) { // Given, When var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("shaders/basic.vert"); // Then comparer.Equals(first, second).ShouldBeTrue(); comparer.Equals(second, first).ShouldBeTrue(); }
public void Different_Paths_Are_Not_Considered_Equal(bool isCaseSensitive) { // Given, When var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("shaders/basic.frag"); // Then Assert.False(comparer.Equals(first, second)); Assert.False(comparer.Equals(second, first)); }
public void Two_Null_Paths_Are_Considered_Equal(bool isCaseSensitive) { // Given var comparer = new PathComparer(isCaseSensitive); // When var result = comparer.Equals(null, null); // Then Assert.True(result); }
public void Paths_Are_Considered_Inequal_If_Any_Is_Null(bool isCaseSensitive) { // Given var comparer = new PathComparer(isCaseSensitive); // When var result = comparer.Equals(null, new FilePath("test.txt")); // Then Assert.False(result); }
public void SamePathsAreConsideredEqual(bool isCaseSensitive) { // Given, When PathComparer comparer = new PathComparer(isCaseSensitive); FilePath first = new FilePath("shaders/basic.vert"); FilePath second = new FilePath("shaders/basic.vert"); // Then Assert.True(comparer.Equals(first, second)); Assert.True(comparer.Equals(second, first)); }
public void Same_Paths_But_Different_Casing_Are_Considered_Equal_Depending_On_Case_Sensitivity(bool isCaseSensitive, bool expected) { // Given, When var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("SHADERS/BASIC.VERT"); // Then Assert.Equal(expected, comparer.Equals(first, second)); Assert.Equal(expected, comparer.Equals(second, first)); }
public void PathsAreConsideredInequalIfAnyIsNull(bool isCaseSensitive) { // Given PathComparer comparer = new PathComparer(isCaseSensitive); // When bool result = comparer.Equals(null, new FilePath("test.txt")); // Then Assert.False(result); }
public void Should_Throw_If_Other_Path_Is_Null() { // Given var comparer = new PathComparer(true); // When var result = Record.Exception(() => comparer.GetHashCode(null)); // Then Assert.IsArgumentNullException(result, "obj"); }
public void Should_Throw_If_Other_Path_Is_Null() { // Given var comparer = new PathComparer(true); // When var result = Assert.Catch(() => comparer.GetHashCode(null)); // Then Assert.That(result, Is.TypeOf <ArgumentNullException>()); Assert.That(((ArgumentNullException)result).ParamName, Is.EqualTo("obj")); }
public void Should_Throw_If_Other_Path_Is_Null() { // Given var comparer = new PathComparer(true); // When var result = Record.Exception(() => comparer.GetHashCode(null)); // Then Assert.IsType <ArgumentNullException>(result); Assert.Equal("obj", ((ArgumentNullException)result).ParamName); }
public void Should_Throw_If_Other_Path_Is_Null() { // Given var comparer = new PathComparer(true); // When var result = Record.Exception(() => comparer.GetHashCode(null)); // Then result.ShouldBeOfType <ArgumentNullException>() .And().ParamName.ShouldBe("obj"); }
public void Should_Return_New_Collection() { // Given var comparer = new PathComparer(false); var collection = new DirectoryPathCollection(comparer); var second = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, comparer); // When var result = collection + second; // Then Assert.False(ReferenceEquals(result, collection)); }
public GlobParserContext(string pattern, PathComparer comparer) { _buffer = GlobTokenizer.Tokenize(pattern); Pattern = pattern; CurrentToken = null; Options = RegexOptions.Compiled | RegexOptions.Singleline; if (!comparer.IsCaseSensitive) { Options |= RegexOptions.IgnoreCase; } }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Paths() { // Given var comparer = new PathComparer(false); var collection = new DirectoryPathCollection(comparer); var second = new DirectoryPathCollection(new DirectoryPath[] { "A", "B" }, comparer); // When var result = collection + second; // Then Assert.Equal(2, result.Count); }
public void Different_Paths_Get_Different_Hash_Codes(bool isCaseSensitive) { // Given var comparer = new PathComparer(isCaseSensitive); var first = new FilePath("shaders/basic.vert"); var second = new FilePath("shaders/basic.frag"); // When var firstHash = comparer.GetHashCode(first); var secondHash = comparer.GetHashCode(second); // Then firstHash.ShouldNotBe(secondHash); }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Paths(bool caseSensitive, int expectedCount) { // Given var comparer = new PathComparer(caseSensitive); var collection = new DirectoryPathCollection(comparer); collection.Add("A"); collection.Add("B"); // When var result = collection - new DirectoryPath("a"); // Then Assert.Equal(expectedCount, result.Count); }
private bool GetPackageAssets(TextWriter textWriter, List <PackageAsset> packageAssets) { var allGood = true; var desktopAssets = new List <PackageAsset>(); var coreClrAssets = new List <PackageAsset>(); allGood &= GetPackageAssetsCore( textWriter, isDesktop: true, desktopAssets, $@"csc\{Configuration}\net472", $@"vbc\{Configuration}\net472", $@"csi\{Configuration}\net472", $@"VBCSCompiler\{Configuration}\net472", $@"Microsoft.Build.Tasks.CodeAnalysis\{Configuration}\net472"); allGood &= GetPackageAssetsCore( textWriter, isDesktop: false, coreClrAssets, $@"csc\{Configuration}\netcoreapp3.1\publish", $@"vbc\{Configuration}\netcoreapp3.1\publish", $@"VBCSCompiler\{Configuration}\netcoreapp3.1\publish"); // The native DLLs ship inside the runtime specific directories but build deploys it at the // root as well. That copy is unnecessary. coreClrAssets.RemoveAll(asset => PathComparer.Equals("Microsoft.DiaSymReader.Native.amd64.dll", asset.FileRelativeName) || PathComparer.Equals("Microsoft.DiaSymReader.Native.arm.dll", asset.FileRelativeName) || PathComparer.Equals("Microsoft.DiaSymReader.Native.x86.dll", asset.FileRelativeName)); // Move all of the assets into bincore as that is where the non-MSBuild task assets will go coreClrAssets = coreClrAssets.Select(x => x.WithFileRelativeName(Path.Combine("bincore", x.FileRelativeName))).ToList(); allGood &= GetPackageAssetsCore( textWriter, isDesktop: false, coreClrAssets, $@"Microsoft.Build.Tasks.CodeAnalysis\{Configuration}\netcoreapp3.1\publish"); packageAssets.AddRange(desktopAssets); packageAssets.AddRange(coreClrAssets); packageAssets.Sort((x, y) => x.FileRelativeName.CompareTo(y.FileRelativeName)); return(allGood); }
public FakeFileSystemTree(ICakeEnvironment environment) { if (environment == null) { throw new ArgumentNullException("environment"); } if (environment.WorkingDirectory == null) { throw new ArgumentException("Working directory not set."); } if (environment.WorkingDirectory.IsRelative) { throw new ArgumentException("Working directory cannot be relative."); } _comparer = new PathComparer(environment.IsUnix()); _root = new FakeDirectory(this, "/"); _root.Create(); }
private IEnumerable <string> FilterRelativeFileNames(IEnumerable <string> relativeFileNames, params string[] excludeNames) { foreach (var relativeFileName in relativeFileNames) { var keep = true; foreach (var excludeName in excludeNames) { if (PathComparer.Equals(excludeName, relativeFileName)) { keep = false; break; } } if (keep) { yield return(relativeFileName); } } }
public void SetWorkingDirectoryTest() { var paths = new List <string>(); var workingDirectories = new List <WorkingDirectory>(); var originalWorkingDirectory = Directory.GetCurrentDirectory(); paths.Add(Path.Combine(originalWorkingDirectory, "dir1")); paths.Add(Path.Combine(originalWorkingDirectory, "dir1", "dir2")); paths.Add(Path.Combine(originalWorkingDirectory, "dir1", "dir2", "dir3a")); paths.Add(Path.Combine(originalWorkingDirectory, "dir1", "dir2", "dir3a", "dir4a")); paths.Add(Path.Combine(originalWorkingDirectory, "dir1", "dir2", "dir3b")); paths.Add(Path.Combine(originalWorkingDirectory, "dir1", "dir2", "dir3b", "dir4b")); paths.ForEach(path => Directory.CreateDirectory(path)); //Push each path into the workingDirectories list, and set the current WorkingDirectory. foreach (var path in paths) { workingDirectories.Add(new WorkingDirectory(path)); Assert.IsTrue(PathComparer.IsEquivalent(path, Directory.GetCurrentDirectory())); } //Pop each path from the workingDirectories list, and check that the current WorkingDirectory also pops. for (int i = workingDirectories.Count - 1; i >= 0; i--) { Assert.IsTrue(PathComparer.IsEquivalent(paths[i], Directory.GetCurrentDirectory())); workingDirectories[i].Dispose(); } Assert.IsTrue(PathComparer.IsEquivalent(originalWorkingDirectory, Directory.GetCurrentDirectory())); try { Directory.Delete(paths[0], true); } catch { Assert.Fail("Failed to delete test directory: " + paths[0]); } }
public PathHandlersBase(string uniquePath, SharedWatcher sharedWatcher, bool subscribeToChanged) { UniquePath = uniquePath; PathPattern = new PathPattern(uniquePath, sharedWatcher.FileSystem.PathsCaseSensitive); SharedWatcher = sharedWatcher; _subscribeToChanged = subscribeToChanged; SharedWatcher.Increment(); SharedWatcher.FolderCreated += OnParentFolderCreated; SharedWatcher.FolderDeleted += OnParentFolderDeleted; PathCaseComparison caseComparison = sharedWatcher.FileSystem.PathsCaseSensitive ? PathCaseComparison.RespectCase : PathCaseComparison.IgnoreCase; var existingPathComparer = new PathComparer(caseComparison, FolderPathEquality.RespectAmbiguity); _matchingPaths = new ConcurrentDictionary <string, bool>(existingPathComparer); RefreshExistingMatchingPaths(); SubscribeToWatcher(); }
public void SamePathsButDifferentCasingGetSameHashCodeDependingOnCaseSensitivity(bool isCaseSensitive, bool expected) { // Given, When PathComparer comparer = new PathComparer(isCaseSensitive); FilePath first = new FilePath("shaders/basic.vert"); FilePath second = new FilePath("SHADERS/BASIC.VERT"); // Then Assert.AreEqual(expected, comparer.GetHashCode(first) == comparer.GetHashCode(second)); }
public void SamePathsGetSameHashCode(bool isCaseSensitive) { // Given, When PathComparer comparer = new PathComparer(isCaseSensitive); FilePath first = new FilePath("shaders/basic.vert"); FilePath second = new FilePath("shaders/basic.vert"); // Then Assert.AreEqual(comparer.GetHashCode(first), comparer.GetHashCode(second)); }
public void ShouldThrowIfOtherPathIsNull() { // Given PathComparer comparer = new PathComparer(true); // When TestDelegate test = () => comparer.GetHashCode(null); // Then Assert.Throws<ArgumentNullException>(test); }
public void ShouldReturnWhetherOrNotTheComparerIsCaseSensitive(bool isCaseSensitive) { // Given, When PathComparer comparer = new PathComparer(isCaseSensitive); // Then Assert.AreEqual(isCaseSensitive, comparer.IsCaseSensitive); }
public void SamePathsButDifferentCasingAreConsideredEqualDependingOnCaseSensitivity(bool isCaseSensitive, bool expected) { // Given, When PathComparer comparer = new PathComparer(isCaseSensitive); FilePath first = new FilePath("shaders/basic.vert"); FilePath second = new FilePath("SHADERS/BASIC.VERT"); // Then Assert.AreEqual(expected, comparer.Equals(first, second)); Assert.AreEqual(expected, comparer.Equals(second, first)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Adding_Paths() { // Given var comparer = new PathComparer(false); var collection = new FilePathCollection(comparer); var second = new FilePathCollection(new FilePath[] { "A.txt", "B.txt" }, comparer); // When var result = collection + second; // Then Assert.Equal(2, result.Count); }
public void Should_Return_New_Collection() { // Given var comparer = new PathComparer(false); var collection = new FilePathCollection(comparer); var second = new FilePathCollection(new FilePath[] { "A.txt", "B.txt" }, comparer); // When var result = collection + second; // Then Assert.False(ReferenceEquals(result, collection)); }
public void Should_Respect_File_System_Case_Sensitivity_When_Removing_Paths(bool caseSensitive, int expectedCount) { // Given var comparer = new PathComparer(caseSensitive); var collection = new FilePathCollection(comparer); collection.Add("A.txt"); collection.Add("B.txt"); // When var result = collection - new FilePath("a.txt"); // Then Assert.Equal(expectedCount, result.Count); }
public void Should_Throw_If_Other_Path_Is_Null() { // Given var comparer = new PathComparer(true); // When var result = Record.Exception(() => comparer.GetHashCode(null)); // Then Assert.IsType<ArgumentNullException>(result); Assert.Equal("obj", ((ArgumentNullException) result).ParamName); }
private bool CheckPortableFacades(TextWriter textWriter) { var(allGood, dllRelativeNames) = GetDllRelativeNames( textWriter, @"Vsix\Roslyn.Compilers.Extension", @"Vsix\Roslyn.VisualStudio.Setup.Dependencies"); if (!allGood) { return(false); } dllRelativeNames = removeItemsNotNeededToDelpoy(dllRelativeNames).ToList(); allGood &= VerifySwrFile(textWriter, @"src\Setup\DevDivVsix\PortableFacades\PortableFacades.swr", dllRelativeNames); return(allGood); // This package is meant to deploy all of the .NET facades necessary for us to execute. This // will remove all of the binaries that we know to be unnecessary for deployment or already // deployed by Visual Studio. IEnumerable <string> removeItemsNotNeededToDelpoy(List <string> relativeNames) { foreach (var itemRelativeName in dllRelativeNames) { var item = Path.GetFileName(itemRelativeName); // Items which are deployed by other teams inside of Visual Studio if (item.StartsWith("Microsoft.Build.", PathComparison) || item.StartsWith("Microsoft.VisualStudio.", PathComparison) || item.StartsWith("System.Composition.", PathComparison) || PathComparer.Equals("stdole.dll", item) || PathComparer.Equals("EnvDTE.dll", item) || PathComparer.Equals("Microsoft.Composition", item) || PathComparer.Equals("System.Threading.Tasks.Dataflow.dll", item) || PathComparer.Equals("System.Runtime.InteropServices.RuntimeInformation.dll", item) || PathComparer.Equals("Newtonsoft.Json", item)) { continue; } // Items which we deploy in another VSIX if (item.StartsWith("Microsoft.Build.", PathComparison) || item.StartsWith("Microsoft.CodeAnalysis.", PathComparison) || item.StartsWith("Microsoft.DiaSymReader.", PathComparison) || PathComparer.Equals("System.Collections.Immutable.dll", item) || PathComparer.Equals("System.Reflection.Metadata.dll", item) || PathComparer.Equals("System.ValueTuple.dll", item) || PathComparer.Equals("System.Threading.Tasks.Extensions.dll", item)) { continue; } // Items which we have specifically chosen not to deploy because at the moment it causes // issues in VS and is not required for us to execute. // - https://github.com/dotnet/roslyn/pull/27537 if (PathComparer.Equals("System.Net.Http.dll", item) || PathComparer.Equals("System.Diagnostics.DiagnosticSource.dll", item) || PathComparer.Equals("System.Text.Encoding.CodePages.dll", item)) { continue; } // These don't actually ship, it's just a build artifact to create a deployment layout if (PathComparer.Equals("Roslyn.Compilers.Extension.dll", item) || PathComparer.Equals("Roslyn.VisualStudio.Setup.Dependencies.dll", item)) { continue; } yield return(itemRelativeName); } } }
public void TwoNullPathsAreConsideredEqual(bool isCaseSensitive) { // Given PathComparer comparer = new PathComparer(isCaseSensitive); // When bool result = comparer.Equals(null, null); // Then Assert.True(result); }