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

Remove unused private members #10848

Merged
merged 6 commits into from
Sep 9, 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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ dotnet_separate_import_directive_groups = false
# IDE0005 - Remove unnecessary imports
dotnet_diagnostic.IDE0005.severity = warning

# IDE0052 - Private member can be removed
dotnet_diagnostic.IDE0052.severity = warning
davidwengier marked this conversation as resolved.
Show resolved Hide resolved

# IDE0046: If expression can be simplified
dotnet_style_prefer_conditional_expression_over_return = false:silent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ internal class OnAutoInsertEndpoint(
IClientConnection clientConnection,
IAutoInsertService autoInsertService,
RazorLSPOptionsMonitor optionsMonitor,
IAdhocWorkspaceFactory workspaceFactory,
IRazorFormattingService razorFormattingService,
ILoggerFactory loggerFactory)
: AbstractRazorDelegatingEndpoint<VSInternalDocumentOnAutoInsertParams, VSInternalDocumentOnAutoInsertResponseItem?>(languageServerFeatureOptions, documentMappingService, clientConnection, loggerFactory.GetOrCreateLogger<OnAutoInsertEndpoint>()), ICapabilitiesProvider
{
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions = languageServerFeatureOptions;
private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor;
private readonly IAdhocWorkspaceFactory _workspaceFactory = workspaceFactory;
private readonly IRazorFormattingService _razorFormattingService = razorFormattingService;
private readonly IAutoInsertService _autoInsertService = autoInsertService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.Protocol.DocumentSymbols;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using ExternalHandlers = Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers;
Expand All @@ -24,7 +23,6 @@ protected override IRemoteDocumentSymbolService CreateService(in ServiceArgs arg
}

private readonly IDocumentSymbolService _documentSymbolService = args.ExportProvider.GetExportedValue<IDocumentSymbolService>();
private readonly IFilePathService _filePathService = args.ExportProvider.GetExportedValue<IFilePathService>();

public ValueTask<SumType<DocumentSymbol[], SymbolInformation[]>?> GetDocumentSymbolsAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId razorDocumentId, bool useHierarchicalSymbols, CancellationToken cancellationToken)
=> RunServiceAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ internal class CohostOnAutoInsertEndpoint(
{
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker;
private readonly IClientSettingsManager _clientSettingsManager = clientSettingsManager;
private readonly IEnumerable<IOnAutoInsertTriggerCharacterProvider> _onAutoInsertTriggerCharacterProviders = onAutoInsertTriggerCharacterProviders;
private readonly IHtmlDocumentSynchronizer _htmlDocumentSynchronizer = htmlDocumentSynchronizer;
private readonly LSPRequestInvoker _requestInvoker = requestInvoker;
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<CohostOnAutoInsertEndpoint>();
Expand All @@ -55,12 +54,12 @@ private static ImmutableArray<string> CalculateTriggerChars(IEnumerable<IOnAutoI
{
var providerTriggerCharacters = onAutoInsertTriggerCharacterProviders.Select((provider) => provider.TriggerCharacter).Distinct();

ImmutableArray<string> _triggerCharacters = [
ImmutableArray<string> triggerCharacters = [
.. providerTriggerCharacters,
.. AutoInsertService.HtmlAllowedAutoInsertTriggerCharacters,
.. AutoInsertService.CSharpAllowedAutoInsertTriggerCharacters ];

return _triggerCharacters;
return triggerCharacters;
}

protected override bool MutatesSolutionState => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
Expand All @@ -34,15 +33,13 @@ internal class CohostSignatureHelpEndpoint(
IRemoteServiceInvoker remoteServiceInvoker,
IClientSettingsManager clientSettingsManager,
IHtmlDocumentSynchronizer htmlDocumentSynchronizer,
LSPRequestInvoker requestInvoker,
ILoggerFactory loggerFactory)
LSPRequestInvoker requestInvoker)
: AbstractRazorCohostDocumentRequestHandler<SignatureHelpParams, SumType<SignatureHelp, RoslynSignatureHelp>?>, IDynamicRegistrationProvider
{
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker;
private readonly IClientSettingsManager _clientSettingsManager = clientSettingsManager;
private readonly IHtmlDocumentSynchronizer _htmlDocumentSynchronizer = htmlDocumentSynchronizer;
private readonly LSPRequestInvoker _requestInvoker = requestInvoker;
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<CohostFoldingRangeEndpoint>();

protected override bool MutatesSolutionState => false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Threading;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.VisualStudio.LanguageServer.Protocol;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
Expand All @@ -15,14 +14,9 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
[Shared]
[CohostEndpoint(VSInternalMethods.WorkspaceSpellCheckableRangesName)]
[ExportCohostStatelessLspService(typeof(CohostWorkspaceSpellCheckEndpoint))]
[method: ImportingConstructor]
#pragma warning restore RS0030 // Do not use banned APIs
internal sealed class CohostWorkspaceSpellCheckEndpoint(
IRemoteServiceInvoker remoteServiceInvoker)
: AbstractRazorCohostRequestHandler<VSInternalWorkspaceSpellCheckableParams, VSInternalWorkspaceSpellCheckableReport[]>
internal sealed class CohostWorkspaceSpellCheckEndpoint : AbstractRazorCohostRequestHandler<VSInternalWorkspaceSpellCheckableParams, VSInternalWorkspaceSpellCheckableReport[]>
{
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker;

protected override bool MutatesSolutionState => false;

protected override bool RequiresLSPSolution => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ internal class SnippetService
private readonly IAdvancedSettingsStorage _advancedSettingsStorage;
private IVsExpansionManager? _vsExpansionManager;

private readonly object _cacheGuard = new();

private static readonly Guid s_CSharpLanguageId = new("694dd9b6-b865-4c5b-ad85-86356e9c88dc");
private static readonly Guid s_HtmlLanguageId = new("9bbfd173-9770-47dc-b191-651b7ff493cd");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Formatting;
using Microsoft.AspNetCore.Razor.LanguageServer.Test;
using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Testing;
Expand Down Expand Up @@ -34,7 +33,6 @@ public async Task Handle_SingleProvider_InvokesProvider()
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -84,7 +82,6 @@ public async Task Handle_MultipleProviderSameTrigger_UsesSuccessful()
languageServer,
new AutoInsertService([insertProvider1, insertProvider2]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -137,7 +134,6 @@ public async Task Handle_MultipleProviderSameTrigger_UsesFirstSuccessful()
languageServer,
new AutoInsertService([insertProvider1, insertProvider2]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -182,7 +178,6 @@ public async Task Handle_NoApplicableProvider_CallsProviderAndReturnsNull()
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -225,7 +220,6 @@ public async Task Handle_OnTypeFormattingOff_Html_CallsLanguageServer()
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -266,7 +260,6 @@ public async Task Handle_AutoInsertAttributeQuotesOff_Html_DoesNotCallLanguageSe
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -412,7 +405,6 @@ private async Task VerifyCSharpOnAutoInsertAsync(string input, string expected,
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
formattingService,
LoggerFactory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.LanguageServer.Test;
using Microsoft.CodeAnalysis.Razor.AutoInsert;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Xunit;
Expand Down Expand Up @@ -34,7 +33,6 @@ public async Task Handle_MultipleProviderUnmatchingTrigger_ReturnsNull()
languageServer,
autoInsertService,
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
null!,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -76,7 +74,6 @@ public async Task Handle_DocumentNotFound_ReturnsNull()
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
null!,
LoggerFactory);
var uri = new Uri("file://path/test.razor");
Expand Down Expand Up @@ -120,7 +117,6 @@ public async Task Handle_UnsupportedCodeDocument_ReturnsNull()
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor,
TestAdhocWorkspaceFactory.Instance,
razorFormattingService: null!,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down Expand Up @@ -161,7 +157,7 @@ public async Task Handle_OnTypeFormattingOff_CSharp_ReturnsNull()
DocumentMappingService,
languageServer,
new AutoInsertService([insertProvider]),
optionsMonitor, TestAdhocWorkspaceFactory.Instance,
optionsMonitor,
razorFormattingService: null!,
LoggerFactory);
var @params = new VSInternalDocumentOnAutoInsertParams()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private async Task VerifySignatureHelpAsync(string input, string expected, bool

var requestInvoker = new TestLSPRequestInvoker([(Methods.TextDocumentSignatureHelpName, null)]);

var endpoint = new CohostSignatureHelpEndpoint(RemoteServiceInvoker, clientSettingsManager, TestHtmlDocumentSynchronizer.Instance, requestInvoker, LoggerFactory);
var endpoint = new CohostSignatureHelpEndpoint(RemoteServiceInvoker, clientSettingsManager, TestHtmlDocumentSynchronizer.Instance, requestInvoker);

var signatureHelpContext = new SignatureHelpContext()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace Microsoft.AspNetCore.Razor.PooledObjects;
internal ref struct PooledHashSet<T>
{
private readonly ObjectPool<HashSet<T>> _pool;
#pragma warning disable IDE0052 // Used in NET only code below. Called API doesn't exist on framework.
private readonly int? _capacity;
#pragma warning restore IDE0052
private HashSet<T>? _set;

public PooledHashSet()
Expand Down