コード例 #1
0
        public void TestIfEqualsReturnsTrueWhenBothPathsAreEmpty()
        {
            // Arrange
            var x = new Path <StopTimeInfo>();
            var y = new Path <StopTimeInfo>();
            // Act
            var result = _pathComparer.Equals(x, y);

            // Assert
            Assert.AreEqual(true, result);
        }
コード例 #2
0
ファイル: PathComparerTests.cs プロジェクト: DNIDNL/hadouken
            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));
            }
コード例 #3
0
            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));
            }
コード例 #4
0
ファイル: PathComparerTests.cs プロジェクト: qhris/cake
            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));
            }
コード例 #5
0
ファイル: PathComparerTests.cs プロジェクト: qhris/cake
            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));
            }
コード例 #6
0
            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();
            }
コード例 #7
0
        /// <summary>
        ///     Called on the UI thread.
        /// </summary>
        /// <param name="files"></param>
        private void Synchronise(IReadOnlyList <string> files)
        {
            foreach (var fileInfo in files)
            {
                if (!_availableSnapshotsByFileName.ContainsKey(fileInfo))
                {
                    var viewModel = new AnalysisSnapshotItemViewModel(fileInfo);
                    _availableSnapshotsByFileName.Add(fileInfo, viewModel);
                    _availableSnapshots.Add(viewModel);
                }
            }

            if (_availableSnapshots.Count != files.Count)
            {
                foreach (var pair in _availableSnapshotsByFileName.ToList())
                {
                    var fname     = pair.Key;
                    var viewModel = pair.Value;
                    if (!files.Any(x => _pathComparer.Equals(x, fname)))
                    {
                        _availableSnapshotsByFileName.Remove(fname);
                        _availableSnapshots.Remove(viewModel);
                    }
                }
            }
        }
コード例 #8
0
        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, ""));
        }
コード例 #9
0
ファイル: PathComparerTests.cs プロジェクト: DNIDNL/hadouken
            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));
            }
コード例 #10
0
ファイル: PathComparerTests.cs プロジェクト: qhris/cake
            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));
            }
コード例 #11
0
            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));
            }
コード例 #12
0
        private static void ShouldContainPath <T>(this IEnumerable <Path> paths, T expected)
            where T : Path
        {
            // Find the path.
            var path = paths.FirstOrDefault(x => _comparer.Equals(x, expected));

            // Make sure that it is what we expect.
            path.ShouldNotBeNull();
            path.ShouldBeOfType <T>();
        }
コード例 #13
0
ファイル: AssertEx.cs プロジェクト: EnoughTea/essentions
        public static void ContainsPath <T>(IEnumerable <Path> paths, T expected)
            where T : Path
        {
            // Find the path.
            var path = paths.FirstOrDefault(x => _comparer.Equals(x, expected));

            // Assert
            Assert.That(path, Is.Not.Null);
            Assert.That(path, Is.TypeOf <T>());
        }
コード例 #14
0
ファイル: PathAsserts.cs プロジェクト: SharpeRAD/Cake
        public static void ContainsPath <T>(IEnumerable <Path> paths, T expected)
            where T : Path
        {
            // Find the path.
            var path = paths.FirstOrDefault(x => _comparer.Equals(x, expected));

            // Assert
            NotNull(path);
            IsType <T>(path);
        }
コード例 #15
0
ファイル: PathComparerTests.cs プロジェクト: DNIDNL/hadouken
            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);
            }
コード例 #16
0
            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);
            }
コード例 #17
0
ファイル: PathComparerTests.cs プロジェクト: DNIDNL/hadouken
            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);
            }
コード例 #18
0
ファイル: PathComparerTests.cs プロジェクト: qhris/cake
            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);
            }
コード例 #19
0
ファイル: PathComparerTests.cs プロジェクト: qhris/cake
            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);
            }
コード例 #20
0
        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);
        }
コード例 #21
0
        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);
                }
            }
        }
コード例 #22
0
        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);
                }
            }
        }
コード例 #23
0
            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));
            }
コード例 #24
0
            public void TwoNullPathsAreConsideredEqual(bool isCaseSensitive)
            {
                // Given
                PathComparer comparer = new PathComparer(isCaseSensitive);

                // When
                bool result = comparer.Equals(null, null);

                // Then
                Assert.True(result);
            }
コード例 #25
0
        private bool CheckPackages(TextWriter textWriter)
        {
            var allGood = true;

            // The VS.Tools.Roslyn package is a bit of a historical artifact from how our files used to
            // be laid out in the VS repository. The structure is flat which means the build assets are
            // mixed in with package artifacts and that makes the verification a bit more complicated and
            // more needs to be excluded
            //
            // The one to call out is excluding csc.exe for validation. That is because it's custom stamped
            // as an x86 exe to work around an issue in the VS build system
            //
            // https://github.com/dotnet/roslyn/issues/17864
            allGood &= VerifyPackageCore(
                textWriter,
                FindNuGetPackage(Path.Combine(ArtifactsDirectory, "VSSetup", Configuration, "DevDivPackages"), "VS.Tools.Roslyn"),
                excludeFunc: relativeFileName =>
                PathComparer.Equals(relativeFileName, "csc.exe") ||
                PathComparer.Equals(relativeFileName, "Icon.png") ||
                PathComparer.Equals(relativeFileName, "Init.cmd") ||
                PathComparer.Equals(relativeFileName, "VS.Tools.Roslyn.nuspec") ||
                PathComparer.Equals(relativeFileName, "csc.exe") ||
                relativeFileName.EndsWith(".resources.dll", PathComparison) ||
                relativeFileName.EndsWith(".rels", PathComparison) ||
                relativeFileName.EndsWith(".psmdcp", PathComparison),
                ("", GetProjectOutputDirectory("csc", "net472")),
                ("", GetProjectOutputDirectory("vbc", "net472")),
                ("", GetProjectOutputDirectory("csi", "net472")),
                ("", GetProjectOutputDirectory("VBCSCompiler", "net472")),
                ("", GetProjectOutputDirectory("Microsoft.Build.Tasks.CodeAnalysis", "net472")));

            allGood &= VerifyPackageCore(
                textWriter,
                FindNuGetPackage(Path.Combine(ArtifactsDirectory, "packages", Configuration, "Shipping"), "Microsoft.Net.Compilers.Toolset.Arm64"),
                (@"tasks\net472", GetProjectOutputDirectory("csc-arm64", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("vbc-arm64", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("csi", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("VBCSCompiler-arm64", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("Microsoft.Build.Tasks.CodeAnalysis", "net472")));;

            allGood &= VerifyPackageCore(
                textWriter,
                FindNuGetPackage(Path.Combine(ArtifactsDirectory, "packages", Configuration, "Shipping"), "Microsoft.Net.Compilers.Toolset"),
                excludeFunc: relativeFileName => relativeFileName.StartsWith(@"tasks\net6.0\bincore\Microsoft.DiaSymReader.Native", PathComparison),
                (@"tasks\net472", GetProjectOutputDirectory("csc", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("vbc", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("csi", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("VBCSCompiler", "net472")),
                (@"tasks\net472", GetProjectOutputDirectory("Microsoft.Build.Tasks.CodeAnalysis", "net472")),
                (@"tasks\net6.0\bincore", GetProjectPublishDirectory("csc", "net6.0")),
                (@"tasks\net6.0\bincore", GetProjectPublishDirectory("vbc", "net6.0")),
                (@"tasks\net6.0\bincore", GetProjectPublishDirectory("VBCSCompiler", "net6.0")),
                (@"tasks\net6.0", GetProjectPublishDirectory("Microsoft.Build.Tasks.CodeAnalysis", "net6.0")));

            foreach (var arch in new[] { "x86", "x64", "arm64" })
            {
                var suffix = arch == "arm64" ? "-arm64" : "";
                allGood &= VerifyPackageCore(
                    textWriter,
                    FindVsix($"Microsoft.CodeAnalysis.Compilers.{arch}"),
                    (@"Contents\MSBuild\Current\Bin\Roslyn", GetProjectOutputDirectory($"csc{suffix}", "net472")),
                    (@"Contents\MSBuild\Current\Bin\Roslyn", GetProjectOutputDirectory($"vbc{suffix}", "net472")),
                    (@"Contents\MSBuild\Current\Bin\Roslyn", GetProjectOutputDirectory("csi", "net472")),
                    (@"Contents\MSBuild\Current\Bin\Roslyn", GetProjectOutputDirectory($"VBCSCompiler{suffix}", "net472")),
                    (@"Contents\MSBuild\Current\Bin\Roslyn", GetProjectOutputDirectory("Microsoft.Build.Tasks.CodeAnalysis", "net472")));;
            }

            return(allGood);
        }
コード例 #26
0
        public int Process(DirectoryPath root, DirectoryPath repository, string version)
        {
            var comparer = new PathComparer(_environment);
            var regex    = new Regex(Pattern);

            var toolPackages = repository.CombineWithFilePath(new FilePath("tools/packages.config"));
            var packageFiles = _globber.Match("**/packages.config", new GlobberSettings
            {
                Root     = repository,
                Comparer = comparer
            }).OfType <FilePath>();

            var processed = 0;

            foreach (var packageFile in packageFiles)
            {
                _log.Write("Processing {0}...", packageFile);

                using (var scope = _log.Indent())
                {
                    if (comparer.Equals(packageFile, toolPackages))
                    {
                        scope.Write("Skipping packages.config in tools.");
                        continue;
                    }

                    if (!_nuget.Restore(scope, root, packageFile))
                    {
                        scope.Error("Could not restore NuGet package.");
                        throw new InvalidOperationException("An error occured when restoring packages!");
                    }

                    // Read the file contents.
                    string contents;
                    using (var stream = _filesystem.File.OpenRead(packageFile))
                        using (var reader = new StreamReader(stream))
                        {
                            contents = reader.ReadToEnd();
                        }

                    // Find all packages that need to be updated.
                    var result = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    var match  = regex.Match(contents);
                    if (match.Success)
                    {
                        while (match.Success)
                        {
                            var package = match.Groups["package"].Value;
                            if (package == "Cake.Core" || package == "Cake.Testing")
                            {
                                result.Add(package);
                            }
                            match = match.NextMatch();
                        }
                        processed++;
                    }

                    foreach (var package in result)
                    {
                        if (!_nuget.Update(scope, root, packageFile, package, version))
                        {
                            scope.Error("Could not update package '{0}' in file '{1}'.", package, packageFile);
                            throw new InvalidOperationException("An error occured when updating package!");
                        }
                    }
                }
            }

            return(processed);
        }
コード例 #27
0
ファイル: PathComparerTests.cs プロジェクト: DNIDNL/hadouken
            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));
            }