static CodeFunction CodeFunctionForUnimplemented(this Project project, Step Step) { return(project.Classes() .Where(x => x.Name == Step.Feature.Name) .SelectMany(x => x.Functions()) .FirstOrDefault(x => x.EqualsTo(Step))); }
// needs to b run from IDE public void should_load_Settings() { var Dte = Marshal.GetActiveObject("VisualStudio.DTE") as DTE; var DteProject = Dte.SelectedItems.Item(1).ProjectItem.ContainingProject; string fullPath = DteProject.Properties.Item("FullPath").Value.ToString(); string outputPath = DteProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString(); string outputDir = Path.Combine(fullPath, outputPath); string outputFileName = DteProject.Properties.Item("OutputFileName").Value.ToString(); string assemblyPath = Path.Combine(outputDir, outputFileName); DteProject.Name.ShouldBe("Features"); (assemblyPath).ShouldNotBeNull(); var Project = new Project { DTEProject = DteProject }; Project.Load(); Settings.XUnit.Name.ShouldBe("MsTest"); }
static CodeFunction CodeFunction(this Project Project, MethodInfo Method) { var DeclaringType = Method.DeclaringType(); return(Project.Classes() .Where(x => x.FullName == DeclaringType) .SelectMany(x => x.Functions()) .FirstOrDefault(x => x.EqualsTo(Method))); }
void GotoDefinition() { try { var Sentence = TextView.Caret.Position.BufferPosition .GetContainingLine().GetText().Trim(); var ProjectItem = (Marshal.GetActiveObject("VisualStudio.DTE") as DTE).ActiveDocument.ProjectItem; var FeatureItem = ObjectFactory.FeatureItemFrom(ProjectItem); var FeatureContent = TextView.TextSnapshot.GetText(); var project = Project.LoadFrom(FeatureItem); var Feature = ObjectFactory.NewFeatureParser.FeatureFrom(FeatureContent, FeatureItem); ObjectFactory.NewFeatureCompiler.Compile(Feature, FeatureItem); var Step = Feature.Steps.Find(x => x.Location.Content == Sentence); if (Step == null) { return; } var CodeFunction = project.CodeFunction(Step); if (CodeFunction == null) { MessageBox.Show("Step implementation not found ..."); return; } if (!CodeFunction.ProjectItem.IsOpen) { CodeFunction.ProjectItem.Open(); } var NavigatePoint = CodeFunction.GetStartPoint(vsCMPart.vsCMPartHeader); NavigatePoint.TryToShow(); NavigatePoint.Parent.Selection.MoveToPoint(NavigatePoint); } catch (Exception e) { MessageBox.Show("Error:" + e); } }
public static CodeFunction CodeFunction(this Project Project, Step Step) { return(Step.IsImplemented ? Project.CodeFunction(Step.Implementation.Method) : Project.CodeFunctionForUnimplemented(Step)); }
public static IEnumerable <ProjectItem> Items(this Project Project) { return(Items(Project.DTEProject.ProjectItems)); }
static IEnumerable <CodeClass> Classes(this Project Project) { return(Project.Items() .Where(x => x.FileCodeModel != null) .SelectMany(projectItem => projectItem.FileCodeModel.CodeElements.Classes())); }