diff --git a/VsDingExtension.sln b/VsDingExtension.sln index e6aab38..3ffd4f0 100644 --- a/VsDingExtension.sln +++ b/VsDingExtension.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BD9D4DB-8683-4698-8D24-01EE7306F73A}" ProjectSection(SolutionItems) = preProject diff --git a/VsDingExtensionFor2012/VsDingExtensionFor2012.csproj b/VsDingExtensionFor2012/VsDingExtensionFor2012.csproj index 8754fca..174e813 100644 --- a/VsDingExtensionFor2012/VsDingExtensionFor2012.csproj +++ b/VsDingExtensionFor2012/VsDingExtensionFor2012.csproj @@ -1,7 +1,7 @@  - 11.0 + 14.0 11.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -27,6 +27,7 @@ True ..\VsDingExtensionProject\Key.snk v4.5 + 8.0 true @@ -79,6 +80,8 @@ $(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll + + diff --git a/VsDingExtensionProject/OptionsDialog.cs b/VsDingExtensionProject/OptionsDialog.cs index 0e29983..f1fa2ba 100644 --- a/VsDingExtensionProject/OptionsDialog.cs +++ b/VsDingExtensionProject/OptionsDialog.cs @@ -26,7 +26,7 @@ public class OptionsDialog : DialogPage [Category("Beeps")] [DisplayName("Failed Tests")] - [Description("Beep only when a test failed")] + [Description("Beep when a test run is completed and there are failed tests")] public bool IsBeepOnTestFailed { get; set; } [DisplayName("Only when in background")] diff --git a/VsDingExtensionProject/Resources.Designer.cs b/VsDingExtensionProject/Resources.Designer.cs index 45d43ae..d7f9f6d 100644 --- a/VsDingExtensionProject/Resources.Designer.cs +++ b/VsDingExtensionProject/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/VsDingExtensionProject/VsDingExtensionProject.csproj b/VsDingExtensionProject/VsDingExtensionProject.csproj index 475afb6..ad71bfe 100644 --- a/VsDingExtensionProject/VsDingExtensionProject.csproj +++ b/VsDingExtensionProject/VsDingExtensionProject.csproj @@ -1,13 +1,18 @@  - 12.0 + 14.0 12.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) Program $(DevEnvDir)\devenv.exe /rootsuffix Exp + + + + + 12.0 speaker.ico @@ -26,6 +31,7 @@ True Key.snk v4.5 + 8.0 true @@ -49,7 +55,7 @@ - + @@ -76,27 +82,17 @@ - - ..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.AttributedModel.dll - - - ..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.Convention.dll - - - ..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.Hosting.dll - - - ..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.Runtime.dll - - - ..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.TypedParts.dll - + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.dll + + + @@ -206,7 +202,6 @@ - Designer diff --git a/VsDingExtensionProject/VsDingExtensionProjectPackage.cs b/VsDingExtensionProject/VsDingExtensionProjectPackage.cs index bdca97d..57a6e4b 100644 --- a/VsDingExtensionProject/VsDingExtensionProjectPackage.cs +++ b/VsDingExtensionProject/VsDingExtensionProjectPackage.cs @@ -12,7 +12,8 @@ namespace VitaliiGanzha.VsDingExtension using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.TestWindow.Extensibility; using Task = System.Threading.Tasks.Task; - + using Windows.UI.Notifications; + using System.Linq; [PackageRegistration(UseManagedResourcesOnly = true)] [InstalledProductRegistration("#110", "#112", "1.1", IconResourceID = 400)] [Guid(GuidList.guidVsDingExtensionProjectPkgString)] @@ -128,7 +129,13 @@ private void ShowNotifyMessage(string messageText, ToolTipIcon icon = ToolTipIco messageText = string.Format("{0}{1}", messageText, autoAppendMessage); } - Task.Run(async () => + if (Win8OrHigher()) + { + ShowToast("Visual Studio Ding extension", messageText); + } + else + { + Task.Run(async () => { var tray = new NotifyIcon { @@ -145,6 +152,40 @@ private void ShowNotifyMessage(string messageText, ToolTipIcon icon = ToolTipIco tray.Visible = false; tray.Dispose(); }); + } + } + + private bool Win8OrHigher() + { + return Environment.OSVersion.Version >= new Version(6, 2, 9200, 0); + } + + private void ShowToast(string title, string message) + { + var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); + toastXml.GetElementsByTagName("text").First().AppendChild(toastXml.CreateTextNode(title)); + toastXml.GetElementsByTagName("text").Last().AppendChild(toastXml.CreateTextNode(message)); + + var dte = GetGlobalService(typeof(DTE)) as DTE; + var notifier = ToastNotificationManager.CreateToastNotifier(EditionToAppUserModelId(dte.Edition)); + notifier.Show(new ToastNotification(toastXml)); + } + + private string EditionToAppUserModelId(string edition) + { + string ApplicationID = "VisualStudio.11.0"; + switch (edition) + { + case "WD Express": + return "VWDExpress.11.0"; + case "Desktop Express": + return "WDExpress.11.0"; + case "VSWin Express": + return "VSWinExpress.11.0"; + case "PD Express": + return "VPDExpress.11.0"; + } + return ApplicationID; } private bool ShouldPerformNotificationAction() @@ -158,33 +199,37 @@ private bool ShouldPerformNotificationAction() private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs) { - if (Options.IsBeepOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished)) + if (operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished)) { - try + if (Options.IsBeepOnTestComplete) + { + HandleEventSafe(EventType.TestsCompletedSuccess, "Test execution has been completed."); + } + + if (Options.IsBeepOnTestFailed) { - // Issue #8: VS 2015 stops working when looking at Test Manager Window #8 - // This extention can't take dependency on Microsoft.VisualStudio.TestWindow.Core.dll - // Because it will crash VS 2015. But DominantTestState is defined in that assembly. - // So as a workaround - cast it to dynamic (ewww, but alternative - to create new project/build and publish it separately.) - var testOperation = (dynamic)(operationStateChangedEventArgs.Operation); - var dominantTestState = (TestState)testOperation.DominantTestState; - var isTestsFailed = dominantTestState == TestState.Failed; - var eventType = isTestsFailed ? EventType.TestsCompletedFailure : EventType.TestsCompletedSuccess; - if (Options.IsBeepOnTestFailed && isTestsFailed) + try { - HandleEventSafe(eventType, "Test execution failed!", ToolTipIcon.Error); + // Issue #8: VS 2015 stops working when looking at Test Manager Window #8 + // This extention can't take dependency on Microsoft.VisualStudio.TestWindow.Core.dll + // Because it will crash VS 2015. But DominantTestState is defined in that assembly. + // So as a workaround - cast it to dynamic (ewww, but alternative - to create new project/build and publish it separately.) + var testOperation = (dynamic)(operationStateChangedEventArgs.Operation); + var dominantTestState = (TestState)testOperation.DominantTestState; + var isTestsFailed = dominantTestState == TestState.Failed; + var eventType = isTestsFailed ? EventType.TestsCompletedFailure : EventType.TestsCompletedSuccess; + if (isTestsFailed) + { + HandleEventSafe(eventType, "Test execution failed!", ToolTipIcon.Error); + } } - else + catch (Exception ex) { - HandleEventSafe(eventType, "Test execution has been completed."); + ActivityLog.LogError(GetType().FullName, ex.Message); + // Unable to get dominate test status, beep default sound for test + HandleEventSafe(EventType.TestsCompletedSuccess, "Test execution has been completed."); } } - catch (Exception ex) - { - ActivityLog.LogError(GetType().FullName, ex.Message); - // Unable to get dominate test status, beep default sound for test - HandleEventSafe(EventType.TestsCompletedSuccess, "Test execution has been completed."); - } } } #endregion diff --git a/VsDingExtensionProject/source.extension.vsixmanifest b/VsDingExtensionProject/source.extension.vsixmanifest index 6e18dfa..df3a1e3 100644 --- a/VsDingExtensionProject/source.extension.vsixmanifest +++ b/VsDingExtensionProject/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Visual Studio Ding extension This small extension will play notification sounds when following events occur: - Build Complete