Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing property to access services #74749

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ internal ProjectSystemProject(
Language = language;
_displayName = displayName;

var provider = _projectSystemProjectFactory.Workspace.Services.GetRequiredService<IAnalyzerAssemblyLoaderProvider>();
var provider = _projectSystemProjectFactory.SolutionServices.GetRequiredService<IAnalyzerAssemblyLoaderProvider>();
// NOTE: The provider will always return the same singleton, shadow copying, analyzer loader instance, which is
// important to ensure that analyzer dependencies are correctly loaded.
_analyzerAssemblyLoader = provider.GetShadowCopyLoader();
Expand Down Expand Up @@ -254,11 +254,11 @@ private void ChangeProjectProperty<T>(

if (logThrowAwayTelemetry)
{
var telemetryService = _projectSystemProjectFactory.Workspace.Services.GetService<IWorkspaceTelemetryService>();
var telemetryService = _projectSystemProjectFactory.SolutionServices.GetService<IWorkspaceTelemetryService>();

if (telemetryService?.HasActiveSession == true)
{
var workspaceStatusService = _projectSystemProjectFactory.Workspace.Services.GetRequiredService<IWorkspaceStatusService>();
var workspaceStatusService = _projectSystemProjectFactory.SolutionServices.GetRequiredService<IWorkspaceStatusService>();

// We only log telemetry during solution open

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ internal sealed partial class ProjectSystemProjectFactory
public Workspace Workspace { get; }
public IAsynchronousOperationListener WorkspaceListener { get; }
public IFileChangeWatcher FileChangeWatcher { get; }

public FileWatchedPortableExecutableReferenceFactory FileWatchedReferenceFactory { get; }
public SolutionServices SolutionServices { get; }

public SolutionServices SolutionServices => this.Workspace.Services.SolutionServices;

private readonly Func<bool, ImmutableArray<string>, Task> _onDocumentsAddedMaybeAsync;
private readonly Action<Project> _onProjectRemoved;
Expand Down Expand Up @@ -74,8 +76,6 @@ public ProjectSystemProjectFactory(Workspace workspace, IFileChangeWatcher fileC
Workspace = workspace;
WorkspaceListener = workspace.Services.GetRequiredService<IWorkspaceAsynchronousOperationListenerProvider>().GetListener();

SolutionServices = workspace.Services.SolutionServices;

FileChangeWatcher = fileChangeWatcher;
FileWatchedReferenceFactory = new FileWatchedPortableExecutableReferenceFactory(fileChangeWatcher);
FileWatchedReferenceFactory.ReferenceChanged += this.StartRefreshingMetadataReferencesForFile;
Expand All @@ -85,7 +85,7 @@ public ProjectSystemProjectFactory(Workspace workspace, IFileChangeWatcher fileC
}

public FileTextLoader CreateFileTextLoader(string fullPath)
=> new WorkspaceFileTextLoader(this.Workspace.Services.SolutionServices, fullPath, defaultEncoding: null);
=> new WorkspaceFileTextLoader(this.SolutionServices, fullPath, defaultEncoding: null);

public async Task<ProjectSystemProject> CreateAndAddToWorkspaceAsync(string projectSystemName, string language, ProjectSystemProjectCreationInfo creationInfo, ProjectSystemHostInfo hostInfo)
{
Expand Down
Loading