Пример #1
0
 //
 // BUGBUG: temporary workaround for CCI bug
 //
 public override TypeAlias VisitTypeAlias(TypeAlias tAlias)
 {
     if (tAlias == null) return null;
     TypeAlias dup = (TypeAlias)this.DuplicateFor[tAlias.UniqueKey];
     if (dup != null) return dup;
     this.DuplicateFor[tAlias.UniqueKey] = dup = (TypeAlias)tAlias.Clone();
     dup.Name = tAlias.Name;
     if (tAlias.AliasedType is ConstrainedType)
         //The type alias defines the constrained type, rather than just referencing it
         dup.AliasedType = this.VisitConstrainedType((ConstrainedType)tAlias.AliasedType);
     else
         dup.AliasedType = this.VisitTypeReference(tAlias.AliasedType);
     dup.DeclaringType = this.TargetType;
     dup.DeclaringModule = this.TargetModule;
     dup.ProvideMembers();
     return dup;
 }
Пример #2
0
    public virtual Differences VisitTypeAlias(TypeAlias tAlias1, TypeAlias tAlias2){
      Differences differences = this.GetMemberDifferences(tAlias1, tAlias2);
      if (differences == null){Debug.Assert(false); differences = new Differences(tAlias1, tAlias2);}
      if (differences.NumberOfDifferences > 0 || differences.NumberOfSimilarities > 0) return differences;
      if (tAlias1 == null || tAlias2 == null){
        if (tAlias1 != tAlias2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      TypeAlias changes = (TypeAlias)tAlias2.Clone();
      TypeAlias deletions = (TypeAlias)tAlias2.Clone();
      TypeAlias insertions = (TypeAlias)tAlias2.Clone();

      Differences diff = this.VisitTypeNode(tAlias1.AliasedType, tAlias2.AliasedType);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.AliasedType = diff.Changes as TypeNode;
      deletions.AliasedType = diff.Deletions as TypeNode;
      insertions.AliasedType = diff.Insertions as TypeNode;
      //Debug.Assert(diff.Changes == changes.AliasedType && diff.Deletions == deletions.AliasedType && diff.Insertions == insertions.AliasedType);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      AttributeList attrChanges, attrDeletions, attrInsertions;
      diff = this.VisitAttributeList(tAlias1.Attributes, tAlias2.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 (tAlias1.Flags == tAlias2.Flags) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      diff = this.VisitIdentifier(tAlias1.Name, tAlias2.Name);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Name = diff.Changes as Identifier;
      deletions.Name = diff.Deletions as Identifier;
      insertions.Name = diff.Insertions as Identifier;
      Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

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

      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;
    }