Exemplo n.º 1
0
    public virtual Differences VisitAssembly(AssemblyNode/*!*/ assembly1, AssemblyNode assembly2) {
      Differences differences = new Differences(assembly1, assembly2);
      if (assembly1 == null || assembly2 == null){
        if (assembly1 != assembly2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      AssemblyNode changes = (AssemblyNode)assembly2.Clone();
      AssemblyNode deletions = (AssemblyNode)assembly2.Clone();
      AssemblyNode insertions = (AssemblyNode)assembly2.Clone();

      this.OriginalModule = assembly1;
      this.NewModule = assembly2;

      AssemblyReferenceList arChanges, arDeletions, arInsertions;
      Differences diff = this.VisitAssemblyReferenceList(assembly1.AssemblyReferences, assembly2.AssemblyReferences, out arChanges, out arDeletions, out arInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.AssemblyReferences = arChanges;
      deletions.AssemblyReferences = arDeletions;
      insertions.AssemblyReferences = arInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      AttributeList attrChanges, attrDeletions, attrInsertions;
      diff = this.VisitAttributeList(assembly1.Attributes, assembly2.Attributes, out attrChanges, out attrDeletions, out attrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Attributes = attrChanges;
      deletions.Attributes = attrDeletions;
      insertions.Attributes = attrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (assembly1.Culture == assembly2.Culture) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      TypeNodeList typeChanges, typeDeletions, typeInsertions;
      diff = this.VisitTypeNodeList(assembly1.ExportedTypes, assembly2.ExportedTypes, out typeChanges, out typeDeletions, out typeInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Types = typeChanges;
      deletions.Types = typeDeletions;
      insertions.Types = typeInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (assembly1.Flags == assembly2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      if (assembly1.Kind == assembly2.Kind) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      diff = this.VisitAttributeList(assembly1.ModuleAttributes, assembly2.ModuleAttributes, out attrChanges, out attrDeletions, out attrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Attributes = attrChanges;
      deletions.Attributes = attrDeletions;
      insertions.Attributes = attrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      ModuleReferenceList mrChanges, mrDeletions, mrInsertions;
      diff = this.VisitModuleReferenceList(assembly1.ModuleReferences, assembly2.ModuleReferences, out mrChanges, out mrDeletions, out mrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.ModuleReferences = mrChanges;
      deletions.ModuleReferences = mrDeletions;
      insertions.ModuleReferences = mrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (assembly1.Name == assembly2.Name) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      SecurityAttributeList secChanges, secDeletions, secInsertions;
      diff = this.VisitSecurityAttributeList(assembly1.SecurityAttributes, assembly2.SecurityAttributes, out secChanges, out secDeletions, out secInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.SecurityAttributes = secChanges;
      deletions.SecurityAttributes = secDeletions;
      insertions.SecurityAttributes = secInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitTypeNodeList(assembly1.Types, assembly2.Types, out typeChanges, out typeDeletions, out typeInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Types = typeChanges;
      deletions.Types = typeDeletions;
      insertions.Types = typeInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (assembly1.Version == assembly2.Version) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Exemplo n.º 2
0
 public override AssemblyNode VisitAssembly(AssemblyNode assembly)
 {
     if (assembly == null) return null;
     this.FindTypesToBeDuplicated(assembly.Types);
     return base.VisitAssembly((AssemblyNode)assembly.Clone());
 }