コード例 #1
0
        static int Run(Options options)
        {
            var module1 = CecilUtility.ReadModule(options.File1);
            var module2 = CecilUtility.ReadModule(options.File2);

            FacadeModuleProcessor.MakePublicFacade(module1, options.IncludeInternals);
            FacadeModuleProcessor.MakePublicFacade(module2, options.IncludeInternals);

            var changes = ApiDiff.FindChanges(module1, module2);

            if (changes.Count == 0)
            {
                Console.WriteLine("No changes");
            }
            foreach (var changeGroup in changes.GroupBy(x => x.IsBreaking))
            {
                Console.WriteLine("{0} changes:", changeGroup.Key ? "Breaking" : "Non-breaking");
                foreach (var change in changeGroup)
                {
                    Console.WriteLine(change.Message);
                }
                Console.WriteLine();
            }

            return(0);
        }
コード例 #2
0
        public void TestFindChanges()
        {
            var directory = Path.GetDirectoryName(typeof(ApiDiffTest).Assembly.Location);

            var module1 = CecilUtility.ReadModule(Path.Combine(directory, "TestLibrary.V1.dll"));
            var module2 = CecilUtility.ReadModule(Path.Combine(directory, "TestLibrary.V2.dll"));

            FacadeModuleProcessor.MakePublicFacade(module1, false);
            FacadeModuleProcessor.MakePublicFacade(module2, false);

            var changes = ApiDiff.FindChanges(module1, module2);

            var diff         = NormalizeDiff(changes.Select(change => $"{(change.IsBreaking ? "B" : "N")} {change.Message}"));
            var expectedDiff = NormalizeDiff(File.ReadAllLines(Path.Join(directory, "expected-diff.txt")));

            var falseNegatives = diff.Except(expectedDiff).ToList();

            if (falseNegatives.Count != 0)
            {
                Console.WriteLine("false positives:");
                Console.Write(string.Join(Environment.NewLine, falseNegatives));
                Console.WriteLine();
            }
            var falsePositives = expectedDiff.Except(diff).ToList();

            if (falsePositives.Count != 0)
            {
                Console.WriteLine("false negatives:");
                Console.Write(string.Join(Environment.NewLine, falsePositives));
                Console.WriteLine();
            }

            CollectionAssert.AreEqual(expectedDiff, diff);
        }
コード例 #3
0
        static IReadOnlyList <TypeChanges> FindChanges(Stream stream1, Stream stream2)
        {
            var module1 = CecilUtility.ReadModule(stream1);
            var module2 = CecilUtility.ReadModule(stream2);

            FacadeModuleProcessor.MakePublicFacade(module1, keepInternalTypes: false);
            FacadeModuleProcessor.MakePublicFacade(module2, keepInternalTypes: false);

            return(ApiDiff.FindTypeChanges(module1, module2));
        }