Ejemplo n.º 1
0
        private static bool DoesContractContainBreakingChanges(string dllName, string baselinePath, string breakingChangesPath)
        {
            TypeTree locally = new TypeTree(typeof(object));

            ContractEnforcement.BuildTypeTree(locally, ContractEnforcement.GetAssemblyLocally(dllName).GetExportedTypes());

            TypeTree baseline = JsonConvert.DeserializeObject <TypeTree>(File.ReadAllText(baselinePath));

            string localJson = JsonConvert.SerializeObject(locally, Formatting.Indented);

            File.WriteAllText($"{breakingChangesPath}", localJson);
            string baselineJson = JsonConvert.SerializeObject(baseline, Formatting.Indented);

            System.Diagnostics.Trace.TraceWarning($"String length Expected: {baselineJson.Length};Actual:{localJson.Length}");
            if (string.Equals(localJson, baselineJson, StringComparison.InvariantCulture))
            {
                return(false);
            }
            else
            {
                System.Diagnostics.Trace.TraceWarning($"Expected: {baselineJson}");
                System.Diagnostics.Trace.TraceWarning($"Actual: {localJson}");
                return(true);
            }
        }
        private static bool CheckBreakingChanges(string dllName, string baselinePath, string breakingChangesPath)
        {
            TypeTree locally = new TypeTree(typeof(object));

            ContractEnforcement.BuildTypeTree(locally, ContractEnforcement.GetAssemblyLocally(dllName).GetExportedTypes());

            TypeTree baseline = JsonConvert.DeserializeObject <TypeTree>(File.ReadAllText(baselinePath));

            string localJson = JsonConvert.SerializeObject(locally, Formatting.Indented);

            File.WriteAllText($"{breakingChangesPath}", localJson);
            string baselineJson = JsonConvert.SerializeObject(baseline, Formatting.Indented);

            return(baselineJson == localJson);
        }