Merge remote-tracking branch 'upstream/main' into merge_main

This commit is contained in:
Chris Sienkiewicz 2022-10-03 14:24:14 -07:00
Родитель dbe38d5de5 e37c2a03ab
Коммит 3dc14e8683
156 изменённых файлов: 927 добавлений и 569 удалений

Просмотреть файл

@ -22,7 +22,6 @@
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
<!-- Used for BenchmarkDotNet prerelease packages -->
<add key="benchmark-dotnet-prerelease" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/benchmark-dotnet-prerelease/nuget/v3/index.json" />
<add key="general-testing" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/general-testing/nuget/v3/index.json" />
</packageSources>
<!--
****************************** AUTOGENERATED ***********************************

Просмотреть файл

@ -32,9 +32,9 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
<Sha>3a25a7f1cc446b60678ed25c9d829420d6321eba</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.22473.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.22480.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>ba4d2568dd2e3e7538feeaba60215f7bcb99e89c</Sha>
<Sha>60e9ab3c31d68167f8dac5b8e2c536deb12ef737</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>

Просмотреть файл

@ -81,7 +81,7 @@
<RoslynPackageVersion>4.4.0-2.22424.2</RoslynPackageVersion>
<VisualStudioLanguageServerProtocolVersion>17.4.1008-preview</VisualStudioLanguageServerProtocolVersion>
<MicrosoftNetCompilersToolsetVersion>4.4.0-1.final</MicrosoftNetCompilersToolsetVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.4.0-3.22463.10</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.5.0-1.22480.13</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
</PropertyGroup>
<PropertyGroup Label="Manual">
<!-- dotnet/runtime packages -->
@ -131,7 +131,6 @@
<NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
<NerdbankStreamsPackageVersion>2.8.57</NerdbankStreamsPackageVersion>
<NuGetSolutionRestoreManagerInteropVersion>4.8.0</NuGetSolutionRestoreManagerInteropVersion>
<OmniSharpExtensionsLanguageServerPackageVersion>0.19.5</OmniSharpExtensionsLanguageServerPackageVersion>
<OmniSharpExtensionsLanguageProtocolPackageVersion>$(OmniSharpExtensionsLanguageServerPackageVersion)</OmniSharpExtensionsLanguageProtocolPackageVersion>
<OmniSharpMSBuildPackageVersion>1.39.1</OmniSharpMSBuildPackageVersion>

Просмотреть файл

@ -113,6 +113,7 @@ try {
$ToolPath = Convert-Path -Path $BinPath
Write-Host "Adding $ToolName to the path ($ToolPath)..."
Write-Host "##vso[task.prependpath]$ToolPath"
$env:PATH = "$ToolPath;$env:PATH"
$InstalledTools += @{ $ToolName = $ToolDirectory.FullName }
}
}

Просмотреть файл

@ -34,7 +34,7 @@ jobs:
- job: Run_SDL
dependsOn: ${{ parameters.dependsOn }}
displayName: Run SDL tool
condition: eq( ${{ parameters.enable }}, 'true')
condition: and(succeededOrFailed(), eq( ${{ parameters.enable }}, 'true'))
variables:
- group: DotNet-VSTS-Bot
- name: AzDOProjectName

Просмотреть файл

@ -25,6 +25,7 @@ parameters:
enablePublishTestResults: false
enablePublishUsingPipelines: false
disableComponentGovernance: false
componentGovernanceIgnoreDirectories: ''
mergeTestResults: false
testRunTitle: ''
testResultsFormat: ''
@ -146,6 +147,8 @@ jobs:
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), ne(parameters.disableComponentGovernance, 'true')) }}:
- task: ComponentGovernanceComponentDetection@0
continueOnError: true
inputs:
ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
- ${{ if eq(parameters.enableMicrobuild, 'true') }}:
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
@ -223,4 +226,5 @@ jobs:
parameters:
PackageVersion: ${{ parameters.packageVersion}}
BuildDropPath: ${{ parameters.buildDropPath }}
IgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}

Просмотреть файл

@ -14,7 +14,7 @@ parameters:
# This is the default platform provided by Arcade, intended for use by a managed-only repo.
defaultManagedPlatform:
name: 'Managed'
container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8-20220809204800-17a4aab'
container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8-latest'
# Defines the platforms on which to run build jobs. One job is created for each platform, and the
# object in this array is sent to the job template as 'platform'. If no platforms are specified,

Просмотреть файл

@ -98,7 +98,7 @@ stages:
jobs:
- job:
displayName: NuGet Validation
condition: eq( ${{ parameters.enableNugetValidation }}, 'true')
condition: and(succeededOrFailed(), eq( ${{ parameters.enableNugetValidation }}, 'true'))
pool:
# We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
@ -282,4 +282,4 @@ stages:
-MaestroToken '$(MaestroApiAccessToken)'
-WaitPublishingFinish true
-ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}'
-SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'
-SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'

Просмотреть файл

@ -2,12 +2,14 @@
# PackageName - The name of the package this SBOM represents.
# PackageVersion - The version of the package this SBOM represents.
# ManifestDirPath - The path of the directory where the generated manifest files will be placed
# IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector.
parameters:
PackageVersion: 7.0.0
BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
PackageName: '.NET'
ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom
IgnoreDirectories: ''
sbomContinueOnError: true
steps:
@ -34,6 +36,8 @@ steps:
BuildDropPath: ${{ parameters.buildDropPath }}
PackageVersion: ${{ parameters.packageVersion }}
ManifestDirPath: ${{ parameters.manifestDirPath }}
${{ if ne(parameters.IgnoreDirectories, '') }}:
AdditionalComponentDetectorArgs: '--IgnoreDirectories ${{ parameters.IgnoreDirectories }}'
- task: PublishPipelineArtifact@1
displayName: Publish SBOM manifest

Просмотреть файл

@ -19,7 +19,7 @@
"version": "7.0.100-rc.1.22431.12"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22473.1",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22480.2",
"Yarn.MSBuild": "1.22.10"
}
}

Просмотреть файл

@ -42,5 +42,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Common
public const string RazorImplementationEndpointName = "razor/implementation";
public const string RazorOnAutoInsertEndpointName = "razor/onAutoInsert";
public const string RazorValidateBreakpointRangeName = "razor/validateBreakpointRange";
}
}

Просмотреть файл

@ -14,6 +14,11 @@ internal record DelegatedPositionParams(
Position ProjectedPosition,
RazorLanguageKind ProjectedKind) : IDelegatedParams;
internal record DelegatedValidateBreakpointRangeParams(
VersionedTextDocumentIdentifier HostDocument,
Range ProjectedRange,
RazorLanguageKind ProjectedKind) : IDelegatedParams;
internal record DelegatedOnAutoInsertParams(
VersionedTextDocumentIdentifier HostDocument,
Position ProjectedPosition,

Просмотреть файл

@ -34,10 +34,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
/// <summary>
/// The delegated object to send to the <see cref="CustomMessageTarget"/>
/// </summary>
protected abstract IDelegatedParams? CreateDelegatedParams(TRequest request, RazorRequestContext razorRequestContext, Projection projection, CancellationToken cancellationToken);
protected virtual bool OnlySingleServer { get; } = true;
/// <summary>
/// The name of the endpoint to delegate to, from <see cref="RazorLanguageServerCustomMessageTargets"/>. This is the
@ -51,6 +48,11 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
public bool MutatesSolutionState { get; } = false;
/// <summary>
/// The delegated object to send to the <see cref="CustomMessageTarget"/>
/// </summary>
protected abstract Task<IDelegatedParams?> CreateDelegatedParamsAsync(TRequest request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken);
/// <summary>
/// If the response needs to be handled, such as for remapping positions back, override and handle here
/// </summary>
@ -75,7 +77,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
/// <summary>
/// Implementation for <see cref="HandleRequestAsync(TRequest, RazorRequestContext, CancellationToken)"/>
/// </summary>
public async Task<TResponse?> HandleRequestAsync(TRequest request, RazorRequestContext context, CancellationToken cancellationToken)
public async Task<TResponse?> HandleRequestAsync(TRequest request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
if (request is null)
{
@ -87,25 +89,25 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
return default;
}
var documentContext = context.DocumentContext;
var documentContext = requestContext.DocumentContext;
if (documentContext is null)
{
return default;
}
var projection = await _documentMappingService.TryGetProjectionAsync(documentContext, request.Position, context.Logger, cancellationToken).ConfigureAwait(false);
var projection = await _documentMappingService.TryGetProjectionAsync(documentContext, request.Position, requestContext.Logger, cancellationToken).ConfigureAwait(false);
if (projection is null)
{
return default;
}
var response = await TryHandleAsync(request, context, projection, cancellationToken).ConfigureAwait(false);
var response = await TryHandleAsync(request, requestContext, projection, cancellationToken).ConfigureAwait(false);
if (response is not null && response is not ISumType { Value: null })
{
return response;
}
if (!_languageServerFeatureOptions.SingleServerSupport)
if (OnlySingleServer && !_languageServerFeatureOptions.SingleServerSupport)
{
return default;
}
@ -117,7 +119,8 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
return default;
}
var delegatedParams = CreateDelegatedParams(request, context, projection, cancellationToken);
var delegatedParams = await CreateDelegatedParamsAsync(request, requestContext, projection, cancellationToken);
if (delegatedParams is null)
{
// I guess they don't want to delegate... fine then!
@ -130,7 +133,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
return default;
}
var remappedResponse = await HandleDelegatedResponseAsync(delegatedRequest, request, context, projection, cancellationToken).ConfigureAwait(false);
var remappedResponse = await HandleDelegatedResponseAsync(delegatedRequest, request, requestContext, projection, cancellationToken).ConfigureAwait(false);
return remappedResponse;
}

Просмотреть файл

@ -112,28 +112,28 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.AutoInsert
return null;
}
protected override IDelegatedParams? CreateDelegatedParams(OnAutoInsertParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(OnAutoInsertParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
if (projection.LanguageKind == RazorLanguageKind.Html &&
!s_htmlAllowedTriggerCharacters.Contains(request.Character))
{
Logger.LogInformation("Inapplicable HTML trigger char {request.Character}.", request.Character);
return null;
return Task.FromResult<IDelegatedParams?>(null);
}
else if (projection.LanguageKind == RazorLanguageKind.CSharp &&
!s_cSharpAllowedTriggerCharacters.Contains(request.Character))
{
Logger.LogInformation("Inapplicable C# trigger char {request.Character}.", request.Character);
return null;
return Task.FromResult<IDelegatedParams?>(null);
}
return new DelegatedOnAutoInsertParams(
return Task.FromResult<IDelegatedParams?>(new DelegatedOnAutoInsertParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind,
request.Character,
request.Options);
request.Options));
}
protected override async Task<VSInternalDocumentOnAutoInsertResponseItem?> HandleDelegatedResponseAsync(

Просмотреть файл

@ -132,5 +132,3 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Completion
}
}
}

Просмотреть файл

@ -0,0 +1,87 @@
// 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.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Debugging
{
internal class ValidateBreakpointRangeEndpoint : AbstractRazorDelegatingEndpoint<ValidateBreakpointRangeParamsBridge, Range?>, IValidateBreakpointRangeEndpoint
{
private readonly RazorDocumentMappingService _documentMappingService;
public ValidateBreakpointRangeEndpoint(
RazorDocumentMappingService documentMappingService,
LanguageServerFeatureOptions languageServerFeatureOptions,
ClientNotifierServiceBase languageServer,
ILoggerFactory loggerFactory)
: base(languageServerFeatureOptions, documentMappingService, languageServer, loggerFactory.CreateLogger<ValidateBreakpointRangeEndpoint>())
{
_documentMappingService = documentMappingService ?? throw new ArgumentNullException(nameof(documentMappingService));
}
protected override bool OnlySingleServer => false;
protected override string CustomMessageTarget => RazorLanguageServerCustomMessageTargets.RazorValidateBreakpointRangeName;
public RegistrationExtensionResult GetRegistration(VSInternalClientCapabilities clientCapabilities)
{
const string ServerCapability = "_vs_breakableRangeProvider";
return new RegistrationExtensionResult(ServerCapability, true);
}
protected override Task<Range?> TryHandleAsync(ValidateBreakpointRangeParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
// no such thing as Razor breakpoints (yet?!)
return Task.FromResult<Range?>(null);
}
protected async override Task<IDelegatedParams?> CreateDelegatedParamsAsync(ValidateBreakpointRangeParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
// only C# supports breakpoints
if (projection.LanguageKind != RazorLanguageKind.CSharp)
{
return null;
}
var documentContext = requestContext.GetRequiredDocumentContext();
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
if (!_documentMappingService.TryMapToProjectedDocumentRange(codeDocument, request.Range, out var projectedRange))
{
return null;
}
return new DelegatedValidateBreakpointRangeParams(
documentContext.Identifier,
projectedRange,
projection.LanguageKind);
}
protected async override Task<Range?> HandleDelegatedResponseAsync(Range? delegatedResponse, ValidateBreakpointRangeParamsBridge originalRequest, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
if (delegatedResponse is null)
{
return null;
}
var documentContext = requestContext.GetRequiredDocumentContext();
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
if (_documentMappingService.TryMapFromProjectedDocumentRange(codeDocument, delegatedResponse, out var projectedRange))
{
return projectedRange;
}
return null;
}
}
}

Просмотреть файл

@ -99,13 +99,13 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Definition
};
}
protected override IDelegatedParams CreateDelegatedParams(TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
return new DelegatedPositionParams(
return Task.FromResult<IDelegatedParams?>(new DelegatedPositionParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind);
projection.LanguageKind));
}
protected async override Task<DefinitionResult?> HandleDelegatedResponseAsync(DefinitionResult? response, TextDocumentPositionParamsBridge originalRequest, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)

Просмотреть файл

@ -38,26 +38,23 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.DocumentHighlighting
return new RegistrationExtensionResult(ServerCapability, options);
}
/// <inheritdoc/>
protected override string CustomMessageTarget => RazorLanguageServerCustomMessageTargets.RazorDocumentHighlightEndpointName;
/// <inheritdoc/>
protected override Task<DocumentHighlight[]?> TryHandleAsync(DocumentHighlightParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
// We don't handle this in any particular way for Razor, we just delegate
return Task.FromResult<DocumentHighlight[]?>(null);
}
/// <inheritdoc/>
protected override IDelegatedParams CreateDelegatedParams(DocumentHighlightParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(DocumentHighlightParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
return new DelegatedPositionParams(
return Task.FromResult<IDelegatedParams?>(new DelegatedPositionParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind);
projection.LanguageKind));
}
/// <inheritdoc/>
protected override async Task<DocumentHighlight[]?> HandleDelegatedResponseAsync(DocumentHighlight[]? response, DocumentHighlightParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();

Просмотреть файл

@ -54,12 +54,12 @@ internal class RazorDidChangeTextDocumentEndpoint : IVSDidChangeTextDocumentEndp
return request.TextDocument;
}
public async Task HandleNotificationAsync(DidChangeTextDocumentParams request, RazorRequestContext context, CancellationToken cancellationToken)
public async Task HandleNotificationAsync(DidChangeTextDocumentParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
var documentContext = context.GetRequiredDocumentContext();
var documentContext = requestContext.GetRequiredDocumentContext();
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken);
sourceText = ApplyContentChanges(request.ContentChanges, sourceText, context.Logger);
sourceText = ApplyContentChanges(request.ContentChanges, sourceText, requestContext.Logger);
await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(
() => _projectService.UpdateDocument(documentContext.FilePath, sourceText, request.TextDocument.Version),

Просмотреть файл

@ -41,7 +41,7 @@ internal class RazorDidCloseTextDocumentEndpoint : IVSDidCloseTextDocumentEndpoi
return request.TextDocument;
}
public async Task HandleNotificationAsync(DidCloseTextDocumentParams request, RazorRequestContext context, CancellationToken cancellationToken)
public async Task HandleNotificationAsync(DidCloseTextDocumentParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(
() => _projectService.CloseDocument(request.TextDocument.Uri.GetAbsoluteOrUNCPath()),

Просмотреть файл

@ -30,7 +30,7 @@ internal class RazorDidOpenTextDocumentEndpoint : IVSDidOpenTextDocumentEndpoint
return request.TextDocument.Uri;
}
public async Task HandleNotificationAsync(DidOpenTextDocumentParams request, RazorRequestContext context, CancellationToken cancellationToken)
public async Task HandleNotificationAsync(DidOpenTextDocumentParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
var sourceText = SourceText.From(request.TextDocument.Text);

Просмотреть файл

@ -18,9 +18,9 @@ internal class RazorDidSaveTextDocumentEndpoint : IVSDidSaveTextDocumentEndpoint
return request.TextDocument;
}
public Task HandleNotificationAsync(DidSaveTextDocumentParams request, RazorRequestContext context, CancellationToken cancellationToken)
public Task HandleNotificationAsync(DidSaveTextDocumentParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
context.LspLogger.LogInformation($"Saved Document {request.TextDocument.Uri.GetAbsoluteOrUNCPath()}");
requestContext.LspLogger.LogInformation($"Saved Document {request.TextDocument.Uri.GetAbsoluteOrUNCPath()}");
return Task.CompletedTask;
}

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
[LanguageServerEndpoint(VSInternalMethods.TextDocumentValidateBreakableRangeName)]
internal interface IValidateBreakpointRangeEndpoint : IRazorRequestHandler<ValidateBreakpointRangeParamsBridge, Range?>,
IRegistrationExtension
{
}
}

Просмотреть файл

@ -10,10 +10,10 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
// Note: This type should be kept in sync with the one in VisualStudio.LanguageServerClient assembly.
internal class RazorDiagnosticsParams
{
public RazorLanguageKind Kind { get; set; }
public RazorLanguageKind Kind { get; init; }
public required Uri RazorDocumentUri { get; set; }
public required Uri RazorDocumentUri { get; init; }
public required VSDiagnostic[] Diagnostics { get; set; }
public required VSDiagnostic[] Diagnostics { get; init; }
}
}

Просмотреть файл

@ -8,8 +8,8 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
// Note: This type should be kept in sync with the one in VisualStudio.LanguageServerClient assembly.
internal class RazorDiagnosticsResponse
{
public VSDiagnostic[]? Diagnostics { get; set; }
public VSDiagnostic[]? Diagnostics { get; init; }
public int? HostDocumentVersion { get; set; }
public int? HostDocumentVersion { get; init; }
}
}

Просмотреть файл

@ -2,14 +2,18 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Runtime.Serialization;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
[DataContract]
internal class RazorLanguageQueryParams
{
[DataMember(Name = "uri")]
public required Uri Uri { get; set; }
[DataMember(Name ="position")]
public required Position Position { get; set; }
}
}

Просмотреть файл

@ -2,21 +2,29 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
// Note: This type should be kept in sync with the one in Razor.HtmlCSharp assembly.
[DataContract]
internal class RazorMapToDocumentEditsParams
{
public RazorLanguageKind Kind { get; set; }
[DataMember(Name = "kind")]
public RazorLanguageKind Kind { get; init; }
public required Uri RazorDocumentUri { get; set; }
[DataMember(Name = "razorDocumentUri")]
public required Uri RazorDocumentUri { get; init; }
public required TextEdit[] ProjectedTextEdits { get; set; }
[DataMember(Name = "projectedTextEdits")]
public required TextEdit[] ProjectedTextEdits { get; init; }
public TextEditKind TextEditKind { get; set; }
[DataMember(Name = "textEditKind")]
public TextEditKind TextEditKind { get; init; }
public required FormattingOptions FormattingOptions { get; set; }
[DataMember(Name = "formattingOptions")]
public required FormattingOptions FormattingOptions { get; init; }
}
}

Просмотреть файл

@ -1,14 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Runtime.Serialization;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
[DataContract]
internal class RazorMapToDocumentEditsResponse
{
public required TextEdit[] TextEdits { get; set; }
[DataMember(Name = "textEdits")]
public required TextEdit[] TextEdits { get; init; }
public int? HostDocumentVersion { get; set; }
[DataMember(Name = "hostDocumentVersion")]
public int? HostDocumentVersion { get; init; }
}
}

Просмотреть файл

@ -2,19 +2,25 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
// Note: This type should be kept in sync with the one in VisualStudio.LanguageServerClient assembly.
[DataContract]
internal class RazorMapToDocumentRangesParams
{
public RazorLanguageKind Kind { get; set; }
[DataMember(Name = "kind")]
public RazorLanguageKind Kind { get; init; }
public required Uri RazorDocumentUri { get; set; }
[DataMember(Name = "razorDocumentUri")]
public required Uri RazorDocumentUri { get; init; }
public required Range[] ProjectedRanges { get; set; }
[DataMember(Name = "projectedRanges")]
public required Range[] ProjectedRanges { get; init; }
public MappingBehavior MappingBehavior { get; set; }
[DataMember(Name = "mappingBehavior")]
public MappingBehavior MappingBehavior { get; init; }
}
}

Просмотреть файл

@ -1,14 +1,19 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Runtime.Serialization;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
// NOTE: Changes here MUST be copied over to
// Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp.RazorMapToDocumentRangesResponse
[DataContract]
internal class RazorMapToDocumentRangesResponse
{
public required Range[] Ranges { get; set; }
[DataMember(Name = "ranges")]
public required Range[] Ranges { get; init; }
public int? HostDocumentVersion { get; set; }
[DataMember(Name = "hostDocumentVersion")]
public int? HostDocumentVersion { get; init; }
}
}

Просмотреть файл

@ -0,0 +1,17 @@
// 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 Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts
{
internal class ValidateBreakpointRangeParamsBridge : VSInternalValidateBreakableRangeParams, ITextDocumentPositionParams
{
public Position Position
{
get { return Range.Start; }
set { throw new NotImplementedException(); }
}
}
}

Просмотреть файл

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Razor.LanguageServer.Common;
using Microsoft.AspNetCore.Razor.LanguageServer.Completion;
using Microsoft.AspNetCore.Razor.LanguageServer.Completion.Delegation;
using Microsoft.AspNetCore.Razor.LanguageServer.DocumentPresentation;
using Microsoft.AspNetCore.Razor.LanguageServer.DocumentSynchronization;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Formatting;
using Microsoft.AspNetCore.Razor.LanguageServer.Hover;
@ -22,8 +23,6 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using StreamJsonRpc;
using Microsoft.AspNetCore.Razor.LanguageServer.DocumentSynchronization;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Extensions;
@ -42,6 +41,8 @@ internal static class IServiceCollectionExtensions
services.AddSingleton<IInitializeManager<InitializeParams, InitializeResult>, CapabilitiesManager>();
services.AddSingleton<IRequestContextFactory<RazorRequestContext>, RazorRequestContextFactory>();
services.AddSingleton<IRegistrationExtension, RazorLanguageServerCapability>();
services.AddSingleton<IOnInitialized>(serverManager);
}
@ -145,7 +146,9 @@ internal static class IServiceCollectionExtensions
services.AddHandler<RazorDidOpenTextDocumentEndpoint>();
services.AddHandler<RazorDidSaveTextDocumentEndpoint>();
services.AddHandler<RazorMapToDocumentEditsEndpoint>();
services.AddHandler<RazorMapToDocumentRangesEndpoint>();
services.AddHandler<RazorLanguageQueryEndpoint>();
}
public static void AddOptionsServices(this IServiceCollection services)

Просмотреть файл

@ -45,23 +45,20 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Hover
return new RegistrationExtensionResult(AssociatedServerCapability, new SumType<bool, HoverOptions>(registrationOptions));
}
/// <inheritdoc/>
protected override string CustomMessageTarget => RazorLanguageServerCustomMessageTargets.RazorHoverEndpointName;
/// <inheritdoc/>
protected override IDelegatedParams CreateDelegatedParams(TextDocumentPositionParamsBridge request, RazorRequestContext razorRequestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = razorRequestContext.GetRequiredDocumentContext();
return new DelegatedPositionParams(
var documentContext = requestContext.GetRequiredDocumentContext();
return Task.FromResult<IDelegatedParams?>(new DelegatedPositionParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind);
projection.LanguageKind));
}
/// <inheritdoc/>
protected override async Task<VSInternalHover?> TryHandleAsync(TextDocumentPositionParamsBridge request, RazorRequestContext razorRequestContext, Projection projection, CancellationToken cancellationToken)
protected override async Task<VSInternalHover?> TryHandleAsync(TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = razorRequestContext.GetRequiredDocumentContext();
var documentContext = requestContext.GetRequiredDocumentContext();
// HTML can still sometimes be handled by razor. For example hovering over
// a component tag like <Counter /> will still be in an html context
if (projection.LanguageKind == RazorLanguageKind.CSharp)
@ -75,15 +72,14 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Hover
return _hoverInfoService.GetHoverInfo(codeDocument, location, _clientCapabilities!);
}
/// <inheritdoc/>
protected override async Task<VSInternalHover?> HandleDelegatedResponseAsync(VSInternalHover? response, TextDocumentPositionParamsBridge originalRequest, RazorRequestContext razorRequestContext, Projection projection, CancellationToken cancellationToken)
protected override async Task<VSInternalHover?> HandleDelegatedResponseAsync(VSInternalHover? response, TextDocumentPositionParamsBridge originalRequest, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
if (response?.Range is null)
{
return response;
}
var documentContext = razorRequestContext.GetRequiredDocumentContext();
var documentContext = requestContext.GetRequiredDocumentContext();
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
if (_documentMappingService.TryMapFromProjectedDocumentRange(codeDocument, response.Range, out var projectedRange))

Просмотреть файл

@ -40,13 +40,13 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Implementation
return new RegistrationExtensionResult(ServerCapability, option);
}
protected override IDelegatedParams CreateDelegatedParams(TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
return new DelegatedPositionParams(
return Task.FromResult<IDelegatedParams?>(new DelegatedPositionParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind);
projection.LanguageKind));
}
protected async override Task<ImplementationResult> HandleDelegatedResponseAsync(ImplementationResult delegatedResponse, TextDocumentPositionParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)

Просмотреть файл

@ -26,9 +26,9 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer
public bool MutatesSolutionState => true;
public async Task HandleNotificationAsync(DidChangeConfigurationParams request, RazorRequestContext context, CancellationToken cancellationToken)
public async Task HandleNotificationAsync(DidChangeConfigurationParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
context.Logger.LogInformation("Settings changed. Updating the server.");
requestContext.Logger.LogInformation("Settings changed. Updating the server.");
await _optionsMonitor.UpdateAsync(cancellationToken);
}

Просмотреть файл

@ -14,9 +14,9 @@ internal class RazorInitializeEndpoint : IRazorDocumentlessRequestHandler<Initia
{
public bool MutatesSolutionState { get; } = true;
public Task<InitializeResult> HandleRequestAsync(InitializeParams request, RazorRequestContext context, CancellationToken cancellationToken)
public Task<InitializeResult> HandleRequestAsync(InitializeParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
var capabilitiesManager = context.GetRequiredService<IInitializeManager<InitializeParams, InitializeResult>>();
var capabilitiesManager = requestContext.GetRequiredService<IInitializeManager<InitializeParams, InitializeResult>>();
capabilitiesManager.SetInitializeParams(request);
var serverCapabilities = capabilitiesManager.GetInitializeResult();

Просмотреть файл

@ -1,19 +1,25 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServer.Protocol;
namespace Microsoft.AspNetCore.Razor.LanguageServer
{
[DataContract]
internal class RazorLanguageQueryResponse
{
[DataMember(Name = "kind")]
public RazorLanguageKind Kind { get; set; }
[DataMember(Name = "positionIndex")]
public int PositionIndex { get; set; }
[DataMember(Name = "position")]
public required Position Position { get; set; }
[DataMember(Name = "hostDocumentVersion")]
public int? HostDocumentVersion { get; set; }
}
}

Просмотреть файл

@ -20,6 +20,7 @@ using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.Telemetry;
@ -122,6 +123,9 @@ internal class RazorLanguageServer : AbstractLanguageServer<RazorRequestContext>
services.AddSingleton<ITelemetryReporter>(provider =>
new TelemetryReporter(ImmutableArray.Create(TelemetryService.DefaultSession), provider.GetRequiredService<ILoggerFactory>()));
// Defaults: For when the caller hasn't provided them through the `configure` action.
services.TryAddSingleton<HostServicesProvider, DefaultHostServicesProvider>();
AddHandlers(services);
var lspServices = new LspServices(services);
@ -142,6 +146,7 @@ internal class RazorLanguageServer : AbstractLanguageServer<RazorRequestContext>
services.AddHandler<RazorProximityExpressionsEndpoint>();
services.AddRegisteringHandler<DocumentColorEndpoint>();
services.AddRegisteringHandler<FoldingRangeEndpoint>();
services.AddRegisteringHandler<ValidateBreakpointRangeEndpoint>();
}
}

Просмотреть файл

@ -1,39 +1,35 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Newtonsoft.Json.Linq;
namespace Microsoft.AspNetCore.Razor.LanguageServer
{
internal record RazorLanguageServerCapability(
bool LanguageQuery,
bool RangeMapping,
bool EditMapping,
bool MonitorProjectConfigurationFilePath,
bool BreakpointSpan,
bool ProximityExpressions)
internal class RazorLanguageServerCapability : IRegistrationExtension
{
private const string RazorCapabilityKey = "razor";
private static readonly RazorLanguageServerCapability s_default = new RazorLanguageServerCapability(
LanguageQuery: true,
RangeMapping: true,
EditMapping: true,
MonitorProjectConfigurationFilePath: true,
BreakpointSpan: true,
ProximityExpressions: true);
public static void AddTo(ServerCapabilities capabilities)
private static readonly RazorLanguageServerCapability s_default = new RazorLanguageServerCapability
{
// We have to use the experimental capabilities bucket here because not all platforms maintain custom capabilities. For instance
// in Visual Studio scenarios it will deserialize server capabilties into what it believes is "valid" and then will re-pass said
// server capabilities to our client side code having lost the information of the custom capabilities. To avoid this we use the
// experimental bag since it's part of the official LSP spec. This approach enables us to work with any client.
capabilities.Experimental ??= new Dictionary<string, JToken> {
{ RazorCapabilityKey, JToken.FromObject(s_default) }
};
LanguageQuery = true,
RangeMapping = true,
EditMapping = true,
MonitorProjectConfigurationFilePath = true,
BreakpointSpan = true,
ProximityExpressions = true
};
public bool LanguageQuery { get; set; }
public bool RangeMapping { get; set; }
public bool EditMapping { get; set; }
public bool MonitorProjectConfigurationFilePath { get; set; }
public bool BreakpointSpan { get; set; }
public bool ProximityExpressions { get; set; }
public RegistrationExtensionResult GetRegistration(VSInternalClientCapabilities clientCapabilities)
{
return new RegistrationExtensionResult(RazorCapabilityKey, JToken.FromObject(s_default));
}
public static bool TryGet(JToken token, [NotNullWhen(true)] out RazorLanguageServerCapability? razorCapability)

Просмотреть файл

@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Newtonsoft.Json.Serialization;
using StreamJsonRpc;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
@ -72,6 +73,7 @@ internal sealed class RazorLanguageServerWrapper : IAsyncDisposable
var messageFormatter = new JsonMessageFormatter();
messageFormatter.JsonSerializer.AddVSInternalExtensionConverters();
messageFormatter.JsonSerializer.Converters.RegisterRazorConverters();
messageFormatter.JsonSerializer.ContractResolver = new CamelCasePropertyNamesContractResolver();
var jsonRpc = new JsonRpc(new HeaderDelimitedMessageHandler(output, input, messageFormatter));

Просмотреть файл

@ -63,10 +63,8 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Refactoring
return new RegistrationExtensionResult(ServerCapability, new SumType<bool, RenameOptions>(options));
}
/// <inheritdoc/>
protected override string CustomMessageTarget => RazorLanguageServerCustomMessageTargets.RazorRenameEndpointName;
/// <inheritdoc/>
protected override async Task<WorkspaceEdit?> TryHandleAsync(RenameParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
@ -88,18 +86,16 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Refactoring
protected override bool IsSupported()
=> _languageServerFeatureOptions.SupportsFileManipulation;
/// <inheritdoc/>
protected override IDelegatedParams CreateDelegatedParams(RenameParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(RenameParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
return new DelegatedRenameParams(
return Task.FromResult<IDelegatedParams?>(new DelegatedRenameParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind,
request.NewName);
request.NewName));
}
/// <inheritdoc/>
protected override async Task<WorkspaceEdit?> HandleDelegatedResponseAsync(WorkspaceEdit? response, RenameParamsBridge request, RazorRequestContext reqeuestContext, Projection projection, CancellationToken cancellationToken)
{
if (response is null)

Просмотреть файл

@ -20,20 +20,20 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Semantic
{
}
public async Task<SemanticTokens?> HandleRequestAsync(SemanticTokensRangeParams request, RazorRequestContext context, CancellationToken cancellationToken)
public async Task<SemanticTokens?> HandleRequestAsync(SemanticTokensRangeParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
if (request is null)
{
throw new ArgumentNullException(nameof(request));
}
var documentContext = context.GetRequiredDocumentContext();
var semanticTokensInfoService = context.GetRequiredService<RazorSemanticTokensInfoService>();
var documentContext = requestContext.GetRequiredDocumentContext();
var semanticTokensInfoService = requestContext.GetRequiredService<RazorSemanticTokensInfoService>();
var semanticTokens = await semanticTokensInfoService.GetSemanticTokensAsync(request.TextDocument, request.Range, documentContext, cancellationToken);
var amount = semanticTokens is null ? "no" : (semanticTokens.Data.Length / 5).ToString(Thread.CurrentThread.CurrentCulture);
context.Logger.LogInformation("Returned {amount} semantic tokens for range {request.Range} in {request.TextDocument.Uri}.", amount, request.Range, request.TextDocument.Uri);
requestContext.Logger.LogInformation("Returned {amount} semantic tokens for range {request.Range} in {request.TextDocument.Uri}.", amount, request.Range, request.TextDocument.Uri);
if (semanticTokens is not null)
{

Просмотреть файл

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Semantic
_semanticTokensRefreshPublisher = semanticTokensRefreshPublisher;
}
public Task HandleNotificationAsync(SemanticTokensRefreshParams request, RazorRequestContext context, CancellationToken cancellationToken)
public Task HandleNotificationAsync(SemanticTokensRefreshParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
// We have to invalidate the tokens cache since it may no longer be up to date.
_semanticTokensRefreshPublisher.EnqueueWorkspaceSemanticTokensRefresh();

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
@ -23,7 +24,6 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.SignatureHelp
{
}
/// <inheritdoc />
protected override string CustomMessageTarget => RazorLanguageServerCustomMessageTargets.RazorSignatureHelpEndpointName;
public RegistrationExtensionResult GetRegistration(VSInternalClientCapabilities clientCapabilities)
@ -38,14 +38,13 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.SignatureHelp
return new RegistrationExtensionResult(ServerCapability, option);
}
/// <inheritdoc />
protected override IDelegatedParams CreateDelegatedParams(SignatureHelpParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
protected override Task<IDelegatedParams?> CreateDelegatedParamsAsync(SignatureHelpParamsBridge request, RazorRequestContext requestContext, Projection projection, CancellationToken cancellationToken)
{
var documentContext = requestContext.GetRequiredDocumentContext();
return new DelegatedPositionParams(
return Task.FromResult<IDelegatedParams?>(new DelegatedPositionParams(
documentContext.Identifier,
projection.Position,
projection.LanguageKind);
projection.LanguageKind));
}
}
}

Просмотреть файл

@ -4,7 +4,6 @@
#nullable disable
using System;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
namespace Microsoft.AspNetCore.Razor.OmniSharpPlugin

Просмотреть файл

@ -465,12 +465,10 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
}
}
RazorCodeDocument? olderOutput = null;
if (_older?._taskUnsafeReference != null &&
_older._taskUnsafeReference.TryGetTarget(out var taskUnsafe))
{
VersionStamp olderInputVersion;
(olderOutput, olderInputVersion) = await taskUnsafe.ConfigureAwait(false);
var (olderOutput, olderInputVersion) = await taskUnsafe.ConfigureAwait(false);
if (inputVersion.GetNewerVersion(olderInputVersion) == olderInputVersion)
{
// Nothing has changed, we can use the cached result.

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.LanguageServer.Protocol;
@ -20,75 +18,40 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
throw new ArgumentNullException(nameof(lspRequestMethodName));
}
switch (lspRequestMethodName)
return lspRequestMethodName switch
{
// Standard LSP capabilities
case Methods.TextDocumentImplementationName:
return CheckImplementationCapabilities;
case Methods.TextDocumentTypeDefinitionName:
return CheckTypeDefinitionCapabilities;
case Methods.TextDocumentReferencesName:
return CheckFindAllReferencesCapabilities;
case Methods.TextDocumentRenameName:
return CheckRenameCapabilities;
case Methods.TextDocumentSignatureHelpName:
return CheckSignatureHelpCapabilities;
case Methods.TextDocumentWillSaveName:
return CheckWillSaveCapabilities;
case Methods.TextDocumentWillSaveWaitUntilName:
return CheckWillSaveWaitUntilCapabilities;
case Methods.TextDocumentRangeFormattingName:
return CheckRangeFormattingCapabilities;
case Methods.WorkspaceSymbolName:
return CheckWorkspaceSymbolCapabilities;
case Methods.TextDocumentOnTypeFormattingName:
return CheckOnTypeFormattingCapabilities;
case Methods.TextDocumentFormattingName:
return CheckFormattingCapabilities;
case Methods.TextDocumentHoverName:
return CheckHoverCapabilities;
case Methods.TextDocumentCodeActionName:
return CheckCodeActionCapabilities;
case Methods.TextDocumentCodeLensName:
return CheckCodeLensCapabilities;
case Methods.TextDocumentCompletionName:
return CheckCompletionCapabilities;
case Methods.TextDocumentCompletionResolveName:
return CheckCompletionResolveCapabilities;
case Methods.TextDocumentDefinitionName:
return CheckDefinitionCapabilities;
case Methods.TextDocumentDocumentHighlightName:
return CheckHighlightCapabilities;
case "textDocument/semanticTokens":
case Methods.TextDocumentSemanticTokensFullName:
case Methods.TextDocumentSemanticTokensFullDeltaName:
case Methods.TextDocumentSemanticTokensRangeName:
return CheckSemanticTokensCapabilities;
case Methods.TextDocumentLinkedEditingRangeName:
return CheckLinkedEditingRangeCapabilities;
case Methods.CodeActionResolveName:
return CheckCodeActionResolveCapabilities;
case Methods.TextDocumentDocumentColorName:
return CheckDocumentColorCapabilities;
Methods.TextDocumentImplementationName => CheckImplementationCapabilities,
Methods.TextDocumentTypeDefinitionName => CheckTypeDefinitionCapabilities,
Methods.TextDocumentReferencesName => CheckFindAllReferencesCapabilities,
Methods.TextDocumentRenameName => CheckRenameCapabilities,
Methods.TextDocumentSignatureHelpName => CheckSignatureHelpCapabilities,
Methods.TextDocumentWillSaveName => CheckWillSaveCapabilities,
Methods.TextDocumentWillSaveWaitUntilName => CheckWillSaveWaitUntilCapabilities,
Methods.TextDocumentRangeFormattingName => CheckRangeFormattingCapabilities,
Methods.WorkspaceSymbolName => CheckWorkspaceSymbolCapabilities,
Methods.TextDocumentOnTypeFormattingName => CheckOnTypeFormattingCapabilities,
Methods.TextDocumentFormattingName => CheckFormattingCapabilities,
Methods.TextDocumentHoverName => CheckHoverCapabilities,
Methods.TextDocumentCodeActionName => CheckCodeActionCapabilities,
Methods.TextDocumentCodeLensName => CheckCodeLensCapabilities,
Methods.TextDocumentCompletionName => CheckCompletionCapabilities,
Methods.TextDocumentCompletionResolveName => CheckCompletionResolveCapabilities,
Methods.TextDocumentDefinitionName => CheckDefinitionCapabilities,
Methods.TextDocumentDocumentHighlightName => CheckHighlightCapabilities,
"textDocument/semanticTokens" or Methods.TextDocumentSemanticTokensFullName or Methods.TextDocumentSemanticTokensFullDeltaName or Methods.TextDocumentSemanticTokensRangeName => CheckSemanticTokensCapabilities,
Methods.TextDocumentLinkedEditingRangeName => CheckLinkedEditingRangeCapabilities,
Methods.CodeActionResolveName => CheckCodeActionResolveCapabilities,
Methods.TextDocumentDocumentColorName => CheckDocumentColorCapabilities,
// VS LSP Expansion capabilities
case VSMethods.GetProjectContextsName:
return CheckProjectContextsCapabilities;
case VSInternalMethods.DocumentReferencesName:
return CheckMSReferencesCapabilities;
case VSInternalMethods.OnAutoInsertName:
return CheckOnAutoInsertCapabilities;
case VSInternalMethods.DocumentPullDiagnosticName:
case VSInternalMethods.WorkspacePullDiagnosticName:
return CheckPullDiagnosticCapabilities;
case VSInternalMethods.TextDocumentTextPresentationName:
return CheckTextPresentationCapabilities;
case VSInternalMethods.TextDocumentUriPresentationName:
return CheckUriPresentationCapabilities;
default:
return FallbackCheckCapabilties;
}
VSMethods.GetProjectContextsName => CheckProjectContextsCapabilities,
VSInternalMethods.DocumentReferencesName => CheckMSReferencesCapabilities,
VSInternalMethods.OnAutoInsertName => CheckOnAutoInsertCapabilities,
VSInternalMethods.DocumentPullDiagnosticName or VSInternalMethods.WorkspacePullDiagnosticName => CheckPullDiagnosticCapabilities,
VSInternalMethods.TextDocumentTextPresentationName => CheckTextPresentationCapabilities,
VSInternalMethods.TextDocumentUriPresentationName => CheckUriPresentationCapabilities,
_ => FallbackCheckCapabilties,
};
}
private bool CheckDocumentColorCapabilities(JToken token)
@ -97,14 +60,14 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.DocumentColorProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckSemanticTokensCapabilities(JToken token)
{
var serverCapabilities = token.ToObject<VSServerCapabilities>();
return serverCapabilities?.SemanticTokensOptions != null;
return serverCapabilities?.SemanticTokensOptions is not null;
}
private static bool CheckImplementationCapabilities(JToken token)
@ -113,7 +76,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.ImplementationProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private bool CheckTypeDefinitionCapabilities(JToken token)
@ -122,7 +85,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.TypeDefinitionProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckFindAllReferencesCapabilities(JToken token)
@ -131,7 +94,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.ReferencesProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckRenameCapabilities(JToken token)
@ -140,14 +103,14 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.RenameProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckSignatureHelpCapabilities(JToken token)
{
var serverCapabilities = token.ToObject<ServerCapabilities>();
return serverCapabilities?.SignatureHelpProvider != null;
return serverCapabilities?.SignatureHelpProvider is not null;
}
private static bool CheckWillSaveCapabilities(JToken token)
@ -170,7 +133,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.DocumentRangeFormattingProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckWorkspaceSymbolCapabilities(JToken token)
@ -179,14 +142,14 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.WorkspaceSymbolProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckOnTypeFormattingCapabilities(JToken token)
{
var serverCapabilities = token.ToObject<ServerCapabilities>();
return serverCapabilities?.DocumentOnTypeFormattingProvider != null;
return serverCapabilities?.DocumentOnTypeFormattingProvider is not null;
}
private static bool CheckFormattingCapabilities(JToken token)
@ -195,7 +158,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.DocumentFormattingProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckHoverCapabilities(JToken token)
@ -204,7 +167,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.HoverProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckCodeActionCapabilities(JToken token)
@ -213,21 +176,21 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.CodeActionProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckCodeLensCapabilities(JToken token)
{
var serverCapabilities = token.ToObject<ServerCapabilities>();
return serverCapabilities?.CodeLensProvider != null;
return serverCapabilities?.CodeLensProvider is not null;
}
private static bool CheckCompletionCapabilities(JToken token)
{
var serverCapabilities = token.ToObject<ServerCapabilities>();
return serverCapabilities?.CompletionProvider != null;
return serverCapabilities?.CompletionProvider is not null;
}
private static bool CheckCompletionResolveCapabilities(JToken token)
@ -243,7 +206,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.DefinitionProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckHighlightCapabilities(JToken token)
@ -252,7 +215,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.DocumentHighlightProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckMSReferencesCapabilities(JToken token)
@ -284,7 +247,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
{
var serverCapabilities = token.ToObject<VSInternalServerCapabilities>();
return serverCapabilities?.OnAutoInsertProvider != null;
return serverCapabilities?.OnAutoInsertProvider is not null;
}
private static bool CheckTextPresentationCapabilities(JToken token)
@ -306,7 +269,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return serverCapabilities?.LinkedEditingRangeProvider?.Match(
boolValue => boolValue,
options => options != null) ?? false;
options => options is not null) ?? false;
}
private static bool CheckPullDiagnosticCapabilities(JToken token)

Просмотреть файл

@ -1,10 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Microsoft.VisualStudio.Text;
@ -71,14 +70,14 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return uri;
}
public override bool TryGet(ITextBuffer textBuffer, out Uri uri)
public override bool TryGet(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Uri? uri)
{
if (textBuffer is null)
{
throw new ArgumentNullException(nameof(textBuffer));
}
if (textBuffer.Properties.TryGetProperty(TextBufferUri, out uri))
if (textBuffer.Properties.TryGetProperty(TextBufferUri, out uri!))
{
return true;
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
@ -11,7 +9,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
{
internal class DefaultLSPDocument : LSPDocument
{
private LSPDocumentSnapshot _currentSnapshot;
private LSPDocumentSnapshot? _currentSnapshot;
public DefaultLSPDocument(
Uri uri,
@ -54,7 +52,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
{
// TextBuffer is tearing itself down, return last known snapshot to avoid generating
// a snapshot for an invalid TextBuffer
return _currentSnapshot;
return _currentSnapshot!;
}
if (_currentSnapshot?.Snapshot != TextBuffer.CurrentSnapshot)
@ -66,7 +64,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
}
public override LSPDocumentSnapshot UpdateVirtualDocument<TVirtualDocument>(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object state)
public override LSPDocumentSnapshot UpdateVirtualDocument<TVirtualDocument>(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object? state)
{
if (!TryGetVirtualDocument<TVirtualDocument>(out var virtualDocument))
{

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Composition;

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Composition;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Threading;
@ -125,7 +124,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
Uri hostDocumentUri,
IReadOnlyList<ITextChange> changes,
int hostDocumentVersion,
object state)
object? state)
{
if (hostDocumentUri is null)
{
@ -145,8 +144,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return;
}
var virtualDocumentAcquired = lspDocument.TryGetVirtualDocument<TVirtualDocument>(out var virtualDocument);
if (!virtualDocumentAcquired)
if (!lspDocument.TryGetVirtualDocument<TVirtualDocument>(out var virtualDocument))
{
// Unable to locate virtual document of typeof(TVirtualDocument)
// Ex. Microsoft.WebTools.Languages.LanguageServer.Delegation.ContainedLanguage.Css.CssVirtualDocument
@ -179,7 +177,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
NotifyDocumentManagerChangeListeners(old, @new, oldVirtual, newVirtual, LSPDocumentChangeKind.VirtualDocumentChanged);
}
public override bool TryGetDocument(Uri uri, out LSPDocumentSnapshot lspDocumentSnapshot)
public override bool TryGetDocument(Uri uri, [NotNullWhen(returnValue: true)] out LSPDocumentSnapshot? lspDocumentSnapshot)
{
if (!_documents.TryGetValue(uri, out var lspDocument))
{
@ -193,23 +191,23 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
private void NotifyDocumentManagerChangeListeners(
LSPDocumentSnapshot old,
LSPDocumentSnapshot @new,
VirtualDocumentSnapshot virtualOld,
VirtualDocumentSnapshot virtualNew,
LSPDocumentSnapshot? old,
LSPDocumentSnapshot? @new,
VirtualDocumentSnapshot? virtualOld,
VirtualDocumentSnapshot? virtualNew,
LSPDocumentChangeKind kind)
{
foreach (var listener in _documentManagerChangeListeners)
{
var notifyListener = false;
if (old != null &&
listener.Metadata.ContentTypes.Any(ct => old.Snapshot.ContentType.IsOfType(ct)))
if (old is not null &&
listener.Metadata.ContentTypes.Any(old.Snapshot.ContentType.IsOfType))
{
notifyListener = true;
}
else if (@new != null &&
listener.Metadata.ContentTypes.Any(ct => @new.Snapshot.ContentType.IsOfType(ct)))
else if (@new is not null &&
listener.Metadata.ContentTypes.Any(@new.Snapshot.ContentType.IsOfType))
{
notifyListener = true;
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
@ -99,13 +97,13 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
}
public override void Changed(LSPDocumentSnapshot old, LSPDocumentSnapshot @new, VirtualDocumentSnapshot virtualOld, VirtualDocumentSnapshot virtualNew, LSPDocumentChangeKind kind)
public override void Changed(LSPDocumentSnapshot? old, LSPDocumentSnapshot? @new, VirtualDocumentSnapshot? virtualOld, VirtualDocumentSnapshot? virtualNew, LSPDocumentChangeKind kind)
{
lock (_documentContextLock)
{
if (kind == LSPDocumentChangeKind.Added)
{
var lspDocument = @new;
var lspDocument = @new!;
for (var i = 0; i < lspDocument.VirtualDocuments.Count; i++)
{
var virtualDocument = lspDocument.VirtualDocuments[i];
@ -119,7 +117,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
else if (kind == LSPDocumentChangeKind.Removed)
{
var lspDocument = old;
var lspDocument = old!;
for (var i = 0; i < lspDocument.VirtualDocuments.Count; i++)
{
var virtualDocument = lspDocument.VirtualDocuments[i];
@ -139,7 +137,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
}
else if (kind == LSPDocumentChangeKind.VirtualDocumentChanged)
{
if (virtualOld.Snapshot.Version == virtualNew.Snapshot.Version)
if (virtualOld!.Snapshot.Version == virtualNew!.Snapshot.Version)
{
// UpdateDocumentContextVersionInternal is typically invoked through a buffer notification,
// however in the case where VirtualDocumentBase.Update is called with a zero change edit,

Просмотреть файл

@ -1,34 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Runtime.InteropServices;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Extensions
{
internal static class LSPDocumentManagerExtensions
{
public static bool TryGetDocument(this LSPDocumentManager documentManager, string filePath, out LSPDocumentSnapshot lspDocumentSnapshot)
{
if (documentManager is null)
{
throw new ArgumentNullException(nameof(documentManager));
}
if (filePath is null)
{
throw new ArgumentNullException(nameof(filePath));
}
if (filePath.StartsWith("/", StringComparison.Ordinal) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
filePath = filePath.Substring(1);
}
var uri = new Uri(filePath, UriKind.Absolute);
return documentManager.TryGetDocument(uri, out lspDocumentSnapshot);
}
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.Text;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Net;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Newtonsoft.Json.Linq;

Просмотреть файл

@ -1,9 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
@ -29,7 +28,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
/// <param name="textBuffer">A text buffer</param>
/// <param name="uri">A <see cref="Uri"/> that can be used to locate the provided <paramref name="textBuffer"/>.</param>
/// <returns><c>true</c> if a Razor based <see cref="Uri"/> existed on the buffer, other wise <c>false</c>.</returns>
public abstract bool TryGet(ITextBuffer textBuffer, out Uri uri);
public abstract bool TryGet(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Uri? uri);
/// <summary>
/// Adds or updates the provided <paramref name="uri"/> for the given <paramref name="textBuffer"/> under a Razor property name.

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@ -22,9 +20,9 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
public abstract IReadOnlyList<VirtualDocument> VirtualDocuments { get; }
public abstract LSPDocumentSnapshot UpdateVirtualDocument<TVirtualDocument>(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object state) where TVirtualDocument : VirtualDocument;
public abstract LSPDocumentSnapshot UpdateVirtualDocument<TVirtualDocument>(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object? state) where TVirtualDocument : VirtualDocument;
public bool TryGetVirtualDocument<TVirtualDocument>(out TVirtualDocument virtualDocument) where TVirtualDocument : VirtualDocument
public bool TryGetVirtualDocument<TVirtualDocument>([NotNullWhen(returnValue: true)] out TVirtualDocument? virtualDocument) where TVirtualDocument : VirtualDocument
{
for (var i = 0; i < VirtualDocuments.Count; i++)
{

Просмотреть файл

@ -1,17 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
{
internal abstract class LSPDocumentChangeListener
{
public abstract void Changed(
LSPDocumentSnapshot old,
LSPDocumentSnapshot @new,
VirtualDocumentSnapshot virtualOld,
VirtualDocumentSnapshot virtualNew,
LSPDocumentSnapshot? old,
LSPDocumentSnapshot? @new,
VirtualDocumentSnapshot? virtualOld,
VirtualDocumentSnapshot? virtualNew,
LSPDocumentChangeKind kind);
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage

Просмотреть файл

@ -1,14 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
{
public abstract class LSPDocumentManager
{
public abstract bool TryGetDocument(Uri uri, out LSPDocumentSnapshot lspDocumentSnapshot);
public abstract bool TryGetDocument(Uri uri, [NotNullWhen(returnValue: true)] out LSPDocumentSnapshot? lspDocumentSnapshot);
}
}

Просмотреть файл

@ -1,10 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
@ -19,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
public abstract IReadOnlyList<VirtualDocumentSnapshot> VirtualDocuments { get; }
public bool TryGetVirtualDocument<TVirtualDocument>(out TVirtualDocument virtualDocument) where TVirtualDocument : VirtualDocumentSnapshot
public bool TryGetVirtualDocument<TVirtualDocument>([NotNullWhen(returnValue: true)] out TVirtualDocument? virtualDocument) where TVirtualDocument : VirtualDocumentSnapshot
{
for (var i = 0; i < VirtualDocuments.Count; i++)
{

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;

Просмотреть файл

@ -15,4 +15,8 @@
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Client.Implementation" Version="$(MicrosoftVisualStudioLanguageServerClientImplementationPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Common\Microsoft.AspNetCore.Razor.Common.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
@ -19,6 +17,6 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
Uri hostDocumentUri,
IReadOnlyList<ITextChange> changes,
int hostDocumentVersion,
object state) where TVirtualDocument : VirtualDocument;
object? state) where TVirtualDocument : VirtualDocument;
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
@ -19,7 +17,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
public abstract int HostDocumentVersion { get; }
public abstract VirtualDocumentSnapshot Update(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object state);
public abstract VirtualDocumentSnapshot Update(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object? state);
public abstract void Dispose();
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@ -41,7 +39,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
public override VirtualDocumentSnapshot CurrentSnapshot => _currentSnapshot;
public override VirtualDocumentSnapshot Update(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object state)
public override VirtualDocumentSnapshot Update(IReadOnlyList<ITextChange> changes, int hostDocumentVersion, object? state)
{
if (changes is null)
{
@ -64,7 +62,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
return _currentSnapshot;
}
protected abstract T GetUpdatedSnapshot(object state);
protected abstract T GetUpdatedSnapshot(object? state);
[SuppressMessage("Usage", "CA1816:Dispose methods should call SuppressFinalize", Justification = "https://github.com/dotnet/roslyn-analyzers/issues/4801")]
public override void Dispose()

Просмотреть файл

@ -1,8 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
@ -21,6 +20,6 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
/// <param name="virtualDocument">The resultant <see cref="VirtualDocument"/> for the top-level <paramref name="hostDocumentBuffer"/>.</param>
/// <returns><c>true</c> if a <see cref="VirtualDocument"/> could be created, <c>false</c> otherwise. A result of <c>false</c> typically indicates
/// that a <see cref="VirtualDocumentFactory"/> was not meant to be called for the given <paramref name="hostDocumentBuffer"/>.</returns>
public abstract bool TryCreateFor(ITextBuffer hostDocumentBuffer, out VirtualDocument virtualDocument);
public abstract bool TryCreateFor(ITextBuffer hostDocumentBuffer, [NotNullWhen(returnValue: true)] out VirtualDocument? virtualDocument);
}
}

Просмотреть файл

@ -1,10 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage.Extensions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
@ -60,7 +59,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
protected abstract IContentType LanguageContentType { get; }
public override bool TryCreateFor(ITextBuffer hostDocumentBuffer, out VirtualDocument virtualDocument)
public override bool TryCreateFor(ITextBuffer hostDocumentBuffer, [NotNullWhen(returnValue: true)] out VirtualDocument? virtualDocument)
{
if (hostDocumentBuffer is null)
{
@ -119,7 +118,7 @@ namespace Microsoft.VisualStudio.LanguageServer.ContainedLanguage
/// <summary>
/// Returns additional properties (if any) to set on the language text buffer prior to language server init
/// </summary>
protected virtual IReadOnlyDictionary<object, object> LanguageBufferProperties => null;
protected virtual IReadOnlyDictionary<object, object>? LanguageBufferProperties => null;
/// <summary>
/// Returns supported host document content type name (i.e. host document content type for which this factory can create virtual documents)

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.Text;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Text;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Utilities;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
@ -101,7 +99,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
return new ExcerptResultInternal(excerptText, razorDocumentSpan, classifiedSpans.ToImmutable(), document, span);
}
private async Task<ImmutableArray<ClassifiedSpan>.Builder> ClassifyPreviewAsync(
private static async Task<ImmutableArray<ClassifiedSpan>.Builder> ClassifyPreviewAsync(
TextSpan razorSpan,
TextSpan excerptSpan,
TextSpan generatedSpan,

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
namespace Microsoft.VisualStudio.LanguageServerClient.Razor
@ -21,6 +19,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
public bool DesignTimeOnly => false;
public string DiagnosticsLspClientName => RoslynRazorLanguageServerClientName;
public string? DiagnosticsLspClientName => RoslynRazorLanguageServerClientName;
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.Text;
@ -15,6 +13,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
{
}
protected override CSharpVirtualDocumentSnapshot GetUpdatedSnapshot(object state) => new(Uri, TextBuffer.CurrentSnapshot, HostDocumentVersion);
protected override CSharpVirtualDocumentSnapshot GetUpdatedSnapshot(object? state) => new(Uri, TextBuffer.CurrentSnapshot, HostDocumentVersion);
}
}

Просмотреть файл

@ -55,7 +55,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
protected override string HostDocumentContentTypeName => RazorConstants.RazorLSPContentTypeName;
protected override string LanguageFileNameSuffix => _languageServerFeatureOptions.CSharpVirtualDocumentSuffix;
protected override IReadOnlyDictionary<object, object> LanguageBufferProperties => s_languageBufferProperties;
protected override IReadOnlyDictionary<object, object>? LanguageBufferProperties => s_languageBufferProperties;
protected override VirtualDocument CreateVirtualDocument(Uri uri, ITextBuffer textBuffer) => new CSharpVirtualDocument(uri, textBuffer);
private class RemoteContentDefinitionType : IContentType

Просмотреть файл

@ -43,7 +43,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
}
// Internal for testing
public override void Changed(LSPDocumentSnapshot old, LSPDocumentSnapshot @new, VirtualDocumentSnapshot virtualOld, VirtualDocumentSnapshot virtualNew, LSPDocumentChangeKind kind)
public override void Changed(LSPDocumentSnapshot? old, LSPDocumentSnapshot? @new, VirtualDocumentSnapshot? virtualOld, VirtualDocumentSnapshot? virtualNew, LSPDocumentChangeKind kind)
{
// We need the below check to address a race condition between when a request is sent to the C# server
// for a generated document and when the C# server receives a document/didOpen notification. This race
@ -54,7 +54,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
// workaround until a longer-term solution is implemented in the future.
if (kind == LSPDocumentChangeKind.Added && _dynamicFileInfoProvider is DefaultRazorDynamicFileInfoProvider defaultProvider)
{
defaultProvider.PromoteBackgroundDocument(@new.Uri, CSharpDocumentPropertiesService.Instance);
defaultProvider.PromoteBackgroundDocument(@new!.Uri, CSharpDocumentPropertiesService.Instance);
}
if (kind != LSPDocumentChangeKind.VirtualDocumentChanged)
@ -64,8 +64,8 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
if (virtualNew is CSharpVirtualDocumentSnapshot)
{
var csharpContainer = new CSharpVirtualDocumentContainer(_lspDocumentMappingProvider, @new, virtualNew.Snapshot);
_dynamicFileInfoProvider.UpdateLSPFileInfo(@new.Uri, csharpContainer);
var csharpContainer = new CSharpVirtualDocumentContainer(_lspDocumentMappingProvider, @new!, virtualNew.Snapshot);
_dynamicFileInfoProvider.UpdateLSPFileInfo(@new!.Uri, csharpContainer);
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.Text;

Просмотреть файл

@ -50,11 +50,8 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Debugging
syntaxTree = await document!.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
}
if (syntaxTree is null)
{
// Couldn't find the document in the workspace OR the version in the workspace couldn't have its syntax tree computed.
syntaxTree = CreateSyntaxTreeFromSnapshot(virtualDocument.Snapshot, cancellationToken);
}
// Couldn't find the document in the workspace OR the version in the workspace couldn't have its syntax tree computed.
syntaxTree ??= CreateSyntaxTreeFromSnapshot(virtualDocument.Snapshot, cancellationToken);
return syntaxTree;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.LanguageServer.Protocol;
@ -10,8 +8,8 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Debugging
{
internal class RazorBreakpointSpanParams
{
public Uri Uri { get; set; }
public required Uri Uri { get; init; }
public Position Position { get; set; }
public required Position Position { get; init; }
}
}

Просмотреть файл

@ -1,13 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Debugging
{
internal class RazorBreakpointSpanResponse
{
public Range Range { get; set; }
public required Range Range { get; init; }
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.LanguageServer.Protocol;
@ -10,8 +8,8 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Debugging
{
internal class RazorProximityExpressionsParams
{
public Uri Uri { get; set; }
public required Uri Uri { get; init; }
public Position Position { get; set; }
public required Position Position { get; init; }
}
}

Просмотреть файл

@ -1,14 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.Collections.Generic;
namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Debugging
{
internal class RazorProximityExpressionsResponse
{
public IReadOnlyList<string> Expressions { get; set; }
public required IReadOnlyList<string> Expressions { get; init; }
}
}

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
@ -79,7 +80,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
Changed?.Invoke(this, args);
}
public override bool TryGet(string projectFilePath, out string configurationFilePath)
public override bool TryGet(string projectFilePath, [NotNullWhen(returnValue: true)] out string? configurationFilePath)
{
if (projectFilePath is null)
{

Просмотреть файл

@ -44,8 +44,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
private readonly EditorSettingsManager _editorSettingsManager;
private readonly LSPDocumentSynchronizer _documentSynchronizer;
private const string RazorReadyFeature = "Razor-Initialization";
[ImportingConstructor]
public DefaultRazorLanguageServerCustomMessageTarget(
LSPDocumentManager documentManager,
@ -130,7 +128,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var hostDocumentUri = new Uri(request.HostDocumentFilePath);
_documentManager.UpdateVirtualDocument<CSharpVirtualDocument>(
hostDocumentUri,
request.Changes?.Select(change => change.ToVisualStudioTextChange()).ToArray(),
request.Changes.Select(change => change.ToVisualStudioTextChange()).ToArray(),
request.HostDocumentVersion.Value,
state: null);
}
@ -158,7 +156,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
var hostDocumentUri = new Uri(request.HostDocumentFilePath);
_documentManager.UpdateVirtualDocument<HtmlVirtualDocument>(
hostDocumentUri,
request.Changes?.Select(change => change.ToVisualStudioTextChange()).ToArray(),
request.Changes.Select(change => change.ToVisualStudioTextChange()).ToArray(),
request.HostDocumentVersion.Value,
state: null);
}
@ -873,7 +871,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
{
await _joinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
var provisionalChange = new VisualStudioTextChange(request.ProvisionalTextEdit, virtualDocumentSnapshot.Snapshot);
var provisionalChange = new VisualStudioTextChange(provisionalTextEdit, virtualDocumentSnapshot.Snapshot);
UpdateVirtualDocument(provisionalChange, request.ProjectedKind, request.HostDocument.Version, documentSnapshot.Uri);
// We want the delegation to continue on the captured context because we're currently on the `main` thread and we need to get back to the
@ -1065,6 +1063,32 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor
return response?.Response;
}
public override async Task<Range?> ValidateBreakpointRangeAsync(DelegatedValidateBreakpointRangeParams request, CancellationToken cancellationToken)
{
var delegationDetails = await GetProjectedRequestDetailsAsync(request, cancellationToken).ConfigureAwait(false);
if (delegationDetails is null)
{
return default;
}
var validateBreakpointRangeParams = new VSInternalValidateBreakableRangeParams
{
TextDocument = new TextDocumentIdentifier()
{
Uri = delegationDetails.Value.ProjectedUri,
},
Range = request.ProjectedRange
};
var response = await _requestInvoker.ReinvokeRequestOnServerAsync<VSInternalValidateBreakableRangeParams, Range?>(
delegationDetails.Value.TextBuffer,
VSInternalMethods.TextDocumentValidateBreakableRangeName,
delegationDetails.Value.LanguageServerName,
validateBreakpointRangeParams,
cancellationToken).ConfigureAwait(false);
return response?.Response;
}
public override Task<VSInternalHover?> HoverAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
=> DelegateTextDocumentPositionRequestAsync<VSInternalHover>(request, Methods.TextDocumentHoverName, cancellationToken);

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Diagnostics;
using Microsoft.VisualStudio.Text;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
@ -14,7 +12,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.Extensions
internal static class TextChangeExtensions
{
public static ITextChange ToVisualStudioTextChange(this TextChange roslynTextChange) =>
new VisualStudioTextChange(roslynTextChange.Span.Start, roslynTextChange.Span.Length, roslynTextChange.NewText);
new VisualStudioTextChange(roslynTextChange.Span.Start, roslynTextChange.Span.Length, roslynTextChange.NewText!);
public static TextEdit AsTextEdit(this TextChange textChange, SourceText sourceText)
{

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.AspNetCore.Razor.LanguageServer.Extensions;
using Microsoft.CodeAnalysis.Text;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.Text.Adornments;

Просмотреть файл

@ -1,17 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using Newtonsoft.Json;
namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
{
internal class CompletionResolveData
{
public long ResultId { get; set; }
public required long ResultId { get; init; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public object OriginalData { get; set; }
public required object OriginalData { get; init; }
}
}

Просмотреть файл

@ -214,7 +214,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
continue;
}
_logger.LogInformation("Returning {diagnosticsLength} diagnostics.", processedDiagnostics.Diagnostics.Length);
_logger.LogInformation("Returning {diagnosticsLength} diagnostics.", processedDiagnostics.Diagnostics?.Length ?? 0);
diagnosticReport.Diagnostics = processedDiagnostics.Diagnostics;
mappedDiagnosticReports.Add(diagnosticReport);

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Composition;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Composition;
@ -91,7 +89,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
}
// Internal for testing
internal async override Task<VSInternalReferenceItem[]> HandleRequestAsync(ReferenceParams request, ClientCapabilities clientCapabilities, string token, CancellationToken cancellationToken)
internal async override Task<VSInternalReferenceItem[]?> HandleRequestAsync(ReferenceParams request, ClientCapabilities clientCapabilities, string token, CancellationToken cancellationToken)
{
if (request is null)
{
@ -278,7 +276,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
return remappedLocations.ToArray();
}
private static object FilterReferenceDisplayText(object referenceText)
private static object? FilterReferenceDisplayText(object? referenceText)
{
const string CodeBehindObjectPrefix = "__o = ";
const string CodeBehindBackingFieldSuffix = "k__BackingField";
@ -330,10 +328,10 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
private class SerializableReferenceParams : TextDocumentPositionParams
{
[DataMember(Name = "context")]
public ReferenceContext Context { get; set; }
public required ReferenceContext Context { get; init; }
[DataMember(Name = "partialResultToken")]
public string PartialResultToken { get; set; }
public required string PartialResultToken { get; init; }
}
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
{
internal interface IRequestHandlerMetadata

Просмотреть файл

@ -16,6 +16,6 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
Func<JToken, CancellationToken, Task> onProgressNotifyAsync,
Func<CancellationToken, Task> delayAfterLastNotifyAsync,
CancellationToken handlerCancellationToken,
[NotNullWhen(true)] out Task? onCompleted);
[NotNullWhen(returnValue: true)] out Task? onCompleted);
}
}

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using System.Threading;
using System.Threading.Tasks;
@ -23,7 +21,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
/// </summary>
private protected CancellationToken ImmediateNotificationTimeout { get; private set; }
public async Task<TResult> HandleRequestAsync(TParams requestParams, ClientCapabilities clientCapabilities, CancellationToken cancellationToken)
public async Task<TResult?> HandleRequestAsync(TParams requestParams, ClientCapabilities clientCapabilities, CancellationToken cancellationToken)
{
// Temporary till IProgress serialization is fixed
var token = Guid.NewGuid().ToString(); // request.PartialResultToken.Id
@ -31,7 +29,7 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
}
// Internal for testing
internal abstract Task<TResult> HandleRequestAsync(TParams request, ClientCapabilities clientCapabilities, string token, CancellationToken cancellationToken);
internal abstract Task<TResult?> HandleRequestAsync(TParams request, ClientCapabilities clientCapabilities, string token, CancellationToken cancellationToken);
internal TestAccessor GetTestAccessor()
=> new(this);

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.VisualStudio.Editor.Razor;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;

Просмотреть файл

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
#nullable disable
using System;
using Microsoft.AspNetCore.Razor.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServer.Protocol;
@ -11,14 +9,14 @@ namespace Microsoft.VisualStudio.LanguageServerClient.Razor.HtmlCSharp
{
internal class ProjectionResult
{
public Uri Uri { get; set; }
public required Uri Uri { get; init; }
public Position Position { get; set; }
public required Position Position { get; init; }
public int PositionIndex { get; set; }
public int PositionIndex { get; init; }
public RazorLanguageKind LanguageKind { get; set; }
public RazorLanguageKind LanguageKind { get; init; }
public int? HostDocumentVersion { get; set; }
public int? HostDocumentVersion { get; init; }
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше