diff --git a/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSInputSet.cs b/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSInputSet.cs index cb41f5831fa3922546ebb7ab2ec7d2441899e225..d61af0a0934a4815f5b3fa2c9fb0c783b519c615 100644 --- a/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSInputSet.cs +++ b/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSInputSet.cs @@ -51,6 +51,8 @@ public void SetOutputFileName(string filename) { VisualStudioProject.AssemblyName = Path.GetFileNameWithoutExtension(filename); } + + RefreshBinOutputPath(); } public void SetOutputFileType(OutputFileType fileType) diff --git a/src/VisualStudio/Core/Def/Implementation/Experimentation/EnhancedColorExperiment.cs b/src/VisualStudio/Core/Def/Implementation/Experimentation/EnhancedColorExperiment.cs index 4d16f84e7368b8e8cb049ef8c6d4942d1f8a5ffa..0589929bcc97a3df94a51ca11bff00cee352f685 100644 --- a/src/VisualStudio/Core/Def/Implementation/Experimentation/EnhancedColorExperiment.cs +++ b/src/VisualStudio/Core/Def/Implementation/Experimentation/EnhancedColorExperiment.cs @@ -10,7 +10,6 @@ using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; -using Microsoft.CodeAnalysis.Experiments; using Microsoft.VisualStudio.PlatformUI; using Microsoft.VisualStudio.Settings; using Microsoft.VisualStudio.Shell; @@ -26,28 +25,22 @@ namespace Microsoft.VisualStudio.LanguageServices.Experimentation [TextViewRole(PredefinedTextViewRoles.Analyzable)] internal class EnhancedColorExperiment : ForegroundThreadAffinitizedObject, IWpfTextViewConnectionListener, IDisposable { - private const string UseEnhancedColorsFlight = "UseEnhancedColors"; - private const string StopEnhancedColorsFlight = "StopEnhancedColors"; private const string UseEnhancedColorsSetting = "WindowManagement.Options.UseEnhancedColorsForManagedLanguages"; - private readonly IExperimentationService _experimentationService; private readonly IServiceProvider _serviceProvider; private EnhancedColorApplier _colorApplier; private ISettingsManager _settingsManager; private bool _isDisposed = false; - private bool _inUseEnhancedColorsFlight; - private bool _inStopEnhancedColorsFlight; private bool _hasTextViewOpened; [ImportingConstructor] [Obsolete] - private EnhancedColorExperiment(IThreadingContext threadingContext, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, VisualStudioExperimentationService experimentationService) + private EnhancedColorExperiment(IThreadingContext threadingContext, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) : base(threadingContext) { _serviceProvider = serviceProvider; - _experimentationService = experimentationService; } public void Dispose() @@ -66,21 +59,11 @@ public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reas _hasTextViewOpened = true; _colorApplier = new EnhancedColorApplier(_serviceProvider); - - // Check which experimental flights we are in - _inUseEnhancedColorsFlight = _experimentationService.IsExperimentEnabled(UseEnhancedColorsFlight); - _inStopEnhancedColorsFlight = _experimentationService.IsExperimentEnabled(StopEnhancedColorsFlight); - _settingsManager = (ISettingsManager)_serviceProvider.GetService(typeof(SVsSettingsPersistenceManager)); - // Do not hook settings changed if we have stopped the experiment. - // We will simply remove the enhanced colors if they are applied. - if (!_inStopEnhancedColorsFlight) - { - // We need to update the theme whenever the Preview Setting changes or the VS Theme changes. - _settingsManager.GetSubset(UseEnhancedColorsSetting).SettingChangedAsync += UseEnhancedColorsSettingChangedAsync; - VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged; - } + // We need to update the theme whenever the Preview Setting changes or the VS Theme changes. + _settingsManager.GetSubset(UseEnhancedColorsSetting).SettingChangedAsync += UseEnhancedColorsSettingChangedAsync; + VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged; VsTaskLibraryHelper.CreateAndStartTask(VsTaskLibraryHelper.ServiceInstance, VsTaskRunContext.UIThreadIdlePriority, UpdateThemeColors); } @@ -117,15 +100,13 @@ private void UpdateThemeColors() var useEnhancedColorsSetting = _settingsManager.GetValueOrDefault(UseEnhancedColorsSetting, defaultValue: 0); // useEnhancedColorsSetting - // 0 -> use value from flight. - // 1 -> always use enhanced colors (unless the kill flight is active). - // -1 -> never use enhanced colors. - var inEnhancedFlightOrOptIn = _inUseEnhancedColorsFlight || useEnhancedColorsSetting == 1; - var inStopFlightOrOptOut = _inStopEnhancedColorsFlight || useEnhancedColorsSetting == -1; + // 0 -> use enhanced colors. + // 1 -> use enhanced colors. + // -1 -> don't use enhanced colors. // Try to set colors appropriately. We will only set colors if the user // has not customized colors and we consider ourselves the color owner. - if (!inStopFlightOrOptOut && inEnhancedFlightOrOptIn) + if (useEnhancedColorsSetting != -1) { _colorApplier.TrySetEnhancedColors(currentThemeId); } @@ -246,7 +227,7 @@ public void TrySetEnhancedColors(Guid themeId) UpdateColorItem(colorItemMap, ClassificationTypeNames.OperatorOverloaded, DarkThemeMethodYellow); UpdateColorItem(colorItemMap, ClassificationTypeNames.ControlKeyword, DarkThemeControlKeywordPurple); UpdateColorItem(colorItemMap, ClassificationTypeNames.StructName, DarkThemeStructMint); - UpdateColorItem(colorItemMap, ClassificationTypeNames.StaticSymbol, DefaultForegroundColor, DefaultBackgroundColor, isBold: true); + UpdateColorItem(colorItemMap, ClassificationTypeNames.StaticSymbol, DefaultForegroundColor, DefaultBackgroundColor); } else { @@ -257,7 +238,7 @@ public void TrySetEnhancedColors(Guid themeId) UpdateColorItem(colorItemMap, ClassificationTypeNames.ExtensionMethodName, LightThemeMethodYellow); UpdateColorItem(colorItemMap, ClassificationTypeNames.OperatorOverloaded, LightThemeMethodYellow); UpdateColorItem(colorItemMap, ClassificationTypeNames.ControlKeyword, LightThemeControlKeywordPurple); - UpdateColorItem(colorItemMap, ClassificationTypeNames.StaticSymbol, DefaultForegroundColor, DefaultBackgroundColor, isBold: true); + UpdateColorItem(colorItemMap, ClassificationTypeNames.StaticSymbol, DefaultForegroundColor, DefaultBackgroundColor); } } diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs index c1bc691988724a5091fc2f703d8b40a1900cffe7..5e3de409ef5e561bb4aca8396a5a16b7df2bd9ed 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/Legacy/AbstractLegacyProject.cs @@ -180,7 +180,7 @@ protected void RemoveFile(string filename) VisualStudioProject.RemoveSourceFile(filename); } - private void RefreshBinOutputPath() + protected void RefreshBinOutputPath() { var storage = Hierarchy as IVsBuildPropertyStorage; if (storage == null) diff --git a/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.Connections.cs b/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.Connections.cs index 890e1e9d99938e2f8cc826977ca96268cfa20376..ad0281b1e6c054540e76424ea1481dc7e58e21e0 100644 --- a/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.Connections.cs +++ b/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.Connections.cs @@ -122,13 +122,11 @@ private static class Connections await Task.Delay(retry_delayInMS, cancellationToken).ConfigureAwait(false); } - // crash right away to get better dump. otherwise, we will get dump from async exception - // which most likely lost all valuable data - FatalError.ReportUnlessCanceled(lastException); - GC.KeepAlive(lastException); + RemoteHostCrashInfoBar.ShowInfoBar(workspace); - // unreachable - throw ExceptionUtilities.Unreachable; + // raise soft crash exception rather than doing hard crash. + // we had enough feedback from users not to crash VS on servicehub failure + throw new SoftCrashException("RequestServiceAsync Failed", lastException, cancellationToken); } #region code related to make diagnosis easier later diff --git a/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs b/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs index 8f0f68ad0a69d6d003ce33278da59aa9a75c6b10..1646eba79129f711017ba6cbf413ce71ffc9adeb 100644 --- a/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs +++ b/src/VisualStudio/Core/Def/Implementation/Remote/ServiceHubRemoteHostClient.cs @@ -48,21 +48,32 @@ private enum GlobalNotificationState public static async Task CreateAsync( Workspace workspace, CancellationToken cancellationToken) { - using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, cancellationToken)) + try { - var primary = new HubClient("ManagedLanguage.IDE.RemoteHostClient"); - var timeout = TimeSpan.FromMilliseconds(workspace.Options.GetOption(RemoteHostOptions.RequestServiceTimeoutInMS)); + using (Logger.LogBlock(FunctionId.ServiceHubRemoteHostClient_CreateAsync, cancellationToken)) + { + var primary = new HubClient("ManagedLanguage.IDE.RemoteHostClient"); + var timeout = TimeSpan.FromMilliseconds(workspace.Options.GetOption(RemoteHostOptions.RequestServiceTimeoutInMS)); - // Retry (with timeout) until we can connect to RemoteHost (service hub process). - // we are seeing cases where we failed to connect to service hub process when a machine is under heavy load. - // (see https://devdiv.visualstudio.com/DevDiv/_workitems/edit/481103 as one of example) - var instance = await Connections.RetryRemoteCallAsync( - workspace, () => CreateWorkerAsync(workspace, primary, timeout, cancellationToken), timeout, cancellationToken).ConfigureAwait(false); + // Retry (with timeout) until we can connect to RemoteHost (service hub process). + // we are seeing cases where we failed to connect to service hub process when a machine is under heavy load. + // (see https://devdiv.visualstudio.com/DevDiv/_workitems/edit/481103 as one of example) + var instance = await Connections.RetryRemoteCallAsync( + workspace, () => CreateWorkerAsync(workspace, primary, timeout, cancellationToken), timeout, cancellationToken).ConfigureAwait(false); - instance.Started(); + instance.Started(); - // return instance - return instance; + // return instance + return instance; + } + } + catch (SoftCrashException) + { + // at this point, we should have shown info bar (RemoteHostCrashInfoBar.ShowInfoBar) to users + // returning null here will disable OOP for this VS session. + // * Note * this is not trying to recover the exception. but giving users to time + // to clean up before restart VS + return null; } } diff --git a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb index eebf93e485bb1a0f6c0cccaced4b4bf2e2c6d3c8..b1b79d1f36ee64680a11683ae1d68c2b704fc71d 100644 --- a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb +++ b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb @@ -317,6 +317,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim VisualStudioProject.AssemblyName = Path.GetFileNameWithoutExtension(pCompilerOptions.wszExeName) End If + RefreshBinOutputPath() + _runtimeLibraries = VisualStudioProjectOptionsProcessor.GetRuntimeLibraries(_compilerHost) If Not _runtimeLibraries.SequenceEqual(oldRuntimeLibraries, StringComparer.Ordinal) Then