public void ProcessIncludesExcludes() { if (ExcludeNamespaces.Any()) { matchers = GetLines(ExcludeNamespaces).ToList(); ShouldIncludeType = type => { return(matchers.All(matcher => !matcher.Match(type.GetNamespace())) && !ContainsIgnoreAttribute(type)); }; return; } if (IncludeNamespaces.Any()) { matchers = GetLines(IncludeNamespaces).ToList(); ShouldIncludeType = type => { return(matchers.Any(lineMatcher => lineMatcher.Match(type.GetNamespace())) && !ContainsIgnoreAttribute(type)); }; return; } ShouldIncludeType = type => !ContainsIgnoreAttribute(type); }
public void ProcessIncludesExcludes() { if (ExcludeNamespaces.Any()) { lineMatchers = GetLines(ExcludeNamespaces).ToList(); ShouldIncludeType = definition => lineMatchers.All(lineMatcher => !lineMatcher.Match(definition.Namespace)) && !ContainsIgnoreAttribute(definition); return; } if (IncludeNamespaces.Any()) { lineMatchers = GetLines(IncludeNamespaces).ToList(); ShouldIncludeType = definition => lineMatchers.Any(lineMatcher => lineMatcher.Match(definition.Namespace)) && !ContainsIgnoreAttribute(definition); return; } ShouldIncludeType = definition => !ContainsIgnoreAttribute(definition); }
private void InitDiff(IEnumerable <TypeDefinition> toTypes, TypeDefinition parent = null) { foreach (var toType in toTypes) { if (ExcludeTypes.Contains(toType.FullName) || parent == null && ExcludeNamespaces.Contains(toType.Namespace)) { continue; } var fromType = from.GetType(toType.FullName); if (fromType == null) { fieldsToInclude[toType.FullName] = toType.Fields.ToList(); methodsToInclude[toType.FullName] = toType.Methods.ToList(); if (parent == null) { typesToInclude.Add(toType); } else { if (!nestedTypesToInclude.TryGetValue(parent.FullName, out var list)) { nestedTypesToInclude[parent.FullName] = list = new List <TypeDefinition>(); } list.Add(toType); } InitDiff(toType.NestedTypes, toType); continue; } foreach (var toField in toType.Fields) { var fromField = fromType.Fields.FirstOrDefault(f => f.Name == toField.Name); if (fromField == null || fromField.FieldType.FullName != toField.FieldType.FullName || fromField.Attributes != toField.Attributes) { if (!fieldsToInclude.TryGetValue(toType.FullName, out var list)) { fieldsToInclude[toType.FullName] = list = new List <FieldDefinition>(); } list.Add(toField); } } foreach (var toMethod in toType.Methods) { var fromMethod = fromType.Methods.FirstOrDefault(m => m.FullName == toMethod.FullName); if (fromMethod == null || fromMethod.HasBody != toMethod.HasBody || fromMethod.Body?.Instructions.Count != toMethod.Body?.Instructions.Count) { if (!methodsToInclude.TryGetValue(toType.FullName, out var list)) { methodsToInclude[toType.FullName] = list = new List <MethodDefinition>(); } list.Add(toMethod); continue; } if (toMethod.HasBody && !toMethod.Body.Instructions.SequenceEqual(fromMethod.Body.Instructions, InstructionComparer)) { if (!methodsToInclude.TryGetValue(toType.FullName, out var list)) { methodsToInclude[toType.FullName] = list = new List <MethodDefinition>(); } list.Add(toMethod); } } if (fieldsToInclude.ContainsKey(toType.FullName) || methodsToInclude.ContainsKey(toType.FullName) || nestedTypesToInclude.ContainsKey(toType.FullName)) { if (parent == null) { typesToInclude.Add(toType); } else { if (!nestedTypesToInclude.TryGetValue(toType.FullName, out var list)) { nestedTypesToInclude[toType.FullName] = list = new List <TypeDefinition>(); } list.Add(toType); } } InitDiff(toType.NestedTypes, toType); } }