Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Common/Product/SharedProject/CommonPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ internal void RegisterCommands(IEnumerable<Command> commands, Guid cmdSet) {
/// </summary>
/// <returns></returns>
public static IWpfTextView GetActiveTextView(System.IServiceProvider serviceProvider) {
if (serviceProvider == null) {
Debug.Assert(false, "No service provider");
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for both null checks, it's okay to fail gracefully, but let's go ahead and also add a debug assert so we know something's up when the issue occurs.


var monitorSelection = (IVsMonitorSelection)serviceProvider.GetService(typeof(SVsShellMonitorSelection));
if (monitorSelection == null) {
return null;
Expand Down Expand Up @@ -174,6 +179,10 @@ public static IComponentModel ComponentModel {
}

internal static CommonProjectNode GetStartupProject(System.IServiceProvider serviceProvider) {
if (serviceProvider == null) {
Debug.Assert(false, "No service provider");
return null;
}
var buildMgr = (IVsSolutionBuildManager)serviceProvider.GetService(typeof(IVsSolutionBuildManager));
IVsHierarchy hierarchy;
if (buildMgr != null && ErrorHandler.Succeeded(buildMgr.get_StartupProject(out hierarchy)) && hierarchy != null) {
Expand Down