void DoDiff(QueryAggregator diffQueries) { // Interfaces have no base type if (!TypeV1.IsInterface) { this.HasChangedBaseType = !IsSameBaseType(TypeV1, TypeV2); } DiffImplementedInterfaces(); DiffFields(diffQueries); DiffMethods(diffQueries); DiffEvents(diffQueries); }
private void DiffEvents(QueryAggregator diffQueries) { List <EventDefinition> eventsV1 = diffQueries.ExecuteAndAggregateEventQueries(TypeV1); List <EventDefinition> eventsV2 = diffQueries.ExecuteAndAggregateEventQueries(TypeV2); ListDiffer <EventDefinition> differ = new ListDiffer <EventDefinition>(CompareEvents); differ.Diff(eventsV1, eventsV2, (added) => { this.Events.Add(new DiffResult <EventDefinition>(added, new DiffOperation(true))); }, (removed) => { this.Events.Add(new DiffResult <EventDefinition>(removed, new DiffOperation(false))); }); }
private void DiffFields(QueryAggregator diffQueries) { List <FieldDefinition> fieldsV1 = diffQueries.ExecuteAndAggregateFieldQueries(TypeV1); List <FieldDefinition> fieldsV2 = diffQueries.ExecuteAndAggregateFieldQueries(TypeV2); ListDiffer <FieldDefinition> fieldDiffer = new ListDiffer <FieldDefinition>(CompareFieldsByTypeAndName); fieldDiffer.Diff(fieldsV1, fieldsV2, (addedField) => { this.Fields.Add(new DiffResult <FieldDefinition>(addedField, new DiffOperation(true))); }, (removedField) => { this.Fields.Add(new DiffResult <FieldDefinition>(removedField, new DiffOperation(false))); }); }
private void DiffMethods(QueryAggregator diffQueries) { var methodsV1 = diffQueries.ExecuteAndAggregateMethodQueries(this.TypeV1); var methodsV2 = diffQueries.ExecuteAndAggregateMethodQueries(this.TypeV2); ListDiffer <MethodDefinition> differ = new ListDiffer <MethodDefinition>(CompareMethodByNameAndTypesIncludingGenericArguments); differ.Diff(methodsV1, methodsV2, (added) => { this.Methods.Add(new DiffResult <MethodDefinition>(added, new DiffOperation(true))); }, (removed) => { this.Methods.Add(new DiffResult <MethodDefinition>(removed, new DiffOperation(false))); } ); }
public AssemblyDiffCollection GenerateTypeDiff(QueryAggregator queries) { if (queries == null || queries.TypeQueries.Count == 0) { throw new ArgumentNullException("queries is null or contains no queries"); } List <TypeDefinition> typesV1 = queries.ExeuteAndAggregateTypeQueries(myV1); List <TypeDefinition> typesV2 = queries.ExeuteAndAggregateTypeQueries(myV2); ListDiffer <TypeDefinition> differ = new ListDiffer <TypeDefinition>(ShallowTypeComapare); differ.Diff(typesV1, typesV2, OnAddedType, OnRemovedType); DiffTypes(typesV1, typesV2, queries); return(myDiff); }
/// <summary> /// Checks if the type has changes /// On type level /// Base Types, implemented interfaces, generic parameters /// On method level /// Method modifiers, return type, generic parameters, parameter count, parameter types (also generics) /// On field level /// Field types /// </summary> /// <param name="typeV1">The type v1.</param> /// <param name="typeV2">The type v2.</param> /// <param name="diffQueries">The diff queries.</param> /// <returns></returns> public static TypeDiff GenerateDiff(TypeDefinition typeV1, TypeDefinition typeV2, QueryAggregator diffQueries) { if (typeV1 == null) { throw new ArgumentNullException("typeV1"); } if (typeV2 == null) { throw new ArgumentNullException("typeV2"); } if (diffQueries == null || diffQueries.FieldQueries.Count == 0 || diffQueries.MethodQueries.Count == 0) { throw new ArgumentException("diffQueries was null or the method or field query list was emtpy. This will not result in a meaningful diff result"); } TypeDiff diff = new TypeDiff(typeV1, typeV2); diff.DoDiff(diffQueries); if (!diff.HasChangedBaseType && diff.Events.Count == 0 && diff.Fields.Count == 0 && diff.Interfaces.Count == 0 && diff.Methods.Count == 0) { return(TypeDiff.None); } return(diff); }
private void DiffTypes(List <TypeDefinition> typesV1, List <TypeDefinition> typesV2, QueryAggregator queries) { TypeDefinition typeV2; foreach (var typeV1 in typesV1) { typeV2 = GetTypeByDefinition(typeV1, typesV2); if (typeV2 != null) { TypeDiff diffed = TypeDiff.GenerateDiff(typeV1, typeV2, queries); if (TypeDiff.None != diffed) { myDiff.ChangedTypes.Add(diffed); } } } }