зеркало из https://github.com/dotnet/razor.git
Merge branch 'main' of github.com:dotnet/razor-tooling into features/CLaSP
This commit is contained in:
Коммит
c1b73814e6
|
@ -32,7 +32,7 @@ stages:
|
|||
- job: Windows
|
||||
pool:
|
||||
name: NetCore-Public
|
||||
demands: ImageOverride -equals build.windows.10.amd64.vs2019.pre.open
|
||||
demands: ImageOverride -equals windows.vs2019.amd64.open
|
||||
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
|
|
|
@ -65,10 +65,10 @@ stages:
|
|||
pool:
|
||||
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
||||
name: NetCore-Public
|
||||
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
|
||||
demands: ImageOverride -equals windows.vs2022preview.amd64.open
|
||||
${{ if ne(variables['System.TeamProject'], 'public') }}:
|
||||
name: NetCore1ESPool-Internal
|
||||
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Main
|
||||
demands: ImageOverride -equals windows.vs2022preview.amd64
|
||||
steps:
|
||||
- task: NodeTool@0
|
||||
displayName: Install Node 10.x
|
||||
|
@ -111,10 +111,10 @@ stages:
|
|||
pool:
|
||||
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
||||
name: NetCore-Public
|
||||
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
|
||||
demands: ImageOverride -equals windows.vs2022preview.amd64.open
|
||||
${{ if ne(variables['System.TeamProject'], 'public') }}:
|
||||
name: NetCore1ESPool-Internal
|
||||
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre
|
||||
demands: ImageOverride -equals windows.vs2022preview.amd64
|
||||
strategy:
|
||||
matrix:
|
||||
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
||||
|
@ -363,7 +363,7 @@ stages:
|
|||
options: --init # This ensures all the stray defunct processes are reaped.
|
||||
pool:
|
||||
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
||||
vmImage: ubuntu-18.04
|
||||
vmImage: ubuntu-latest
|
||||
${{ if eq(variables['System.TeamProject'], 'internal') }}:
|
||||
name: NetCore1ESPool-Internal
|
||||
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64
|
||||
|
|
|
@ -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.22462.4">
|
||||
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.22473.1">
|
||||
<Uri>https://github.com/dotnet/arcade</Uri>
|
||||
<Sha>91db46836065516e87e05bbdb51c5aee0f90428c</Sha>
|
||||
<Sha>ba4d2568dd2e3e7538feeaba60215f7bcb99e89c</Sha>
|
||||
</Dependency>
|
||||
</ToolsetDependencies>
|
||||
</Dependencies>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<MicrosoftVisualStudioShellPackagesVersion>17.2.32330.158</MicrosoftVisualStudioShellPackagesVersion>
|
||||
<MicrosoftVisualStudioPackagesVersion>17.3.133-preview</MicrosoftVisualStudioPackagesVersion>
|
||||
<RoslynPackageVersion>4.4.0-2.22424.2</RoslynPackageVersion>
|
||||
<VisualStudioLanguageServerProtocolVersion>17.4.1004-preview</VisualStudioLanguageServerProtocolVersion>
|
||||
<VisualStudioLanguageServerProtocolVersion>17.4.1008-preview</VisualStudioLanguageServerProtocolVersion>
|
||||
<MicrosoftNetCompilersToolsetVersion>4.4.0-1.final</MicrosoftNetCompilersToolsetVersion>
|
||||
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.4.0-3.22463.10</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
|
||||
</PropertyGroup>
|
||||
|
@ -111,6 +111,7 @@
|
|||
<MicrosoftVisualStudioInteropPackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioInteropPackageVersion>
|
||||
<MicrosoftInternalVisualStudioInteropPackageVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftInternalVisualStudioInteropPackageVersion>
|
||||
<MicrosoftVisualStudioRpcContractsPackageVersion>17.3.3-alpha</MicrosoftVisualStudioRpcContractsPackageVersion>
|
||||
<MicrosoftVisualStudioTelemetryVersion>16.4.137</MicrosoftVisualStudioTelemetryVersion>
|
||||
<MicrosoftVisualStudioTextDataPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextDataPackageVersion>
|
||||
<MicrosoftVisualStudioTextImplementationPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextImplementationPackageVersion>
|
||||
<MicrosoftVisualStudioTextLogicPackageVersion>$(MicrosoftVisualStudioPackagesVersion)</MicrosoftVisualStudioTextLogicPackageVersion>
|
||||
|
|
|
@ -26,6 +26,7 @@ Param(
|
|||
[string] $runtimeSourceFeed = '',
|
||||
[string] $runtimeSourceFeedKey = '',
|
||||
[switch] $excludePrereleaseVS,
|
||||
[switch] $nativeToolsOnMachine,
|
||||
[switch] $help,
|
||||
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
|
||||
)
|
||||
|
@ -67,6 +68,7 @@ function Print-Usage() {
|
|||
Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
|
||||
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
|
||||
Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio"
|
||||
Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine)"
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "Command line arguments not listed above are passed thru to msbuild."
|
||||
|
@ -146,6 +148,9 @@ try {
|
|||
$nodeReuse = $false
|
||||
}
|
||||
|
||||
if ($nativeToolsOnMachine) {
|
||||
$env:NativeToolsOnMachine = $true
|
||||
}
|
||||
if ($restore) {
|
||||
InitializeNativeTools
|
||||
}
|
||||
|
|
|
@ -98,11 +98,12 @@ try {
|
|||
Write-Error "Arcade tools directory '$ArcadeToolsDirectory' was not found; artifacts were not properly installed."
|
||||
exit 1
|
||||
}
|
||||
$ToolDirectory = (Get-ChildItem -Path "$ArcadeToolsDirectory" -Filter "$ToolName-$ToolVersion*" | Sort-Object -Descending)[0]
|
||||
if ([string]::IsNullOrWhiteSpace($ToolDirectory)) {
|
||||
$ToolDirectories = (Get-ChildItem -Path "$ArcadeToolsDirectory" -Filter "$ToolName-$ToolVersion*" | Sort-Object -Descending)
|
||||
if ($ToolDirectories -eq $null) {
|
||||
Write-Error "Unable to find directory for $ToolName $ToolVersion; please make sure the tool is installed on this image."
|
||||
exit 1
|
||||
}
|
||||
$ToolDirectory = $ToolDirectories[0]
|
||||
$BinPathFile = "$($ToolDirectory.FullName)\binpath.txt"
|
||||
if (-not (Test-Path -Path "$BinPathFile")) {
|
||||
Write-Error "Unable to find binpath.txt in '$($ToolDirectory.FullName)' ($ToolName $ToolVersion); artifact is either installed incorrectly or is not a bootstrappable tool."
|
||||
|
|
|
@ -59,7 +59,9 @@ jobs:
|
|||
- checkout: self
|
||||
clean: true
|
||||
|
||||
- template: /eng/common/templates/post-build/setup-maestro-vars.yml
|
||||
# If the template caller didn't provide an AzDO parameter, set them all up as Maestro vars.
|
||||
- ${{ if not(and(parameters.AzDOProjectName, parameters.AzDOPipelineId, parameters.AzDOBuildId)) }}:
|
||||
- template: /eng/common/templates/post-build/setup-maestro-vars.yml
|
||||
|
||||
- ${{ if ne(parameters.downloadArtifacts, 'false')}}:
|
||||
- ${{ if ne(parameters.artifactNames, '') }}:
|
||||
|
|
|
@ -140,6 +140,7 @@ jobs:
|
|||
languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }}
|
||||
environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }}
|
||||
richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin
|
||||
uploadRichNavArtifacts: ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }}
|
||||
continueOnError: true
|
||||
|
||||
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), ne(parameters.disableComponentGovernance, 'true')) }}:
|
||||
|
@ -183,24 +184,6 @@ jobs:
|
|||
displayName: Publish logs
|
||||
continueOnError: true
|
||||
condition: always()
|
||||
- ${{ if or(eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, '')) }}:
|
||||
- ${{ if and(ne(parameters.enablePublishUsingPipelines, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
|
||||
- task: CopyFiles@2
|
||||
displayName: Gather Asset Manifests
|
||||
inputs:
|
||||
SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest'
|
||||
TargetFolder: '$(Build.ArtifactStagingDirectory)/AssetManifests'
|
||||
continueOnError: ${{ parameters.continueOnError }}
|
||||
condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true'))
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
displayName: Push Asset Manifests
|
||||
inputs:
|
||||
PathtoPublish: '$(Build.ArtifactStagingDirectory)/AssetManifests'
|
||||
PublishLocation: Container
|
||||
ArtifactName: AssetManifests
|
||||
continueOnError: ${{ parameters.continueOnError }}
|
||||
condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true'))
|
||||
|
||||
- ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}:
|
||||
- task: PublishBuildArtifacts@1
|
||||
|
@ -234,24 +217,6 @@ jobs:
|
|||
mergeTestResults: ${{ parameters.mergeTestResults }}
|
||||
continueOnError: true
|
||||
condition: always()
|
||||
|
||||
- ${{ if and(eq(parameters.enablePublishBuildAssets, true), ne(parameters.enablePublishUsingPipelines, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
|
||||
- task: CopyFiles@2
|
||||
displayName: Gather Asset Manifests
|
||||
inputs:
|
||||
SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest'
|
||||
TargetFolder: '$(Build.StagingDirectory)/AssetManifests'
|
||||
continueOnError: ${{ parameters.continueOnError }}
|
||||
condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true'))
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
displayName: Push Asset Manifests
|
||||
inputs:
|
||||
PathtoPublish: '$(Build.StagingDirectory)/AssetManifests'
|
||||
PublishLocation: Container
|
||||
ArtifactName: AssetManifests
|
||||
continueOnError: ${{ parameters.continueOnError }}
|
||||
condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true'))
|
||||
|
||||
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}:
|
||||
- template: /eng/common/templates/steps/generate-sbom.yml
|
||||
|
|
|
@ -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-7-3e800f1-20190501005343'
|
||||
container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8-20220809204800-17a4aab'
|
||||
|
||||
# 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,
|
||||
|
|
|
@ -68,6 +68,11 @@ steps:
|
|||
publishArgs='--publish'
|
||||
fi
|
||||
|
||||
assetManifestFileName=SourceBuild_RidSpecific.xml
|
||||
if [ '${{ parameters.platform.name }}' != '' ]; then
|
||||
assetManifestFileName=SourceBuild_${{ parameters.platform.name }}.xml
|
||||
fi
|
||||
|
||||
${{ coalesce(parameters.platform.buildScript, './build.sh') }} --ci \
|
||||
--configuration $buildConfig \
|
||||
--restore --build --pack $publishArgs -bl \
|
||||
|
@ -76,7 +81,8 @@ steps:
|
|||
$internalRestoreArgs \
|
||||
$targetRidArgs \
|
||||
/p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \
|
||||
/p:ArcadeBuildFromSource=true
|
||||
/p:ArcadeBuildFromSource=true \
|
||||
/p:AssetManifestFileName=$assetManifestFileName
|
||||
displayName: Build
|
||||
|
||||
# Upload build logs for diagnosis.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"tools": {
|
||||
"dotnet": "7.0.100-preview.7.22377.5",
|
||||
"dotnet": "7.0.100-rc.1.22431.12",
|
||||
"runtimes": {
|
||||
"dotnet": [
|
||||
"2.1.11",
|
||||
|
@ -16,10 +16,10 @@
|
|||
}
|
||||
},
|
||||
"sdk": {
|
||||
"version": "7.0.100-preview.7.22377.5"
|
||||
"version": "7.0.100-rc.1.22431.12"
|
||||
},
|
||||
"msbuild-sdks": {
|
||||
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22462.4",
|
||||
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22473.1",
|
||||
"Yarn.MSBuild": "1.22.10"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion)"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Internal.Transport" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsVersion1_XInternalTransportPackageVersion)"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Internal.Transport" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsVersion2_XInternalTransportPackageVersion)"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Internal.Transport" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsVersion1_XInternalTransportPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.Internal.Transport" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsVersion2_XInternalTransportPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.VisualStudio.Telemetry;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common.Telemetry
|
||||
{
|
||||
internal interface ITelemetryReporter
|
||||
{
|
||||
void ReportEvent(string name, TelemetrySeverity severity);
|
||||
}
|
||||
}
|
|
@ -112,6 +112,12 @@ internal class RazorLanguageServer : AbstractLanguageServer<RazorRequestContext>
|
|||
// Folding Range Providers
|
||||
services.AddSingleton<RazorFoldingRangeProvider, RazorCodeBlockFoldingProvider>();
|
||||
|
||||
// Get the DefaultSession for telemetry. This is set by VS with
|
||||
// TelemetryService.SetDefaultSession and provides the correct
|
||||
// appinsights keys etc
|
||||
services.AddSingleton<ITelemetryReporter>(provider =>
|
||||
new TelemetryReporter(ImmutableArray.Create(TelemetryService.DefaultSession), provider.GetRequiredService<ILoggerFactory>()));
|
||||
|
||||
AddHandlers(services);
|
||||
|
||||
var lspServices = new LspServices(services);
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// 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.Collections.Immutable;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Common.Telemetry;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualStudio.Telemetry;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.Telemetry
|
||||
{
|
||||
internal class TelemetryReporter : ITelemetryReporter
|
||||
{
|
||||
private readonly ImmutableArray<TelemetrySession> _telemetrySessions;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public TelemetryReporter(ImmutableArray<TelemetrySession> telemetrySessions, ILoggerFactory loggerFactory)
|
||||
{
|
||||
_telemetrySessions = telemetrySessions;
|
||||
_logger = loggerFactory.CreateLogger<TelemetryReporter>();
|
||||
}
|
||||
|
||||
public void ReportEvent(string name, TelemetrySeverity severity)
|
||||
{
|
||||
var telemetryEvent = new TelemetryEvent(name, severity);
|
||||
Report(telemetryEvent);
|
||||
}
|
||||
|
||||
private void Report(TelemetryEvent telemetryEvent)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var session in _telemetrySessions)
|
||||
{
|
||||
session.PostEvent(telemetryEvent);
|
||||
}
|
||||
}
|
||||
catch (OutOfMemoryException)
|
||||
{
|
||||
// Do we want to failfast like Roslyn here?
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No need to do anything here. We failed to report telemetry
|
||||
// which isn't good, but not catastrophic for a user
|
||||
_logger.LogError(e, "Failed logging telemetry event");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
public override string FilePath => State.HostProject.FilePath;
|
||||
|
||||
public override string RootNamespace => State.HostProject.RootNamespace;
|
||||
public override string? RootNamespace => State.HostProject.RootNamespace;
|
||||
|
||||
public override LanguageVersion CSharpLanguageVersion => State.CSharpLanguageVersion;
|
||||
|
||||
|
|
|
@ -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.Language;
|
||||
|
||||
|
@ -10,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
{
|
||||
internal class HostProject
|
||||
{
|
||||
public HostProject(string projectFilePath, RazorConfiguration razorConfiguration, string rootNamespace)
|
||||
public HostProject(string projectFilePath, RazorConfiguration razorConfiguration, string? rootNamespace)
|
||||
{
|
||||
if (projectFilePath is null)
|
||||
{
|
||||
|
@ -31,6 +29,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
public string FilePath { get; }
|
||||
|
||||
public string RootNamespace { get; }
|
||||
public string? RootNamespace { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.CodeAnalysis.Remote.Razor.CoreComponents
|
||||
{
|
||||
internal static class Program
|
||||
|
|
|
@ -13,6 +13,6 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
{
|
||||
ValueTask<TagHelperResolutionResult> GetTagHelpersAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken);
|
||||
|
||||
ValueTask<TagHelperDeltaResult> GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken);
|
||||
ValueTask<TagHelperDeltaResult> GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string? factoryTypeName, int lastResultId, CancellationToken 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.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
@ -75,17 +73,14 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
|
||||
try
|
||||
{
|
||||
TagHelperResolutionResult result = null;
|
||||
TagHelperResolutionResult? result = null;
|
||||
if (factory != null)
|
||||
{
|
||||
result = await ResolveTagHelpersOutOfProcessAsync(factory, workspaceProject, projectSnapshot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (result is null)
|
||||
{
|
||||
// Was unable to get tag helpers OOP, fallback to default behavior.
|
||||
result = await ResolveTagHelpersInProcessAsync(workspaceProject, projectSnapshot, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// Was unable to get tag helpers OOP, fallback to default behavior.
|
||||
result ??= await ResolveTagHelpersInProcessAsync(workspaceProject, projectSnapshot, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -95,7 +90,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual async Task<TagHelperResolutionResult> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, Project workspaceProject, ProjectSnapshot projectSnapshot, CancellationToken cancellationToken)
|
||||
protected virtual async Task<TagHelperResolutionResult?> ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, Project workspaceProject, ProjectSnapshot projectSnapshot, CancellationToken cancellationToken)
|
||||
{
|
||||
// We're being overly defensive here because the OOP host can return null for the client/session/operation
|
||||
// when it's disconnected (user stops the process).
|
||||
|
@ -133,7 +128,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
}
|
||||
|
||||
// Protected virtual for testing
|
||||
protected virtual IReadOnlyCollection<TagHelperDescriptor> ProduceTagHelpersFromDelta(string projectFilePath, int lastResultId, TagHelperDeltaResult deltaResult)
|
||||
protected virtual IReadOnlyCollection<TagHelperDescriptor>? ProduceTagHelpersFromDelta(string projectFilePath, int lastResultId, TagHelperDeltaResult deltaResult)
|
||||
{
|
||||
if (!_resultCache.TryGet(projectFilePath, lastResultId, out var tagHelpers))
|
||||
{
|
||||
|
|
|
@ -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.Host;
|
||||
using Microsoft.CodeAnalysis.Host.Mef;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
|
||||
private class SerializedProjectSnapshot : ProjectSnapshot
|
||||
{
|
||||
public SerializedProjectSnapshot(string filePath, RazorConfiguration configuration, string rootNamespace)
|
||||
public SerializedProjectSnapshot(string filePath, RazorConfiguration? configuration, string? rootNamespace)
|
||||
{
|
||||
FilePath = filePath;
|
||||
Configuration = configuration;
|
||||
|
@ -54,13 +54,13 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
Version = VersionStamp.Default;
|
||||
}
|
||||
|
||||
public override RazorConfiguration Configuration { get; }
|
||||
public override RazorConfiguration? Configuration { get; }
|
||||
|
||||
public override IEnumerable<string> DocumentFilePaths => Array.Empty<string>();
|
||||
|
||||
public override string FilePath { get; }
|
||||
|
||||
public override string RootNamespace { get; }
|
||||
public override string? RootNamespace { get; }
|
||||
|
||||
public override VersionStamp Version { get; }
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
public ValueTask<TagHelperResolutionResult> GetTagHelpersAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken = default)
|
||||
=> RazorBrokeredServiceImplementation.RunServiceAsync(cancellationToken => GetTagHelpersCoreAsync(solutionInfo, projectHandle, factoryTypeName, cancellationToken), cancellationToken);
|
||||
|
||||
public ValueTask<TagHelperDeltaResult> GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken)
|
||||
public ValueTask<TagHelperDeltaResult> GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string? factoryTypeName, int lastResultId, CancellationToken cancellationToken)
|
||||
=> RazorBrokeredServiceImplementation.RunServiceAsync(cancellationToken => GetTagHelpersDeltaCoreAsync(solutionInfo, projectHandle, factoryTypeName, lastResultId, cancellationToken), cancellationToken);
|
||||
|
||||
private async ValueTask<TagHelperResolutionResult> GetTagHelpersCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken)
|
||||
private async ValueTask<TagHelperResolutionResult> GetTagHelpersCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string? factoryTypeName, CancellationToken cancellationToken)
|
||||
{
|
||||
if (projectHandle is null)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
return resolutionResult;
|
||||
}
|
||||
|
||||
public async ValueTask<TagHelperDeltaResult> GetTagHelpersDeltaCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken)
|
||||
public async ValueTask<TagHelperDeltaResult> GetTagHelpersDeltaCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string? factoryTypeName, int lastResultId, CancellationToken cancellationToken)
|
||||
{
|
||||
var tagHelperResolutionResult = await GetTagHelpersCoreAsync(solutionInfo, projectHandle, factoryTypeName, cancellationToken).ConfigureAwait(false);
|
||||
var currentTagHelpers = tagHelperResolutionResult.Descriptors;
|
||||
|
|
|
@ -32,8 +32,8 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
|
||||
public Task<TagHelperResolutionResult> GetTagHelpersAsync(
|
||||
Project project,
|
||||
RazorConfiguration configuration,
|
||||
string factoryTypeName,
|
||||
RazorConfiguration? configuration,
|
||||
string? factoryTypeName,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (project is null)
|
||||
|
@ -50,7 +50,7 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
return GetTagHelpersAsync(project, engine, cancellationToken);
|
||||
}
|
||||
|
||||
internal RazorProjectEngine CreateProjectEngine(RazorConfiguration configuration, string factoryTypeName)
|
||||
internal RazorProjectEngine CreateProjectEngine(RazorConfiguration? configuration, string? factoryTypeName)
|
||||
{
|
||||
// This section is really similar to the code DefaultProjectEngineFactoryService
|
||||
// but with a few differences that are significant in the remote scenario
|
||||
|
@ -71,7 +71,7 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
return factory.Create(configuration, RazorProjectFileSystem.Empty, b => { });
|
||||
}
|
||||
|
||||
private static IProjectEngineFactory? CreateFactory(string factoryTypeName)
|
||||
private static IProjectEngineFactory? CreateFactory(string? factoryTypeName)
|
||||
{
|
||||
if (factoryTypeName is null)
|
||||
{
|
||||
|
|
|
@ -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.Razor.Serialization;
|
||||
using Microsoft.VisualStudio.LanguageServices.Razor.Serialization;
|
||||
|
|
|
@ -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.Language;
|
||||
|
||||
|
@ -12,8 +10,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
{
|
||||
public ProjectSnapshotHandle(
|
||||
string filePath,
|
||||
RazorConfiguration configuration,
|
||||
string rootNamespace)
|
||||
RazorConfiguration? configuration,
|
||||
string? rootNamespace)
|
||||
{
|
||||
if (filePath is null)
|
||||
{
|
||||
|
@ -25,10 +23,10 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
RootNamespace = rootNamespace;
|
||||
}
|
||||
|
||||
public RazorConfiguration Configuration { get; }
|
||||
public RazorConfiguration? Configuration { get; }
|
||||
|
||||
public string FilePath { get; }
|
||||
|
||||
public string RootNamespace { get; }
|
||||
public string? RootNamespace { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -20,7 +18,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Serialization
|
|||
return typeof(ProjectSnapshotHandle).IsAssignableFrom(objectType);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType != JsonToken.StartObject)
|
||||
{
|
||||
|
@ -35,7 +33,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Serialization
|
|||
case nameof(ProjectSnapshotHandle.FilePath):
|
||||
if (reader.Read())
|
||||
{
|
||||
filePath = (string)reader.Value;
|
||||
filePath = (string)reader.Value!;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -49,21 +47,21 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Serialization
|
|||
case nameof(ProjectSnapshotHandle.RootNamespace):
|
||||
if (reader.Read())
|
||||
{
|
||||
rootNamespace = (string)reader.Value;
|
||||
rootNamespace = (string)reader.Value!;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return (reader, objectType, existingValue, serializer, filePath, configuration, rootNamespace);
|
||||
}, (reader, objectType, existingValue, serializer, filePath: (string)null, configuration: (RazorConfiguration)null, rootNamespace: (string)null));
|
||||
}, (reader, objectType, existingValue, serializer, filePath: (string?)null, configuration: (RazorConfiguration?)null, rootNamespace: (string?)null));
|
||||
|
||||
return new ProjectSnapshotHandle(filePath, configuration, rootNamespace);
|
||||
return new ProjectSnapshotHandle(filePath!, configuration, rootNamespace);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
||||
{
|
||||
var handle = (ProjectSnapshotHandle)value;
|
||||
var handle = (ProjectSnapshotHandle)value!;
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
||||
|
@ -16,7 +17,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
|
|||
_projectResultCache = new MemoryCache<string, ProjectResultCacheEntry>(sizeLimit: 50);
|
||||
}
|
||||
|
||||
public bool TryGet(string projectFilePath, int resultId, out IReadOnlyCollection<TagHelperDescriptor>? cachedTagHelpers)
|
||||
public bool TryGet(string projectFilePath, int resultId, [NotNullWhen(returnValue: true)] out IReadOnlyCollection<TagHelperDescriptor>? cachedTagHelpers)
|
||||
{
|
||||
if (!_projectResultCache.TryGetValue(projectFilePath, out var cachedResult))
|
||||
{
|
||||
|
|
|
@ -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.Editor.Razor
|
||||
|
@ -26,7 +25,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
_liveShareProjectPathProvider = liveShareProjectPathProvider;
|
||||
}
|
||||
|
||||
public override bool TryGetProjectPath(ITextBuffer textBuffer, out string filePath)
|
||||
public override bool TryGetProjectPath(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out string? filePath)
|
||||
{
|
||||
if (textBuffer is null)
|
||||
{
|
||||
|
|
|
@ -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.CodeAnalysis.Host;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
|
||||
|
@ -10,6 +9,6 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
{
|
||||
internal abstract class ProjectPathProvider : IWorkspaceService
|
||||
{
|
||||
public abstract bool TryGetProjectPath(ITextBuffer textBuffer, out string filePath);
|
||||
public abstract bool TryGetProjectPath(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out string? filePath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.Host;
|
||||
using Microsoft.VisualStudio.Text.Editor;
|
||||
|
||||
|
|
|
@ -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.CodeAnalysis;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
|
||||
|
@ -10,6 +9,6 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
{
|
||||
internal abstract class VisualStudioWorkspaceAccessor
|
||||
{
|
||||
public abstract bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace);
|
||||
public abstract bool TryGetWorkspace(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Workspace? workspace);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 Microsoft.VisualStudio.TextManager.Interop;
|
||||
|
||||
|
|
|
@ -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.ComponentModel.Composition;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
@ -48,7 +47,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
_defaultWorkspace = defaultWorkspace;
|
||||
}
|
||||
|
||||
public override bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace)
|
||||
public override bool TryGetWorkspace(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Workspace? workspace)
|
||||
{
|
||||
if (textBuffer is null)
|
||||
{
|
||||
|
@ -79,7 +78,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
|
||||
// Internal virtual for testing
|
||||
internal virtual bool TryGetWorkspaceFromProjectionBuffer(ITextBuffer textBuffer, out Workspace workspace)
|
||||
internal virtual bool TryGetWorkspaceFromProjectionBuffer(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Workspace? workspace)
|
||||
{
|
||||
var graph = _bufferGraphService.CreateBufferGraph(textBuffer);
|
||||
var projectedCSharpBuffer = graph.GetTextBuffers(buffer => buffer.ContentType.IsOfType("CSharp")).FirstOrDefault();
|
||||
|
@ -101,7 +100,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
|
||||
// Internal virtual for testing
|
||||
internal virtual bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, out Workspace workspace)
|
||||
internal virtual bool TryGetWorkspaceFromHostProject(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Workspace? workspace)
|
||||
{
|
||||
var project = _projectService.GetHostProject(textBuffer);
|
||||
|
||||
|
|
|
@ -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.Shell.Interop;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -59,7 +57,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
_cookiesByDocument = new Dictionary<DocumentKey, uint>();
|
||||
}
|
||||
|
||||
protected override ITextBuffer GetTextBufferForOpenDocument(string filePath)
|
||||
protected override ITextBuffer? GetTextBufferForOpenDocument(string filePath)
|
||||
{
|
||||
if (filePath is null)
|
||||
{
|
||||
|
@ -185,7 +183,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
}
|
||||
}
|
||||
|
||||
public void DocumentClosed(uint cookie, string exceptFilePath = null)
|
||||
public void DocumentClosed(uint cookie, string? exceptFilePath = null)
|
||||
{
|
||||
JoinableTaskContext.AssertUIThread();
|
||||
|
||||
|
@ -202,7 +200,11 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
// We we might see multiple documents open for a cookie (due to linked files), but only one of them
|
||||
// has been renamed. In that case, we just process the change that we know about.
|
||||
var filePaths = new HashSet<string>(documents.Select(d => d.DocumentFilePath));
|
||||
filePaths.Remove(exceptFilePath);
|
||||
|
||||
// `Remove` can correctly handle the case when the incoming value is null without any exceptions.
|
||||
// The method is just not properly annotated for it,
|
||||
// so we can suppress the warning here
|
||||
filePaths.Remove(exceptFilePath!);
|
||||
|
||||
foreach (var filePath in filePaths)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
|
|
@ -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.IO;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
@ -23,11 +21,11 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
private readonly JoinableTaskContext _joinableTaskContext;
|
||||
|
||||
// Internal for testing
|
||||
internal JoinableTask<uint> _fileChangeAdviseTask;
|
||||
internal JoinableTask _fileChangeUnadviseTask;
|
||||
internal JoinableTask _fileChangedTask;
|
||||
internal JoinableTask<uint>? _fileChangeAdviseTask;
|
||||
internal JoinableTask? _fileChangeUnadviseTask;
|
||||
internal JoinableTask? _fileChangedTask;
|
||||
|
||||
public override event EventHandler<FileChangeEventArgs> Changed;
|
||||
public override event EventHandler<FileChangeEventArgs>? Changed;
|
||||
|
||||
public VisualStudioFileChangeTracker(
|
||||
string filePath,
|
||||
|
@ -74,7 +72,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
{
|
||||
_projectSnapshotManagerDispatcher.AssertDispatcherThread();
|
||||
|
||||
if (_fileChangeAdviseTask != null)
|
||||
if (_fileChangeAdviseTask is not null)
|
||||
{
|
||||
// Already listening
|
||||
return;
|
||||
|
|
|
@ -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.Razor;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
|
|
|
@ -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;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
@ -18,7 +16,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
[ExportWorkspaceServiceFactory(typeof(FileChangeTrackerFactory), ServiceLayer.Host)]
|
||||
internal class VisualStudioFileChangeTrackerFactoryFactory : IWorkspaceServiceFactory
|
||||
{
|
||||
private readonly IVsAsyncFileChangeEx _fileChangeService;
|
||||
private readonly IVsAsyncFileChangeEx? _fileChangeService;
|
||||
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
|
||||
private readonly JoinableTaskContext _joinableTaskContext;
|
||||
|
||||
|
@ -56,7 +54,7 @@ namespace Microsoft.VisualStudio.Editor.Razor.Documents
|
|||
}
|
||||
|
||||
var errorReporter = workspaceServices.GetRequiredService<ErrorReporter>();
|
||||
return new VisualStudioFileChangeTrackerFactory(errorReporter, _fileChangeService, _projectSnapshotManagerDispatcher, _joinableTaskContext);
|
||||
return new VisualStudioFileChangeTrackerFactory(errorReporter, _fileChangeService!, _projectSnapshotManagerDispatcher, _joinableTaskContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.OLE.Interop;
|
||||
using Microsoft.VisualStudio.TextManager.Interop;
|
||||
|
|
|
@ -1,11 +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.ComponentModel.Composition;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
using Microsoft.VisualStudio.Shell.Interop;
|
||||
|
@ -52,7 +49,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
|||
_documentTable = new RunningDocumentTable(services);
|
||||
}
|
||||
|
||||
public override object GetHostProject(ITextBuffer textBuffer)
|
||||
public override object? GetHostProject(ITextBuffer textBuffer)
|
||||
{
|
||||
if (textBuffer is null)
|
||||
{
|
||||
|
@ -88,7 +85,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
|||
}
|
||||
|
||||
var hierarchy = project as IVsHierarchy;
|
||||
Debug.Assert(hierarchy != null);
|
||||
Assumes.NotNull(hierarchy);
|
||||
|
||||
ErrorHandler.ThrowOnFailure(((IVsProject)hierarchy).GetMkDocument((uint)VSConstants.VSITEMID.Root, out var path), VSConstants.E_NOTIMPL);
|
||||
return path;
|
||||
|
@ -105,15 +102,14 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
|
|||
return capabilitySupported;
|
||||
}
|
||||
|
||||
public override string GetProjectName(object project)
|
||||
public override string? GetProjectName(object project)
|
||||
{
|
||||
if (project is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(project));
|
||||
}
|
||||
|
||||
var hierarchy = project as IVsHierarchy;
|
||||
Debug.Assert(hierarchy != null);
|
||||
var hierarchy = (IVsHierarchy)project;
|
||||
|
||||
if (ErrorHandler.Failed(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_Name, out var 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 Microsoft.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.Language.Intellisense;
|
||||
|
|
|
@ -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;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
// 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.Collections.Immutable;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -14,7 +13,6 @@ using System.Threading.Tasks;
|
|||
using System.Threading.Tasks.Dataflow;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.LanguageServices;
|
||||
using Microsoft.VisualStudio.ProjectSystem;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Properties;
|
||||
|
@ -30,7 +28,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
[Export(ExportContractNames.Scopes.UnconfiguredProject, typeof(IProjectDynamicLoadComponent))]
|
||||
internal class DefaultWindowsRazorProjectHost : WindowsRazorProjectHostBase
|
||||
{
|
||||
private IDisposable _subscription;
|
||||
private IDisposable? _subscription;
|
||||
|
||||
private const string RootNamespaceProperty = "RootNamespace";
|
||||
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
|
||||
|
@ -48,7 +46,9 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Internal for testing
|
||||
#pragma warning disable CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
internal DefaultWindowsRazorProjectHost(
|
||||
#pragma warning restore CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
IUnconfiguredProjectCommonServices commonServices,
|
||||
Workspace workspace,
|
||||
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
|
||||
|
@ -86,7 +86,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
{
|
||||
await base.DisposeCoreAsync(initialized).ConfigureAwait(false);
|
||||
|
||||
if (initialized && _subscription != null)
|
||||
if (initialized && _subscription is not null)
|
||||
{
|
||||
_subscription.Dispose();
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
// Internal for testing
|
||||
internal static bool TryGetConfiguration(
|
||||
IImmutableDictionary<string, IProjectRuleSnapshot> state,
|
||||
out RazorConfiguration configuration)
|
||||
[NotNullWhen(returnValue: true)] out RazorConfiguration? configuration)
|
||||
{
|
||||
if (!TryGetDefaultConfiguration(state, out var defaultConfiguration))
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
// Internal for testing
|
||||
internal static bool TryGetDefaultConfiguration(
|
||||
IImmutableDictionary<string, IProjectRuleSnapshot> state,
|
||||
out string defaultConfiguration)
|
||||
[NotNullWhen(returnValue: true)] out string? defaultConfiguration)
|
||||
{
|
||||
if (!state.TryGetValue(Rules.RazorGeneral.SchemaName, out var rule))
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
// Internal for testing
|
||||
internal static bool TryGetLanguageVersion(
|
||||
IImmutableDictionary<string, IProjectRuleSnapshot> state,
|
||||
out RazorLanguageVersion languageVersion)
|
||||
[NotNullWhen(returnValue: true)] out RazorLanguageVersion? languageVersion)
|
||||
{
|
||||
if (!state.TryGetValue(Rules.RazorGeneral.SchemaName, out var rule))
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
// Internal for testing
|
||||
internal static bool TryGetRootNamespace(
|
||||
IImmutableDictionary<string, IProjectRuleSnapshot> state,
|
||||
out string rootNamespace)
|
||||
[NotNullWhen(returnValue: true)] out string? rootNamespace)
|
||||
{
|
||||
if (!state.TryGetValue(ConfigurationGeneralSchemaName, out var rule))
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
// Temporary code until we get access to these APIs
|
||||
#if WORKSPACE_PROJECT_CONTEXT_FACTORY
|
||||
|
||||
|
@ -30,11 +28,11 @@ namespace Microsoft.VisualStudio.LanguageServices.ProjectSystem
|
|||
|
||||
private class WorkspaceProjectContext : IWorkspaceProjectContext
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string ProjectFilePath { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
public string? ProjectFilePath { get; set; }
|
||||
public Guid Guid { get; set; }
|
||||
public bool LastDesignTimeBuildSucceeded { get; set; }
|
||||
public string BinOutputPath { get; set; }
|
||||
public string? BinOutputPath { get; set; }
|
||||
|
||||
public void AddAdditionalFile(string filePath, bool isInCurrentContext = true)
|
||||
{
|
||||
|
@ -56,7 +54,7 @@ namespace Microsoft.VisualStudio.LanguageServices.ProjectSystem
|
|||
{
|
||||
}
|
||||
|
||||
public void AddDynamicSourceFile(string filePath, IEnumerable<string> folderNames = null)
|
||||
public void AddDynamicSourceFile(string filePath, IEnumerable<string>? folderNames = null)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
// 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.Collections.Immutable;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
|
@ -35,7 +34,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
{
|
||||
private const string MvcAssemblyFileName = "Microsoft.AspNetCore.Mvc.Razor.dll";
|
||||
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
|
||||
private IDisposable _subscription;
|
||||
private IDisposable? _subscription;
|
||||
|
||||
[ImportingConstructor]
|
||||
public FallbackWindowsRazorProjectHost(
|
||||
|
@ -49,7 +48,10 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
_languageServerFeatureOptions = languageServerFeatureOptions;
|
||||
}
|
||||
|
||||
// Internal for testing
|
||||
#pragma warning disable CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
internal FallbackWindowsRazorProjectHost(
|
||||
#pragma warning restore CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
IUnconfiguredProjectCommonServices commonServices,
|
||||
Workspace workspace,
|
||||
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
|
||||
|
@ -87,7 +89,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
if (initialized)
|
||||
{
|
||||
_subscription.Dispose();
|
||||
_subscription?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
await CommonServices.TasksService.LoadedProjectAsync(async () => await ExecuteWithLockAsync(async () =>
|
||||
{
|
||||
string mvcReferenceFullPath = null;
|
||||
string? mvcReferenceFullPath = null;
|
||||
if (update.Value.CurrentState.ContainsKey(ResolvedCompilationReference.SchemaName))
|
||||
{
|
||||
var references = update.Value.CurrentState[ResolvedCompilationReference.SchemaName].Items;
|
||||
|
@ -167,7 +169,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// virtual for overriding in tests
|
||||
protected virtual Version GetAssemblyVersion(string filePath)
|
||||
protected virtual Version? GetAssemblyVersion(string filePath)
|
||||
{
|
||||
return ReadAssemblyVersion(filePath);
|
||||
}
|
||||
|
@ -239,7 +241,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Internal for testing
|
||||
internal bool TryGetRazorDocument(IImmutableDictionary<string, string> itemState, out HostDocument razorDocument)
|
||||
internal bool TryGetRazorDocument(IImmutableDictionary<string, string> itemState, [NotNullWhen(returnValue: true)] out HostDocument? razorDocument)
|
||||
{
|
||||
if (itemState.TryGetValue(ItemReference.FullPathPropertyName, out var filePath))
|
||||
{
|
||||
|
@ -263,7 +265,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
return false;
|
||||
}
|
||||
|
||||
private static Version ReadAssemblyVersion(string filePath)
|
||||
private static Version? ReadAssemblyVersion(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -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.ProjectSystem;
|
||||
using Microsoft.VisualStudio.ProjectSystem.References;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
// Temporary code until we get access to these APIs
|
||||
#if WORKSPACE_PROJECT_CONTEXT_FACTORY
|
||||
|
||||
|
@ -35,7 +33,7 @@ namespace Microsoft.VisualStudio.LanguageServices.ProjectSystem
|
|||
|
||||
// Files.
|
||||
void AddSourceFile(string filePath, bool isInCurrentContext, IEnumerable<string> folderNames, SourceCodeKind sourceCodeKind);
|
||||
void AddDynamicSourceFile(string filePath, IEnumerable<string> folderNames = null);
|
||||
void AddDynamicSourceFile(string filePath, IEnumerable<string>? folderNames = null);
|
||||
void RemoveSourceFile(string filePath);
|
||||
void RemoveDynamicSourceFile(string filePath);
|
||||
void AddAdditionalFile(string filePath, bool isInCurrentContext = 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
|
||||
|
||||
// Temporary code until we get access to these APIs
|
||||
#if WORKSPACE_PROJECT_CONTEXT_FACTORY
|
||||
|
||||
|
@ -17,9 +15,8 @@ namespace Microsoft.VisualStudio.LanguageServices.ProjectSystem
|
|||
{
|
||||
IWorkspaceProjectContext CreateProjectContext(string languageName, string projectDisplayName, string projectFilePath, Guid projectGuid, object hierarchy, string binOutputPath);
|
||||
|
||||
|
||||
IWorkspaceProjectContext CreateProjectContext(string languageName, string projectDisplayName, string projectFilePath, Guid projectGuid, object hierarchy, string binOutputPath, ProjectExternalErrorReporter errorReporter);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -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.CodeAnalysis.Razor.ProjectSystem
|
||||
{
|
||||
// Well-Known Schema and property names defined by the ManagedProjectSystem
|
||||
|
|
|
@ -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
|
||||
|
||||
// Temporary code until we get access to these APIs
|
||||
#if WORKSPACE_PROJECT_CONTEXT_FACTORY
|
||||
|
||||
|
@ -13,4 +11,4 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -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.VisualStudio.ProjectSystem;
|
||||
using Microsoft.VisualStudio.ProjectSystem.Properties;
|
||||
|
|
|
@ -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.ProjectSystem;
|
||||
|
|
|
@ -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.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -28,7 +27,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
|
||||
private readonly AsyncSemaphore _lock;
|
||||
|
||||
private ProjectSnapshotManagerBase _projectManager;
|
||||
private ProjectSnapshotManagerBase? _projectManager;
|
||||
private readonly Dictionary<string, HostDocument> _currentDocuments;
|
||||
protected readonly ProjectConfigurationFilePathStore ProjectConfigurationFilePathStore;
|
||||
|
||||
|
@ -95,7 +94,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
_projectManager = projectManager;
|
||||
}
|
||||
|
||||
protected HostProject Current { get; private set; }
|
||||
protected HostProject? Current { get; private set; }
|
||||
|
||||
protected IUnconfiguredProjectCommonServices CommonServices { get; }
|
||||
|
||||
|
@ -120,7 +119,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
|
||||
await ExecuteWithLockAsync(async () =>
|
||||
{
|
||||
if (Current != null)
|
||||
if (Current is not null)
|
||||
{
|
||||
await UpdateAsync(UninitializeProjectUnsafe, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -138,7 +137,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
// FilePath.
|
||||
await ExecuteWithLockAsync(async () =>
|
||||
{
|
||||
if (Current != null)
|
||||
if (Current is not null)
|
||||
{
|
||||
var old = Current;
|
||||
var oldDocuments = _currentDocuments.Values.ToArray();
|
||||
|
@ -165,10 +164,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
{
|
||||
_projectSnapshotManagerDispatcher.AssertDispatcherThread();
|
||||
|
||||
if (_projectManager is null)
|
||||
{
|
||||
_projectManager = (ProjectSnapshotManagerBase)_workspace.Services.GetLanguageServices(RazorLanguage.Name).GetRequiredService<ProjectSnapshotManager>();
|
||||
}
|
||||
_projectManager ??= (ProjectSnapshotManagerBase)_workspace.Services.GetLanguageServices(RazorLanguage.Name).GetRequiredService<ProjectSnapshotManager>();
|
||||
|
||||
return _projectManager;
|
||||
}
|
||||
|
@ -182,7 +178,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
UpdateProjectUnsafe(null);
|
||||
}
|
||||
|
||||
protected void UpdateProjectUnsafe(HostProject project)
|
||||
protected void UpdateProjectUnsafe(HostProject? project)
|
||||
{
|
||||
var projectManager = GetProjectManager();
|
||||
if (Current is null && project is null)
|
||||
|
@ -268,7 +264,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
return DisposeAsync();
|
||||
}
|
||||
|
||||
private async Task UnconfiguredProject_ProjectRenamingAsync(object sender, ProjectRenamedEventArgs args)
|
||||
private async Task UnconfiguredProject_ProjectRenamingAsync(object? sender, ProjectRenamedEventArgs args)
|
||||
{
|
||||
await OnProjectRenamingAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
@ -276,7 +272,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
// Internal for testing
|
||||
internal static bool TryGetIntermediateOutputPath(
|
||||
IImmutableDictionary<string, IProjectRuleSnapshot> state,
|
||||
out string path)
|
||||
[NotNullWhen(returnValue: true)] out string? path)
|
||||
{
|
||||
if (!state.TryGetValue(ConfigurationGeneralSchemaName, out var rule))
|
||||
{
|
||||
|
@ -329,7 +325,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
return true;
|
||||
}
|
||||
|
||||
private static string ResolveFallbackIntermediateOutputPath(IProjectRuleSnapshot rule, string intermediateOutputPathValue)
|
||||
private static string? ResolveFallbackIntermediateOutputPath(IProjectRuleSnapshot rule, string intermediateOutputPathValue)
|
||||
{
|
||||
if (!rule.Properties.TryGetValue(MSBuildProjectDirectoryPropertyName, out var projectDirectory))
|
||||
{
|
||||
|
|
|
@ -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.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.Text.Editor;
|
||||
|
|
|
@ -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;
|
||||
|
@ -52,7 +50,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
#region protected by _lock
|
||||
private readonly List<ITextView> _activeTextViews = new();
|
||||
|
||||
private ITextBuffer _textBuffer;
|
||||
private ITextBuffer? _textBuffer;
|
||||
#endregion
|
||||
|
||||
[ImportingConstructor]
|
||||
|
@ -106,6 +104,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
|
||||
var vsTextView = _editorAdaptersFactory.GetViewAdapter(textView);
|
||||
|
||||
Assumes.NotNull(vsTextView);
|
||||
|
||||
// In remote client scenarios there's a custom language service applied to buffers in order to enable delegation of interactions.
|
||||
// Because of this we don't want to break that experience so we ensure not to "set" a langauge service for remote clients.
|
||||
if (!_editorFeatureDetector.IsRemoteClient())
|
||||
|
@ -207,7 +207,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
}
|
||||
|
||||
private void RazorOptions_OptionChanged(object sender, EditorOptionChangedEventArgs e)
|
||||
private void RazorOptions_OptionChanged(object? sender, EditorOptionChangedEventArgs? e)
|
||||
{
|
||||
Assumes.NotNull(_textBuffer);
|
||||
|
||||
|
@ -298,7 +298,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
{
|
||||
}
|
||||
|
||||
private IOleCommandTarget _next;
|
||||
private IOleCommandTarget? _next;
|
||||
|
||||
private IOleCommandTarget Next
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
|
||||
public int GetDataTipText(TextSpan[] pSpan, out string pbstrText)
|
||||
{
|
||||
pbstrText = null;
|
||||
pbstrText = null!;
|
||||
return VSConstants.E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.CodeAnalysis;
|
||||
|
@ -47,15 +45,10 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
}
|
||||
|
||||
public override void ReportError(Exception exception, ProjectSnapshot project)
|
||||
public override void ReportError(Exception exception, ProjectSnapshot? project)
|
||||
{
|
||||
if (exception is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var activityLog = GetActivityLog();
|
||||
if (activityLog != null)
|
||||
if (activityLog is not null)
|
||||
{
|
||||
var hr = activityLog.LogEntry(
|
||||
(uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
|
||||
|
@ -67,13 +60,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
|
||||
public override void ReportError(Exception exception, Project workspaceProject)
|
||||
{
|
||||
if (exception is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var activityLog = GetActivityLog();
|
||||
if (activityLog != null)
|
||||
if (activityLog is not null)
|
||||
{
|
||||
var hr = activityLog.LogEntry(
|
||||
(uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
|
||||
|
@ -83,7 +71,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
}
|
||||
}
|
||||
|
||||
private IVsActivityLog GetActivityLog()
|
||||
private IVsActivityLog? GetActivityLog()
|
||||
{
|
||||
return _services.GetService(typeof(SVsActivityLog)) as IVsActivityLog;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
|
|
@ -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.CodeAnalysis.Razor;
|
||||
|
|
|
@ -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.CodeAnalysis.Host;
|
||||
|
|
|
@ -41,11 +41,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
|
||||
private bool LocalHasCapability(IVsHierarchy hierarchy, string capability)
|
||||
{
|
||||
if (hierarchy is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var hasCapability = hierarchy.IsCapabilityMatch(capability);
|
||||
|
|
|
@ -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 System.Diagnostics;
|
||||
|
@ -27,10 +25,10 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
private readonly ProjectWorkspaceStateGenerator _workspaceStateGenerator;
|
||||
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
|
||||
private readonly JoinableTaskContext _joinableTaskContext;
|
||||
private ProjectSnapshotManagerBase _projectManager;
|
||||
private CancellationTokenSource _activeSolutionCancellationTokenSource;
|
||||
private ProjectSnapshotManagerBase? _projectManager;
|
||||
private CancellationTokenSource? _activeSolutionCancellationTokenSource;
|
||||
private uint _updateCookie;
|
||||
private IVsSolutionBuildManager _solutionBuildManager;
|
||||
private IVsSolutionBuildManager? _solutionBuildManager;
|
||||
|
||||
[ImportingConstructor]
|
||||
public VsSolutionUpdatesProjectSnapshotChangeTrigger(
|
||||
|
@ -73,7 +71,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
_activeSolutionCancellationTokenSource = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
internal Task CurrentUpdateTaskForTests { get; private set; }
|
||||
internal Task? CurrentUpdateTaskForTests { get; private set; }
|
||||
|
||||
public override void Initialize(ProjectSnapshotManagerBase projectManager)
|
||||
{
|
||||
|
@ -134,9 +132,9 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
_activeSolutionCancellationTokenSource?.Dispose();
|
||||
_activeSolutionCancellationTokenSource = null;
|
||||
}
|
||||
else if (_activeSolutionCancellationTokenSource is null)
|
||||
else
|
||||
{
|
||||
_activeSolutionCancellationTokenSource = new CancellationTokenSource();
|
||||
_activeSolutionCancellationTokenSource ??= new CancellationTokenSource();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,12 +144,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
|
|||
var projectFilePath = _projectService.GetProjectPath(projectHierarchy);
|
||||
return _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(() =>
|
||||
{
|
||||
var projectSnapshot = _projectManager.GetLoadedProject(projectFilePath);
|
||||
if (projectSnapshot != null)
|
||||
var projectSnapshot = _projectManager?.GetLoadedProject(projectFilePath);
|
||||
if (projectSnapshot is not null)
|
||||
{
|
||||
var workspaceProject = _projectManager.Workspace.CurrentSolution.Projects.FirstOrDefault(
|
||||
var workspaceProject = _projectManager?.Workspace.CurrentSolution.Projects.FirstOrDefault(
|
||||
wp => FilePathComparer.Instance.Equals(wp.FilePath, projectSnapshot.FilePath));
|
||||
if (workspaceProject != null)
|
||||
if (workspaceProject is not null)
|
||||
{
|
||||
// Trigger a tag helper update by forcing the project manager to see the workspace Project
|
||||
// from the current solution.
|
||||
|
|
|
@ -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;
|
||||
|
||||
namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
||||
|
@ -11,17 +9,17 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
[Export(typeof(LiveShareSessionAccessor))]
|
||||
internal class DefaultLiveShareSessionAccessor : LiveShareSessionAccessor
|
||||
{
|
||||
private CollaborationSession _currentSession;
|
||||
private CollaborationSession? _currentSession;
|
||||
private bool _guestSessionIsActive;
|
||||
|
||||
// We have a separate IsGuestSessionActive to avoid loading LiveShare dlls unnecessarily.
|
||||
public override bool IsGuestSessionActive => _guestSessionIsActive;
|
||||
|
||||
public override CollaborationSession Session => _currentSession;
|
||||
public override CollaborationSession? Session => _currentSession;
|
||||
|
||||
public void SetSession(CollaborationSession session)
|
||||
public void SetSession(CollaborationSession? session)
|
||||
{
|
||||
_guestSessionIsActive = session != null;
|
||||
_guestSessionIsActive = session is not null;
|
||||
_currentSession = session;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 System.Threading;
|
||||
|
@ -16,7 +14,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
{
|
||||
private readonly LiveShareSessionAccessor _liveShareSessionAccessor;
|
||||
private readonly JoinableTaskFactory _joinableTaskFactory;
|
||||
private IProjectHierarchyProxy _projectHierarchyProxy;
|
||||
private IProjectHierarchyProxy? _projectHierarchyProxy;
|
||||
|
||||
[ImportingConstructor]
|
||||
public DefaultProxyAccessor(
|
||||
|
@ -38,16 +36,15 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
}
|
||||
|
||||
// Testing constructor
|
||||
#pragma warning disable CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
private protected DefaultProxyAccessor()
|
||||
#pragma warning restore CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
{
|
||||
}
|
||||
|
||||
public override IProjectHierarchyProxy GetProjectHierarchyProxy()
|
||||
{
|
||||
if (_projectHierarchyProxy is null)
|
||||
{
|
||||
_projectHierarchyProxy = CreateServiceProxy<IProjectHierarchyProxy>();
|
||||
}
|
||||
_projectHierarchyProxy ??= CreateServiceProxy<IProjectHierarchyProxy>();
|
||||
|
||||
return _projectHierarchyProxy;
|
||||
}
|
||||
|
@ -55,8 +52,9 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
// Internal virtual for testing
|
||||
internal virtual TProxy CreateServiceProxy<TProxy>() where TProxy : class
|
||||
{
|
||||
Assumes.NotNull(_liveShareSessionAccessor.Session);
|
||||
#pragma warning disable VSTHRD110 // Observe result of async calls
|
||||
return _joinableTaskFactory.Run(() => _liveShareSessionAccessor.Session?.GetRemoteServiceAsync<TProxy>(typeof(TProxy).Name, CancellationToken.None));
|
||||
return _joinableTaskFactory.Run(() => _liveShareSessionAccessor.Session.GetRemoteServiceAsync<TProxy>(typeof(TProxy).Name, CancellationToken.None));
|
||||
#pragma warning restore VSTHRD110 // Observe result of async calls
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.ComponentModel.Composition;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.Editor.Razor;
|
||||
|
@ -55,7 +54,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
_liveShareSessionAccessor = liveShareSessionAccessor;
|
||||
}
|
||||
|
||||
public override bool TryGetProjectPath(ITextBuffer textBuffer, out string filePath)
|
||||
public override bool TryGetProjectPath(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out string? filePath)
|
||||
{
|
||||
if (!_liveShareSessionAccessor.IsGuestSessionActive)
|
||||
{
|
||||
|
@ -82,10 +81,12 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
}
|
||||
|
||||
// Internal virtual for testing
|
||||
internal virtual Uri GetHostProjectPath(ITextDocument textDocument)
|
||||
internal virtual Uri? GetHostProjectPath(ITextDocument textDocument)
|
||||
{
|
||||
Assumes.NotNull(_liveShareSessionAccessor.Session);
|
||||
|
||||
// The path we're given is from the guest so following other patterns we always ask the host information in its own form (aka convert on guest instead of on host).
|
||||
var ownerPath = _liveShareSessionAccessor.Session?.ConvertLocalPathToSharedUri(textDocument.FilePath);
|
||||
var ownerPath = _liveShareSessionAccessor.Session.ConvertLocalPathToSharedUri(textDocument.FilePath);
|
||||
|
||||
var hostProjectPath = _joinableTaskFactory.Run(() =>
|
||||
{
|
||||
|
@ -103,7 +104,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private string ResolveGuestPath(Uri hostProjectPath)
|
||||
{
|
||||
return _liveShareSessionAccessor.Session.ConvertSharedUriToLocalPath(hostProjectPath);
|
||||
return _liveShareSessionAccessor.Session!.ConvertSharedUriToLocalPath(hostProjectPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
// 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.LiveShare.Razor.Guest
|
||||
{
|
||||
public abstract class LiveShareSessionAccessor
|
||||
{
|
||||
public abstract CollaborationSession Session { get; }
|
||||
public abstract CollaborationSession? Session { get; }
|
||||
|
||||
public abstract bool IsGuestSessionActive { get; }
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
if (args.Kind == ProjectProxyChangeKind.ProjectAdded)
|
||||
{
|
||||
var guestPath = ResolveGuestPath(args.ProjectFilePath);
|
||||
var hostProject = new HostProject(guestPath, args.Newer.Configuration, args.Newer.RootNamespace);
|
||||
var hostProject = new HostProject(guestPath, args.Newer!.Configuration, args.Newer.RootNamespace);
|
||||
_projectSnapshotManager.ProjectAdded(hostProject);
|
||||
|
||||
if (args.Newer.ProjectWorkspaceState != null)
|
||||
|
@ -99,12 +99,12 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
else if (args.Kind == ProjectProxyChangeKind.ProjectRemoved)
|
||||
{
|
||||
var guestPath = ResolveGuestPath(args.ProjectFilePath);
|
||||
var hostProject = new HostProject(guestPath, args.Older.Configuration, args.Older.RootNamespace);
|
||||
var hostProject = new HostProject(guestPath, args.Older!.Configuration, args.Older.RootNamespace);
|
||||
_projectSnapshotManager.ProjectRemoved(hostProject);
|
||||
}
|
||||
else if (args.Kind == ProjectProxyChangeKind.ProjectChanged)
|
||||
{
|
||||
if (!args.Older.Configuration.Equals(args.Newer.Configuration))
|
||||
if (!args.Older!.Configuration.Equals(args.Newer!.Configuration))
|
||||
{
|
||||
var guestPath = ResolveGuestPath(args.Newer.FilePath);
|
||||
var hostProject = new HostProject(guestPath, args.Newer.Configuration, args.Newer.RootNamespace);
|
||||
|
@ -131,7 +131,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
var hostProject = new HostProject(guestPath, projectHandle.Configuration, projectHandle.RootNamespace);
|
||||
_projectSnapshotManager.ProjectAdded(hostProject);
|
||||
|
||||
if (projectHandle.ProjectWorkspaceState != null)
|
||||
if (projectHandle.ProjectWorkspaceState is not null)
|
||||
{
|
||||
_projectSnapshotManager.ProjectWorkspaceStateChanged(guestPath, projectHandle.ProjectWorkspaceState);
|
||||
}
|
||||
|
|
|
@ -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 System.Threading;
|
||||
|
|
|
@ -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.LiveShare.Razor.Guest
|
||||
{
|
||||
public abstract class ProxyAccessor
|
||||
|
|
|
@ -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;
|
||||
|
@ -20,7 +18,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
private readonly DefaultLiveShareSessionAccessor _sessionAccessor;
|
||||
|
||||
// Internal for testing
|
||||
internal Task _viewImportsCopyTask;
|
||||
internal Task? _viewImportsCopyTask;
|
||||
|
||||
[ImportingConstructor]
|
||||
public RazorGuestInitializationService([Import(typeof(LiveShareSessionAccessor))] DefaultLiveShareSessionAccessor sessionAccessor)
|
||||
|
@ -57,7 +55,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
|
|||
// Today we ensure that all _ViewImports in the shared project exist on the guest because we don't currently track import documents
|
||||
// in a manner that would allow us to retrieve/monitor that data across the wire. Once the Razor sub-system is moved to use
|
||||
// DocumentSnapshots we'll be able to rely on that API to more properly manage files that impact parsing of Razor documents.
|
||||
private async Task EnsureViewImportsCopiedAsync(CollaborationSession sessionContext, CancellationToken cancellationToken)
|
||||
private static async Task EnsureViewImportsCopiedAsync(CollaborationSession sessionContext, CancellationToken cancellationToken)
|
||||
{
|
||||
var listDirectoryOptions = new ListDirectoryOptions()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
@ -17,7 +15,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
private readonly CollaborationSession _session;
|
||||
|
||||
private readonly JoinableTaskFactory _joinableTaskFactory;
|
||||
private IVsUIShellOpenDocument _openDocumentShell;
|
||||
private IVsUIShellOpenDocument? _openDocumentShell;
|
||||
|
||||
public DefaultProjectHierarchyProxy(
|
||||
CollaborationSession session,
|
||||
|
@ -37,7 +35,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
_joinableTaskFactory = joinableTaskFactory;
|
||||
}
|
||||
|
||||
public async Task<Uri> GetProjectPathAsync(Uri documentFilePath, CancellationToken cancellationToken)
|
||||
public async Task<Uri?> GetProjectPathAsync(Uri documentFilePath, CancellationToken cancellationToken)
|
||||
{
|
||||
if (documentFilePath is null)
|
||||
{
|
||||
|
@ -46,13 +44,11 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
|
||||
await _joinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
|
||||
|
||||
if (_openDocumentShell is null)
|
||||
{
|
||||
_openDocumentShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
|
||||
}
|
||||
|
||||
#pragma warning disable VSSDK006 // Check services exist
|
||||
_openDocumentShell ??= ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
|
||||
#pragma warning restore VSSDK006 // Check services exist
|
||||
var hostDocumentFilePath = _session.ConvertSharedUriToLocalPath(documentFilePath);
|
||||
var hr = _openDocumentShell.IsDocumentInAProject(hostDocumentFilePath, out var hierarchy, out _, out _, out _);
|
||||
var hr = _openDocumentShell!.IsDocumentInAProject(hostDocumentFilePath, out var hierarchy, out _, out _, out _);
|
||||
if (ErrorHandler.Succeeded(hr) && hierarchy != null)
|
||||
{
|
||||
ErrorHandler.ThrowOnFailure(((IVsProject)hierarchy).GetMkDocument((uint)VSConstants.VSITEMID.Root, out var path), VSConstants.E_NOTIMPL);
|
||||
|
|
|
@ -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 System.Threading;
|
||||
|
|
|
@ -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 System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -22,10 +21,10 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
private readonly JoinableTaskFactory _joinableTaskFactory;
|
||||
private readonly AsyncSemaphore _latestStateSemaphore;
|
||||
private bool _disposed;
|
||||
private ProjectSnapshotManagerProxyState _latestState;
|
||||
private ProjectSnapshotManagerProxyState? _latestState;
|
||||
|
||||
// Internal for testing
|
||||
internal JoinableTask _processingChangedEventTestTask;
|
||||
internal JoinableTask? _processingChangedEventTestTask;
|
||||
|
||||
public DefaultProjectSnapshotManagerProxy(
|
||||
CollaborationSession session,
|
||||
|
@ -62,13 +61,13 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
_projectSnapshotManager.Changed += ProjectSnapshotManager_Changed;
|
||||
}
|
||||
|
||||
public event EventHandler<ProjectChangeEventProxyArgs> Changed;
|
||||
public event EventHandler<ProjectChangeEventProxyArgs>? Changed;
|
||||
|
||||
public async Task<ProjectSnapshotManagerProxyState> GetProjectManagerStateAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using (await _latestStateSemaphore.EnterAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (_latestState != null)
|
||||
if (_latestState is not null)
|
||||
{
|
||||
return _latestState;
|
||||
}
|
||||
|
@ -117,7 +116,8 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
}
|
||||
}
|
||||
|
||||
private ProjectSnapshotHandleProxy ConvertToProxy(ProjectSnapshot project)
|
||||
[return: NotNullIfNotNull(nameof(project))]
|
||||
private ProjectSnapshotHandleProxy? ConvertToProxy(ProjectSnapshot? project)
|
||||
{
|
||||
if (project is null)
|
||||
{
|
||||
|
|
|
@ -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 System.Threading;
|
||||
|
@ -51,7 +49,6 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host
|
|||
|
||||
_projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
|
||||
_joinableTaskContext = joinableTaskContext;
|
||||
|
||||
_workspace = workspace;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -11,6 +9,6 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
{
|
||||
public interface IProjectHierarchyProxy
|
||||
{
|
||||
Task<Uri> GetProjectPathAsync(Uri documentFilePath, CancellationToken cancellationToken);
|
||||
Task<Uri?> GetProjectPathAsync(Uri documentFilePath, CancellationToken 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.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -11,7 +9,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
{
|
||||
public interface IProjectSnapshotManagerProxy
|
||||
{
|
||||
event EventHandler<ProjectChangeEventProxyArgs> Changed;
|
||||
event EventHandler<ProjectChangeEventProxyArgs>? Changed;
|
||||
|
||||
Task<ProjectSnapshotManagerProxyState> GetProjectManagerStateAsync(CancellationToken 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.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
// questions on hierarchy capabilities.
|
||||
return _joinableTaskFactory.Run(async () =>
|
||||
{
|
||||
var remoteHierarchyService = await _sessionAccessor.Session.GetRemoteServiceAsync<IRemoteHierarchyService>(nameof(IRemoteHierarchyService), CancellationToken.None).ConfigureAwait(false);
|
||||
var remoteHierarchyService = await _sessionAccessor.Session!.GetRemoteServiceAsync<IRemoteHierarchyService>(nameof(IRemoteHierarchyService), CancellationToken.None).ConfigureAwait(false);
|
||||
var documentMonikerUri = _sessionAccessor.Session.ConvertLocalPathToSharedUri(documentMoniker);
|
||||
var hasCapability = await remoteHierarchyService.HasCapabilityAsync(documentMonikerUri, capability, CancellationToken.None).ConfigureAwait(false);
|
||||
return hasCapability;
|
||||
|
|
|
@ -1,15 +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;
|
||||
|
||||
namespace Microsoft.VisualStudio.LiveShare.Razor
|
||||
{
|
||||
public sealed class ProjectChangeEventProxyArgs : EventArgs
|
||||
{
|
||||
public ProjectChangeEventProxyArgs(ProjectSnapshotHandleProxy older, ProjectSnapshotHandleProxy newer, ProjectProxyChangeKind kind)
|
||||
public ProjectChangeEventProxyArgs(ProjectSnapshotHandleProxy? older, ProjectSnapshotHandleProxy? newer, ProjectProxyChangeKind kind)
|
||||
{
|
||||
if (older is null && newer is null)
|
||||
{
|
||||
|
@ -20,12 +18,12 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
Newer = newer;
|
||||
Kind = kind;
|
||||
|
||||
ProjectFilePath = older?.FilePath ?? newer.FilePath;
|
||||
ProjectFilePath = older?.FilePath ?? newer!.FilePath;
|
||||
}
|
||||
|
||||
public ProjectSnapshotHandleProxy Older { get; }
|
||||
public ProjectSnapshotHandleProxy? Older { get; }
|
||||
|
||||
public ProjectSnapshotHandleProxy Newer { get; }
|
||||
public ProjectSnapshotHandleProxy? Newer { get; }
|
||||
|
||||
public Uri ProjectFilePath { get; }
|
||||
|
||||
|
|
|
@ -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.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -14,8 +12,8 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
public ProjectSnapshotHandleProxy(
|
||||
Uri filePath,
|
||||
RazorConfiguration configuration,
|
||||
string rootNamespace,
|
||||
ProjectWorkspaceState projectWorkspaceState)
|
||||
string? rootNamespace,
|
||||
ProjectWorkspaceState? projectWorkspaceState)
|
||||
{
|
||||
if (filePath is null)
|
||||
{
|
||||
|
@ -37,8 +35,8 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
|
||||
public RazorConfiguration Configuration { get; }
|
||||
|
||||
public string RootNamespace { get; }
|
||||
public string? RootNamespace { get; }
|
||||
|
||||
public ProjectWorkspaceState ProjectWorkspaceState { get; }
|
||||
public ProjectWorkspaceState? ProjectWorkspaceState { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -35,16 +33,16 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
|
|||
|
||||
public async Task<bool> HasCapabilityAsync(Uri pathOfFileInProject, string capability, CancellationToken cancellationToken)
|
||||
{
|
||||
if (capability is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(capability));
|
||||
}
|
||||
|
||||
if (pathOfFileInProject is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(pathOfFileInProject));
|
||||
}
|
||||
|
||||
if (capability is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(capability));
|
||||
}
|
||||
|
||||
await _joinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
|
||||
|
||||
var hostPathOfFileInProject = _session.ConvertSharedUriToLocalPath(pathOfFileInProject);
|
||||
|
|
|
@ -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.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.Shell;
|
||||
|
|
|
@ -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.Razor;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -28,4 +26,4 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Serialization
|
|||
collection.RegisterRazorConverters();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -20,7 +18,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Serialization
|
|||
return typeof(ProjectSnapshotHandleProxy).IsAssignableFrom(objectType);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType != JsonToken.StartObject)
|
||||
{
|
||||
|
@ -28,17 +26,17 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Serialization
|
|||
}
|
||||
|
||||
var obj = JObject.Load(reader);
|
||||
var filePath = obj[nameof(ProjectSnapshotHandleProxy.FilePath)].ToObject<Uri>(serializer);
|
||||
var rootNamespace = obj[nameof(ProjectSnapshotHandleProxy.RootNamespace)].ToObject<string>(serializer);
|
||||
var projectWorkspaceState = obj[nameof(ProjectSnapshotHandleProxy.ProjectWorkspaceState)].ToObject<ProjectWorkspaceState>(serializer);
|
||||
var configuration = obj[nameof(ProjectSnapshotHandleProxy.Configuration)].ToObject<RazorConfiguration>(serializer);
|
||||
var filePath = obj[nameof(ProjectSnapshotHandleProxy.FilePath)]!.ToObject<Uri>(serializer);
|
||||
var rootNamespace = obj[nameof(ProjectSnapshotHandleProxy.RootNamespace)]!.ToObject<string>(serializer);
|
||||
var projectWorkspaceState = obj[nameof(ProjectSnapshotHandleProxy.ProjectWorkspaceState)]!.ToObject<ProjectWorkspaceState>(serializer);
|
||||
var configuration = obj[nameof(ProjectSnapshotHandleProxy.Configuration)]!.ToObject<RazorConfiguration>(serializer);
|
||||
|
||||
return new ProjectSnapshotHandleProxy(filePath, configuration, rootNamespace, projectWorkspaceState);
|
||||
return new ProjectSnapshotHandleProxy(filePath!, configuration!, rootNamespace, projectWorkspaceState);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
||||
{
|
||||
var handle = (ProjectSnapshotHandleProxy)value;
|
||||
var handle = (ProjectSnapshotHandleProxy)value!;
|
||||
|
||||
writer.WriteStartObject();
|
||||
|
||||
|
|
|
@ -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.ComponentModel.Composition;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.Text;
|
||||
using MonoDevelop.Ide;
|
||||
|
@ -31,7 +30,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
_projectService = projectService;
|
||||
}
|
||||
|
||||
public override bool TryGetWorkspace(ITextBuffer textBuffer, out Workspace workspace)
|
||||
public override bool TryGetWorkspace(ITextBuffer textBuffer, [NotNullWhen(returnValue: true)] out Workspace? workspace)
|
||||
{
|
||||
if (textBuffer is null)
|
||||
{
|
||||
|
@ -62,7 +61,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
return TryGetWorkspace(hostSolution, out workspace);
|
||||
}
|
||||
|
||||
public override bool TryGetWorkspace(Solution solution, out Workspace workspace)
|
||||
public override bool TryGetWorkspace(Solution solution, [NotNullWhen(returnValue: true)] out Workspace? workspace)
|
||||
{
|
||||
if (solution is null)
|
||||
{
|
||||
|
|
|
@ -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.Editor.Razor;
|
||||
|
@ -42,7 +40,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor
|
|||
_projectCapabilityResolver = projectCapabilityResolver;
|
||||
}
|
||||
|
||||
public override object GetHostProject(ITextBuffer textBuffer)
|
||||
public override object? GetHostProject(ITextBuffer textBuffer)
|
||||
{
|
||||
if (textBuffer is null)
|
||||
{
|
||||
|
@ -59,7 +57,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.Editor
|
|||
return hostProject;
|
||||
}
|
||||
|
||||
public override object GetHostProject(string documentFilePath)
|
||||
public override object? GetHostProject(string documentFilePath)
|
||||
{
|
||||
var projectsContainingFilePath = IdeApp.Workspace.GetProjectsContainingFile(documentFilePath);
|
||||
foreach (var project in projectsContainingFilePath)
|
||||
|
|
|
@ -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.Text.Editor;
|
||||
|
|
|
@ -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;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
|
|
@ -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 System.Linq;
|
||||
|
@ -22,7 +20,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
private readonly TextBufferProjectService _projectService;
|
||||
private readonly ProjectWorkspaceStateGenerator _workspaceStateGenerator;
|
||||
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
|
||||
private ProjectSnapshotManagerBase _projectManager;
|
||||
private ProjectSnapshotManagerBase? _projectManager;
|
||||
|
||||
[ImportingConstructor]
|
||||
public ProjectBuildChangeTrigger(
|
||||
|
@ -92,7 +90,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
|
||||
_projectManager = projectManager;
|
||||
|
||||
if (IdeApp.ProjectOperations != null)
|
||||
if (IdeApp.ProjectOperations is not null)
|
||||
{
|
||||
IdeApp.ProjectOperations.EndBuild += ProjectOperations_EndBuild;
|
||||
}
|
||||
|
@ -126,12 +124,12 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
}
|
||||
|
||||
var projectPath = _projectService.GetProjectPath(projectItem);
|
||||
var projectSnapshot = _projectManager.GetLoadedProject(projectPath);
|
||||
if (projectSnapshot != null)
|
||||
var projectSnapshot = _projectManager?.GetLoadedProject(projectPath);
|
||||
if (projectSnapshot is not null)
|
||||
{
|
||||
var workspaceProject = _projectManager.Workspace.CurrentSolution?.Projects.FirstOrDefault(
|
||||
var workspaceProject = _projectManager?.Workspace.CurrentSolution?.Projects.FirstOrDefault(
|
||||
project => FilePathComparer.Instance.Equals(project.FilePath, projectSnapshot.FilePath));
|
||||
if (workspaceProject != null)
|
||||
if (workspaceProject is not null)
|
||||
{
|
||||
// Trigger a tag helper update by forcing the project manager to see the workspace Project
|
||||
// from the current solution.
|
||||
|
|
|
@ -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 System.Threading;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -23,7 +22,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
private readonly TextBufferProjectService _projectService;
|
||||
private readonly ProjectConfigurationFilePathStore _projectConfigurationFilePathStore;
|
||||
private readonly LanguageServerFeatureOptions _languageServerFeatureOptions;
|
||||
private MacRazorProjectHostBase _razorProjectHost;
|
||||
private MacRazorProjectHostBase? _razorProjectHost;
|
||||
|
||||
public DefaultDotNetProjectHost(
|
||||
DotNetProject project,
|
||||
|
@ -72,7 +71,9 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Internal for testing
|
||||
#pragma warning disable CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
internal DefaultDotNetProjectHost(
|
||||
#pragma warning restore CS8618 // Non-nullable variable must contain a non-null value when exiting constructor. Consider declaring it as nullable.
|
||||
ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
|
||||
VisualStudioMacWorkspaceAccessor workspaceAccessor,
|
||||
TextBufferProjectService projectService,
|
||||
|
@ -162,7 +163,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}, CancellationToken.None);
|
||||
}
|
||||
|
||||
private bool TryGetProjectSnapshotManager(out ProjectSnapshotManagerBase projectSnapshotManagerBase)
|
||||
private bool TryGetProjectSnapshotManager([NotNullWhen(returnValue: true)] out ProjectSnapshotManagerBase? projectSnapshotManagerBase)
|
||||
{
|
||||
if (!_workspaceAccessor.TryGetWorkspace(_project.ParentSolution, out var workspace))
|
||||
{
|
||||
|
|
|
@ -1,11 +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
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -136,7 +135,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
return true;
|
||||
}
|
||||
|
||||
private string GetAbsolutePath(string projectDirectory, string relativePath)
|
||||
private static string GetAbsolutePath(string projectDirectory, string relativePath)
|
||||
{
|
||||
if (!Path.IsPathRooted(relativePath))
|
||||
{
|
||||
|
@ -153,7 +152,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
internal static bool TryGetConfiguration(
|
||||
IMSBuildEvaluatedPropertyCollection projectProperties,
|
||||
IEnumerable<IMSBuildItemEvaluated> projectItems,
|
||||
out RazorConfiguration configuration)
|
||||
[NotNullWhen(returnValue: true)] out RazorConfiguration? configuration)
|
||||
{
|
||||
if (!TryGetDefaultConfiguration(projectProperties, out var defaultConfiguration))
|
||||
{
|
||||
|
@ -180,7 +179,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Internal for testing
|
||||
internal static bool TryGetDefaultConfiguration(IMSBuildEvaluatedPropertyCollection projectProperties, out string defaultConfiguration)
|
||||
internal static bool TryGetDefaultConfiguration(IMSBuildEvaluatedPropertyCollection projectProperties, [NotNullWhen(returnValue: true)] out string? defaultConfiguration)
|
||||
{
|
||||
defaultConfiguration = projectProperties.GetValue(RazorDefaultConfigurationProperty);
|
||||
if (string.IsNullOrEmpty(defaultConfiguration))
|
||||
|
@ -193,7 +192,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Internal for testing
|
||||
internal static bool TryGetLanguageVersion(IMSBuildEvaluatedPropertyCollection projectProperties, out RazorLanguageVersion languageVersion)
|
||||
internal static bool TryGetLanguageVersion(IMSBuildEvaluatedPropertyCollection projectProperties, [NotNullWhen(returnValue: true)] out RazorLanguageVersion? languageVersion)
|
||||
{
|
||||
var languageVersionValue = projectProperties.GetValue(RazorLangVersionProperty);
|
||||
if (string.IsNullOrEmpty(languageVersionValue))
|
||||
|
@ -214,7 +213,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
internal static bool TryGetConfigurationItem(
|
||||
string configuration,
|
||||
IEnumerable<IMSBuildItemEvaluated> projectItems,
|
||||
out IMSBuildItemEvaluated configurationItem)
|
||||
[NotNullWhen(returnValue: true)] out IMSBuildItemEvaluated? configurationItem)
|
||||
{
|
||||
foreach (var item in projectItems)
|
||||
{
|
||||
|
@ -268,7 +267,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Internal for testing
|
||||
internal static bool TryGetRootNamespace(IMSBuildEvaluatedPropertyCollection projectProperties, out string rootNamespace)
|
||||
internal static bool TryGetRootNamespace(IMSBuildEvaluatedPropertyCollection projectProperties, [NotNullWhen(returnValue: true)] out string? rootNamespace)
|
||||
{
|
||||
rootNamespace = projectProperties.GetValue(RootNamespaceProperty);
|
||||
if (string.IsNullOrEmpty(rootNamespace))
|
||||
|
|
|
@ -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 MonoDevelop.Projects;
|
||||
|
||||
namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
||||
|
|
|
@ -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.CodeAnalysis.Razor;
|
||||
|
|
|
@ -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.IO;
|
||||
using System.Linq;
|
||||
|
@ -78,7 +76,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
return false;
|
||||
}
|
||||
|
||||
if (string.Equals(reference.FilePath.FileName, MvcAssemblyFileName, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(reference!.FilePath.FileName, MvcAssemblyFileName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Mvc assembly
|
||||
return true;
|
||||
|
@ -87,18 +85,16 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
return false;
|
||||
}
|
||||
|
||||
private static Version GetAssemblyVersion(string filePath)
|
||||
private static Version? GetAssemblyVersion(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
using (var reader = new PEReader(stream))
|
||||
{
|
||||
var metadataReader = reader.GetMetadataReader();
|
||||
using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using var reader = new PEReader(stream);
|
||||
var metadataReader = reader.GetMetadataReader();
|
||||
|
||||
var assemblyDefinition = metadataReader.GetAssemblyDefinition();
|
||||
return assemblyDefinition.Version;
|
||||
}
|
||||
var assemblyDefinition = metadataReader.GetAssemblyDefinition();
|
||||
return assemblyDefinition.Version;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -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 System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
@ -72,7 +71,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
|
||||
public DotNetProject DotNetProject { get; }
|
||||
|
||||
public HostProject HostProject { get; private set; }
|
||||
public HostProject? HostProject { get; private set; }
|
||||
|
||||
protected ProjectSnapshotManagerDispatcher ProjectSnapshotManagerDispatcher { get; }
|
||||
|
||||
|
@ -100,7 +99,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}
|
||||
|
||||
// Must be called inside the lock.
|
||||
protected async Task UpdateHostProjectUnsafeAsync(HostProject newHostProject)
|
||||
protected async Task UpdateHostProjectUnsafeAsync(HostProject? newHostProject)
|
||||
{
|
||||
await ProjectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(
|
||||
() => UpdateHostProjectProjectSnapshotManagerDispatcher(newHostProject), CancellationToken.None).ConfigureAwait(false);
|
||||
|
@ -154,11 +153,11 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
}, args, CancellationToken.None);
|
||||
}
|
||||
|
||||
private void UpdateHostProjectProjectSnapshotManagerDispatcher(object state)
|
||||
private void UpdateHostProjectProjectSnapshotManagerDispatcher(object? state)
|
||||
{
|
||||
ProjectSnapshotManagerDispatcher.AssertDispatcherThread();
|
||||
|
||||
var newHostProject = (HostProject)state;
|
||||
var newHostProject = (HostProject?)state;
|
||||
|
||||
if (HostProject is null && newHostProject is null)
|
||||
{
|
||||
|
@ -208,7 +207,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
// Internal for testing
|
||||
internal static bool TryGetIntermediateOutputPath(
|
||||
IMSBuildEvaluatedPropertyCollection projectProperties,
|
||||
out string path)
|
||||
[NotNullWhen(returnValue: true)] out string? path)
|
||||
{
|
||||
if (!projectProperties.HasProperty(BaseIntermediateOutputPathPropertyName))
|
||||
{
|
||||
|
@ -265,7 +264,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor.ProjectSystem
|
|||
return true;
|
||||
}
|
||||
|
||||
private static string ResolveFallbackIntermediateOutputPath(IMSBuildEvaluatedPropertyCollection projectProperties, string intermediateOutputPathValue)
|
||||
private static string? ResolveFallbackIntermediateOutputPath(IMSBuildEvaluatedPropertyCollection projectProperties, string intermediateOutputPathValue)
|
||||
{
|
||||
if (!projectProperties.HasProperty(MSBuildProjectDirectoryPropertyName))
|
||||
{
|
||||
|
|
|
@ -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.Concurrent;
|
||||
using System.ComponentModel.Composition;
|
||||
|
@ -37,7 +35,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
_dynamicFileInfoProvider.Updated += InnerUpdated;
|
||||
}
|
||||
|
||||
public event Action<DocumentInfo> Updated;
|
||||
public event Action<DocumentInfo>? Updated;
|
||||
|
||||
public DocumentInfo GetDynamicDocumentInfo(ProjectId projectId, string projectFilePath, string filePath)
|
||||
{
|
||||
|
@ -119,7 +117,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
throw new ArgumentNullException(nameof(current));
|
||||
}
|
||||
|
||||
Current = current;
|
||||
_current = current;
|
||||
Lock = new object();
|
||||
}
|
||||
|
||||
|
@ -143,7 +141,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem
|
|||
{
|
||||
lock (Lock)
|
||||
{
|
||||
return $"{Current.FilePath} - {Current.TextLoader.GetType()}";
|
||||
return $"{Current.FilePath} - {(Current.TextLoader is null ? "null" : Current.TextLoader.GetType())}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +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.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.Editor.Razor;
|
||||
using Microsoft.VisualStudio.Editor.Razor.Documents;
|
||||
|
@ -22,7 +19,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
internal class RazorDocumentControllerExtension : DocumentControllerExtension
|
||||
{
|
||||
private readonly VisualStudioWorkspaceAccessor _workspaceAccessor;
|
||||
private VisualStudioMacEditorDocumentManager _editorDocumentManager;
|
||||
private VisualStudioMacEditorDocumentManager? _editorDocumentManager;
|
||||
|
||||
public RazorDocumentControllerExtension()
|
||||
{
|
||||
|
@ -42,7 +39,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
|
||||
_editorDocumentManager = workspace.Services.GetRequiredService<EditorDocumentManager>() as VisualStudioMacEditorDocumentManager;
|
||||
|
||||
Debug.Assert(_editorDocumentManager != null);
|
||||
Assumes.NotNull(_editorDocumentManager);
|
||||
|
||||
_editorDocumentManager.HandleDocumentOpened(filePath, textBuffer);
|
||||
|
||||
|
|
|
@ -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 System.Diagnostics;
|
||||
|
@ -42,7 +40,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
|
|||
exception);
|
||||
}
|
||||
|
||||
public override void ReportError(Exception exception, ProjectSnapshot project)
|
||||
public override void ReportError(Exception exception, ProjectSnapshot? project)
|
||||
{
|
||||
if (exception is null)
|
||||
{
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче