private SearchEngine() { var types = typeof(TypeVertex).Assembly.GetTypes(); var typeGraph = new TypeGraph <TBaseSearchInterface>(types); _pathBuilder = new PathBuilder <TBaseSearchInterface>(typeGraph); }
public TypeNode(TypeGraph typeGraph, TypeSpecifier type) { foreach (TypeSpecifier genArg in type.GenericArguments) { AddInputTypePin(null); } }
private static TypeGraph CreateGraph(TypeViewModel typeViewModel, bool adjustExpansion) { var graph = new TypeGraph(true); if (adjustExpansion) { ExpandAll(typeViewModel); if (typeViewModel.DescendantsCount > 100) { AdjustExpansion(typeViewModel); } } else { typeViewModel.IsExpanded = true; if (typeViewModel.DescendantsCount <= 100) { ExpandAll(typeViewModel); } } var flattenedHierarchy = typeViewModel.FlattenedHierarchy; graph.AddVertexRange(flattenedHierarchy); foreach (var viewModel in flattenedHierarchy) { if (viewModel.BaseType == null || viewModel == typeViewModel) { continue; } graph.AddEdge(new Edge <TypeViewModel>(viewModel, viewModel.BaseType)); } return(graph); }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); var pathBuilder = new PathBuilder <IBase>(typeGraph); var result = pathBuilder.Find(new A(), typeof(IF)); var ab = typeof(IA).GetProperty("B"); var ac = typeof(IA).GetProperty("C"); var bc = typeof(IB).GetProperty("C"); var cf = typeof(IC).GetProperty("F"); var pathCommon = new CompositPropertyVertex(); pathCommon.PropertyList.AddLast(cf); var path1 = new CompositPropertyVertex(); path1.PropertyList.AddLast(ab); path1.PropertyList.AddLast(bc); path1.Children.AddLast(pathCommon); var path2 = new CompositPropertyVertex(); path2.PropertyList.AddLast(ac); path2.Children.AddLast(pathCommon); var expected = new[] { path1, path2 }; Assert.True(IsEqual(expected, result)); }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); var pathBuilder = new PathBuilder <IBase>(typeGraph); var result = pathBuilder.Find(new ClassA(), typeof(IE)); //// 1) IA.B -> IB.C -> IC.D -> ID.E //// |-> IE.BaseE //// |-> IE.BaseE ... //// |-> IE.DerivedE ... //// |-> IE.DerivedE //// |-> IE.BaseE ... //// |-> IE.DerivedE ... //// //// 2) IBaseA.A //// |-> IBaseA.A ... //// |-> IA.B -> IB.C -> IC.D -> ID.E ... var ab = typeof(IA).GetProperty("B"); var bc = typeof(IB).GetProperty("C"); var cd = typeof(IC).GetProperty("D"); var de = typeof(ID).GetProperty("E"); var baseaA = typeof(IBaseA).GetProperty("A"); var eBase = typeof(IE).GetProperty("BaseE"); var eDerived = typeof(IE).GetProperty("DerivedE"); var vertexABCDE = new CompositPropertyVertex(); vertexABCDE.PropertyList.AddLast(ab); vertexABCDE.PropertyList.AddLast(bc); vertexABCDE.PropertyList.AddLast(cd); vertexABCDE.PropertyList.AddLast(de); var vertexBaseAA = new CompositPropertyVertex(); vertexBaseAA.PropertyList.AddLast(baseaA); var vertexEBaseE = new CompositPropertyVertex(); vertexEBaseE.PropertyList.AddLast(eBase); var vertexEDerivedE = new CompositPropertyVertex(); vertexEDerivedE.PropertyList.AddLast(eDerived); vertexABCDE.Children.AddLast(vertexEBaseE); vertexABCDE.Children.AddLast(vertexEDerivedE); vertexEBaseE.Children.AddLast(vertexEBaseE); vertexEBaseE.Children.AddLast(vertexEDerivedE); vertexEDerivedE.Children.AddLast(vertexEBaseE); vertexEDerivedE.Children.AddLast(vertexEDerivedE); vertexBaseAA.Children.AddLast(vertexABCDE); vertexBaseAA.Children.AddLast(vertexBaseAA); var expected = new[] { vertexABCDE, vertexBaseAA }; Assert.True(IsEqual(expected, result)); }
public void Type_CreationWithTypeGraphDirected_Directed() { TypeGraph expected = TypeGraph.Directed; AdjacencyMatrix am = new AdjacencyMatrix(2, expected); Assert.AreEqual(expected, am.Type); }
public AdjacencyList(int vertices, TypeGraph type) : base(vertices, type) { list = new List <int> [Vertices]; for (int i = 0; i < list.Length; i++) { list[i] = new List <int>(); } }
public AdjacencyMatrix(int vertices, TypeGraph type) : base(vertices, type) { matrix = new BitArray[Vertices]; for (int i = 0; i < matrix.Length; i++) { matrix[i] = new BitArray(Vertices); } }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); var pathBuilder = new PathBuilder <IBase>(typeGraph); var result = pathBuilder.Find(new A(), typeof(IF)); var dictionary = new Dictionary <PropertyInfo, CompositPropertyVertex>(); Assert.True(CheckCyclicGraph(result, dictionary)); }
public TypeGraph GetTypeGraph() { string typeGraphStr = textProgram.Split(new Char[] { ' ' })[0]; switch (typeGraphStr) { case "graph": typeGraph = TypeGraph.Graph; break; default: typeGraph = TypeGraph.None; break; } return typeGraph; }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); var pathBuilder = new PathBuilder <IBase>(typeGraph); var result = pathBuilder.Find(new A(), typeof(IB)); var ab = typeof(IA).GetProperty("ListB"); var vertex1 = new CompositPropertyVertex(); vertex1.PropertyList.AddLast(ab); var expected = new[] { vertex1 }; Assert.True(IsEqual(expected, result)); }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); var pathBuilder = new PathBuilder <IBase>(typeGraph); var result = pathBuilder.Find(new A(), typeof(ID)); var ab = typeof(IA).GetProperty("Base"); var bc = typeof(IB).GetProperty("Base"); var cd = typeof(IC).GetProperty("Base"); var vertexAB = new CompositPropertyVertex(); vertexAB.PropertyList.AddLast(ab); var vertexBC = new CompositPropertyVertex(); vertexBC.PropertyList.AddLast(bc); var vertexCD = new CompositPropertyVertex(); vertexCD.PropertyList.AddLast(cd); vertexAB.Children.AddLast(vertexAB); vertexAB.Children.AddLast(vertexBC); vertexAB.Children.AddLast(vertexCD); vertexBC.Children.AddLast(vertexAB); vertexBC.Children.AddLast(vertexBC); vertexBC.Children.AddLast(vertexCD); vertexCD.Children.AddLast(vertexAB); vertexCD.Children.AddLast(vertexBC); vertexCD.Children.AddLast(vertexCD); var expected = new[] { vertexAB }; Assert.True(IsEqual(expected, result)); }
/// <summary> /// Builds a graph of derived type definitions. /// </summary> public static TypeGraphNode BuildDerivedTypesGraph(ITypeDefinition baseType) { if (baseType == null) { throw new ArgumentNullException("baseType"); } var solutionSnapshot = GetSolutionSnapshot(baseType.Compilation); var assemblies = GetProjectsThatCouldReferenceEntity(baseType).Select(p => solutionSnapshot.GetCompilation(p).MainAssembly); var graph = new TypeGraph(assemblies); var node = graph.GetNode(baseType); if (node != null) { // only derived types were requested, so don't return the base types // (this helps the GC to collect the unused parts of the graph more quickly) node.BaseTypes.Clear(); return(node); } else { return(new TypeGraphNode(baseType)); } }
IList <AstNode> Rename(string fullyQualifiedName, string newName, bool includeOverloads) { var sym = GetSymbol(compilation, fullyQualifiedName); Assert.NotNull(sym); var graph = new TypeGraph(compilation.Assemblies); var col = new SymbolCollector(); col.IncludeOverloads = includeOverloads; col.GroupForRenaming = true; var scopes = findReferences.GetSearchScopes(col.GetRelatedSymbols(graph, sym)); List <AstNode> result = new List <AstNode>(); findReferences.RenameReferencesInFile( scopes, newName, new CSharpAstResolver(compilation, syntaxTree, unresolvedFile), delegate(RenameCallbackArguments obj) { result.Add(obj.NodeToReplace); }, delegate(Error obj) { }); return(result); }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); var pathBuilder = new PathBuilder <IBase>(typeGraph); var result = pathBuilder.Find(new A(), typeof(ID)); var ab = typeof(IA).GetProperty("B"); var bc = typeof(IB).GetProperty("C"); var cd1 = typeof(IC).GetProperty("D1"); var cd2 = typeof(IC).GetProperty("D2"); var cd3 = typeof(IC).GetProperty("D3"); var cd1Vertex = new CompositPropertyVertex(); cd1Vertex.PropertyList.AddLast(cd1); var cd2Vertex = new CompositPropertyVertex(); cd2Vertex.PropertyList.AddLast(cd2); var cd3Vertex = new CompositPropertyVertex(); cd3Vertex.PropertyList.AddLast(cd3); var startVertex = new CompositPropertyVertex(); startVertex.PropertyList.AddLast(ab); startVertex.PropertyList.AddLast(bc); startVertex.Children.AddRange(new[] { cd1Vertex, cd2Vertex, cd3Vertex }); var expected = new[] { startVertex }; Assert.True(IsEqual(expected, result)); }
public ReferenceFinder(TypeGraph graph) { mGraph = graph; }
public Graph(TypeGraph type) { vertices = new Dictionary <T, Vertex <T> >(); this.type = type; }
public GraphStorage(int vertices, TypeGraph type) { Vertices = vertices; Type = type; }
internal void ProcessReplacements() { foreach (var t in rewriteAssembly.GetTypes()) { bool forceImplRewrite = t.Name.StartsWith("<PrivateImplementationDetails>"); var repl = t.GetCustomAttribute <RewriteAttribute>(false); TypeGraph typeTarget = null; TypeRewrite typeRewrite = null; if (repl != null) { if (repl.action == RewriteAction.Add) { typeTarget = new TypeGraph(t, null, _graph._modules.First()); if (repl.typeName != null) { typeTarget.FullName = repl.typeName; } continue; } typeTarget = (from x in Graph.Modules from y in x.TypeGraphs where y.FullName == repl.typeName select y).Single(); if (repl.action == RewriteAction.Replace) { typeTarget._replacementType = t; } _typeRewrites.Add(typeRewrite = new TypeRewrite() { MemberInfo = t, Rewrite = repl, Graph = typeTarget }); } foreach (var m in t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { if (forceImplRewrite) { if (m is MethodInfo) { _staticImplCache.Add(m as MethodInfo); } } var mRep = m.GetCustomAttribute <RewriteAttribute>(); if (mRep == null) { continue; } var mTypeTarget = mRep.typeName == null || (repl != null && repl.typeName == mRep.typeName) ? typeTarget : (from x in Graph.Modules from y in x.TypeGraphs where y.FullName == mRep.typeName select y).Single(); if (typeRewrite == null) { _typeRewrites.Add(typeRewrite = new TypeRewrite() { MemberInfo = t }); } var name = mRep.targetName ?? m.Name; if (m is MethodBase) { var mb = m as MethodBase; var target = mTypeTarget.Methods.FirstOrDefault(x => x.Name == name); MethodGraph newTarget = null; if (mRep.action == RewriteAction.Add) { newTarget = new MethodGraph(mb, mTypeTarget); } else if (mRep.action == RewriteAction.Remove) { target.DeclaringObject = null; } else if (mRep.action != RewriteAction.None) { newTarget = target.SwitchImpl(mb, mRep.newName, mRep.oldName); if (mRep.action == RewriteAction.Replace) { target.DeclaringObject = null; } else if (mRep.action == RewriteAction.Swap && newTarget.Name == target.Name) { target.Name += "_Orig"; } } if (mRep.contentHandler != null) { t.GetMethod(mRep.contentHandler).Invoke(null, new object[] { target, newTarget }); } typeRewrite.MethodRewrites.Add(new RewriteInfo <MethodBase, MethodGraph>() { MemberInfo = mb, Rewrite = mRep, Graph = mRep.action == RewriteAction.Replace || mRep.stubAction == StubAction.UseNew ? (newTarget ?? target) : (target ?? newTarget) }); } else if (m is PropertyInfo) { var p = m as PropertyInfo; var target = mTypeTarget.Properties.FirstOrDefault(x => x.Name == name); PropertyGraph newTarget = null; MethodGraph newGet = null, newSet = null; MethodGraph oldGet = null, oldSet = null; if (mRep.action == RewriteAction.Add) { newTarget = new PropertyGraph(p, mTypeTarget); if (newTarget._getAccessor != null) { newGet = new MethodGraph(newTarget._getAccessor, mTypeTarget); } if (newTarget._setAccessor != null) { newSet = new MethodGraph(newTarget._setAccessor, mTypeTarget); } } else { oldGet = target._getAccessor != null?mTypeTarget.Methods.FirstOrDefault(x => x._sourceObject == target._getAccessor) : null; oldSet = target._setAccessor != null?mTypeTarget.Methods.FirstOrDefault(x => x._sourceObject == target._setAccessor) : null; if (mRep.action == RewriteAction.Remove) { if (oldGet != null) { oldGet.DeclaringObject = null; } if (oldSet != null) { oldSet.DeclaringObject = null; } target.DeclaringObject = null; } else if (mRep.action != RewriteAction.None) { newTarget = new PropertyGraph(p, mTypeTarget); newTarget.Source = target.Source; if (newTarget._getAccessor != null) { newGet = oldGet.SwitchImpl(newTarget._getAccessor); } if (newTarget._setAccessor != null) { newSet = oldSet.SwitchImpl(newTarget._setAccessor); } if (mRep.action == RewriteAction.Replace) { if (oldGet != null) { oldGet.DeclaringObject = null; } if (oldSet != null) { oldSet.DeclaringObject = null; } target.DeclaringObject = null; } else if (mRep.action == RewriteAction.Swap && newTarget.Name == target.Name) { target.Name += "_Orig"; if (oldGet != null) { oldGet.Name += "_Orig"; } if (oldSet != null) { oldSet.Name += "_Orig"; } } } } if (mRep.contentHandler != null) { t.GetMethod(mRep.contentHandler).Invoke(null, new object[] { target, newTarget }); } typeRewrite.PropertyRewrites.Add(new PropertyRewrite() { MemberInfo = p, Rewrite = mRep, Graph = mRep.action == RewriteAction.Replace || mRep.stubAction == StubAction.UseNew ? (newTarget ?? target) : (target ?? newTarget), GetGraph = mRep.action == RewriteAction.Replace || mRep.stubAction == StubAction.UseNew ? (newGet ?? oldGet) : (oldGet ?? newGet), SetGraph = mRep.action == RewriteAction.Replace || mRep.stubAction == StubAction.UseNew ? (newSet ?? oldSet) : (oldSet ?? newSet) }); } else if (m is FieldInfo) { var f = m as FieldInfo; var target = mTypeTarget.Fields.FirstOrDefault(x => x.Name == name); FieldGraph newTarget = null; if (mRep.action == RewriteAction.Remove) { target.DeclaringObject = null; } else if (mRep.action != RewriteAction.None) { newTarget = new FieldGraph(f, mTypeTarget); if (mRep.action == RewriteAction.Replace) { newTarget.Source = target.Source; target.DeclaringObject = null; } else if (mRep.action == RewriteAction.Swap) { target.Name += "_Orig"; } } if (mRep.contentHandler != null) { t.GetMethod(mRep.contentHandler).Invoke(null, new object[] { target, newTarget }); } typeRewrite.FieldRewrites.Add(new RewriteInfo <FieldInfo, FieldGraph>() { MemberInfo = f, Rewrite = mRep, Graph = mRep.action == RewriteAction.Replace || mRep.stubAction == StubAction.UseNew ? (newTarget ?? target) : (target ?? newTarget) }); } } } }
public GraphConditional(TypeGraph type) { this.type = type; }
public TypeReturnNode(TypeGraph graph) : base(graph) { AddInputTypePin("Type"); }
private static TypeGraph CreateGraph(TypeViewModel typeViewModel) { var graph = new TypeGraph(true); var flattededHierarchy = typeViewModel.FlattenedHierarchy; graph.AddVertexRange(flattededHierarchy); foreach (var viewModel in flattededHierarchy) { if (viewModel.BaseType == null || viewModel == typeViewModel) { continue; } graph.AddEdge(new Edge<TypeViewModel>(viewModel, viewModel.BaseType)); } return graph; }
public void Run() { var assemblies = new HashSet <IAssembly> (); foreach (var project in IdeApp.ProjectOperations.CurrentSelectedSolution.GetAllProjects()) { var comp = TypeSystemService.GetCompilation(project); if (comp == null) { continue; } assemblies.Add(comp.MainAssembly); } TypeGraph tg = new TypeGraph(assemblies); var node = tg.GetNode(entity.DeclaringTypeDefinition); using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true)) { Stack <IList <TypeGraphNode> > derivedTypes = new Stack <IList <TypeGraphNode> > (); derivedTypes.Push(node.DerivedTypes); HashSet <ITypeDefinition> visitedType = new HashSet <ITypeDefinition> (); while (derivedTypes.Count > 0) { foreach (var derived in derivedTypes.Pop()) { if (visitedType.Contains(derived.TypeDefinition)) { continue; } derivedTypes.Push(tg.GetNode(derived.TypeDefinition).DerivedTypes); visitedType.Add(derived.TypeDefinition); var impMember = derived.TypeDefinition.Compilation.Import(entity); if (impMember == null) { continue; } IMember derivedMember; if (entity.DeclaringTypeDefinition.Kind == TypeKind.Interface) { derivedMember = derived.TypeDefinition.GetMembers(null, GetMemberOptions.IgnoreInheritedMembers).FirstOrDefault( m => m.ImplementedInterfaceMembers.Any(im => im.Region == entity.Region) ); } else { derivedMember = InheritanceHelper.GetDerivedMember(impMember, derived.TypeDefinition); } if (derivedMember == null) { continue; } var tf = TextFileProvider.Instance.GetReadOnlyTextEditorData(derivedMember.Region.FileName); var start = tf.LocationToOffset(derivedMember.Region.Begin); tf.SearchRequest.SearchPattern = derivedMember.Name; var sr = tf.SearchForward(start); if (sr != null) { start = sr.Offset; } monitor.ReportResult(new MemberReference(derivedMember, derivedMember.Region, start, derivedMember.Name.Length)); } } } }
private static TypeGraph CreateGraph(TypeViewModel typeViewModel, bool adjustExpansion) { var graph = new TypeGraph(true); if (adjustExpansion) { ExpandAll(typeViewModel); if (typeViewModel.DescendantsCount > 100) { AdjustExpansion(typeViewModel); } } else { typeViewModel.IsExpanded = true; if (typeViewModel.DescendantsCount <= 100) { ExpandAll(typeViewModel); } } var flattenedHierarchy = typeViewModel.FlattenedHierarchy; graph.AddVertexRange(flattenedHierarchy); foreach (var viewModel in flattenedHierarchy) { if (viewModel.BaseType == null || viewModel == typeViewModel) { continue; } graph.AddEdge(new Edge<TypeViewModel>(viewModel, viewModel.BaseType)); } return graph; }
public static string GenerateStandAloneThriftSpec(Type type, List <string> dependentSpecFiles) { var builder = new CodeBuilder(); builder.AppendLine(); builder.AppendLine("namespace csharp " + type.Namespace); builder.AppendLine(); var trackedTypes = new HashSet <Type>(); var tobetracked = new Queue <Type>(); foreach (var m in GetServiceCalls(type)) { var return_value_type = m.ReturnType.GetGenericArguments()[0]; var parameter_type = m.GetParameters()[0].ParameterType.GetGenericArguments()[0]; if (!IsDependentOfPrimitiveTypes(return_value_type) && !trackedTypes.Contains(return_value_type)) { tobetracked.Enqueue(return_value_type); trackedTypes.Add(return_value_type); } if (IsDependentOfPrimitiveTypes(parameter_type) || trackedTypes.Contains(parameter_type)) { continue; } tobetracked.Enqueue(parameter_type); trackedTypes.Add(parameter_type); } while (tobetracked.Count > 0) { var t = tobetracked.Dequeue(); foreach (var fld in t.GetFields().Where(fld => !IsDependentOfPrimitiveTypes(fld.FieldType) && !trackedTypes.Contains(fld.FieldType))) { if (fld.FieldType.IsGenericType) { foreach (var p in fld.FieldType.GetGenericArguments().Where(p => !IsDependentOfPrimitiveTypes(p) && !trackedTypes.Contains(p))) { tobetracked.Enqueue(p); trackedTypes.Add(p); } } else { tobetracked.Enqueue(fld.FieldType); trackedTypes.Add(fld.FieldType); } } } // dump types with dependency order var g = new TypeGraph(); foreach (var t in trackedTypes) { var v = g.CreateVertex(typeof(TypeVertex), (ulong)t.GetHashCode()); v.Owner = t; } foreach (var t in trackedTypes) { var fv = g.Vertices.First(v => v.Value.Owner == t); foreach (var fld in t.GetFields().Where(fld => !IsDependentOfPrimitiveTypes(fld.FieldType))) { if (fld.FieldType.IsGenericType) { foreach (var tv in from p in fld.FieldType.GetGenericArguments() where !IsDependentOfPrimitiveTypes(p) select g.Vertices.First(v => v.Value.Owner == p)) { tv.Value.ConnectTo <TypeEdge>(fv.Value); } } else { var tv = g.Vertices.First(v => v.Value.Owner == fld.FieldType); tv.Value.ConnectTo <TypeEdge>(fv.Value); } } } var traversal = new DAGTraverserSatisfied <TypeVertex, TypeEdge, TypeGraph>(true); traversal.Traverse(g, v => { builder.AppendLine("struct " + GetThriftTypeName(v.Owner)); builder.BeginBlock(); var idx = 0; foreach (var fld in v.Owner.GetFields()) { if (fld.GetCustomAttributes().Any(a => a is FieldAttribute)) { idx = ((FieldAttribute)fld.GetCustomAttributes().First(a => a is FieldAttribute)).index; } else { idx++; } builder.AppendLine(idx + ":" + GetThriftTypeName(fld.FieldType) + " " + fld.Name + ";"); } builder.EndBlock(); builder.AppendLine(); return(true); }, false, false); builder.AppendLine("service " + type.Name); builder.BeginBlock(); foreach (var m in GetServiceCalls(type)) { var return_value_type = m.ReturnType.GetGenericArguments()[0]; var parameter_type = m.GetParameters()[0].ParameterType.GetGenericArguments()[0]; var return_value_name = GetThriftTypeName(return_value_type); var parameter_name = GetThriftTypeName(parameter_type); builder.AppendLine(return_value_name + " " + m.Name + "(1: " + parameter_name + " req);"); } builder.EndBlock(); builder.AppendLine(); return(builder.ToString()); }
public PathBuilder(TypeGraph <TBaseSearchInterface> typeGraph) { _typeGraph = typeGraph; }
public Graph(TypeGraph type) { this.type = type; }
public void Run() { var assemblies = GetAllAssemblies(); assemblies.ContinueWith(delegate(Task <HashSet <IAssembly> > arg) { using (var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true)) { monitor.BeginTask(GettextCatalog.GetString("Building type graph in solution ..."), 1); var tg = new TypeGraph(arg.Result); var node = tg.GetNode(entity.DeclaringTypeDefinition); monitor.EndTask(); if (node == null) { return; } Gtk.Application.Invoke(delegate { Stack <IList <TypeGraphNode> > derivedTypes = new Stack <IList <TypeGraphNode> > (); derivedTypes.Push(node.DerivedTypes); HashSet <ITypeDefinition> visitedType = new HashSet <ITypeDefinition> (); while (derivedTypes.Count > 0) { foreach (var derived in derivedTypes.Pop()) { if (visitedType.Contains(derived.TypeDefinition)) { continue; } derivedTypes.Push(tg.GetNode(derived.TypeDefinition).DerivedTypes); visitedType.Add(derived.TypeDefinition); var impMember = derived.TypeDefinition.Compilation.Import(entity); if (impMember == null) { continue; } IMember derivedMember; if (entity.DeclaringTypeDefinition.Kind == TypeKind.Interface) { derivedMember = derived.TypeDefinition.GetMembers(null, GetMemberOptions.IgnoreInheritedMembers).FirstOrDefault( m => m.ImplementedInterfaceMembers.Any(im => im.Region == entity.Region) ); } else { derivedMember = InheritanceHelper.GetDerivedMember(impMember, derived.TypeDefinition); } if (derivedMember == null || string.IsNullOrEmpty(derivedMember.Region.FileName)) { continue; } var tf = TextFileProvider.Instance.GetReadOnlyTextEditorData(derivedMember.Region.FileName); var start = tf.LocationToOffset(derivedMember.Region.Begin); tf.SearchRequest.SearchPattern = derivedMember.Name; var sr = tf.SearchForward(start); if (sr != null) { start = sr.Offset; } monitor.ReportResult(new MemberReference(derivedMember, derivedMember.Region, start, derivedMember.Name.Length)); } } }); } }); }
public void Test() { var typeGraph = new TypeGraph <IBase>(GetType().Assembly.GetTypes()); Assert.True(CheckCyclicGraph(typeGraph.Vertices, new Dictionary <Type, TypeVertex>())); }