Automate search command in Visual Studio 2017 C#

偶尔善良 提交于 2019-12-11 17:05:53

问题


I need to search for a long list of phrases from a Solution. So instead of using the Ctr+Shift+F command to do it manually, is there a way to automate this search? As most I found was writing codes to search from a file, I want to use visual studio to search within its Solution. Thank you!!


回答1:


You can use DTE.Find object to set search options and invoke search. With my Visual Commander extension it looks like:

public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
{
    DTE.Find.FindWhat = @"Test";
    DTE.Find.Target = EnvDTE.vsFindTarget.vsFindTargetSolution;

    DTE.Find.Action = EnvDTE.vsFindAction.vsFindActionFindAll;
    DTE.Find.Backwards = false;
    DTE.Find.FilesOfType = @"";
    DTE.Find.KeepModifiedDocumentsOpen = false;
    DTE.Find.MatchCase = false;
    DTE.Find.MatchInHiddenText = true;
    DTE.Find.MatchWholeWord = false;
    DTE.Find.PatternSyntax = EnvDTE.vsFindPatternSyntax.vsFindPatternSyntaxLiteral;
    DTE.Find.ReplaceWith = @"";
    DTE.Find.ResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1;
    DTE.Find.SearchSubfolders = true;
    DTE.Find.SearchPath = @"Entire Solution";
    DTE.Find.Execute();     
}


来源:https://stackoverflow.com/questions/47604664/automate-search-command-in-visual-studio-2017-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!