[ABIChecker] Add feature to check internal api changes (#424)
authorJay Cho <chojoong@gmail.com>
Fri, 31 Aug 2018 07:24:40 +0000 (16:24 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Fri, 31 Aug 2018 07:24:40 +0000 (16:24 +0900)
* [ABIChecker] Add feature to check internal api changes

* Add new fature that checks changed module

* Remove repeated code

* Rename the file

    - Remame the file name from ABITester.cs to ABIChecker.cs
    - Fix typo

* Remove unused files and code blocks

* Apply Review comments

    - Fix property name
    - Remove unnessassary try-catch statement

17 files changed:
tools/bin/ABIChecker/ABIChecker.deps.json
tools/bin/ABIChecker/ABIChecker.dll
tools/bin/ABIChecker/ABIChecker.pdb
tools/bin/ABIChecker/System.Composition.AttributedModel.dll [changed mode: 0644->0755]
tools/bin/ABIChecker/System.Composition.Convention.dll [changed mode: 0644->0755]
tools/bin/ABIChecker/System.Composition.Hosting.dll [changed mode: 0644->0755]
tools/bin/ABIChecker/System.Composition.Runtime.dll [changed mode: 0644->0755]
tools/bin/ABIChecker/System.Composition.TypedParts.dll [changed mode: 0644->0755]
tools/src/ABIChecker/ABIChecker.cs [new file with mode: 0644]
tools/src/ABIChecker/ABITester.cs [deleted file]
tools/src/ABIChecker/AssemblyChecker.cs [new file with mode: 0644]
tools/src/ABIChecker/Checker/AssemblyChecker.cs [deleted file]
tools/src/ABIChecker/Checker_ABI.sln [deleted file]
tools/src/ABIChecker/Program.cs
tools/src/ABIChecker/Properties/launchSettings.json [deleted file]
tools/src/ABIChecker/Utilities/ObjectUtil.cs [deleted file]
tools/src/ABIChecker/Utilities/ReflectionExtension.cs [deleted file]

index 7ac35e1..7778382 100644 (file)
           "System.Runtime.Extensions": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.5/CommandLine.dll": {
-            "assemblyVersion": "2.0.275.0",
-            "fileVersion": "2.0.275.0"
-          }
+          "lib/netstandard1.5/CommandLine.dll": {}
         }
       },
       "Microsoft.CodeAnalysis/2.6.1": {
           "System.Xml.XmlDocument": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.CodeAnalysis.dll": {
-            "assemblyVersion": "2.6.0.0",
-            "fileVersion": "2.6.1.62414"
-          }
+          "lib/netstandard1.3/Microsoft.CodeAnalysis.dll": {}
         }
       },
       "Microsoft.CodeAnalysis.CSharp/2.6.1": {
           "Microsoft.CodeAnalysis.Common": "2.6.1"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.dll": {
-            "assemblyVersion": "2.6.0.0",
-            "fileVersion": "2.6.1.62414"
-          }
+          "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.dll": {}
         }
       },
       "Microsoft.CodeAnalysis.CSharp.Workspaces/2.6.1": {
           "Microsoft.CodeAnalysis.Workspaces.Common": "2.6.1"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.Workspaces.dll": {
-            "assemblyVersion": "2.6.0.0",
-            "fileVersion": "2.6.1.62414"
-          }
+          "lib/netstandard1.3/Microsoft.CodeAnalysis.CSharp.Workspaces.dll": {}
         }
       },
       "Microsoft.CodeAnalysis.VisualBasic/2.6.1": {
           "Microsoft.CodeAnalysis.Common": "2.6.1"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.dll": {
-            "assemblyVersion": "2.6.0.0",
-            "fileVersion": "2.6.1.62414"
-          }
+          "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.dll": {}
         }
       },
       "Microsoft.CodeAnalysis.VisualBasic.Workspaces/2.6.1": {
           "Microsoft.CodeAnalysis.Workspaces.Common": "2.6.1"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll": {
-            "assemblyVersion": "2.6.0.0",
-            "fileVersion": "2.6.1.62414"
-          }
+          "lib/netstandard1.3/Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll": {}
         }
       },
       "Microsoft.CodeAnalysis.Workspaces.Common/2.6.1": {
           "System.Threading.Tasks.Parallel": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.CodeAnalysis.Workspaces.dll": {
-            "assemblyVersion": "2.6.0.0",
-            "fileVersion": "2.6.1.62414"
-          }
+          "lib/netstandard1.3/Microsoft.CodeAnalysis.Workspaces.dll": {}
         }
       },
       "Microsoft.CSharp/4.0.1": {
           "System.Runtime.InteropServices.RuntimeInformation": "4.0.0"
         },
         "runtime": {
-          "lib/netstandard1.3/Microsoft.DotNet.PlatformAbstractions.dll": {
-            "assemblyVersion": "2.0.4.0",
-            "fileVersion": "2.0.4.0"
-          }
+          "lib/netstandard1.3/Microsoft.DotNet.PlatformAbstractions.dll": {}
         }
       },
       "Microsoft.Extensions.DependencyModel/2.0.4": {
           "System.Linq": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll": {
-            "assemblyVersion": "2.0.4.0",
-            "fileVersion": "2.0.4.0"
-          }
+          "lib/netstandard1.6/Microsoft.Extensions.DependencyModel.dll": {}
         }
       },
       "Microsoft.NETCore.Targets/1.1.0": {},
           "System.Xml.XDocument": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.0/Newtonsoft.Json.dll": {
-            "assemblyVersion": "9.0.0.0",
-            "fileVersion": "9.0.1.19813"
-          }
+          "lib/netstandard1.0/Newtonsoft.Json.dll": {}
         }
       },
       "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl/4.3.0": {
           "System.Runtime": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.0/System.Composition.AttributedModel.dll": {
-            "assemblyVersion": "1.0.31.0",
-            "fileVersion": "4.6.24705.1"
-          }
+          "lib/netstandard1.0/System.Composition.AttributedModel.dll": {}
         }
       },
       "System.Composition.Convention/1.0.31": {
           "System.Threading": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.0/System.Composition.Convention.dll": {
-            "assemblyVersion": "1.0.31.0",
-            "fileVersion": "4.6.24705.1"
-          }
+          "lib/netstandard1.0/System.Composition.Convention.dll": {}
         }
       },
       "System.Composition.Hosting/1.0.31": {
           "System.Threading": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.0/System.Composition.Hosting.dll": {
-            "assemblyVersion": "1.0.31.0",
-            "fileVersion": "4.6.24705.1"
-          }
+          "lib/netstandard1.0/System.Composition.Hosting.dll": {}
         }
       },
       "System.Composition.Runtime/1.0.31": {
           "System.Runtime": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.0/System.Composition.Runtime.dll": {
-            "assemblyVersion": "1.0.31.0",
-            "fileVersion": "4.6.24705.1"
-          }
+          "lib/netstandard1.0/System.Composition.Runtime.dll": {}
         }
       },
       "System.Composition.TypedParts/1.0.31": {
           "System.Runtime.Extensions": "4.3.0"
         },
         "runtime": {
-          "lib/netstandard1.0/System.Composition.TypedParts.dll": {
-            "assemblyVersion": "1.0.31.0",
-            "fileVersion": "4.6.24705.1"
-          }
+          "lib/netstandard1.0/System.Composition.TypedParts.dll": {}
         }
       },
       "System.Console/4.3.0": {
         "runtimeTargets": {
           "runtimes/unix/lib/netstandard1.3/System.Text.Encoding.CodePages.dll": {
             "rid": "unix",
-            "assetType": "runtime",
-            "assemblyVersion": "4.0.2.0",
-            "fileVersion": "4.6.24705.1"
+            "assetType": "runtime"
           },
           "runtimes/win/lib/netstandard1.3/System.Text.Encoding.CodePages.dll": {
             "rid": "win",
-            "assetType": "runtime",
-            "assemblyVersion": "4.0.2.0",
-            "fileVersion": "4.6.24705.1"
+            "assetType": "runtime"
           }
         }
       },
     "Microsoft.CSharp/4.0.1": {
       "type": "package",
       "serviceable": true,
-      "sha512": "sha512-bM7IkLhJmBFtocrseXxf1cywbbkf49VkjPUhTKhDt8rhJ2b3Umd1N1FZCcfZowKQgithC1SZa3ldWjzN0O49aw==",
+      "sha512": "sha512-17h8b5mXa87XYKrrVqdgZ38JefSUqLChUQpXgSnpzsM0nDOhE40FTeNWOJ/YmySGV6tG6T8+hjz6vxbknHJr6A==",
       "path": "microsoft.csharp/4.0.1",
       "hashPath": "microsoft.csharp.4.0.1.nupkg.sha512"
     },
     "Newtonsoft.Json/9.0.1": {
       "type": "package",
       "serviceable": true,
-      "sha512": "sha512-EZsVUqtnBHEhlJE22IjA3BU3JENwdgjwI5k/hBj7fn4pY4wRs8AU0F4m+NeEfcysrRiDXGj50SLlQTZxiqK+7g==",
+      "sha512": "sha512-U82mHQSKaIk+lpSVCbWYKNavmNH1i5xrExDEquU1i6I5pV6UMOqRnJRSlKO3cMPfcpp0RgDY+8jUXHdQ4IfXvw==",
       "path": "newtonsoft.json/9.0.1",
       "hashPath": "newtonsoft.json.9.0.1.nupkg.sha512"
     },
index 5cdf58d..bd61eee 100644 (file)
Binary files a/tools/bin/ABIChecker/ABIChecker.dll and b/tools/bin/ABIChecker/ABIChecker.dll differ
index 7d03610..7ef5a2e 100644 (file)
Binary files a/tools/bin/ABIChecker/ABIChecker.pdb and b/tools/bin/ABIChecker/ABIChecker.pdb differ
diff --git a/tools/src/ABIChecker/ABIChecker.cs b/tools/src/ABIChecker/ABIChecker.cs
new file mode 100644 (file)
index 0000000..448d12f
--- /dev/null
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+
+namespace Checker_ABI
+{
+    public class ABIChecker
+    {
+        AssemblyChecker _checker = new AssemblyChecker();
+        string _basePath;
+        string _targetPath;
+        bool _isFile;
+
+        [Flags]
+        public enum ABITestResult
+        {
+            None = 0,
+            InternalAPIChanged = 1 << 0,
+            ACRRequired = 1 << 1
+        }
+
+        public ABIChecker(string basePath, string targetPath, bool isFile)
+        {
+            _basePath = basePath;
+            _targetPath = targetPath;
+            _isFile = isFile;
+        }
+
+        public ABITestResult CheckABI()
+        {
+            if (!_isFile)
+            {
+                return CheckDirectory();
+            }
+            else
+            {
+                var result = CheckFile(new FileInfo(_basePath).FullName, new FileInfo(_targetPath).FullName);
+                Console.WriteLine($"File check result: {((result & ABITestResult.ACRRequired) == ABITestResult.ACRRequired ? "FAIL" : "PASS")}");
+                return result;
+            }
+        }
+
+        ABITestResult CheckDirectory()
+        {
+            DirectoryInfo baseDirectoryInfo = new DirectoryInfo(_basePath);
+            DirectoryInfo targetDirectoryInfo = new DirectoryInfo(_targetPath);
+
+            if (!baseDirectoryInfo.Exists || !targetDirectoryInfo.Exists)
+            {
+                Console.WriteLine($"invalid directory path");
+            }
+
+            FileInfo[] baseDllFiles = baseDirectoryInfo.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
+            FileInfo[] targetDllFiles = targetDirectoryInfo.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
+
+            Console.WriteLine($"File Count : {baseDllFiles.Length} == {targetDllFiles.Length}");
+
+            ABITestResult directoryResult = ABITestResult.None;
+            directoryResult |= CheckChangedModule(baseDllFiles, targetDllFiles);
+            Console.WriteLine($"Module Check : {directoryResult.ToString()}");
+            Console.WriteLine("---------------------------------");
+
+            int count = 1;
+            foreach (var baseFile in baseDllFiles)
+            {
+                foreach (var targetFile in targetDllFiles)
+                {
+                    if (baseFile.Name == targetFile.Name)
+                    {
+                        var fileResult = CheckFile(baseFile.FullName, targetFile.FullName);
+                        Console.WriteLine($"{count++}. {baseFile.ToString()} : {((fileResult & ABITestResult.ACRRequired) == ABITestResult.ACRRequired ? "FAIL" : "PASS")}");
+                        directoryResult |= fileResult;
+                    }
+                }
+            }
+            return directoryResult;
+        }
+
+        ABITestResult CheckChangedModule(FileInfo[] baseDllFiles, FileInfo[] targetDllFiles)
+        {
+            var result = ABITestResult.None;
+
+            var removedDllFiles = baseDllFiles.Where(b => !targetDllFiles.Any(t => t.Name == b.Name));
+            foreach (var file in removedDllFiles)
+            {
+                Console.WriteLine($"!! Missing DLL: {file.Name}");
+                result |= CheckFile(file.FullName);
+            }
+
+            var addedDllFiles = targetDllFiles.Where(t => !baseDllFiles.Any(b => b.Name == t.Name));
+            foreach (var file in addedDllFiles)
+            {
+                Console.WriteLine($"!! Added DLL : {file.Name}");
+                result |= CheckFile(file.FullName);
+            }
+
+            return result;
+        }
+
+        ABITestResult CheckFile(string file)
+        {
+            return CheckFile(file, string.Empty);
+        }
+
+        ABITestResult CheckFile(string baseFile, string targetFile)
+        {
+            ABITestResult result = ABITestResult.None;
+            IList<MemberInfo> changedAPIList;
+            try
+            {
+                if (targetFile == string.Empty)
+                {
+                    changedAPIList = _checker.CheckAssemblyFile(Assembly.LoadFrom(baseFile));
+                }
+                else
+                {
+                    changedAPIList = _checker.CheckAssemblyFile(Assembly.LoadFrom(baseFile), Assembly.LoadFile(targetFile));
+                }
+                var internalAPIList = new List<MemberInfo>();
+                for (int i = changedAPIList.Count - 1; i >= 0; i--)
+                {
+                    if (changedAPIList[i].GetCustomAttribute<System.ComponentModel.EditorBrowsableAttribute>()?.State == System.ComponentModel.EditorBrowsableState.Never)
+                    {
+                        Console.WriteLine($"  Internal API changed: {changedAPIList[i].DeclaringType}::{changedAPIList[i].ToString()}");
+                        internalAPIList.Add(changedAPIList[i]);
+                        changedAPIList.Remove(changedAPIList[i]);
+                    }
+                }
+
+                if (changedAPIList.Count > 0)
+                {
+                    result |= ABITestResult.ACRRequired;
+                }
+                if (internalAPIList.Count > 0)
+                {
+                    result |= ABITestResult.InternalAPIChanged;
+                }
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+            }
+
+            return result;
+        }
+    }
+}
diff --git a/tools/src/ABIChecker/ABITester.cs b/tools/src/ABIChecker/ABITester.cs
deleted file mode 100644 (file)
index 47703a4..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-
-namespace Checker_ABI
-{
-    public class ABITester
-    {
-        AssemblyChecker _checker = new AssemblyChecker();
-        string _basePath;
-        string _latestPath;
-        bool _isFile;
-
-        public ABITester(string basePath, string latestPath, bool isFile)
-        {
-            _basePath = basePath;
-            _latestPath = latestPath;
-            _isFile = isFile;
-        }
-
-        public bool CheckABI()
-        {
-            if (!_isFile)
-            {
-                return InternalDirectoryCheck();
-            }
-            else
-            {
-                var result = _checker.CheckAssemblyToList(Assembly.LoadFrom(_basePath), Assembly.LoadFile(_latestPath));
-                var bResult = result.Count > 0 ? false : true;
-                Console.WriteLine($"{_basePath} : {(bResult ? "PASS" : "FAIL")}");
-                return bResult;
-            }
-        }
-
-        bool InternalDirectoryCheck()
-        {
-            DirectoryInfo baseDirectoryInfo = new DirectoryInfo(_basePath);
-            DirectoryInfo targetDirectoryInfo = new DirectoryInfo(_latestPath);
-
-            if (!baseDirectoryInfo.Exists || !targetDirectoryInfo.Exists)
-            {
-                Console.WriteLine($"invalid directory path");
-            }
-
-            FileInfo[] baseDllFiles = baseDirectoryInfo.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
-            FileInfo[] targetDllFiles = targetDirectoryInfo.GetFiles("*.dll", SearchOption.TopDirectoryOnly);
-
-            Console.WriteLine($"File Count : {baseDllFiles.Length} == {targetDllFiles.Length}");
-
-            int num = 1;
-            int errCount = 0;
-
-            foreach (var baseFile in baseDllFiles)
-            {
-                foreach (var latestFile in targetDllFiles)
-                {
-                    if (baseFile.Name == latestFile.Name)
-                    {
-                        try
-                        {
-                            var result = _checker.CheckAssemblyToList(Assembly.LoadFrom(baseFile.FullName), Assembly.LoadFile(latestFile.FullName));
-                            bool bResult = result.Count > 0 ? false : true;
-                            Console.WriteLine($"{num++}. {baseFile.ToString()} : {(bResult ? "PASS" : "FAIL")}");
-
-                            if (!bResult) errCount++;
-                        }
-                        catch (Exception)
-                        {
-                            continue;
-                        }
-                    }
-                }
-            }
-            return errCount > 0 ? false : true;
-        }
-    }
-}
diff --git a/tools/src/ABIChecker/AssemblyChecker.cs b/tools/src/ABIChecker/AssemblyChecker.cs
new file mode 100644 (file)
index 0000000..973fe5e
--- /dev/null
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Checker_ABI
+{
+    internal class AssemblyChecker
+    {
+        private const BindingFlags PublicOnlyFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Static;
+
+        public IList<MemberInfo> CompareClassTypes(Type originalType, Type targetType)
+        {
+            if (originalType.ToString() != targetType.ToString())
+            {
+                throw new ArgumentException("The full name of type is different. ABI check is only possible if name is the same.");
+            }
+
+            var originalMembers = originalType.GetMembers(PublicOnlyFlags).ToList();
+            var targetMembers = targetType.GetMembers(PublicOnlyFlags).ToList();
+
+            for (int i = originalMembers.Count-1; i >= 0; i--)
+            {
+                for (int j = targetMembers.Count-1; j >= 0; j--)
+                {
+                    if (originalMembers[i].ToString() == targetMembers[j].ToString())
+                    {
+                        if (originalMembers[i] is MethodInfo originalMember && targetMembers[j] is MethodInfo targetMamber)
+                        {
+                            if (originalMember.GetBaseDefinition().DeclaringType.ToString() != targetMamber.GetBaseDefinition().DeclaringType.ToString())
+                            {
+                                continue;
+                            }
+                        }
+                        originalMembers.RemoveAt(i);
+                        targetMembers.RemoveAt(j);
+                        break;
+                    }
+                }
+            }
+
+            IList<MemberInfo> diffrentMemberList = new List<MemberInfo>();
+            foreach (var item in originalMembers)
+            {
+                Console.WriteLine($"  !! Missing API: {item.DeclaringType}::{item.ToString()}");
+                diffrentMemberList.Add(item);
+            }
+
+            foreach (var item in targetMembers)
+            {
+                Console.WriteLine($"  !! Added API: {item.DeclaringType}::{item.ToString()}");
+                diffrentMemberList.Add(item);
+            }
+
+            return diffrentMemberList;
+        }
+
+        public IList<MemberInfo> CheckAssemblyFile(Assembly baseAssembly, Assembly targetAssembly)
+        {
+            var basePublicTypes = baseAssembly.GetTypes().Where(b => b.IsPublic).ToList();
+            var targetPublicTypes = targetAssembly.GetTypes().Where(b => b.IsPublic).ToList();
+            var diffrentMemberList = new List<MemberInfo>();
+
+            for (int i = 0; i < basePublicTypes.Count; i++)
+            {
+                for (int j = 0; j < targetPublicTypes.Count; j++)
+                {
+                    if (basePublicTypes[i].ToString() == targetPublicTypes[j].ToString())
+                    {
+                        var differentMembers = CompareClassTypes(basePublicTypes[i], targetPublicTypes[j]);
+
+                        if (differentMembers?.Count > 0)
+                        {
+                            Console.WriteLine($"  ==> {basePublicTypes[i]}, Diffrent Member Count : {differentMembers.Count}");
+                            foreach (var member in differentMembers)
+                            {
+                                diffrentMemberList.Add(member);
+                            }
+                        }
+                    }
+                }
+            }
+            return diffrentMemberList;
+        }
+
+        public IList<MemberInfo> CheckAssemblyFile(Assembly assembly)
+        {
+            var publicTypes = assembly.GetTypes().Where(b => b.IsPublic).ToList();
+            var diffrentMemberList = new List<MemberInfo>();
+
+            foreach (var type in publicTypes)
+            {
+                diffrentMemberList = diffrentMemberList.Concat(type.GetMembers(PublicOnlyFlags)).ToList();
+            }
+
+            return diffrentMemberList;
+        }
+    }
+}
diff --git a/tools/src/ABIChecker/Checker/AssemblyChecker.cs b/tools/src/ABIChecker/Checker/AssemblyChecker.cs
deleted file mode 100644 (file)
index 2bc15bd..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace Checker_ABI
-{
-    internal class AssemblyChecker
-    {
-        private const BindingFlags s_PublicOnlyFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Static;
-
-        public bool TypeValidate(Type originalType, Type comparedType)
-        {
-            var originalMembers = originalType.GetMembers(s_PublicOnlyFlags);
-            var comparedMembers = comparedType.GetMembers(s_PublicOnlyFlags);
-
-            // Compare Number of public Methods
-            MethodInfo[] originalMethods = originalType.GetMethods(s_PublicOnlyFlags);
-            MethodInfo[] comparedMethods = comparedType.GetMethods(s_PublicOnlyFlags);
-
-            if (comparedMethods.Length != originalMethods.Length)
-                return false;
-
-            // Compare Number of public Properties
-            PropertyInfo[] originalProperties = originalType.GetProperties(s_PublicOnlyFlags);
-            PropertyInfo[] comparedProperties = comparedType.GetProperties(s_PublicOnlyFlags);
-
-            if (comparedProperties.Length != originalProperties.Length)
-                return false;
-
-            // Compare number of public fields
-            FieldInfo[] originalFields = originalType.GetFields(s_PublicOnlyFlags);
-            FieldInfo[] comparedToFields = comparedType.GetFields(s_PublicOnlyFlags);
-
-            if (comparedToFields.Length != originalFields.Length)
-                return false;
-
-
-            // Compare number of public events
-            EventInfo[] originalEvents = originalType.GetEvents(s_PublicOnlyFlags);
-            EventInfo[] comparedToEvents = comparedType.GetEvents(s_PublicOnlyFlags);
-
-            if (originalEvents.Length != comparedToEvents.Length)
-                return false;
-
-            return true;
-        }
-
-        public IList<MemberInfo> CompareClassTypeToList(Type originalType, Type comparedType)
-        {
-            if (originalType.ToString() != comparedType.ToString())
-            {
-                throw new ArgumentException("The full name of type is different. ABI check is only possible if name is the same.");
-            }
-
-            IList<MemberInfo> diffrentMemberList = new List<MemberInfo>();
-            var originalMembers = originalType.GetMembers(s_PublicOnlyFlags).ToList();
-            var comparedMembers = comparedType.GetMembers(s_PublicOnlyFlags).ToList();
-
-            for (int i = originalMembers.Count-1; i >= 0; i--)
-            {
-                bool bResult = false;
-                for (int j = comparedMembers.Count-1; j >= 0; j--)
-                {
-                     if (originalMembers[i].ToString() == comparedMembers[j].ToString())
-                    {
-                        if (originalMembers[i] is MethodInfo first && comparedMembers[j] is MethodInfo last)
-                        {
-                            if (first.GetBaseDefinition().DeclaringType.ToString() != last.GetBaseDefinition().DeclaringType.ToString())
-                            {
-                                continue;
-                            }
-                        }
-
-                        bResult = true;
-                        originalMembers.RemoveAt(i);
-                        comparedMembers.RemoveAt(j);
-                        break;
-                    }
-                }
-
-                if (!bResult)
-                {
-                    diffrentMemberList.Add(originalMembers[i]);
-                }
-            }
-
-            if (comparedMembers.Count > 0)
-            {
-                foreach (var item in originalMembers)
-                    diffrentMemberList.Add(item);
-
-                foreach (var item in comparedMembers)
-                    diffrentMemberList.Add(item);
-            }
-
-            return diffrentMemberList;
-        }
-
-        public IList<MemberInfo> CheckAssemblyToList(Assembly baseAssembly, Assembly latestAssembly)
-        {
-            var baseInfos = baseAssembly.GetTypes().Where(b => b.IsPublic).ToList();
-            var lastInfos = latestAssembly.GetTypes().Where(b => b.IsPublic).ToList();
-            var diffrentMemberList = new List<MemberInfo>();
-
-            for (int i = 0; i < baseInfos.Count; i++)
-            {
-                for (int j = 0; j < lastInfos.Count; j++)
-                {
-                    if (baseInfos[i].ToString() == lastInfos[j].ToString())
-                    {
-                        var result = CompareClassTypeToList(baseInfos[i], lastInfos[j]);
-
-                        if (result?.Count > 0)
-                        {
-                            Console.WriteLine($"ABI BREAK!! {baseInfos[i]} : Diffrent Member Count : {result.Count}");
-                            foreach (var item in result)
-                            {
-                                diffrentMemberList.Add(item);
-                                Console.WriteLine($"ABI BREAK!! {item.DeclaringType}::{item}");
-                            }
-                        }
-                    }
-                }
-            }
-            return diffrentMemberList;
-        }
-    }
-}
diff --git a/tools/src/ABIChecker/Checker_ABI.sln b/tools/src/ABIChecker/Checker_ABI.sln
deleted file mode 100644 (file)
index d88a160..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2036
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Checker_ABI", "Checker_ABI.csproj", "{99956C3A-4C56-455F-9793-7E98A056ED34}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|Any CPU = Debug|Any CPU
-               Release|Any CPU = Release|Any CPU
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {99956C3A-4C56-455F-9793-7E98A056ED34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {99956C3A-4C56-455F-9793-7E98A056ED34}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {99956C3A-4C56-455F-9793-7E98A056ED34}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {99956C3A-4C56-455F-9793-7E98A056ED34}.Release|Any CPU.Build.0 = Release|Any CPU
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-       GlobalSection(ExtensibilityGlobals) = postSolution
-               SolutionGuid = {FFC2467C-4F5E-4B70-86B1-DD71FC699C12}
-       EndGlobalSection
-EndGlobal
index 8c0277c..1831919 100644 (file)
@@ -36,37 +36,16 @@ namespace Checker_ABI
                 return 0;
             }
 
-            var tester = new ABITester(options.BasePath, options.PrPath, options.IsFile);
-            var bResult = tester.CheckABI();
+            var abiChecker = new ABIChecker(options.BasePath, options.PrPath, options.IsFile);
+            var result = abiChecker.CheckABI();
             Console.WriteLine("=====================");
-            Console.WriteLine($"ABI CHECK : {bResult}");
+            Console.WriteLine($"ABI CHECK : {((result & ABIChecker.ABITestResult.ACRRequired) == ABIChecker.ABITestResult.ACRRequired ? "Fail" : "Pass")}");
             Console.WriteLine("=====================");
 
             Console.WriteLine("=========ABI CHECK END=========");
+            Console.WriteLine("Return : " + (int)result);
 
-            return bResult ? 0 : 1;
-        }
-
-        public static void LabelingTest()
-        {
-            WebRequest request = WebRequest.Create("https://api.github.com/repos/darkleem/google-diff-match-patch/issues/111/labels");
-            request.Method = "POST";
-            request.Headers.Add(HttpRequestHeader.UserAgent, "google-diff-match-patch");
-            request.Headers.Add(HttpRequestHeader.ContentType, "application/json");
-            request.Headers.Add(HttpRequestHeader.Authorization, "token 3a37a027156bca0e561ae7a317d29fd249502899");
-
-
-            var postData = @"[""bug""]";
-            var data = Encoding.ASCII.GetBytes(postData);
-
-            using (var stream = request.GetRequestStream())
-            {
-                stream.Write(data, 0, data.Length);
-            }
-
-            var response = (HttpWebResponse)request.GetResponse();
-            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
-            Console.WriteLine(responseString);
+            return (int)result;
         }
     }
 }
diff --git a/tools/src/ABIChecker/Properties/launchSettings.json b/tools/src/ABIChecker/Properties/launchSettings.json
deleted file mode 100644 (file)
index 5929676..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "profiles": {
-    "Checker_ABI": {
-      "commandName": "Project",
-      "commandLineArgs": "-p c:/base/bin/public -b c:/target/bin/public"
-    }
-  }
-}
\ No newline at end of file
diff --git a/tools/src/ABIChecker/Utilities/ObjectUtil.cs b/tools/src/ABIChecker/Utilities/ObjectUtil.cs
deleted file mode 100644 (file)
index e5c8baa..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-using System;
-using System.Reflection;
-
-namespace Checker_ABI.Utilities
-{
-    /// -----------------------------------------------------------------------
-    /// <summary>  
-    /// This utility class contains a rich sets of utility methods that perform operations 
-    /// on objects during runtime such as copying of property and field values
-    /// between 2 objects, deep cloning of objects, etc.  
-    /// </summary>
-    /// -----------------------------------------------------------------------
-    public abstract class ObjectUtils
-    {
-        /// <summary>
-        /// Deep Comparison two objects if they are alike. The objects are consider alike if 
-        /// they are:
-        /// <list type="ordered">
-        ///    <item>of the same <see cref="System.Type"/>,</item>
-        ///    <item>have the same number of methods, properties and fields</item>
-        ///    <item>the public and private properties and fields values reflect each other's. </item>
-        /// </list>
-        /// </summary>
-        /// <param name="original"></param>
-        /// <param name="comparedToObject"></param>
-        /// <returns></returns>
-        public static bool IsALike(object original, object comparedToObject)
-        {
-
-            if (original.GetType() != comparedToObject.GetType())
-                return false;
-
-            // ...............................................
-            // Compare Number of Private and public Methods
-            // ...............................................
-            MethodInfo[] originalMethods = original
-              .GetType()
-              .GetMethods(BindingFlags.Instance |
-              BindingFlags.NonPublic |
-              BindingFlags.Public);
-
-            MethodInfo[] comparedMethods = comparedToObject
-              .GetType()
-              .GetMethods(BindingFlags.Instance |
-              BindingFlags.NonPublic |
-              BindingFlags.Public);
-
-            if (comparedMethods.Length != originalMethods.Length)
-                return false;
-
-            // ...............................................
-            // Compare Number of Private and public Properties
-            // ................................................
-            PropertyInfo[] originalProperties = original
-              .GetType()
-              .GetProperties(BindingFlags.Instance |
-              BindingFlags.NonPublic |
-              BindingFlags.Public);
-
-            PropertyInfo[] comparedProperties = comparedToObject
-              .GetType()
-              .GetProperties(BindingFlags.Instance |
-              BindingFlags.NonPublic |
-              BindingFlags.Public);
-
-
-            if (comparedProperties.Length != originalProperties.Length)
-                return false;
-
-
-            // ...........................................
-            // Compare number of public and private fields
-            // ...........................................
-            FieldInfo[] originalFields = original
-              .GetType()
-              .GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-
-            FieldInfo[] comparedToFields = comparedToObject
-              .GetType()
-              .GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-
-
-            if (comparedToFields.Length != originalFields.Length)
-                return false;
-
-            // ........................................
-            // compare field values
-            // ........................................
-            foreach (FieldInfo fi in originalFields)
-            {
-
-                // check to see if the object to contains the field          
-                FieldInfo fiComparedObj = comparedToObject.GetType().GetField(fi.Name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-
-                if (fiComparedObj == null)
-                    return false;
-
-                // Get the value of the field from the original object        
-                Object srcValue = original.GetType().InvokeMember(fi.Name,
-                  BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
-                  null,
-                  original,
-                  null);
-
-
-
-                // Get the value of the field
-                object comparedObjFieldValue = comparedToObject
-                  .GetType()
-                  .InvokeMember(fiComparedObj.Name,
-                  BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
-                  null,
-                  comparedToObject,
-                  null);
-
-
-                // -------------------------------
-                // now compare the field values
-                // -------------------------------
-
-                if (srcValue == null)
-                {
-                    if (comparedObjFieldValue != null)
-                        return false;
-                    else
-                        return true;
-                }
-
-                if (srcValue.GetType() != comparedObjFieldValue.GetType())
-                    return false;
-
-                if (!srcValue.ToString().Equals(comparedObjFieldValue.ToString()))
-                    return false;
-            }
-
-            // ........................................
-            // compare each Property values
-            // ........................................
-            foreach (PropertyInfo pi in originalProperties)
-            {
-
-                // check to see if the object to contains the field          
-                PropertyInfo piComparedObj = comparedToObject
-                  .GetType()
-                  .GetProperty(pi.Name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
-
-                if (piComparedObj == null)
-                    return false;
-
-                // Get the value of the property from the original object        
-                Object srcValue = original
-                  .GetType()
-                  .InvokeMember(pi.Name,
-                  BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
-                  null,
-                  original,
-                  null);
-
-                // Get the value of the property
-                object comparedObjValue = comparedToObject
-                  .GetType()
-                  .InvokeMember(piComparedObj.Name,
-                  BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
-                  null,
-                  comparedToObject,
-                  null);
-
-
-                // -------------------------------
-                // now compare the property values
-                // -------------------------------
-                if (srcValue.GetType() != comparedObjValue.GetType())
-                    return false;
-
-                if (!srcValue.ToString().Equals(comparedObjValue.ToString()))
-                    return false;
-            }
-            return true;
-        }
-    }
-}
diff --git a/tools/src/ABIChecker/Utilities/ReflectionExtension.cs b/tools/src/ABIChecker/Utilities/ReflectionExtension.cs
deleted file mode 100644 (file)
index de4db85..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Linq;
-using System.Reflection;
-
-namespace Checker_ABI.Utilities
-{
-    public static class ReflectionExtension
-    {
-        public static bool IsOverride(this MethodInfo method)
-        {
-            if (method == null) throw new ArgumentNullException();
-            return method.DeclaringType != method.GetBaseDefinition().DeclaringType;
-        }
-
-        public static bool AreMethodsEqualForDeclaringType(MethodInfo first, MethodInfo second)
-        {
-            first = first.ReflectedType == first.DeclaringType ? first : first.DeclaringType.GetMethod(first.Name, first.GetParameters().Select(p => p.ParameterType).ToArray());
-            second = second.ReflectedType == second.DeclaringType ? second : second.DeclaringType.GetMethod(second.Name, second.GetParameters().Select(p => p.ParameterType).ToArray());
-            return first == second;
-        }
-
-    }
-}