diff --git a/azure-pipelines-richnav.yml b/azure-pipelines-richnav.yml
index 5e99eb8ae1..ae26443c9a 100644
--- a/azure-pipelines-richnav.yml
+++ b/azure-pipelines-richnav.yml
@@ -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
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 6780f0e9dc..d87fcc9931 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -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
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index b3c76cb5bd..58f161a3fb 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -32,9 +32,9 @@
https://dev.azure.com/dnceng/internal/_git/dotnet-runtime
3a25a7f1cc446b60678ed25c9d829420d6321eba
-
+
https://github.com/dotnet/arcade
- 91db46836065516e87e05bbdb51c5aee0f90428c
+ ba4d2568dd2e3e7538feeaba60215f7bcb99e89c
diff --git a/eng/Versions.props b/eng/Versions.props
index 5508dcafbc..632c9b7802 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -77,7 +77,7 @@
17.2.32330.158
17.3.133-preview
4.4.0-2.22424.2
- 17.4.1004-preview
+ 17.4.1008-preview
4.4.0-1.final
4.4.0-3.22463.10
@@ -111,6 +111,7 @@
$(MicrosoftVisualStudioShellPackagesVersion)
$(MicrosoftVisualStudioShellPackagesVersion)
17.3.3-alpha
+ 16.4.137
$(MicrosoftVisualStudioPackagesVersion)
$(MicrosoftVisualStudioPackagesVersion)
$(MicrosoftVisualStudioPackagesVersion)
diff --git a/eng/common/build.ps1 b/eng/common/build.ps1
index 8943da242f..33a6f2d0e2 100644
--- a/eng/common/build.ps1
+++ b/eng/common/build.ps1
@@ -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 Sets warnaserror msbuild parameter ('true' or 'false')"
Write-Host " -msbuildEngine 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
}
diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1
index 8d48ec5680..ac42f04a9d 100644
--- a/eng/common/init-tools-native.ps1
+++ b/eng/common/init-tools-native.ps1
@@ -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."
diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml
index 9ff6a10a68..781a41c940 100644
--- a/eng/common/templates/job/execute-sdl.yml
+++ b/eng/common/templates/job/execute-sdl.yml
@@ -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, '') }}:
diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml
index e3ba939801..459f3c4fcb 100644
--- a/eng/common/templates/job/job.yml
+++ b/eng/common/templates/job/job.yml
@@ -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
diff --git a/eng/common/templates/jobs/source-build.yml b/eng/common/templates/jobs/source-build.yml
index 00aa98eb3b..8dd2d355f2 100644
--- a/eng/common/templates/jobs/source-build.yml
+++ b/eng/common/templates/jobs/source-build.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,
diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml
index 12a8ff94d8..4ec5577d28 100644
--- a/eng/common/templates/steps/source-build.yml
+++ b/eng/common/templates/steps/source-build.yml
@@ -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.
diff --git a/global.json b/global.json
index 04dcea6e3b..41ee89d9cd 100644
--- a/global.json
+++ b/global.json
@@ -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"
}
}
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj
index 28787dee7a..485d28d874 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj
@@ -8,9 +8,10 @@
-
-
-
+
+
+
+
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Telemetry/ITelemetryReporter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Telemetry/ITelemetryReporter.cs
new file mode 100644
index 0000000000..e61476f8fa
--- /dev/null
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer.Common/Telemetry/ITelemetryReporter.cs
@@ -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);
+ }
+}
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
index 0789603c71..4b70ad1cc9 100644
--- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorLanguageServer.cs
@@ -112,6 +112,12 @@ internal class RazorLanguageServer : AbstractLanguageServer
// Folding Range Providers
services.AddSingleton();
+ // Get the DefaultSession for telemetry. This is set by VS with
+ // TelemetryService.SetDefaultSession and provides the correct
+ // appinsights keys etc
+ services.AddSingleton(provider =>
+ new TelemetryReporter(ImmutableArray.Create(TelemetryService.DefaultSession), provider.GetRequiredService()));
+
AddHandlers(services);
var lspServices = new LspServices(services);
diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Telemetry/TelemetryReporter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Telemetry/TelemetryReporter.cs
new file mode 100644
index 0000000000..6c05d96f96
--- /dev/null
+++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Telemetry/TelemetryReporter.cs
@@ -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 _telemetrySessions;
+ private readonly ILogger _logger;
+
+ public TelemetryReporter(ImmutableArray telemetrySessions, ILoggerFactory loggerFactory)
+ {
+ _telemetrySessions = telemetrySessions;
+ _logger = loggerFactory.CreateLogger();
+ }
+
+ 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");
+ }
+ }
+ }
+}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs
index ea66096926..4fea46e962 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs
index e1b475aaf7..f5b00fad7a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/HostProject.cs
@@ -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; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Program.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Program.cs
index 6ae96136aa..89532d66e3 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Program.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor.CoreComponents/Program.cs
@@ -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
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/IRemoteTagHelperProviderService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/IRemoteTagHelperProviderService.cs
index 0d91ba93ea..d3bd05aebb 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/IRemoteTagHelperProviderService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/IRemoteTagHelperProviderService.cs
@@ -13,6 +13,6 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
{
ValueTask GetTagHelpersAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken);
- ValueTask GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken);
+ ValueTask GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string? factoryTypeName, int lastResultId, CancellationToken cancellationToken);
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolver.cs
index 3f0b2712f4..d41398b571 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolver.cs
@@ -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 ResolveTagHelpersOutOfProcessAsync(IProjectEngineFactory factory, Project workspaceProject, ProjectSnapshot projectSnapshot, CancellationToken cancellationToken)
+ protected virtual async Task 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 ProduceTagHelpersFromDelta(string projectFilePath, int lastResultId, TagHelperDeltaResult deltaResult)
+ protected virtual IReadOnlyCollection? ProduceTagHelpersFromDelta(string projectFilePath, int lastResultId, TagHelperDeltaResult deltaResult)
{
if (!_resultCache.TryGet(projectFilePath, lastResultId, out var tagHelpers))
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolverFactory.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolverFactory.cs
index 1757580f19..83cfa14f3a 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolverFactory.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/OOPTagHelperResolverFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs
index cbd015136f..60306bc10f 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs
@@ -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 DocumentFilePaths => Array.Empty();
public override string FilePath { get; }
- public override string RootNamespace { get; }
+ public override string? RootNamespace { get; }
public override VersionStamp Version { get; }
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperProviderService.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperProviderService.cs
index 04369271cb..2e454581f4 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperProviderService.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperProviderService.cs
@@ -26,10 +26,10 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
public ValueTask GetTagHelpersAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken = default)
=> RazorBrokeredServiceImplementation.RunServiceAsync(cancellationToken => GetTagHelpersCoreAsync(solutionInfo, projectHandle, factoryTypeName, cancellationToken), cancellationToken);
- public ValueTask GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken)
+ public ValueTask GetTagHelpersDeltaAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string? factoryTypeName, int lastResultId, CancellationToken cancellationToken)
=> RazorBrokeredServiceImplementation.RunServiceAsync(cancellationToken => GetTagHelpersDeltaCoreAsync(solutionInfo, projectHandle, factoryTypeName, lastResultId, cancellationToken), cancellationToken);
- private async ValueTask GetTagHelpersCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, CancellationToken cancellationToken)
+ private async ValueTask 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 GetTagHelpersDeltaCoreAsync(RazorPinnedSolutionInfoWrapper solutionInfo, ProjectSnapshotHandle projectHandle, string factoryTypeName, int lastResultId, CancellationToken cancellationToken)
+ public async ValueTask 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;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperResolver.cs
index 850cd7732e..9d667adfd9 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperResolver.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RemoteTagHelperResolver.cs
@@ -32,8 +32,8 @@ namespace Microsoft.CodeAnalysis.Razor
public Task 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)
{
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/JsonConverterCollectionExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/JsonConverterCollectionExtensions.cs
index 23df1379fc..d8c5fed2cf 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/JsonConverterCollectionExtensions.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/JsonConverterCollectionExtensions.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandle.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandle.cs
index e1a3688580..949c552135 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandle.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandle.cs
@@ -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; }
}
}
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandleJsonConverter.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandleJsonConverter.cs
index 165cda5936..f145b5d409 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandleJsonConverter.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Serialization/ProjectSnapshotHandleJsonConverter.cs
@@ -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();
diff --git a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/TagHelperResultCache.cs b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/TagHelperResultCache.cs
index bfe3ea93a5..05ab04f645 100644
--- a/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/TagHelperResultCache.cs
+++ b/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/TagHelperResultCache.cs
@@ -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(sizeLimit: 50);
}
- public bool TryGet(string projectFilePath, int resultId, out IReadOnlyCollection? cachedTagHelpers)
+ public bool TryGet(string projectFilePath, int resultId, [NotNullWhen(returnValue: true)] out IReadOnlyCollection? cachedTagHelpers)
{
if (!_projectResultCache.TryGetValue(projectFilePath, out var cachedResult))
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectPathProvider.cs b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectPathProvider.cs
index 314762b2ad..a855c38ec5 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectPathProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/DefaultProjectPathProvider.cs
@@ -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)
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/ProjectPathProvider.cs b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/ProjectPathProvider.cs
index c64f1e65fb..6cc0e673a1 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/ProjectPathProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/ProjectPathProvider.cs
@@ -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);
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs
index bacbe41dc6..b945e54799 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioCompletionBroker.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs
index f60fa75078..1e68b7469e 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Editor.Razor/VisualStudioWorkspaceAccessor.cs
@@ -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);
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Debugging/VsEnumBSTR.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Debugging/VsEnumBSTR.cs
index 2b64c8bdb9..1197edbbc3 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Debugging/VsEnumBSTR.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Debugging/VsEnumBSTR.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs
index 76c716e47b..ba9cec5a57 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultVisualStudioWorkspaceAccessor.cs
@@ -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);
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/RunningDocumentTableEventSink.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/RunningDocumentTableEventSink.cs
index 8c27f240ee..6d848c35df 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/RunningDocumentTableEventSink.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/RunningDocumentTableEventSink.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManager.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManager.cs
index 811c2ee3d1..c74d0a6969 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManager.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManager.cs
@@ -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();
}
- 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(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)
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManagerFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManagerFactory.cs
index f7451f78f6..3073c733dc 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManagerFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioEditorDocumentManagerFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTracker.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTracker.cs
index 72194681a5..e15e77ce26 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTracker.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTracker.cs
@@ -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 _fileChangeAdviseTask;
- internal JoinableTask _fileChangeUnadviseTask;
- internal JoinableTask _fileChangedTask;
+ internal JoinableTask? _fileChangeAdviseTask;
+ internal JoinableTask? _fileChangeUnadviseTask;
+ internal JoinableTask? _fileChangedTask;
- public override event EventHandler Changed;
+ public override event EventHandler? 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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs
index 079940e3b3..f605a04f19 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs
index 11701456d8..722306b3e4 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs
@@ -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();
- return new VisualStudioFileChangeTrackerFactory(errorReporter, _fileChangeService, _projectSnapshotManagerDispatcher, _joinableTaskContext);
+ return new VisualStudioFileChangeTrackerFactory(errorReporter, _fileChangeService!, _projectSnapshotManagerDispatcher, _joinableTaskContext);
}
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VsTextBufferDataEventsSink.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VsTextBufferDataEventsSink.cs
index aba6c2905c..b3ae10dd49 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VsTextBufferDataEventsSink.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VsTextBufferDataEventsSink.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs
index 3979bde234..c27ef10cd4 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs
@@ -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)))
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs
index e59190bd68..9ec76a1077 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs
index 69f868aca5..f006eda573 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs
index 9518a52964..71f8a1812e 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWindowsRazorProjectHost.cs
@@ -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 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 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 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 state,
- out string rootNamespace)
+ [NotNullWhen(returnValue: true)] out string? rootNamespace)
{
if (!state.TryGetValue(ConfigurationGeneralSchemaName, out var rule))
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWorkspaceProjectContextFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWorkspaceProjectContextFactory.cs
index 94ebd32975..e760864ed7 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWorkspaceProjectContextFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultWorkspaceProjectContextFactory.cs
@@ -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 folderNames = null)
+ public void AddDynamicSourceFile(string filePath, IEnumerable? folderNames = null)
{
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackWindowsRazorProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackWindowsRazorProjectHost.cs
index 581b5c2dd5..352603dd47 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackWindowsRazorProjectHost.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/FallbackWindowsRazorProjectHost.cs
@@ -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 itemState, out HostDocument razorDocument)
+ internal bool TryGetRazorDocument(IImmutableDictionary 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
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IUnconfiguredProjectCommonServices.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IUnconfiguredProjectCommonServices.cs
index 10eda49a71..9a81fc21a7 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IUnconfiguredProjectCommonServices.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IUnconfiguredProjectCommonServices.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContext.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContext.cs
index 9b035d468d..535132ac8c 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContext.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContext.cs
@@ -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 folderNames, SourceCodeKind sourceCodeKind);
- void AddDynamicSourceFile(string filePath, IEnumerable folderNames = null);
+ void AddDynamicSourceFile(string filePath, IEnumerable? folderNames = null);
void RemoveSourceFile(string filePath);
void RemoveDynamicSourceFile(string filePath);
void AddAdditionalFile(string filePath, bool isInCurrentContext = true);
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContextFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContextFactory.cs
index 3520d19029..3a1afdb473 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContextFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/IWorkspaceProjectContextFactory.cs
@@ -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
\ No newline at end of file
+#endif
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ManagedProjectSystemSchema.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ManagedProjectSystemSchema.cs
index 064943ca68..462b8e9d77 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ManagedProjectSystemSchema.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ManagedProjectSystemSchema.cs
@@ -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
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ProjectExternalErrorReporter.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ProjectExternalErrorReporter.cs
index acf6a05c5e..fc6d6ea480 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ProjectExternalErrorReporter.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/ProjectExternalErrorReporter.cs
@@ -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
\ No newline at end of file
+#endif
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs
index 2da0579635..98d20d313e 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/Rules/RazorProjectProperties.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/UnconfiguredProjectCommonServices.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/UnconfiguredProjectCommonServices.cs
index fb89d67bd6..8a8ced1f83 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/UnconfiguredProjectCommonServices.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/UnconfiguredProjectCommonServices.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/WindowsRazorProjectHostBase.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/WindowsRazorProjectHostBase.cs
index 2070d7e078..6d347dd871 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/WindowsRazorProjectHostBase.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/WindowsRazorProjectHostBase.cs
@@ -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 _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();
- }
+ _projectManager ??= (ProjectSnapshotManagerBase)_workspace.Services.GetLanguageServices(RazorLanguage.Name).GetRequiredService();
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 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))
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDisableDropHandlerProvider.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDisableDropHandlerProvider.cs
index 4ad538fd8d..78aefca117 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDisableDropHandlerProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorDisableDropHandlerProvider.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorLSPTextViewConnectionListener.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorLSPTextViewConnectionListener.cs
index f9c66e29fc..5fd5284c3f 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorLSPTextViewConnectionListener.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorLSPTextViewConnectionListener.cs
@@ -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 _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;
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporter.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporter.cs
index be16620526..69d4988d85 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporter.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporter.cs
@@ -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;
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs
index c40d733e9d..3838963ce1 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs
index 6ed61e89d3..081e3a04ce 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsHostServicesProvider.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsHostServicesProvider.cs
index b0ad97a1dc..cf438c86d0 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsHostServicesProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsHostServicesProvider.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsProjectCapabilityResolver.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsProjectCapabilityResolver.cs
index 61ca41c06e..bb030a6411 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsProjectCapabilityResolver.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VisualStudioWindowsProjectCapabilityResolver.cs
@@ -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);
diff --git a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VsSolutionUpdatesProjectSnapshotChangeTrigger.cs b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VsSolutionUpdatesProjectSnapshotChangeTrigger.cs
index 10203d9ce1..e6ede07393 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VsSolutionUpdatesProjectSnapshotChangeTrigger.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/VsSolutionUpdatesProjectSnapshotChangeTrigger.cs
@@ -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.
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultLiveShareSessionAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultLiveShareSessionAccessor.cs
index d8b3518fdb..bfa00f853a 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultLiveShareSessionAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultLiveShareSessionAccessor.cs
@@ -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;
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultProxyAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultProxyAccessor.cs
index 6ef772b3bd..e5e11aa617 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultProxyAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/DefaultProxyAccessor.cs
@@ -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();
- }
+ _projectHierarchyProxy ??= CreateServiceProxy();
return _projectHierarchyProxy;
}
@@ -55,8 +52,9 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Guest
// Internal virtual for testing
internal virtual TProxy CreateServiceProxy() where TProxy : class
{
+ Assumes.NotNull(_liveShareSessionAccessor.Session);
#pragma warning disable VSTHRD110 // Observe result of async calls
- return _joinableTaskFactory.Run(() => _liveShareSessionAccessor.Session?.GetRemoteServiceAsync(typeof(TProxy).Name, CancellationToken.None));
+ return _joinableTaskFactory.Run(() => _liveShareSessionAccessor.Session.GetRemoteServiceAsync(typeof(TProxy).Name, CancellationToken.None));
#pragma warning restore VSTHRD110 // Observe result of async calls
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/GuestProjectPathProvider.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/GuestProjectPathProvider.cs
index 92191bcd67..6609f369a2 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/GuestProjectPathProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/GuestProjectPathProvider.cs
@@ -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);
}
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/LiveShareSessionAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/LiveShareSessionAccessor.cs
index b0199bd9dc..6be8e6f27b 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/LiveShareSessionAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/LiveShareSessionAccessor.cs
@@ -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; }
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationService.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationService.cs
index d6d5792ab0..ffc7b2e541 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationService.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationService.cs
@@ -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);
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationServiceFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationServiceFactory.cs
index 32158ebf14..785749a1d3 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationServiceFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProjectSnapshotSynchronizationServiceFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProxyAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProxyAccessor.cs
index 9f9ed66ed4..be3c9c7f17 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProxyAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/ProxyAccessor.cs
@@ -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
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/RazorGuestInitializationService.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/RazorGuestInitializationService.cs
index 687e82ebb0..e93c7cecfa 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/RazorGuestInitializationService.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Guest/RazorGuestInitializationService.cs
@@ -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()
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxy.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxy.cs
index ce9999abac..17a4a7c9fb 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxy.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxy.cs
@@ -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 GetProjectPathAsync(Uri documentFilePath, CancellationToken cancellationToken)
+ public async Task 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);
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxyFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxyFactory.cs
index 4394ade512..353fb63bb9 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxyFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectHierarchyProxyFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxy.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxy.cs
index 4caee8c734..ddf8e92547 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxy.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxy.cs
@@ -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 Changed;
+ public event EventHandler? Changed;
public async Task 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)
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxyFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxyFactory.cs
index 79cd2b6582..1194df311c 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxyFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Host/DefaultProjectSnapshotManagerProxyFactory.cs
@@ -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;
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectHierarchyProxy.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectHierarchyProxy.cs
index 6e88e43c41..ff62d3c05b 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectHierarchyProxy.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectHierarchyProxy.cs
@@ -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 GetProjectPathAsync(Uri documentFilePath, CancellationToken cancellationToken);
+ Task GetProjectPathAsync(Uri documentFilePath, CancellationToken cancellationToken);
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectSnapshotManagerProxy.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectSnapshotManagerProxy.cs
index e69f54a949..259ba39248 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectSnapshotManagerProxy.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IProjectSnapshotManagerProxy.cs
@@ -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 Changed;
+ event EventHandler? Changed;
Task GetProjectManagerStateAsync(CancellationToken cancellationToken);
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IRemoteHierarchyService.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IRemoteHierarchyService.cs
index a9f1460b1a..49691bf934 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IRemoteHierarchyService.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/IRemoteHierarchyService.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/LiveShareProjectCapabilityResolver.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/LiveShareProjectCapabilityResolver.cs
index f29f634488..ee7b80c51d 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/LiveShareProjectCapabilityResolver.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/LiveShareProjectCapabilityResolver.cs
@@ -59,7 +59,7 @@ namespace Microsoft.VisualStudio.LiveShare.Razor
// questions on hierarchy capabilities.
return _joinableTaskFactory.Run(async () =>
{
- var remoteHierarchyService = await _sessionAccessor.Session.GetRemoteServiceAsync(nameof(IRemoteHierarchyService), CancellationToken.None).ConfigureAwait(false);
+ var remoteHierarchyService = await _sessionAccessor.Session!.GetRemoteServiceAsync(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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectChangeEventProxyArgs.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectChangeEventProxyArgs.cs
index 124ee7bd8c..c83a94c555 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectChangeEventProxyArgs.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectChangeEventProxyArgs.cs
@@ -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; }
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotHandleProxy.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotHandleProxy.cs
index 5c05a96f79..63d34f327e 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotHandleProxy.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotHandleProxy.cs
@@ -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; }
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotManagerProxyState.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotManagerProxyState.cs
index a946dea6a8..b3ca7b3aa3 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotManagerProxyState.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/ProjectSnapshotManagerProxyState.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyService.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyService.cs
index 09db175ef1..a6fb49cada 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyService.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyService.cs
@@ -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 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);
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyServiceFactory.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyServiceFactory.cs
index 2864735c90..aaeae236cd 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyServiceFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/RemoteHierarchyServiceFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/LiveShareJsonConverterCollectionExtensions.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/LiveShareJsonConverterCollectionExtensions.cs
index 5f8a727789..11c4c8ac42 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/LiveShareJsonConverterCollectionExtensions.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/LiveShareJsonConverterCollectionExtensions.cs
@@ -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();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/ProjectSnapshotHandleProxyJsonConverter.cs b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/ProjectSnapshotHandleProxyJsonConverter.cs
index 1394d7ccb1..8bc7aa2a63 100644
--- a/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/ProjectSnapshotHandleProxyJsonConverter.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.LiveShare.Razor/Serialization/ProjectSnapshotHandleProxyJsonConverter.cs
@@ -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(serializer);
- var rootNamespace = obj[nameof(ProjectSnapshotHandleProxy.RootNamespace)].ToObject(serializer);
- var projectWorkspaceState = obj[nameof(ProjectSnapshotHandleProxy.ProjectWorkspaceState)].ToObject(serializer);
- var configuration = obj[nameof(ProjectSnapshotHandleProxy.Configuration)].ToObject(serializer);
+ var filePath = obj[nameof(ProjectSnapshotHandleProxy.FilePath)]!.ToObject(serializer);
+ var rootNamespace = obj[nameof(ProjectSnapshotHandleProxy.RootNamespace)]!.ToObject(serializer);
+ var projectWorkspaceState = obj[nameof(ProjectSnapshotHandleProxy.ProjectWorkspaceState)]!.ToObject(serializer);
+ var configuration = obj[nameof(ProjectSnapshotHandleProxy.Configuration)]!.ToObject(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();
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultVisualStudioMacWorkspaceAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultVisualStudioMacWorkspaceAccessor.cs
index 01b2c531a2..02e071fb6a 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultVisualStudioMacWorkspaceAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultVisualStudioMacWorkspaceAccessor.cs
@@ -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)
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs
index 5a65023e17..bf49065450 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs
@@ -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)
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs
index db3636c55e..08bc85bcd2 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBroker.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs
index ab299b2d73..9992e2a9f0 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Editor/DefaultVisualStudioCompletionBrokerFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectBuildChangeTrigger.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectBuildChangeTrigger.cs
index 4a3499ceec..bd9d6ae486 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectBuildChangeTrigger.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectBuildChangeTrigger.cs
@@ -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.
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultDotNetProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultDotNetProjectHost.cs
index 2f44077a30..9b19c8928f 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultDotNetProjectHost.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultDotNetProjectHost.cs
@@ -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))
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultMacRazorProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultMacRazorProjectHost.cs
index 8ebf034556..3bbe117517 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultMacRazorProjectHost.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DefaultMacRazorProjectHost.cs
@@ -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 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 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))
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHost.cs
index f29848aed6..e814d821a2 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHost.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHost.cs
@@ -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
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHostFactory.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHostFactory.cs
index 0d36a89602..a17eff7426 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHostFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/DotNetProjectHostFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/FallbackMacRazorProjectHost.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/FallbackMacRazorProjectHost.cs
index af3f01f44b..27538d0553 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/FallbackMacRazorProjectHost.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/FallbackMacRazorProjectHost.cs
@@ -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
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/MacRazorProjectHostBase.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/MacRazorProjectHostBase.cs
index 5ad4d7c00b..47e76bded8 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/MacRazorProjectHostBase.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/MacRazorProjectHostBase.cs
@@ -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))
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/RazorDynamicDocumentInfoProvider.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/RazorDynamicDocumentInfoProvider.cs
index 7542693839..346d889f5b 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/RazorDynamicDocumentInfoProvider.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/ProjectSystem/RazorDynamicDocumentInfoProvider.cs
@@ -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 Updated;
+ public event Action? 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())}";
}
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/RazorDocumentControllerExtension.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/RazorDocumentControllerExtension.cs
index fcb56a5bdb..0a589e44e9 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/RazorDocumentControllerExtension.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/RazorDocumentControllerExtension.cs
@@ -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() as VisualStudioMacEditorDocumentManager;
- Debug.Assert(_editorDocumentManager != null);
+ Assumes.NotNull(_editorDocumentManager);
_editorDocumentManager.HandleDocumentOpened(filePath, textBuffer);
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporter.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporter.cs
index 4c7ea8d609..590ea621e2 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporter.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporter.cs
@@ -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)
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs
index c62649c2d0..dba121539b 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioErrorReporterFactory.cs
@@ -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.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManager.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManager.cs
index 8b9dc3658f..f5e8766c9b 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManager.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManager.cs
@@ -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;
@@ -25,7 +23,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
{
}
- protected override ITextBuffer GetTextBufferForOpenDocument(string filePath)
+ protected override ITextBuffer? GetTextBufferForOpenDocument(string filePath)
{
if (filePath is null)
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManagerFactory.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManagerFactory.cs
index 3f135de6eb..32d81f7836 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManagerFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacEditorDocumentManagerFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTracker.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTracker.cs
index 0e271b40a3..64b5993d1b 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTracker.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTracker.cs
@@ -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 Microsoft.CodeAnalysis.Razor;
@@ -17,7 +15,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
private readonly string _normalizedFilePath;
private bool _listening;
- public override event EventHandler Changed;
+ public override event EventHandler? Changed;
public VisualStudioMacFileChangeTracker(
string filePath,
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactory.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactory.cs
index dcad09dec9..5e24b478fc 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactory.cs
@@ -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.Editor.Razor.Documents;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactoryFactory.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactoryFactory.cs
index 661153a762..6ab4490bed 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactoryFactory.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacFileChangeTrackerFactoryFactory.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacLSPEditorFeatureDetector.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacLSPEditorFeatureDetector.cs
index 7ba2c33f46..1f5a6c5233 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacLSPEditorFeatureDetector.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacLSPEditorFeatureDetector.cs
@@ -50,13 +50,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
{
}
- public override bool IsLSPEditorAvailable(string documentFilePath, object hierarchy)
+ public override bool IsLSPEditorAvailable(string documentFilePath, object? hierarchy)
{
- if (documentFilePath is null)
- {
- return false;
- }
-
if (!IsLSPEditorAvailable())
{
return false;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacWorkspaceAccessor.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacWorkspaceAccessor.cs
index 0a7c7eed5f..ab0ea7a726 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacWorkspaceAccessor.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioMacWorkspaceAccessor.cs
@@ -1,8 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-#nullable disable
-
+using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Editor.Razor;
using MonoDevelop.Projects;
using Workspace = Microsoft.CodeAnalysis.Workspace;
@@ -11,6 +10,6 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor
{
internal abstract class VisualStudioMacWorkspaceAccessor : VisualStudioWorkspaceAccessor
{
- public abstract bool TryGetWorkspace(Solution solution, out Workspace workspace);
+ public abstract bool TryGetWorkspace(Solution solution, [NotNullWhen(returnValue: true)] out Workspace? workspace);
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs
index 74cdb8cace..6938e325ea 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/VisualStudioProjectSnapshotManagerDispatcher.cs
@@ -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;
diff --git a/src/Razor/src/Microsoft.VisualStudio.Mac.RazorAddin/RazorProjectExtension.cs b/src/Razor/src/Microsoft.VisualStudio.Mac.RazorAddin/RazorProjectExtension.cs
index 83a8326ec1..d24a89d597 100644
--- a/src/Razor/src/Microsoft.VisualStudio.Mac.RazorAddin/RazorProjectExtension.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.Mac.RazorAddin/RazorProjectExtension.cs
@@ -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.CodeAnalysis.Razor;
@@ -17,7 +15,7 @@ namespace Microsoft.VisualStudio.Mac.RazorAddin
{
private readonly object _lock = new();
private readonly ProjectSnapshotManagerDispatcher _projectSnapshotManagerDispatcher;
- private CancellationTokenSource _cancellationTokenSource;
+ private CancellationTokenSource? _cancellationTokenSource;
public RazorProjectExtension()
{
diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AboutDialogInfoAttribute.cs b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AboutDialogInfoAttribute.cs
index 805b7343d5..89d445bf07 100644
--- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AboutDialogInfoAttribute.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AboutDialogInfoAttribute.cs
@@ -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.Globalization;
using System.Reflection;
@@ -27,7 +25,7 @@ namespace Microsoft.VisualStudio.RazorExtension
}
// This is a resource ID it should start with #
- public string IconResourceID { get; set; }
+ public string? IconResourceID { get; set; }
private string GetKeyName()
{
@@ -44,23 +42,21 @@ namespace Microsoft.VisualStudio.RazorExtension
var attribute = typeof(AboutDialogInfoAttribute).Assembly.GetCustomAttribute();
var version = attribute?.InformationalVersion;
- using (var key = context.CreateKey(GetKeyName()))
+ using var key = context.CreateKey(GetKeyName());
+ key.SetValue(null, _nameId);
+ key.SetValue("Package", Guid.Parse(_packageGuid).ToString("B", CultureInfo.InvariantCulture));
+ key.SetValue("ProductDetails", _detailsId);
+ key.SetValue("UseInterface", false);
+ key.SetValue("UseVSProductID", false);
+
+ if (version != null)
{
- key.SetValue(null, _nameId);
- key.SetValue("Package", Guid.Parse(_packageGuid).ToString("B", CultureInfo.InvariantCulture));
- key.SetValue("ProductDetails", _detailsId);
- key.SetValue("UseInterface", false);
- key.SetValue("UseVSProductID", false);
+ key.SetValue("PID", version);
+ }
- if (version != null)
- {
- key.SetValue("PID", version);
- }
-
- if (IconResourceID != null)
- {
- key.SetValue("LogoID", IconResourceID);
- }
+ if (IconResourceID != null)
+ {
+ key.SetValue("LogoID", IconResourceID);
}
}
diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyBindingRedirects.cs b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyBindingRedirects.cs
index b860230694..5220580b34 100644
--- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyBindingRedirects.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyBindingRedirects.cs
@@ -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.Shell;
[assembly: ProvideBindingRedirection(
diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyCodeBases.cs b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyCodeBases.cs
index a896d8d072..78f18688fa 100644
--- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyCodeBases.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/AssemblyCodeBases.cs
@@ -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.Shell;
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.CommonLanguageServerProtocol.Framework.dll")]
diff --git a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/RazorPackage.cs b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/RazorPackage.cs
index ca4f3021fb..5c3d028499 100644
--- a/src/Razor/src/Microsoft.VisualStudio.RazorExtension/RazorPackage.cs
+++ b/src/Razor/src/Microsoft.VisualStudio.RazorExtension/RazorPackage.cs
@@ -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.Design;
using System.Runtime.InteropServices;
diff --git a/src/Razor/src/rzls/Program.cs b/src/Razor/src/rzls/Program.cs
index c75c42f7aa..245d393f04 100644
--- a/src/Razor/src/rzls/Program.cs
+++ b/src/Razor/src/rzls/Program.cs
@@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
-#nullable disable
-
using System;
using System.Diagnostics;
using System.Threading;