diff --git a/src/Features/Core/Portable/CodeLens/CodeLensReferencesService.cs b/src/Features/Core/Portable/CodeLens/CodeLensReferencesService.cs index f54277fe8a1b8..30294fc6dd13f 100644 --- a/src/Features/Core/Portable/CodeLens/CodeLensReferencesService.cs +++ b/src/Features/Core/Portable/CodeLens/CodeLensReferencesService.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.FindSymbols; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -276,8 +277,8 @@ public async Task GetFullyQualifiedNameAsync(Solution solution, Document CancellationToken cancellationToken) { var document = solution.GetDocument(syntaxNode.GetLocation().SourceTree); - - using (solution.Services.CacheService?.EnableCaching(document.Project.Id)) + var cacheService = solution.Services.GetService(); + using (cacheService?.EnableCaching(document.Project.Id)) { var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var declaredSymbol = semanticModel.GetDeclaredSymbol(syntaxNode, cancellationToken); diff --git a/src/Workspaces/Core/Portable/Classification/AbstractClassificationService.cs b/src/Workspaces/Core/Portable/Classification/AbstractClassificationService.cs index 4e74e598e9bce..7bf65f597f10f 100644 --- a/src/Workspaces/Core/Portable/Classification/AbstractClassificationService.cs +++ b/src/Workspaces/Core/Portable/Classification/AbstractClassificationService.cs @@ -96,7 +96,7 @@ await AddClassificationsInCurrentProcessAsync( private static bool IsFullyLoaded(Document document, CancellationToken cancellationToken) { - var workspaceStatusService = document.Project.Solution.Workspace.Services.GetRequiredService(); + var workspaceStatusService = document.Project.Solution.Services.GetRequiredService(); // Importantly, we do not await/wait on the fullyLoadedStateTask. We do not want to ever be waiting on work // that may end up touching the UI thread (As we can deadlock if GetTagsSynchronous waits on us). Instead, diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs index 3ba619bf8a971..10183c7291e84 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs @@ -14,6 +14,7 @@ using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.Formatting; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -118,7 +119,8 @@ public async Task ResolveConflictsAsync() foreach (var documentsByProject in documentsGroupedByTopologicallySortedProjectId) { var documentIdsThatGetsAnnotatedAndRenamed = new HashSet(documentsByProject); - using (baseSolution.Services.CacheService?.EnableCaching(documentsByProject.Key)) + var cacheService = baseSolution.Services.GetService(); + using (cacheService?.EnableCaching(documentsByProject.Key)) { // Rename is going to be in 5 phases. // 1st phase - Does a simple token replacement @@ -238,7 +240,7 @@ await conflictResolution.CurrentSolution.GetRequiredDocument(_documentIdOfRename { var definitionLocations = _renameLocationSet.Symbol.Locations; var definitionDocuments = definitionLocations - .Select(l => conflictResolution.OldSolution.GetRequiredDocument(l.SourceTree)) + .Select(l => conflictResolution.OldSolution.GetRequiredDocument(l.SourceTree!)) .Distinct(); if (definitionDocuments.Count() == 1 && _replacementTextValid) diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/AdditionalDocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/AdditionalDocumentState.cs index 1216a5261dc7f..d2584f640cded 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/AdditionalDocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/AdditionalDocumentState.cs @@ -14,7 +14,7 @@ internal sealed class AdditionalDocumentState : TextDocumentState private readonly AdditionalText _additionalText; private AdditionalDocumentState( - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, IDocumentServiceProvider documentServiceProvider, DocumentInfo.DocumentAttributes attributes, SourceText? sourceText, @@ -26,7 +26,7 @@ private AdditionalDocumentState( public AdditionalDocumentState( DocumentInfo documentInfo, - SolutionServices solutionServices) + HostWorkspaceServices solutionServices) : base(documentInfo, solutionServices) { _additionalText = new AdditionalTextWithState(this); diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/AnalyzerConfigDocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/AnalyzerConfigDocumentState.cs index 1376e75174f8e..df2bdcd5dc8a0 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/AnalyzerConfigDocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/AnalyzerConfigDocumentState.cs @@ -17,7 +17,7 @@ internal sealed class AnalyzerConfigDocumentState : TextDocumentState private readonly ValueSource _analyzerConfigValueSource; private AnalyzerConfigDocumentState( - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, IDocumentServiceProvider documentServiceProvider, DocumentInfo.DocumentAttributes attributes, SourceText sourceTextOpt, @@ -29,7 +29,7 @@ private AnalyzerConfigDocumentState( public AnalyzerConfigDocumentState( DocumentInfo documentInfo, - SolutionServices solutionServices) + HostWorkspaceServices solutionServices) : base(documentInfo, solutionServices) { _analyzerConfigValueSource = CreateAnalyzerConfigValueSource(); diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/DocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/DocumentState.cs index b7ec67e7680da..6894c089338ec 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/DocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/DocumentState.cs @@ -34,7 +34,7 @@ internal partial class DocumentState : TextDocumentState protected DocumentState( HostLanguageServices languageServices, - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, IDocumentServiceProvider? documentServiceProvider, DocumentInfo.DocumentAttributes attributes, ParseOptions? options, @@ -54,7 +54,7 @@ public DocumentState( DocumentInfo info, ParseOptions? options, HostLanguageServices languageServices, - SolutionServices services) + HostWorkspaceServices services) : base(info, services) { _languageServices = languageServices; diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/ProjectState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/ProjectState.cs index 9fb208910e552..2799cadb4dc06 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/ProjectState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/ProjectState.cs @@ -27,7 +27,7 @@ internal partial class ProjectState { private readonly ProjectInfo _projectInfo; private readonly HostLanguageServices _languageServices; - private readonly SolutionServices _solutionServices; + private readonly HostWorkspaceServices _solutionServices; /// /// The documents in this project. They are sorted by to provide a stable sort for @@ -68,7 +68,7 @@ internal partial class ProjectState private ProjectState( ProjectInfo projectInfo, HostLanguageServices languageServices, - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, TextDocumentStates documentStates, TextDocumentStates additionalDocumentStates, TextDocumentStates analyzerConfigDocumentStates, @@ -93,7 +93,7 @@ private ProjectState( _lazyChecksums = new AsyncLazy(ComputeChecksumsAsync, cacheResult: true); } - public ProjectState(ProjectInfo projectInfo, HostLanguageServices languageServices, SolutionServices solutionServices) + public ProjectState(ProjectInfo projectInfo, HostLanguageServices languageServices, HostWorkspaceServices solutionServices) { Contract.ThrowIfNull(projectInfo); Contract.ThrowIfNull(languageServices); diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs b/src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs index c45395fe1b769..5421212af3935 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/Solution.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; @@ -38,7 +39,7 @@ private Solution(SolutionState state) } internal Solution(Workspace workspace, SolutionInfo.SolutionAttributes solutionAttributes, SolutionOptionSet options, IReadOnlyList analyzerReferences) - : this(new SolutionState(workspace.PrimaryBranchId, new SolutionServices(workspace), solutionAttributes, options, analyzerReferences)) + : this(new SolutionState(workspace.PrimaryBranchId, workspace.Services, solutionAttributes, options, analyzerReferences)) { } @@ -46,7 +47,7 @@ internal Solution(Workspace workspace, SolutionInfo.SolutionAttributes solutionA internal int WorkspaceVersion => _state.WorkspaceVersion; - internal SolutionServices Services => _state.Services; + internal HostWorkspaceServices Services => _state.Services; internal BranchId BranchId => _state.BranchId; diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionServices.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionServices.cs deleted file mode 100644 index 825d980ec43b0..0000000000000 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionServices.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable disable - -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis -{ - /// - /// This class basically holds onto a set of services and gets reused across solution instances. - /// - internal partial class SolutionServices - { - internal readonly Workspace Workspace; - internal readonly ITemporaryStorageService TemporaryStorage; - internal readonly IMetadataService MetadataService; - internal readonly IProjectCacheHostService CacheService; - - internal bool SupportsCachingRecoverableObjects { get { return this.CacheService != null; } } - - public SolutionServices(Workspace workspace) - { - this.Workspace = workspace; - this.TemporaryStorage = workspace.Services.GetService(); - this.MetadataService = workspace.Services.GetService(); - this.CacheService = workspace.Services.GetService(); - } - } -} diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs index ec06a7eca6b6e..0e60da8a5fe01 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.CompilationTracker.cs @@ -70,14 +70,15 @@ public CompilationTracker(ProjectState project) private CompilationTrackerState ReadState() => Volatile.Read(ref _stateDoNotAccessDirectly); - private void WriteState(CompilationTrackerState state, SolutionServices solutionServices) + private void WriteState(CompilationTrackerState state, HostWorkspaceServices solutionServices) { - if (solutionServices.SupportsCachingRecoverableObjects) + var cacheService = solutionServices.GetService(); + if (cacheService != null) { // Allow the cache service to create a strong reference to the compilation. We'll get the "furthest along" compilation we have // and hold onto that. var compilationToCache = state.FinalCompilationWithGeneratedDocuments ?? state.CompilationWithoutGeneratedDocuments; - solutionServices.CacheService.CacheObjectIfCachingEnabledForKey(ProjectState.Id, state, compilationToCache); + cacheService.CacheObjectIfCachingEnabledForKey(ProjectState.Id, state, compilationToCache); } Volatile.Write(ref _stateDoNotAccessDirectly, state); @@ -115,7 +116,7 @@ SymbolKind.NetModule or /// compilation state as the now 'old' state /// public ICompilationTracker Fork( - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default) @@ -395,7 +396,7 @@ private async Task GetCompilationSlowAsync(SolutionState solution, return compilationInfo.Compilation; } - private async Task GetOrBuildDeclarationCompilationAsync(SolutionServices solutionServices, CancellationToken cancellationToken) + private async Task GetOrBuildDeclarationCompilationAsync(HostWorkspaceServices solutionServices, CancellationToken cancellationToken) { try { @@ -562,7 +563,7 @@ private async Task BuildCompilationInfoFromScratchAsync( "https://github.com/dotnet/roslyn/issues/23582", Constraint = "Avoid calling " + nameof(Compilation.AddSyntaxTrees) + " in a loop due to allocation overhead.")] private async Task BuildDeclarationCompilationFromScratchAsync( - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, CompilationTrackerGeneratorInfo generatorInfo, CancellationToken cancellationToken) { @@ -627,7 +628,7 @@ private async Task BuildFinalStateFromInProgressStateAsync( } private async Task<(Compilation compilationWithoutGenerators, Compilation? compilationWithGenerators, GeneratorDriver? generatorDriver)> BuildDeclarationCompilationFromInProgressAsync( - SolutionServices solutionServices, InProgressState state, Compilation compilationWithoutGenerators, CancellationToken cancellationToken) + HostWorkspaceServices solutionServices, InProgressState state, Compilation compilationWithoutGenerators, CancellationToken cancellationToken) { try { diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.GeneratedFileReplacingCompilationTracker.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.GeneratedFileReplacingCompilationTracker.cs index 1142660844f14..90f5bdaeda997 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.GeneratedFileReplacingCompilationTracker.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.GeneratedFileReplacingCompilationTracker.cs @@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis @@ -57,7 +58,7 @@ public bool ContainsAssemblyOrModuleOrDynamic(ISymbol symbol, bool primary) } } - public ICompilationTracker Fork(SolutionServices solutionServices, ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default) + public ICompilationTracker Fork(HostWorkspaceServices solutionServices, ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default) { // TODO: This only needs to be implemented if a feature that operates from a source generated file then makes // further mutations to that project, which isn't needed for now. This will be need to be fixed up when we complete diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.ICompilationTracker.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.ICompilationTracker.cs index 26f97da7b6069..4a443ba187cb8 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.ICompilationTracker.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.ICompilationTracker.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis { @@ -33,7 +34,7 @@ private interface ICompilationTracker /// any of the references of the . /// bool ContainsAssemblyOrModuleOrDynamic(ISymbol symbol, bool primary); - ICompilationTracker Fork(SolutionServices solutionServices, ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default); + ICompilationTracker Fork(HostWorkspaceServices solutionServices, ProjectState newProject, CompilationAndGeneratorDriverTranslationAction? translate = null, CancellationToken cancellationToken = default); ICompilationTracker FreezePartialStateWithTree(SolutionState solution, DocumentState docState, SyntaxTree tree, CancellationToken cancellationToken); Task GetCompilationAsync(SolutionState solution, CancellationToken cancellationToken); diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs index ad8f1c40010ef..78329ed25ff1f 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState.cs @@ -13,6 +13,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ErrorReporting; +using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Logging; using Microsoft.CodeAnalysis.Options; @@ -40,7 +41,6 @@ internal partial class SolutionState private readonly int _workspaceVersion; private readonly SolutionInfo.SolutionAttributes _solutionAttributes; - private readonly SolutionServices _solutionServices; private readonly ImmutableDictionary _projectIdToProjectStateMap; private readonly ImmutableDictionary> _filePathToDocumentIdsMap; private readonly ProjectDependencyGraph _dependencyGraph; @@ -75,7 +75,7 @@ internal partial class SolutionState private SolutionState( BranchId branchId, int workspaceVersion, - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, SolutionInfo.SolutionAttributes solutionAttributes, IReadOnlyList projectIds, SolutionOptionSet options, @@ -90,7 +90,7 @@ private SolutionState( _branchId = branchId; _workspaceVersion = workspaceVersion; _solutionAttributes = solutionAttributes; - _solutionServices = solutionServices; + Services = solutionServices; ProjectIds = projectIds; Options = options; AnalyzerReferences = analyzerReferences; @@ -114,14 +114,14 @@ static Lazy CreateLazyHostDiagnosticAnalyzers(IReadOnly public SolutionState( BranchId primaryBranchId, - SolutionServices solutionServices, + HostWorkspaceServices services, SolutionInfo.SolutionAttributes solutionAttributes, SolutionOptionSet options, IReadOnlyList analyzerReferences) : this( primaryBranchId, workspaceVersion: 0, - solutionServices, + services, solutionAttributes, projectIds: SpecializedCollections.EmptyBoxedImmutableArray(), options, @@ -137,13 +137,9 @@ public SolutionState( public SolutionState WithNewWorkspace(Workspace workspace, int workspaceVersion) { - var services = workspace != _solutionServices.Workspace - ? new SolutionServices(workspace) - : _solutionServices; - // Note: this will potentially have problems if the workspace services are different, as some services // get locked-in by document states and project states when first constructed. - return CreatePrimarySolution(branchId: workspace.PrimaryBranchId, workspaceVersion: workspaceVersion, services: services); + return CreatePrimarySolution(branchId: workspace.PrimaryBranchId, workspaceVersion: workspaceVersion, services: workspace.Services); } public HostDiagnosticAnalyzers Analyzers => _lazyAnalyzers.Value; @@ -156,7 +152,7 @@ public SolutionState WithNewWorkspace(Workspace workspace, int workspaceVersion) public int WorkspaceVersion => _workspaceVersion; - public SolutionServices Services => _solutionServices; + public HostWorkspaceServices Services { get; } public SolutionOptionSet Options { get; } @@ -176,7 +172,7 @@ public SolutionState WithNewWorkspace(Workspace workspace, int workspaceVersion) /// /// The Workspace this solution is associated with. /// - public Workspace Workspace => _solutionServices.Workspace; + public Workspace Workspace => Services.Workspace; /// /// The Id of the solution. Multiple solution instances may share the same Id. @@ -257,7 +253,7 @@ private SolutionState Branch( return new SolutionState( branchId, _workspaceVersion, - _solutionServices, + Services, solutionAttributes, projectIds, options, @@ -273,11 +269,11 @@ private SolutionState Branch( private SolutionState CreatePrimarySolution( BranchId branchId, int workspaceVersion, - SolutionServices services) + HostWorkspaceServices services) { if (branchId == _branchId && workspaceVersion == _workspaceVersion && - services == _solutionServices) + services == Services) { return this; } @@ -540,7 +536,7 @@ public SolutionState AddProject(ProjectInfo projectInfo) throw new ArgumentException(string.Format(WorkspacesResources.The_language_0_is_not_supported, language)); } - var newProject = new ProjectState(projectInfo, languageServices, _solutionServices); + var newProject = new ProjectState(projectInfo, languageServices, Services); return this.AddProject(newProject.Id, newProject); } @@ -1127,7 +1123,7 @@ private SolutionState AddDocumentsToMultipleProjects( public SolutionState AddAdditionalDocuments(ImmutableArray documentInfos) { return AddDocumentsToMultipleProjects(documentInfos, - (documentInfo, project) => new AdditionalDocumentState(documentInfo, _solutionServices), + (documentInfo, project) => new AdditionalDocumentState(documentInfo, Services), (projectState, documents) => (projectState.AddAdditionalDocuments(documents), new CompilationAndGeneratorDriverTranslationAction.AddAdditionalDocumentsAction(documents))); } @@ -1135,7 +1131,7 @@ public SolutionState AddAnalyzerConfigDocuments(ImmutableArray doc { // Adding a new analyzer config potentially modifies the compilation options return AddDocumentsToMultipleProjects(documentInfos, - (documentInfo, project) => new AnalyzerConfigDocumentState(documentInfo, _solutionServices), + (documentInfo, project) => new AnalyzerConfigDocumentState(documentInfo, Services), (oldProject, documents) => { var newProject = oldProject.AddAnalyzerConfigDocuments(documents); @@ -1502,7 +1498,7 @@ private SolutionState ForkProject( if (forkTracker) { - newTrackerMap = newTrackerMap.Add(projectId, tracker.Fork(_solutionServices, newProjectState, translate)); + newTrackerMap = newTrackerMap.Add(projectId, tracker.Fork(Services, newProjectState, translate)); } } @@ -1546,7 +1542,7 @@ private ImmutableDictionary CreateCompilationTra var builder = ImmutableDictionary.CreateBuilder(); foreach (var (id, tracker) in _projectIdToTrackerMap) - builder.Add(id, CanReuse(id) ? tracker : tracker.Fork(_solutionServices, tracker.ProjectState)); + builder.Add(id, CanReuse(id) ? tracker : tracker.Fork(Services, tracker.ProjectState)); return builder.ToImmutable(); @@ -1818,7 +1814,7 @@ public SolutionState WithFrozenSourceGeneratedDocument(SourceGeneratedDocumentId sourceText, projectState.ParseOptions!, projectState.LanguageServices, - _solutionServices); + Services); } var projectId = documentIdentity.DocumentId.ProjectId; diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState_Checksum.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState_Checksum.cs index 68663b1317fb3..d148ae8dd053f 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState_Checksum.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionState_Checksum.cs @@ -142,7 +142,7 @@ private async Task ComputeChecksumsAsync( }) .ToArray(); - var serializer = _solutionServices.Workspace.Services.GetRequiredService(); + var serializer = Services.GetRequiredService(); var attributesChecksum = serializer.CreateChecksum(SolutionAttributes, cancellationToken); var frozenSourceGeneratedDocumentIdentityChecksum = Checksum.Null; diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SourceGeneratedDocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SourceGeneratedDocumentState.cs index 38adb7b6ebd71..389b8f3d8943e 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SourceGeneratedDocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SourceGeneratedDocumentState.cs @@ -21,7 +21,7 @@ public static SourceGeneratedDocumentState Create( SourceText generatedSourceText, ParseOptions parseOptions, HostLanguageServices languageServices, - SolutionServices solutionServices) + HostWorkspaceServices solutionServices) { var textAndVersion = TextAndVersion.Create(generatedSourceText, VersionStamp.Create()); var textSource = new ConstantValueSource(textAndVersion); @@ -53,7 +53,7 @@ public static SourceGeneratedDocumentState Create( private SourceGeneratedDocumentState( SourceGeneratedDocumentIdentity documentIdentity, HostLanguageServices languageServices, - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, IDocumentServiceProvider? documentServiceProvider, DocumentInfo.DocumentAttributes attributes, ParseOptions options, diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs index 14efd8ffb0f67..2ff2032fbfe66 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis { internal partial class TextDocumentState { - protected readonly SolutionServices solutionServices; + protected readonly HostWorkspaceServices solutionServices; /// /// A direct reference to our source text. This is only kept around in specialized scenarios. @@ -46,7 +46,7 @@ internal partial class TextDocumentState public IDocumentServiceProvider Services { get; } protected TextDocumentState( - SolutionServices solutionServices, + HostWorkspaceServices solutionServices, IDocumentServiceProvider? documentServiceProvider, DocumentInfo.DocumentAttributes attributes, SourceText? sourceText, @@ -67,7 +67,7 @@ protected TextDocumentState( _lazyChecksums = new AsyncLazy(ComputeChecksumsAsync, cacheResult: true); } - public TextDocumentState(DocumentInfo info, SolutionServices services) + public TextDocumentState(DocumentInfo info, HostWorkspaceServices services) : this(services, info.DocumentServiceProvider, @@ -87,7 +87,7 @@ public TextDocumentState(DocumentInfo info, SolutionServices services) protected static ValueSource CreateStrongText(TextAndVersion text) => new ConstantValueSource(text); - protected static ValueSource CreateStrongText(TextLoader loader, DocumentId documentId, SolutionServices services) + protected static ValueSource CreateStrongText(TextLoader loader, DocumentId documentId, HostWorkspaceServices services) { return new AsyncLazy( asynchronousComputeFunction: cancellationToken => loader.LoadTextAsync(services.Workspace, documentId, cancellationToken), @@ -95,7 +95,7 @@ protected static ValueSource CreateStrongText(TextLoader loader, cacheResult: true); } - protected static ValueSource CreateRecoverableText(TextAndVersion text, SolutionServices services) + protected static ValueSource CreateRecoverableText(TextAndVersion text, HostWorkspaceServices services) { var result = new RecoverableTextAndVersion(CreateStrongText(text), services.TemporaryStorage); @@ -110,7 +110,7 @@ protected static ValueSource CreateRecoverableText(TextAndVersio return result; } - protected static ValueSource CreateRecoverableText(TextLoader loader, DocumentId documentId, SolutionServices services) + protected static ValueSource CreateRecoverableText(TextLoader loader, DocumentId documentId, HostWorkspaceServices services) { return new RecoverableTextAndVersion( new AsyncLazy( diff --git a/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs b/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs index 28f20e42d8cb3..5c8a0829465db 100644 --- a/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs +++ b/src/Workspaces/MSBuildTest/VisualStudioMSBuildWorkspaceTests.cs @@ -2790,7 +2790,7 @@ public void DisposeMSBuildWorkspaceAndServicesCollected() Assert.NotNull(compilation); // MSBuildWorkspace doesn't have a cache service - Assert.Null(workspace.UseReference(static w => w.CurrentSolution.Services.CacheService)); + Assert.Null(workspace.UseReference(static w => w.CurrentSolution.Services.GetService())); document.ReleaseStrongReference(); project.ReleaseStrongReference();