/// <summary> /// Explores given PSI file. /// </summary> public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted) { if (psiFile == null) { throw new ArgumentNullException("psiFile"); } if (consumer == null) { throw new ArgumentNullException("consumer"); } #if !RESHARPER_31 && !RESHARPER_40 && !RESHARPER_41 using (ReadLockCookie.Create()) #endif { if (!psiFile.IsValid()) { return; } try { PsiReflectionPolicy reflectionPolicy = new PsiReflectionPolicy(psiFile.GetManager()); ConsumerAdapter consumerAdapter = new ConsumerAdapter(provider, consumer, psiFile); var codeElements = new List <ICodeElementInfo>(); psiFile.ProcessDescendants(new OneActionProcessorWithoutVisit(delegate(IElement element) { ITypeDeclaration declaration = element as ITypeDeclaration; if (declaration != null) { PopulateCodeElementsFromTypeDeclaration(codeElements, reflectionPolicy, declaration); } }, delegate(IElement element) { if (interrupted()) { throw new ProcessCancelledException(); } // Stop recursing at the first type declaration found. return(element is ITypeDeclaration); })); Describe(reflectionPolicy, codeElements, consumerAdapter); ProjectFileState.SetFileState(psiFile.GetProjectFile(), consumerAdapter.CreateProjectFileState()); } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } } }
/// <summary> /// Explores given PSI file. /// </summary> public void ExploreFile(ITreeNode psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted) { if (psiFile == null) { throw new ArgumentNullException("psiFile"); } if (consumer == null) { throw new ArgumentNullException("consumer"); } if (!psiFile.IsValid()) { return; } try { #if RESHARPER_60 var reflectionPolicy = new PsiReflectionPolicy(psiFile.GetPsiServices().PsiManager); #else var reflectionPolicy = new PsiReflectionPolicy(psiFile.GetPsiServices().PsiManager, provider.CacheManager); #endif var consumerAdapter = new ConsumerAdapter(provider, consumer, psiFile); var codeElements = new List <ICodeElementInfo>(); psiFile.ProcessDescendants(new OneActionProcessorWithoutVisit(delegate(ITreeNode element) { var declaration = element as ITypeDeclaration; if (declaration != null) { PopulateCodeElementsFromTypeDeclaration(codeElements, reflectionPolicy, declaration); } }, delegate(ITreeNode element) { if (interrupted()) { throw new ProcessCancelledException(); } // Stop recursing at the first type declaration found. return(element is ITypeDeclaration); })); Describe(reflectionPolicy, codeElements, consumerAdapter); ProjectFileState.SetFileState(psiFile.GetSourceFile().ToProjectFile(), consumerAdapter.CreateProjectFileState()); } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } }
/// <summary> /// Explores given compiled project. /// </summary> public void ExploreAssembly(IMetadataAssembly assembly, IProject project, UnitTestElementConsumer consumer) { if (assembly == null) { throw new ArgumentNullException("assembly"); } if (project == null) { throw new ArgumentNullException("project"); } if (consumer == null) { throw new ArgumentNullException("consumer"); } #if !RESHARPER_31 && !RESHARPER_40 && !RESHARPER_41 using (ReadLockCookie.Create()) #endif { if (!project.IsValid) { return; } try { MetadataReflectionPolicy reflectionPolicy = new MetadataReflectionPolicy(assembly, project); IAssemblyInfo assemblyInfo = reflectionPolicy.Wrap(assembly); if (assemblyInfo != null) { ConsumerAdapter consumerAdapter = new ConsumerAdapter(provider, consumer); Describe(reflectionPolicy, new ICodeElementInfo[] { assemblyInfo }, consumerAdapter); } } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } } }
/// <summary> /// Explores given compiled project. /// </summary> public void ExploreAssembly(IMetadataAssembly assembly, IProject project, UnitTestElementConsumer consumer) { if (assembly == null) { throw new ArgumentNullException("assembly"); } if (project == null) { throw new ArgumentNullException("project"); } if (consumer == null) { throw new ArgumentNullException("consumer"); } try { #if RESHARPER_60 var reflectionPolicy = new MetadataReflectionPolicy(assembly, project); #else var reflectionPolicy = new MetadataReflectionPolicy(assembly, project, provider.CacheManager); #endif IAssemblyInfo assemblyInfo = reflectionPolicy.Wrap(assembly); if (assemblyInfo != null) { var consumerAdapter = new ConsumerAdapter(provider, consumer); Describe(reflectionPolicy, new ICodeElementInfo[] { assemblyInfo }, consumerAdapter); } } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } }
private void Describe(IReflectionPolicy reflectionPolicy, IList<ICodeElementInfo> codeElements, ConsumerAdapter consumerAdapter) { var testDriver = CreateTestDriver(); var testExplorationOptions = new TestExplorationOptions(); testDriver.Describe(reflectionPolicy, codeElements, testExplorationOptions, consumerAdapter, NullProgressMonitor.CreateInstance()); }
/// <summary> /// Explores given PSI file. /// </summary> public void ExploreFile(IFile psiFile, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted) { if (psiFile == null) throw new ArgumentNullException("psiFile"); if (consumer == null) throw new ArgumentNullException("consumer"); #if ! RESHARPER_31 && ! RESHARPER_40 && ! RESHARPER_41 using (ReadLockCookie.Create()) #endif { if (!psiFile.IsValid()) return; try { PsiReflectionPolicy reflectionPolicy = new PsiReflectionPolicy(psiFile.GetManager()); ConsumerAdapter consumerAdapter = new ConsumerAdapter(provider, consumer, psiFile); var codeElements = new List<ICodeElementInfo>(); psiFile.ProcessDescendants(new OneActionProcessorWithoutVisit(delegate(IElement element) { ITypeDeclaration declaration = element as ITypeDeclaration; if (declaration != null) PopulateCodeElementsFromTypeDeclaration(codeElements, reflectionPolicy, declaration); }, delegate(IElement element) { if (interrupted()) throw new ProcessCancelledException(); // Stop recursing at the first type declaration found. return element is ITypeDeclaration; })); Describe(reflectionPolicy, codeElements, consumerAdapter); ProjectFileState.SetFileState(psiFile.GetProjectFile(), consumerAdapter.CreateProjectFileState()); } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } } }
/// <summary> /// Explores given compiled project. /// </summary> public void ExploreAssembly(IMetadataAssembly assembly, IProject project, UnitTestElementConsumer consumer) { if (assembly == null) throw new ArgumentNullException("assembly"); if (project == null) throw new ArgumentNullException("project"); if (consumer == null) throw new ArgumentNullException("consumer"); #if ! RESHARPER_31 && ! RESHARPER_40 && ! RESHARPER_41 using (ReadLockCookie.Create()) #endif { if (!project.IsValid) return; try { MetadataReflectionPolicy reflectionPolicy = new MetadataReflectionPolicy(assembly, project); IAssemblyInfo assemblyInfo = reflectionPolicy.Wrap(assembly); if (assemblyInfo != null) { ConsumerAdapter consumerAdapter = new ConsumerAdapter(provider, consumer); Describe(reflectionPolicy, new ICodeElementInfo[] { assemblyInfo }, consumerAdapter); } } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } } }
/// <summary> /// Explores given compiled project. /// </summary> public void ExploreAssembly(IMetadataAssembly assembly, IProject project, UnitTestElementConsumer consumer) { if (assembly == null) throw new ArgumentNullException("assembly"); if (project == null) throw new ArgumentNullException("project"); if (consumer == null) throw new ArgumentNullException("consumer"); try { #if RESHARPER_60 var reflectionPolicy = new MetadataReflectionPolicy(assembly, project); #else var reflectionPolicy = new MetadataReflectionPolicy(assembly, project, provider.CacheManager); #endif IAssemblyInfo assemblyInfo = reflectionPolicy.Wrap(assembly); if (assemblyInfo != null) { var consumerAdapter = new ConsumerAdapter(provider, consumer); Describe(reflectionPolicy, new ICodeElementInfo[] {assemblyInfo}, consumerAdapter); } } catch (Exception ex) { HandleEmbeddedProcessCancelledException(ex); throw; } }
private void Describe(IReflectionPolicy reflectionPolicy, IList <ICodeElementInfo> codeElements, ConsumerAdapter consumerAdapter) { var testDriver = CreateTestDriver(); var testExplorationOptions = new TestExplorationOptions(); testDriver.Describe(reflectionPolicy, codeElements, testExplorationOptions, consumerAdapter, NullProgressMonitor.CreateInstance()); }