Beispiel #1
0
 private static FilesCompareModel BuildFilesChangesModel(FilesCompareModel filesCompareModel)
 {
     return(new FilesCompareModel(
                filesCompareModel.FileName,
                filesCompareModel.TypesAdded,
                filesCompareModel.TypesRemoved,
                filesCompareModel.TypesCompareResult
                .Select(BuildTypesChangesModel)
                .Where(model =>
                       model.MethodsAdded.Any() ||
                       model.MethodsRemoved.Any() ||
                       model.MethodsCompareResult.Any())));
 }
Beispiel #2
0
 private static ChangesToStudyModel BuildFilesChangesToStudyModel(FilesCompareModel filesCompareModel)
 {
     return(new ChangesToStudyModel(
                filesCompareModel.FileName,
                filesCompareModel.TypesAdded,
                filesCompareModel.TypesCompareResult
                .SelectMany(typesCompareModel =>
                            typesCompareModel.MethodsAdded
                            .Union(
                                typesCompareModel.MethodsCompareResult
                                .Where(methodsCompareModel =>
                                       methodsCompareModel.MethodBodyStatus == MethodBodyStatus.Added ||
                                       methodsCompareModel.MethodBodyStatus == MethodBodyStatus.Changed)
                                .Select(methodsCompareModel => methodsCompareModel.MethodName)))));
 }
Beispiel #3
0
        private static ChangesToStudyModel CompareTypes(string fileName)
        {
            Console.WriteLine("Сравнение файлов: " + fileName);

            var file462 = ModuleDefMD.Load(Path.Combine(_root462, fileName));
            var file48  = ModuleDefMD.Load(Path.Combine(_root48, fileName));

            file462.EnableTypeDefFindCache = true;
            file48.EnableTypeDefFindCache  = true;

            var types462 = file462.GetTypes().Select(type => type.FullName).ToImmutableList();
            var types48  = file48.GetTypes().Select(type => type.FullName).ToImmutableList();

            var typesAdded = types48.Except(types462).ToImmutableList();
            // PrintList("Добавленные типы", typesAdded);

            var typesRemoved = types462.Except(types48).ToImmutableList();
            // PrintList("Удалённые типы", typesRemoved);

            var typesInBoth = types462.Intersect(types48).ToImmutableList();

            var filesCompareModel = new FilesCompareModel(fileName, typesAdded, typesRemoved,
                                                          typesInBoth.Select(
                                                              typeName => CompareTypes(
                                                                  file462.Find(typeName, false),
                                                                  file48.Find(typeName, false))));

            File.WriteAllText(
                $"{fileName.Replace(Path.DirectorySeparatorChar, '_')} — Compare.html",
                new CompareTemplate(BuildFilesChangesModel(filesCompareModel)).TransformText());
            File.WriteAllText(
                $"{fileName.Replace(Path.DirectorySeparatorChar, '_')} — VerboseCompare.html",
                new VerboseCompareTemplate(filesCompareModel).TransformText());

            return(BuildFilesChangesToStudyModel(filesCompareModel));
        }
Beispiel #4
0
 public VerboseCompareTemplate(FilesCompareModel model)
 {
     _model = model;
 }
Beispiel #5
0
 public CompareTemplate(FilesCompareModel model)
 {
     _model = model;
 }