public void NewUnitTestModule(VBProject project) { var settings = _configLoader.LoadConfiguration().UserSettings.UnitTestSettings; VBComponent component; try { if (settings.BindingMode == BindingMode.EarlyBinding) { project.EnsureReferenceToAddInLibrary(); } component = project.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule); component.Name = GetNextTestModuleName(project); var hasOptionExplicit = false; if (component.CodeModule.CountOfLines > 0 && component.CodeModule.CountOfDeclarationLines > 0) { hasOptionExplicit = component.CodeModule.Lines[1, component.CodeModule.CountOfDeclarationLines].Contains("Option Explicit"); } var options = string.Concat(hasOptionExplicit ? string.Empty : "Option Explicit\n", "Option Private Module\n\n"); var defaultTestMethod = string.Empty; if (settings.DefaultTestStubInNewModule) { defaultTestMethod = NewTestMethodCommand.TestMethodTemplate.Replace( NewTestMethodCommand.NamePlaceholder, "TestMethod1"); } component.CodeModule.AddFromString(options + GetTestModule(settings) + defaultTestMethod); component.Activate(); } catch (Exception) { //can we please comment when we swallow every possible exception? return; } _state.OnParseRequested(this, component); }