/// <summary> /// Invokes SetEditLabel and checkes if the exception with the error message is caught. /// </summary> internal static bool CheckForSetEditLabelBadFileName <T>(HierarchyNode node, string badFileName, string expectedMessage) where T : Exception { bool badFileNameCaught = false; IVsExtensibility extensibility = node.GetService(typeof(IVsExtensibility)) as IVsExtensibility; extensibility.EnterAutomationFunction(); try { node.SetEditLabel(badFileName); } catch (Exception e) { if ((e is T) && (e.Message == expectedMessage || e.Message.Contains(expectedMessage))) { badFileNameCaught = true; } } finally { extensibility.ExitAutomationFunction(); } return(badFileNameCaught); }