提交 7fb1ba06 编写于 作者: C CyrusNajmabadi

Be resilient to VS API version changes in navigateto.

上级 e1478740
......@@ -59,10 +59,7 @@ public void StartSearch(INavigateToCallback callback, string searchValue)
return;
}
var optionsService = _optionsServices.Length > 0
? VersionSelector.SelectHighest(_optionsServices)
: null;
var searchCurrentDocument = optionsService?.GetSearchCurrentDocument(callback.Options) ?? false;
var searchCurrentDocument = GetSearchCurrentDocumentOption(callback);
var searcher = new Searcher(
_workspace.CurrentSolution,
_asyncListener,
......@@ -74,5 +71,30 @@ public void StartSearch(INavigateToCallback callback, string searchValue)
searcher.Search();
}
private bool GetSearchCurrentDocumentOption(INavigateToCallback callback)
{
try
{
return GetSearchCurrentDocumentOptionWorker(callback);
}
catch (TypeLoadException)
{
// The version of the APIs we call in VS may not match what the
// user currently has on the box (as the APIs have changed during
// the VS15 timeframe. Be resilient to this happening and just
// default to searching all documents.
return false;
}
}
private bool GetSearchCurrentDocumentOptionWorker(INavigateToCallback callback)
{
var optionsService = _optionsServices.Length > 0
? VersionSelector.SelectHighest(_optionsServices)
: null;
var searchCurrentDocument = optionsService?.GetSearchCurrentDocument(callback.Options) ?? false;
return searchCurrentDocument;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册