Skip to content

Client settings tweaks, and implement VS Code configuration monitoring #11800

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Shell;

namespace Microsoft.AspNetCore.Razor.ExternalAccess.LegacyEditor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;

namespace Microsoft.AspNetCore.Razor.ExternalAccess.LegacyEditor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.LegacyEditor.Razor;
using Microsoft.VisualStudio.LegacyEditor.Razor.Parsing;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.AspNetCore.Razor.ExternalAccess.LegacyEditor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@
{
return new LspLoggingScope(context, _logger);
}

public IDisposable? CreateLanguageContext(string? language)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build macOS release)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build macOS release)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build macOS release)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build Linux release)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build Linux release)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build Linux release)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build macOS debug)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build macOS debug)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build macOS debug)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build Linux debug)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build Linux debug)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci (Build Linux debug)

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)

Check failure on line 75 in src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs

View check run for this annotation

Azure Pipelines / razor-tooling-ci

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs#L75

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Hosting/ClaspLoggingBridge.cs(75,55): error IDE0060: (NETCORE_ENGINEERING_TELEMETRY=Build) Remove unused parameter 'language' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0060)
{
// We don't support hosting other languages in our LSP server
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
#pragma warning restore RS0030 // Do not use banned APIs
internal sealed class CohostSemanticTokensRangeEndpoint(
IRemoteServiceInvoker remoteServiceInvoker,
IClientSettingsReader clientSettingsManager,
IClientSettingsManager clientSettingsManager,
ITelemetryReporter telemetryReporter)
: AbstractRazorCohostDocumentRequestHandler<SemanticTokensRangeParams, SemanticTokens?>
{
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker;
private readonly IClientSettingsReader _clientSettingsManager = clientSettingsManager;
private readonly IClientSettingsManager _clientSettingsManager = clientSettingsManager;
private readonly ITelemetryReporter _telemetryReporter = telemetryReporter;

protected override bool MutatesSolutionState => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

using System;
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;

namespace Microsoft.VisualStudio.Razor.Settings;
namespace Microsoft.CodeAnalysis.Razor.Workspaces.Settings;

internal interface IClientSettingsManager : IClientSettingsReader
internal interface IClientSettingsManager
{
ClientSettings GetClientSettings();

void Update(ClientSpaceSettings updateSettings);
void Update(ClientCompletionSettings updateSettings);
void Update(ClientAdvancedSettings updateSettings);

event EventHandler<ClientSettingsChangedEventArgs> ClientSettingsChanged;
event EventHandler<EventArgs> ClientSettingsChanged;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Telemetry;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol.AutoInsert;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
using Microsoft.VisualStudio.Razor.Settings;
using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse<Microsoft.CodeAnalysis.Razor.Protocol.AutoInsert.RemoteAutoInsertTextEdit?>;

namespace Microsoft.VisualStudio.LanguageServices.Razor.LanguageClient.Cohost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.VisualStudio.LanguageServices.Razor.LanguageClient.Cohost;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Razor.Snippets;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Api;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using FormattingOptions = Microsoft.CodeAnalysis.Formatting.FormattingOptions;

namespace Microsoft.VisualStudio.Razor.LanguageClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.LanguageServer.Client;
using Microsoft.VisualStudio.Razor.LanguageClient.Endpoints;
using Microsoft.VisualStudio.Razor.LanguageClient.ProjectSystem;
using Microsoft.VisualStudio.Razor.Logging;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using Microsoft.VisualStudio.Utilities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.Razor.Settings;

Expand All @@ -20,7 +22,7 @@ public void Initialize(IClientSettingsManager editorSettingsManager)
editorSettingsManager.ClientSettingsChanged += OnClientSettingsChanged;
}

private void OnClientSettingsChanged(object sender, ClientSettingsChangedEventArgs args)
private void OnClientSettingsChanged(object sender, EventArgs args)
{
_ = OnClientSettingsChangedAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.Razor.Extensions;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Razor.Extensions;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

namespace Microsoft.VisualStudio.Razor.Settings;

[Export(typeof(IClientSettingsReader))]
[Export(typeof(IClientSettingsManager))]
internal class ClientSettingsManager : IClientSettingsManager
internal sealed class ClientSettingsManager : IClientSettingsManager
{
public event EventHandler<ClientSettingsChangedEventArgs>? ClientSettingsChanged;
public event EventHandler<EventArgs>? ClientSettingsChanged;

private readonly object _settingsUpdateLock = new();
private readonly IAdvancedSettingsStorage? _advancedSettingsStorage;
Expand Down Expand Up @@ -106,8 +105,7 @@ private void UpdateSettings_NoLock(ClientSettings settings)
{
_settings = settings;

var args = new ClientSettingsChangedEventArgs(_settings);
ClientSettingsChanged?.Invoke(this, args);
ClientSettingsChanged?.Invoke(this, EventArgs.Empty);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;

namespace Microsoft.VisualStudio.Razor.Settings;

internal interface IClientSettingsChangedTrigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

using System;
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.VisualStudio.Razor.Settings;

namespace Microsoft.VisualStudio.LegacyEditor.Razor.Settings;

internal interface IWorkspaceEditorSettings
{
ClientSettings Current { get; }

event EventHandler<ClientSettingsChangedEventArgs> Changed;
event EventHandler<EventArgs> Changed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.CodeAnalysis.Razor.Workspaces.Settings;

namespace Microsoft.VisualStudio.LegacyEditor.Razor.Settings;

[Export(typeof(IWorkspaceEditorSettings))]
internal sealed class WorkspaceEditorSettings : IWorkspaceEditorSettings
{
private readonly IClientSettingsManager _clientSettingsManager;
private readonly EventHandler<ClientSettingsChangedEventArgs> _onClientSettingsChanged;
private readonly EventHandler<EventArgs> _onClientSettingsChanged;

private EventHandler<ClientSettingsChangedEventArgs>? _changedHandler;
private EventHandler<EventArgs>? _changedHandler;
private int _listenerCount = 0;

[ImportingConstructor]
Expand All @@ -26,15 +26,14 @@ public WorkspaceEditorSettings(IClientSettingsManager clientSettingsManager)

public ClientSettings Current => _clientSettingsManager.GetClientSettings();

private void OnClientSettingsChanged(object sender, ClientSettingsChangedEventArgs e)
private void OnClientSettingsChanged(object sender, EventArgs e)
{
Assumes.True(_changedHandler is not null, $"{nameof(OnClientSettingsChanged)} should not be invoked when there are no listeners.");

var args = new ClientSettingsChangedEventArgs(Current);
_changedHandler.Invoke(this, args);
_changedHandler.Invoke(this, EventArgs.Empty);
}

public event EventHandler<ClientSettingsChangedEventArgs> Changed
public event EventHandler<EventArgs> Changed
{
add
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.ProjectSystem.Legacy;
using Microsoft.CodeAnalysis.Razor.Settings;

using Microsoft.VisualStudio.LegacyEditor.Razor.Settings;
using Microsoft.VisualStudio.Razor.Extensions;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Threading;
Expand Down Expand Up @@ -241,7 +239,7 @@ internal void ProjectManager_Changed(object sender, ProjectChangeEventArgs e)
}

// Internal for testing
internal void EditorSettingsManager_Changed(object sender, ClientSettingsChangedEventArgs args)
internal void EditorSettingsManager_Changed(object sender, EventArgs args)
=> OnContextChangedAsync(ContextChangeKind.EditorSettingsChanged).Forget();

// Internal for testing
Expand Down
Loading
Loading