From cccfc1be66675df1f159fb5e3a1fe2748dfb9be1 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Nov 2021 12:31:06 -0800 Subject: [PATCH 1/2] Remove weakref that telemetry indicates has no impact at all. --- .../VisualStudioMetadataReferenceManager.cs | 6 +----- .../Portable/Workspace/WorkspaceConfigurationOptions.cs | 8 -------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs index ac9300f0146d8..06ac3f1f069e9 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs @@ -130,11 +130,7 @@ internal Metadata GetMetadata(string fullPath, DateTime snapshotTimestamp) if (VsSmartScopeCandidate(key.FullPath) && TryCreateAssemblyMetadataFromMetadataImporter(key, out var newMetadata)) { - ValueSource> metadataValueSource = _workspace.Options.GetOption(WorkspaceConfigurationOptions.DisableReferenceManagerWeakRuntimeReferences) - ? new ConstantValueSource>(newMetadata) - : new WeakValueSource(newMetadata); - - if (!_metadataCache.GetOrAddMetadata(key, metadataValueSource, out metadata)) + if (!_metadataCache.GetOrAddMetadata(key, new ConstantValueSource>(newMetadata), out metadata)) { newMetadata.Dispose(); } diff --git a/src/Workspaces/Core/Portable/Workspace/WorkspaceConfigurationOptions.cs b/src/Workspaces/Core/Portable/Workspace/WorkspaceConfigurationOptions.cs index 2192bd7abac94..a865ce4a4c85d 100644 --- a/src/Workspaces/Core/Portable/Workspace/WorkspaceConfigurationOptions.cs +++ b/src/Workspaces/Core/Portable/Workspace/WorkspaceConfigurationOptions.cs @@ -26,13 +26,6 @@ internal class WorkspaceConfigurationOptions : IOptionProvider nameof(WorkspaceConfigurationOptions), nameof(DisableProjectCacheService), defaultValue: false, new FeatureFlagStorageLocation("Roslyn.DisableProjectCacheService")); - /// - /// Disables holding onto the assembly references for runtime (not user/nuget/etc.) dlls weakly. - /// - public static readonly Option DisableReferenceManagerWeakRuntimeReferences = new( - nameof(WorkspaceConfigurationOptions), nameof(DisableReferenceManagerWeakRuntimeReferences), defaultValue: false, - new FeatureFlagStorageLocation("Roslyn.DisableReferenceManagerWeakRuntimeReferences")); - /// /// Disables holding onto the assembly references for runtime (not user/nuget/etc.) dlls weakly. /// @@ -43,7 +36,6 @@ internal class WorkspaceConfigurationOptions : IOptionProvider ImmutableArray IOptionProvider.Options { get; } = ImmutableArray.Create( DisableRecoverableTrees, DisableProjectCacheService, - DisableReferenceManagerWeakRuntimeReferences, DisableCompilationTrackerWeakCompilationReferences); [ImportingConstructor] From 7dd619be5733e5983ffc630bc3000276941e55be Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 16 Nov 2021 19:14:18 -0800 Subject: [PATCH 2/2] Linting --- .../VisualStudioMetadataReferenceManager.Factory.cs | 2 +- .../MetadataReferences/VisualStudioMetadataReferenceManager.cs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.Factory.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.Factory.cs index aa4c65791d57f..c4fa85094c6a1 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.Factory.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.Factory.cs @@ -32,7 +32,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) if (_singleton == null) { var temporaryStorage = workspaceServices.GetService(); - Interlocked.CompareExchange(ref _singleton, new VisualStudioMetadataReferenceManager(workspaceServices.Workspace, _serviceProvider, temporaryStorage), null); + Interlocked.CompareExchange(ref _singleton, new VisualStudioMetadataReferenceManager(_serviceProvider, temporaryStorage), null); } return _singleton; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs index 06ac3f1f069e9..02bbe5225917b 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs @@ -36,7 +36,6 @@ internal sealed partial class VisualStudioMetadataReferenceManager : IWorkspaceS private readonly MetadataCache _metadataCache; private readonly ImmutableArray _runtimeDirectories; - private readonly Workspace _workspace; private readonly ITemporaryStorageService _temporaryStorageService; internal IVsXMLMemberIndexService XmlMemberIndexService { get; } @@ -53,7 +52,6 @@ internal sealed partial class VisualStudioMetadataReferenceManager : IWorkspaceS private readonly ReaderWriterLockSlim _readerWriterLock = new(); internal VisualStudioMetadataReferenceManager( - Workspace workspace, IServiceProvider serviceProvider, ITemporaryStorageService temporaryStorageService) { @@ -68,7 +66,6 @@ internal VisualStudioMetadataReferenceManager( FileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx)); Assumes.Present(FileChangeService); - _workspace = workspace; _temporaryStorageService = temporaryStorageService; Assumes.Present(_temporaryStorageService); }