Merge branch 'main' of github.com:dotnet/razor-tooling into OmniSharpDecouple

This commit is contained in:
Ryan Brandenburg 2022-11-22 11:19:19 -08:00
Родитель f7b35c202c b647abee9c
Коммит da167eb0c4
109 изменённых файлов: 755 добавлений и 602 удалений

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

@ -80,7 +80,6 @@
<package pattern="humanizer.core" />
<package pattern="iced" />
<package pattern="icsharpcode.decompiler" />
<package pattern="mediatr" />
<package pattern="messagepack" />
<package pattern="messagepack.annotations" />
<package pattern="messagepackanalyzer" />
@ -104,12 +103,12 @@
<package pattern="omnisharp.abstractions" />
<!-- The following are all needed because of a single reference to DocumentUri in
FormattingLanguageServerClient for testing. We should remove them -->
<package pattern="omnisharp.abstractions" />
<package pattern="mediatr" />
<package pattern="omnisharp.extensions.jsonrpc" />
<package pattern="omnisharp.extensions.jsonrpc.generators" />
<package pattern="omnisharp.extensions.languageprotocol" />
<package pattern="omnisharp.extensions.languageserver" />
<package pattern="omnisharp.extensions.languageserver.shared" />
<!-- -->
<package pattern="omnisharp.abstractions" />
<package pattern="omnisharp.msbuild" />
<package pattern="omnisharp.roslyn" />
<package pattern="omnisharp.roslyn.csharp" />

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

@ -16,6 +16,24 @@ variables:
- name: _InternalRuntimeDownloadArgs
value: /p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal
/p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64)
- group: DotNet-DevDiv-Insertion-Workflow-Variables
- name: _DevDivDropAccessToken
value: $(dn-bot-devdiv-drop-rw-code-rw)
- group: DotNet-Roslyn-Insertion-Variables
- name: Razor.GitHubEmail
value: dotnet-build-bot@microsoft.com
- name: Razor.GitHubToken
value: $(AccessToken-dotnet-build-bot-public-repo)
- name: Razor.GitHubUserName
value: dotnet-build-bot
- name: Insertion.CreateDraftPR
value: true
- name: Insertion.TitlePrefix
value: '[Auto Insertion]'
- name: Insertion.TitleSuffix
value: ''
- ${{ if eq(variables['System.TeamProject'], 'public') }}:
- name: _InternalRuntimeDownloadArgs
value: ''
@ -138,7 +156,7 @@ stages:
/p:OfficialBuildId=$(Build.BuildNumber)
/p:ManifestBuildBranch=$(Build.SourceBranchName)
/p:ManifestBuildNumber=$(Build.BuildNumber)
/p:VisualStudioDropName=Products/dotnet/razor-tooling/$(Build.SourceBranchName)/$(Build.BuildNumber)
/p:VisualStudioDropName=Products/$(System.TeamProject)/$(Build.Repository.Name)/$(Build.SourceBranchName)/$(Build.BuildNumber)
/p:GenerateSbom=true
steps:
@ -288,21 +306,20 @@ stages:
# searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
# continueOnError: true
# condition: always()
# Publish an artifact that the RoslynInsertionTool is able to find by its name.
- task: PublishBuildArtifacts@1
displayName: Publish VSIX Artifacts
displayName: Publish Artifact VSSetup
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/VSSetup/$(_BuildConfig)'
PublishLocation: Container
ArtifactName: VSIX_$(Agent.Os)_$(_BuildConfig)
PathtoPublish: 'artifacts\VSSetup\$(_BuildConfig)'
ArtifactName: 'VSSetup'
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- task: PublishBuildArtifacts@1
displayName: Publish VS for Mac Artifacts
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/MPack/$(_BuildConfig)'
PublishLocation: Container
PathtoPublish: 'artifacts\MPack\$(_BuildConfig)'
ArtifactName: MPack_$(Agent.Os)_$(_BuildConfig)
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
@ -310,8 +327,7 @@ stages:
- task: PublishBuildArtifacts@1
displayName: Publish package artifacts
inputs:
PathtoPublish: $(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)
PublishLocation: Container
PathtoPublish: 'artifacts\packages\$(_BuildConfig)'
ArtifactName: Packages_$(Agent.Os)_$(_BuildConfig)
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
@ -319,11 +335,25 @@ stages:
- task: PublishBuildArtifacts@1
displayName: Publish VS Code extension artifacts
inputs:
PathtoPublish: $(Build.SourcesDirectory)/artifacts/packages/VSCode/$(_BuildConfig)
PublishLocation: Container
PathtoPublish: 'artifacts\packages\VSCode\$(_BuildConfig)'
ArtifactName: BlazorWasmDebuggingExtension
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(Build.SourceBranchName)/$(Build.BuildNumber)"
displayName: Setting VisualStudio.DropName variable
# Publishes setup VSIXes to a drop.
# Note: The insertion tool looks for the display name of this task in the logs.
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
- task: ms-vseng.MicroBuildTasks.4305a8de-ba66-4d8b-b2d1-0dc4ecbbf5e8.MicroBuildUploadVstsDropFolder@1
displayName: Upload VSTS Drop
inputs:
DropName: $(VisualStudio.DropName)
DropFolder: 'artifacts\VSSetup\$(_BuildConfig)\Insertion'
AccessToken: $(_DevDivDropAccessToken)
continueOnError: true
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false), eq(variables['_BuildConfig'], 'Release'))
- ${{ if eq(variables['System.TeamProject'], 'public') }}:
- job: macOS
@ -449,3 +479,31 @@ stages:
-TsaRepositoryName "Razor-Tooling"
-TsaCodebaseName "Razor-Tooling"
-TsaPublish $True
- stage: insert
dependsOn: publish_using_darc
displayName: Insert to VS
jobs:
- job: insert
displayName: Insert to VS
pool:
name: NetCore1ESPool-Svc-Internal
demands: ImageOverride -equals windows.vs2022.amd64
steps:
- download: current
artifact: VSSetup
- powershell: |
$branchName = "$(Build.SourceBranch)".Substring("refs/heads/".Length)
Write-Host "##vso[task.setvariable variable=ComponentBranchName]$branchName"
displayName: Get Branch Name
- template: eng/pipelines/insert.yml
parameters:
buildUserName: "dn-bot@microsoft.com"
buildPassword: $(dn-bot-devdiv-build-e-code-full-release-e-packaging-r)
componentUserName: "dn-bot@microsoft.com"
componentPassword: $(dn-bot-dnceng-build-e-code-full-release-e-packaging-r)
componentBuildProjectName: internal
sourceBranch: "$(ComponentBranchName)"
publishDataURI: "https://dev.azure.com/dnceng/internal/_apis/git/repositories/dotnet-razor/items?path=/eng/config/PublishData.json&versionType=commit&version=507dd3c0c9af56897c7d9f2830c82d690e0ef3d4&api-version=6.0"
publishDataAccessToken: "$(System.AccessToken)"
dropPath: '$(Pipeline.Workspace)\VSSetup'

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

@ -2,7 +2,9 @@
## Shared
- Target Framework: `netstandard2.0`
This project is shared between all layers (both compiler and tooling) to provide language support types for modern C# language features.
- Target Framework: `net7.0;netstandard2.0;net472`
- Projects:
- Microsoft.AspNetCore.Razor.LanguageSupport
@ -19,13 +21,21 @@
## Tooling Core
- Target Framework: `netstandard2.0`
These projects are referenced by most Razor tooling projects. Because of this, they
target the broadest set of frameworks.
- Target Framework: `net7.0;netstandard2.0;net472`
- Projects:
- Microsoft.AspNetCore.Razor.Common
- Microsoft.CodeAnalysis.Razor.Workspaces
## Razor Language Server
- Target Framework: `net7.0;net472`
- Projects:
- Microsoft.AspNetCore.Razor.LanguageServer
- Microsoft.AspNetCore.Razor.LanguageServer.Common
- Microsoft.AspNetCore.Razor.LanguageServer.Protocol
- Microsoft.CodeAnalysis.Razor.Workspaces
## Razor Language Server (rzls)
@ -70,23 +80,26 @@
## Shared
- Microsoft.AspNetCore.Razor.Test.Common (`net6.0`;`netstandard2.0`;`net472`)
- Microsoft.AspNetCore.Razor.Test.Common (`net7.0`;`net472`)
## API Shims
- Microsoft.AspNetCore.Razor.Test.ComponentShim (`netstandard2.0`;`net472`)
- Microsoft.AspNetCore.Razor.Test.ComponentShim (`netstandard2.0`)
- Microsoft.AspNetCore.Razor.Test.MvcShim (`net7.0`;`net472`)
- Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib (`netstandard2.0`)
- Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X (`net7.0`;`netstandard2.0`)
- Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X (`net7.0`;`netstandard2.0`)
- Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X (`net7.0`;`net472`)
- Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X (`net7.0`;`net4720`)
## Tooling Core
- Microsoft.CodeAnalysis.Razor.Workspaces.Test (`net7.0`;`net472` - only on Windows)
- Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common (`netstandard2.0`)
- Microsoft.CodeAnalysis.Razor.Workspaces.Test.Common (`net7.0`;`net472`)
## Language Server
- Microsoft.AspNetCore.Razor.LanguageServer.Common.Test (`net7.0`)
- Microsoft.AspNetCore.Razor.LanguageServer.Test (`net7.0-windows`)
- Microsoft.AspNetCore.Razor.LanguageServer.Test.Common (`netstandard2.0`)
- Microsoft.AspNetCore.Razor.LanguageServer.Test.Common (`net7.0`;`net472`)
## Roslyn OOP (for Visual Studio)

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

@ -14,11 +14,6 @@
-->
<ItemGroup>
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="MediatR.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.JsonRpc.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.LanguageProtocol.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="OmniSharp.Extensions.LanguageServer.Shared.dll" CertificateName="3PartySHA2" />
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="3PartySHA2" />
</ItemGroup>

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

@ -36,8 +36,8 @@
imported. This OK because we want to just have an obvious salt for a local build.
-->
<PropertyGroup>
<VsixVersionPrefix>17.0.0</VsixVersionPrefix>
<AddinMajorVersion>17.3</AddinMajorVersion>
<VsixVersionPrefix>17.5.2</VsixVersionPrefix>
<AddinMajorVersion>17.5</AddinMajorVersion>
<AddinVersion>$(AddinMajorVersion)</AddinVersion>
<AddinVersion Condition="'$(OfficialBuildId)' != ''">$(AddinVersion).$(OfficialBuildId)</AddinVersion>
<AddinVersion Condition="'$(OfficialBuildId)' == ''">$(AddinVersion).42424242.42</AddinVersion>
@ -86,8 +86,8 @@
<PropertyGroup Label="Manual">
<!-- dotnet/runtime packages -->
<MicrosoftExtensionsPackageVersion>6.0.0</MicrosoftExtensionsPackageVersion>
<SystemComponentModelPackageVersion>6.0.0</SystemComponentModelPackageVersion>
<SystemCollectionsImmutablePackageVersion>6.0.0</SystemCollectionsImmutablePackageVersion>
<SystemCompositionPackageVersion>6.0.0</SystemCompositionPackageVersion>
<SystemDiagnosticsDiagnosticSourcePackageVersion>6.0.0</SystemDiagnosticsDiagnosticSourcePackageVersion>
<SystemResourcesExtensionsPackageVersion>6.0.0</SystemResourcesExtensionsPackageVersion>
<SystemTextEncodingsWebPackageVersion>6.0.0</SystemTextEncodingsWebPackageVersion>

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

@ -0,0 +1,14 @@
{
"branches": {
"main": {
"nugetKind": [
"Shipping",
"NonShipping"
],
"vsBranch": "main",
"vsMajorVersion": 17,
"insertionCreateDraftPR": false,
"insertionTitlePrefix": "[17.5p2]"
}
}
}

198
eng/pipelines/insert.yml Normal file
Просмотреть файл

@ -0,0 +1,198 @@
parameters:
# These are actually booleans but must be defined as string.
# Parameters are evaluated at compile time, but all variables are strings at compile time.
# So in order to pass a parameter that comes from a variable these must be typed as string.
- name: createDraftPR
type: string
default: ''
- name: autoComplete
type: string
default: ''
- name: queueSpeedometerValidation
type: string
default: 'false'
- name: buildUserName
type: string
- name: buildPassword
type: string
- name: componentUserName
type: string
- name: componentPassword
type: string
- name: publishDataURI
type: string
- name: publishDataAccessToken
type: string
default: ''
- name: vsBranchName
type: string
default: ''
- name: componentBuildProjectName
type: string
default: ''
- name: titlePrefix
type: string
default: ''
- name: sourceBranch
type: string
- name: dropPath
type: string
default: ''
steps:
- checkout: none
- task: NuGetCommand@2
displayName: 'Install RIT from Azure Artifacts'
inputs:
command: custom
arguments: 'install RoslynTools.VisualStudioInsertionTool -PreRelease -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json'
- powershell: |
$authorization = if ("" -ne $Env:PublishDataAccessToken) { "Bearer $Env:PublishDataAccessToken" } else { "" }
$response = Invoke-RestMethod -Headers @{Authorization = $authorization} "${{ parameters.publishDataURI }}"
$branchName = "${{ parameters.sourceBranch }}"
$branchData = $response.branches.$branchName
if (!$branchData)
{
Write-Host "No PublishData found for branch '$branchName'. Using PublishData for branch 'main'."
$branchData = $response.branches.main
}
# Set our template variables to reasonable defaults
Write-Host "##vso[task.setvariable variable=Template.CreateDraftPR]$($true)"
Write-Host "##vso[task.setvariable variable=Template.AutoComplete]$($false)"
Write-Host "##vso[task.setvariable variable=Template.TitlePrefix]$('')"
Write-Host "##vso[task.setvariable variable=Template.TitleSuffix]$('')"
Write-Host "##vso[task.setvariable variable=Template.ComponentAzdoUri]$('')"
Write-Host "##vso[task.setvariable variable=Template.ComponentProjectName]$('')"
Write-Host "##vso[task.setvariable variable=Template.DropPath]$('(default)')"
Write-Host "##vso[task.setvariable variable=Template.ComponentBranchName]$branchName"
Write-Host "##vso[task.setvariable variable=Template.VSBranchName]$($branchData.vsBranch)"
# Overwrite the default template variables with the values from PublishData for this sourceBranch
if ($null -ne $branchData.insertionCreateDraftPR)
{
Write-Host "##vso[task.setvariable variable=Template.CreateDraftPR]$($branchData.insertionCreateDraftPR)"
}
if ($null -ne $branchData.insertionCreateDraftPR)
{
Write-Host "##vso[task.setvariable variable=Template.AutoComplete]$(-not $branchData.insertionCreateDraftPR)"
}
if ($null -ne $branchData.insertionTitlePrefix)
{
Write-Host "##vso[task.setvariable variable=Template.TitlePrefix]$($branchData.insertionTitlePrefix)"
}
displayName: Set Variables from PublishData
env:
PublishDataAccessToken: ${{ parameters.publishDataAccessToken }}
- powershell: |
# Set AzDO authorization template variables
Write-Host "Setting BuildUserName to $Env:BuildUserName"
Write-Host "##vso[task.setvariable variable=Template.BuildUserName]$Env:BuildUserName"
Write-Host "##vso[task.setvariable variable=Template.BuildPassword]$Env:BuildPassword"
Write-Host "Setting ComponentUserName to $Env:ComponentUserName"
Write-Host "##vso[task.setvariable variable=Template.ComponentUserName]$Env:ComponentUserName"
Write-Host "##vso[task.setvariable variable=Template.ComponentPassword]$Env:ComponentPassword"
# Overwrite template variables with values passed into this template as parameters
if ("" -ne $Env:CreateDraftPR)
{
Write-Host "Setting CreateDraftPR to $Env:CreateDraftPR"
Write-Host "##vso[task.setvariable variable=Template.CreateDraftPR]$Env:CreateDraftPR"
}
if ("" -ne $Env:AutoComplete)
{
Write-Host "Setting AutoComplete to $Env:AutoComplete"
Write-Host "##vso[task.setvariable variable=Template.AutoComplete]$Env:AutoComplete"
}
if ("" -ne $Env:TitlePrefix)
{
Write-Host "Setting TitlePrefix to $Env:TitlePrefix"
Write-Host "##vso[task.setvariable variable=Template.TitlePrefix]$Env:TitlePrefix"
}
# Workaround for pipeline parameters not supporting optional empty parameters.
if ("" -ne $Env:VSBranchName -and "default" -ne $Env:VSBranchName)
{
Write-Host "Setting VSBranchName to $Env:VSBranchName"
Write-Host "##vso[task.setvariable variable=Template.VSBranchName]$Env:VSBranchName"
}
if ("" -ne $Env:ComponentBuildProjectName)
{
Write-Host "Setting component Azdo parameters $('$(System.CollectionUri)') and $Env:ComponentBuildProjectName"
Write-Host "##vso[task.setvariable variable=Template.ComponentAzdoUri]$('$(System.CollectionUri)')"
Write-Host "##vso[task.setvariable variable=Template.ComponentProjectName]$Env:ComponentBuildProjectName"
}
if ("" -ne $Env:DropPath)
{
Write-Host "Setting DropPath to $Env:DropPath"
Write-Host "##vso[task.setvariable variable=Template.DropPath]$Env:DropPath"
}
displayName: Set Variables from Input Parameters
env:
BuildUserName: ${{ parameters.buildUserName }}
BuildPassword: ${{ parameters.buildPassword }}
ComponentUserName: ${{ parameters.componentUserName }}
ComponentPassword: ${{ parameters.componentPassword }}
CreateDraftPR: ${{ parameters.createDraftPR }}
AutoComplete: ${{ parameters.autoComplete }}
TitlePrefix: ${{ parameters.titlePrefix }}
VSBranchName: ${{ parameters.vsBranchName }}
ComponentBuildProjectName: ${{ parameters.componentBuildProjectName }}
DropPath: ${{ parameters.dropPath }}
# Now that everything is set, actually perform the insertion.
- powershell: |
mv RoslynTools.VisualStudioInsertionTool.* RIT
.\RIT\tools\net46\OneOffInsertion.ps1 `
-autoComplete "$(Template.AutoComplete)" `
-buildQueueName "$(Build.DefinitionName)" `
-cherryPick "(default)" `
-userName "$(Template.BuildUserName)" `
-password "$(Template.BuildPassword)" `
-componentUserName "$(Template.ComponentUserName)" `
-componentPassword "$(Template.ComponentPassword)" `
-componentAzdoUri "$(Template.ComponentAzdoUri)" `
-componentProjectName "$(Template.ComponentProjectName)" `
-componentName "Razor" `
-componentGitHubRepoName "dotnet/razor" `
-componentBranchName "$(Template.ComponentBranchName)" `
-createDraftPR "$(Template.CreateDraftPR)" `
-defaultValueSentinel "(default)" `
-dropPath "$(Template.DropPath)" `
-insertCore "false" `
-insertDevDiv "(default)" `
-insertionCount "1" `
-insertToolset "false" `
-titlePrefix "$(Template.TitlePrefix)" `
-titleSuffix "$(Template.TitleSuffix)" `
-queueValidation "true" `
-requiredValueSentinel "REQUIRED" `
-reviewerGUID "6c25b447-1d90-4840-8fde-d8b22cb8733e" `
-specificBuild "$(Build.BuildNumber)" `
-updateAssemblyVersions "false" `
-updateCoreXTLibraries "false" `
-visualStudioBranchName "$(Template.VSBranchName)" `
-writePullRequest "prid.txt" `
-queueSpeedometerValidation "${{ parameters.queueSpeedometerValidation }}"
displayName: 'Run OneOffInsertion.ps1'
- script: 'echo. && echo. && type "prid.txt" && echo. && echo.'
displayName: 'Report PR URL'

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

@ -13,8 +13,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X;
public sealed class ViewComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, ITagHelperDescriptorProvider
{
public string Name => nameof(ViewComponentTagHelperDescriptorProvider);
public int Order { get; set; }
public void Execute(TagHelperDescriptorProviderContext context)

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

@ -13,7 +13,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X;
public sealed class ViewComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, ITagHelperDescriptorProvider
{
public string Name => nameof(ViewComponentTagHelperDescriptorProvider);
public int Order { get; set; }
public void Execute(TagHelperDescriptorProviderContext context)

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

@ -13,7 +13,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions;
public sealed class ViewComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, ITagHelperDescriptorProvider
{
public string Name => nameof(ViewComponentTagHelperDescriptorProvider);
public int Order { get; set; }
public void Execute(TagHelperDescriptorProviderContext context)

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

@ -7,7 +7,6 @@ namespace Microsoft.AspNetCore.Razor.Language;
public interface ITagHelperDescriptorProvider : IRazorEngineFeature
{
string Name { get; }
int Order { get; }
void Execute(TagHelperDescriptorProviderContext context);

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

@ -15,8 +15,6 @@ namespace Microsoft.CodeAnalysis.Razor;
internal class BindTagHelperDescriptorProvider : ITagHelperDescriptorProvider
{
public string Name => nameof(BindTagHelperDescriptorProvider);
// Run after the component tag helper provider, because we need to see the results.
public int Order { get; set; } = 1000;

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

@ -26,7 +26,6 @@ internal class ComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, IT
.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Included)
.WithMiscellaneousOptions(SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions & (~SymbolDisplayMiscellaneousOptions.UseSpecialTypes));
public string Name => nameof(ComponentTagHelperDescriptorProvider);
public bool IncludeDocumentation { get; set; }
public int Order { get; set; }

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

@ -11,7 +11,6 @@ namespace Microsoft.CodeAnalysis.Razor;
public sealed class DefaultTagHelperDescriptorProvider : RazorEngineFeatureBase, ITagHelperDescriptorProvider
{
public string Name => nameof(DefaultTagHelperDescriptorProvider);
public int Order { get; set; }
public void Execute(TagHelperDescriptorProviderContext context)

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

@ -13,7 +13,6 @@ namespace Microsoft.CodeAnalysis.Razor;
internal class EventHandlerTagHelperDescriptorProvider : ITagHelperDescriptorProvider
{
public string Name => nameof(EventHandlerTagHelperDescriptorProvider);
public int Order { get; set; }
public RazorEngine Engine { get; set; }

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

@ -11,7 +11,6 @@ namespace Microsoft.CodeAnalysis.Razor;
internal class KeyTagHelperDescriptorProvider : ITagHelperDescriptorProvider
{
public string Name => nameof(KeyTagHelperDescriptorProvider);
// Run after the component tag helper provider
public int Order { get; set; } = 1000;

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

@ -11,8 +11,6 @@ namespace Microsoft.CodeAnalysis.Razor;
internal class RefTagHelperDescriptorProvider : ITagHelperDescriptorProvider
{
public string Name => nameof(RefTagHelperDescriptorProvider);
// Run after the component tag helper provider, because later we may want component-type-specific variants of this
public int Order { get; set; } = 1000;

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

@ -11,8 +11,6 @@ namespace Microsoft.CodeAnalysis.Razor;
internal class SplatTagHelperDescriptorProvider : ITagHelperDescriptorProvider
{
public string Name => nameof(SplatTagHelperDescriptorProvider);
// Order doesn't matter
public int Order { get; set; }

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>$(DefaultNetFxTargetFramework);$(DefaultNetCoreTargetFramework)</TargetFrameworks>
<OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);netstandard2.0;$(DefaultNetFxTargetFramework)</TargetFrameworks>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the language server library assets.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>
@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.VisualStudio.Telemetry" Version="$(MicrosoftVisualStudioTelemetryVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingPackageVersion)" />
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePackageVersion)" />
<PackageReference Include="System.Composition.AttributedModel" Version="$(SystemComponentModelPackageVersion)" />
<PackageReference Include="System.Composition.AttributedModel" Version="$(SystemCompositionPackageVersion)" />
</ItemGroup>
<ItemGroup>

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

@ -43,7 +43,10 @@ internal class AdhocServices : HostServices
// We need to create workspace services from the provided fallback host services. To do that we need to invoke into Roslyn's
// CreateWorkspaceServices method. Ultimately the reason behind this is to ensure that any services created by this class are
// truly isolated from the passed in fallback services host workspace.
_createWorkspaceServicesMethod = typeof(HostServices).GetMethod(nameof(CreateWorkspaceServices), BindingFlags.Instance | BindingFlags.NonPublic);
var createWorkspaceServicesMethod = typeof(HostServices).GetMethod(nameof(CreateWorkspaceServices), BindingFlags.Instance | BindingFlags.NonPublic);
Assumes.NotNull(createWorkspaceServicesMethod);
_createWorkspaceServicesMethod = createWorkspaceServicesMethod;
}
protected override HostWorkspaceServices CreateWorkspaceServices(Workspace workspace)
@ -64,5 +67,10 @@ internal class AdhocServices : HostServices
=> new AdhocServices(workspaceServices, razorLanguageServices, fallbackServices);
private HostWorkspaceServices CreateFallbackWorkspaceServices(Workspace workspace)
=> (HostWorkspaceServices)_createWorkspaceServicesMethod.Invoke(_fallbackHostServices, new[] { workspace });
{
var result = _createWorkspaceServicesMethod.Invoke(_fallbackHostServices, new[] { workspace }) as HostWorkspaceServices;
Assumes.NotNull(result);
return result;
}
}

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

@ -10,6 +10,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
@ -155,16 +156,13 @@ internal class BackgroundDocumentGenerator : ProjectSnapshotChangeTrigger
private void StartWorker()
{
// Access to the timer is protected by the lock in Synchronize and in Timer_Tick
if (_timer is null)
{
// Timer will fire after a fixed delay, but only once.
_timer = new Timer(Timer_Tick, null, Delay, Timeout.InfiniteTimeSpan);
}
// Timer will fire after a fixed delay, but only once.
_timer ??= new Timer(Timer_Tick, null, Delay, Timeout.InfiniteTimeSpan);
}
private void Timer_Tick(object state)
private void Timer_Tick(object? state)
{
_ = Timer_TickAsync(CancellationToken.None);
Timer_TickAsync(CancellationToken.None).Forget();
}
private async Task Timer_TickAsync(CancellationToken cancellationToken)
@ -213,10 +211,15 @@ internal class BackgroundDocumentGenerator : ProjectSnapshotChangeTrigger
lock (_work)
{
// Suppress analyzer that suggests using DisposeAsync().
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// Resetting the timer allows another batch of work to start.
_timer?.Dispose();
_timer = null;
#pragma warning restore VSTHRD103
// If more work came in while we were running start the worker again.
if (_work.Count > 0 && !_solutionIsClosing)
{
@ -231,8 +234,13 @@ internal class BackgroundDocumentGenerator : ProjectSnapshotChangeTrigger
// This is something totally unexpected, let's just send it over to the workspace.
ReportError(ex);
// Suppress analyzer that suggests using DisposeAsync().
#pragma warning disable VSTHRD103 // Call async methods when in an async method
_timer?.Dispose();
_timer = null;
#pragma warning restore VSTHRD103
}
}
@ -250,7 +258,7 @@ internal class BackgroundDocumentGenerator : ProjectSnapshotChangeTrigger
}
}
private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectSnapshotManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Don't do any work if the solution is closing
if (args.SolutionIsClosing)

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

@ -10,7 +10,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal static class FilePathNormalizer
{
public static string NormalizeDirectory(string directoryFilePath)
public static string NormalizeDirectory(string? directoryFilePath)
{
var normalized = Normalize(directoryFilePath);
@ -22,13 +22,15 @@ internal static class FilePathNormalizer
return normalized;
}
public static string Normalize(string filePath)
public static string Normalize(string? filePath)
{
if (string.IsNullOrEmpty(filePath))
{
return "/";
}
Assumes.NotNullOrEmpty(filePath);
var decodedPath = filePath.Contains("%") ? WebUtility.UrlDecode(filePath) : filePath;
var normalized = decodedPath.Replace('\\', '/');

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

@ -16,24 +16,20 @@ internal class HostDocumentComparer : IEqualityComparer<HostDocument>
{
}
public bool Equals(HostDocument x, HostDocument y)
public bool Equals(HostDocument? x, HostDocument? y)
{
if (x.FileKind != y.FileKind)
if (x is null)
{
return y is null;
}
else if (y is null)
{
return false;
}
if (!FilePathComparer.Instance.Equals(x.FilePath, y.FilePath))
{
return false;
}
if (!FilePathComparer.Instance.Equals(x.TargetPath, y.TargetPath))
{
return false;
}
return true;
return x.FileKind == y.FileKind &&
FilePathComparer.Instance.Equals(x.FilePath, y.FilePath) &&
FilePathComparer.Instance.Equals(x.TargetPath, y.TargetPath);
}
public int GetHashCode(HostDocument hostDocument)

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains common assets that are used in the Razor language server and other assemblies.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal class ProjectEngineFactories
internal static class ProjectEngineFactories
{
public static readonly Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>[] Factories =
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>[]
@ -31,9 +31,9 @@ internal class ProjectEngineFactories
() => new ProjectEngineFactory_3_0(),
new ExportCustomProjectEngineFactoryAttribute("MVC-3.0") { SupportsSerialization = true }),
// Unsupported (Legacy/System.Web.Razor)
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>(
() => new ProjectEngineFactory_Unsupported(),
new ExportCustomProjectEngineFactoryAttribute(UnsupportedRazorConfiguration.Instance.ConfigurationName) { SupportsSerialization = true }),
};
// Unsupported (Legacy/System.Web.Razor)
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>(
() => new ProjectEngineFactory_Unsupported(),
new ExportCustomProjectEngineFactoryAttribute(UnsupportedRazorConfiguration.Instance.ConfigurationName) { SupportsSerialization = true }),
};
}

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

@ -0,0 +1,38 @@
// 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.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal abstract class ProjectEngineFactory : IProjectEngineFactory
{
protected abstract string AssemblyName { get; }
public RazorProjectEngine Create(
RazorConfiguration configuration,
RazorProjectFileSystem fileSystem,
Action<RazorProjectEngineBuilder> configure)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyFullName = typeof(RazorProjectEngine).Assembly.FullName;
Assumes.NotNull(assemblyFullName);
var assemblyName = new AssemblyName(assemblyFullName)
{
Name = AssemblyName
};
var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName));
var initializer = extension.CreateInitializer();
return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
initializer.Initialize(b);
configure?.Invoke(b);
});
}
}

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

@ -1,32 +1,9 @@
// 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.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal class ProjectEngineFactory_1_0 : IProjectEngineFactory
internal class ProjectEngineFactory_1_0 : ProjectEngineFactory
{
private const string AssemblyName = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X";
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action<RazorProjectEngineBuilder> configure)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyName = new AssemblyName(typeof(RazorProjectEngine).Assembly.FullName)
{
Name = AssemblyName
};
var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName));
var initializer = extension.CreateInitializer();
return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
initializer.Initialize(b);
configure?.Invoke(b);
});
}
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X";
}

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

@ -1,32 +1,9 @@
// 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.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal class ProjectEngineFactory_1_1 : IProjectEngineFactory
internal class ProjectEngineFactory_1_1 : ProjectEngineFactory
{
private const string AssemblyName = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X";
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action<RazorProjectEngineBuilder> configure)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyName = new AssemblyName(typeof(RazorProjectEngine).Assembly.FullName)
{
Name = AssemblyName
};
var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName));
var initializer = extension.CreateInitializer();
return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
initializer.Initialize(b);
configure?.Invoke(b);
});
}
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X";
}

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

@ -1,32 +1,9 @@
// 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.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal class ProjectEngineFactory_2_0 : IProjectEngineFactory
internal class ProjectEngineFactory_2_0 : ProjectEngineFactory
{
private const string AssemblyName = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X";
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action<RazorProjectEngineBuilder> configure)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyName = new AssemblyName(typeof(RazorProjectEngine).Assembly.FullName)
{
Name = AssemblyName
};
var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName));
var initializer = extension.CreateInitializer();
return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
initializer.Initialize(b);
configure?.Invoke(b);
});
}
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X";
}

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

@ -1,31 +1,9 @@
// 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.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal class ProjectEngineFactory_2_1 : IProjectEngineFactory
internal class ProjectEngineFactory_2_1 : ProjectEngineFactory
{
private const string AssemblyName = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X";
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action<RazorProjectEngineBuilder> configure)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyName = new AssemblyName(typeof(RazorProjectEngine).Assembly.FullName)
{
Name = AssemblyName
};
var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName));
var initializer = extension.CreateInitializer();
return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
initializer.Initialize(b);
configure?.Invoke(b);
});
}
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X";
}

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

@ -1,34 +1,9 @@
// 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.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.CodeAnalysis.Razor;
namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;
internal class ProjectEngineFactory_3_0 : IProjectEngineFactory
internal class ProjectEngineFactory_3_0 : ProjectEngineFactory
{
private const string AssemblyName = "Microsoft.AspNetCore.Mvc.Razor.Extensions";
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action<RazorProjectEngineBuilder> configure)
{
// Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly.
var assemblyName = new AssemblyName(typeof(RazorProjectEngine).Assembly.FullName)
{
Name = AssemblyName
};
var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName));
var initializer = extension.CreateInitializer();
return RazorProjectEngine.Create(configuration, fileSystem, b =>
{
CompilerFeatures.Register(b);
initializer.Initialize(b);
configure?.Invoke(b);
});
}
protected override string AssemblyName { get; } = "Microsoft.AspNetCore.Mvc.Razor.Extensions";
}

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the language server protocol library assets for communicating server -&gt; client</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>
@ -14,5 +14,5 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Razor.Common\Microsoft.AspNetCore.Razor.Common.csproj" />
</ItemGroup>
</Project>

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

@ -45,7 +45,7 @@ internal class ComponentAccessibilityCodeActionProvider : RazorCodeActionProvide
}
// Find start tag
var startTag = (MarkupStartTagSyntax)node.Ancestors().FirstOrDefault(n => n is MarkupStartTagSyntax);
var startTag = node.Ancestors().FirstOrDefault(n => n is MarkupStartTagSyntax) as MarkupStartTagSyntax;
if (startTag is null)
{
return s_emptyResult;
@ -96,7 +96,11 @@ internal class ComponentAccessibilityCodeActionProvider : RazorCodeActionProvide
var path = context.Request.TextDocument.Uri.GetAbsoluteOrUNCPath();
path = FilePathNormalizer.Normalize(path);
var newComponentPath = Path.Combine(Path.GetDirectoryName(path), $"{startTag.Name.Content}.razor");
var directoryName = Path.GetDirectoryName(path);
Assumes.NotNull(directoryName);
var newComponentPath = Path.Combine(directoryName, $"{startTag.Name.Content}.razor");
if (File.Exists(newComponentPath))
{
return;

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

@ -146,11 +146,16 @@ internal class ExtractToCodeBehindCodeActionResolver : RazorCodeActionResolver
do
{
var identifier = n > 0 ? n.ToString(CultureInfo.InvariantCulture) : string.Empty; // Make it look nice
var directoryName = Path.GetDirectoryName(path);
Assumes.NotNull(directoryName);
codeBehindPath = Path.Combine(
Path.GetDirectoryName(path),
directoryName,
$"{Path.GetFileNameWithoutExtension(path)}{identifier}{Path.GetExtension(path)}.cs");
n++;
} while (File.Exists(codeBehindPath));
}
while (File.Exists(codeBehindPath));
return codeBehindPath;
}

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

@ -34,7 +34,7 @@ internal class CodeDocumentReferenceHolder : DocumentProcessedListener
_projectManager.Changed += ProjectManager_Changed;
}
private void ProjectManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Goal here is to evict cache entries (really just references to code documents) of known documents when
// related information changes for them

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

@ -95,20 +95,21 @@ internal class DesignTimeHelperResponseRewriter : DelegatedCompletionResponseRew
{
public static CompletionItemComparer Instance = new();
public bool Equals(CompletionItem x, CompletionItem y)
public bool Equals(CompletionItem? x, CompletionItem? y)
{
if (x is null && y is null)
if (x is null)
{
return true;
return y is null;
}
else if (x is null || y is null)
else if (y is null)
{
return false;
}
return x.Label.Equals(y.Label, StringComparison.Ordinal);
return x.Label == y.Label;
}
public int GetHashCode(CompletionItem obj) => obj?.Label?.GetHashCode() ?? 0;
public int GetHashCode(CompletionItem obj)
=> obj?.Label?.GetHashCode() ?? 0;
}
}

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

@ -136,7 +136,7 @@ internal class DefaultDocumentVersionCache : DocumentVersionCache
ProjectSnapshotManager.Changed += ProjectSnapshotManager_Changed;
}
private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectSnapshotManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Don't do any work if the solution is closing
if (args.SolutionIsClosing)

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

@ -166,7 +166,7 @@ internal class DefaultGeneratedDocumentPublisher : GeneratedDocumentPublisher
_ = _server.SendNotificationAsync(RazorLanguageServerCustomMessageTargets.RazorUpdateHtmlBufferEndpoint, request, CancellationToken.None);
}
private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectSnapshotManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Don't do any work if the solution is closing
if (args.SolutionIsClosing)

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

@ -25,7 +25,7 @@ internal class DefaultWorkspaceSemanticTokensRefreshTrigger : ProjectSnapshotCha
}
// Does not handle C# files
private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectSnapshotManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Don't send for a simple Document edit. The platform should re-request any range that
// is edited and if a parameter or type change is made it should be reflected as a ProjectChanged.

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

@ -230,27 +230,26 @@ internal class RazorTranslateDiagnosticsEndpoint :
_ => false,
};
static bool IsCSharpInStyleBlock(VSDiagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
static bool IsCSharpInStyleBlock(VSDiagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
{
// C# in a style block causes diagnostics because the HTML background document replaces C# with "~"
var owner = syntaxTree.GetOwner(sourceText, d.Range.Start, logger);
var owner = syntaxTree.GetOwner(sourceText, diagnostic.Range.Start, logger);
if (owner is null)
{
return false;
}
var element = owner.FirstAncestorOrSelf<MarkupElementSyntax>(
n => n.StartTag?.Name.Content.Equals("style", StringComparison.Ordinal) == true);
var cSharp = owner.FirstAncestorOrSelf<CSharpCodeBlockSyntax>();
var element = owner.FirstAncestorOrSelf<MarkupElementSyntax>(n => n.StartTag?.Name.Content == "style");
var csharp = owner.FirstAncestorOrSelf<CSharpCodeBlockSyntax>();
return element.Body.Any(c => c is CSharpCodeBlockSyntax) || cSharp is not null;
return element.Body.Any(c => c is CSharpCodeBlockSyntax) || csharp is not null;
}
// Ideally this would be solved instead by not emitting the "!" at the HTML backing file,
// but we don't currently have a system to accomplish that
static bool IsAnyFilteredTooFewElementsError(VSDiagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
static bool IsAnyFilteredTooFewElementsError(VSDiagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
{
var owner = syntaxTree.GetOwner(sourceText, d.Range.Start, logger);
var owner = syntaxTree.GetOwner(sourceText, diagnostic.Range.Start, logger);
if (owner is null)
{
return false;
@ -258,20 +257,24 @@ internal class RazorTranslateDiagnosticsEndpoint :
var element = owner.FirstAncestorOrSelf<MarkupElementSyntax>();
if (element.StartTag?.Name.Content.Equals("html", StringComparison.Ordinal) != true)
if (element.StartTag?.Name.Content != "html")
{
return false;
}
var bodyElement = (MarkupElementSyntax)element.ChildNodes().SingleOrDefault(c => c is MarkupElementSyntax tag && tag.StartTag?.Name.Content.Equals("body", StringComparison.Ordinal) == true);
return bodyElement is not null && bodyElement.StartTag?.Bang is not null;
var bodyElement = element
.ChildNodes()
.SingleOrDefault(c => c is MarkupElementSyntax tag && tag.StartTag?.Name.Content == "body") as MarkupElementSyntax;
return bodyElement is not null &&
bodyElement.StartTag?.Bang is not null;
}
// Ideally this would be solved instead by not emitting the "!" at the HTML backing file,
// but we don't currently have a system to accomplish that
static bool IsHtmlWithBangAndMatchingTags(VSDiagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
static bool IsHtmlWithBangAndMatchingTags(VSDiagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
{
var owner = syntaxTree.GetOwner(sourceText, d.Range.Start, logger);
var owner = syntaxTree.GetOwner(sourceText, diagnostic.Range.Start, logger);
if (owner is null)
{
return false;
@ -287,21 +290,19 @@ internal class RazorTranslateDiagnosticsEndpoint :
return false;
}
var haveBang = startNode.Bang != null && endNode.Bang != null;
var namesEquivilant = startNode.Name.Content.Equals(endNode.Name.Content, StringComparison.Ordinal);
var haveBang = startNode.Bang is not null && endNode.Bang is not null;
var namesEquivilant = startNode.Name.Content == endNode.Name.Content;
return haveBang && namesEquivilant;
}
static bool IsAnyFilteredInvalidNestingError(VSDiagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
{
return IsInvalidNestingWarningWithinComponent(d, sourceText, syntaxTree, logger) ||
IsInvalidNestingFromBody(d, sourceText, syntaxTree, logger);
}
static bool IsAnyFilteredInvalidNestingError(VSDiagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
=> IsInvalidNestingWarningWithinComponent(diagnostic, sourceText, syntaxTree, logger) ||
IsInvalidNestingFromBody(diagnostic, sourceText, syntaxTree, logger);
static bool IsInvalidNestingWarningWithinComponent(VSDiagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
static bool IsInvalidNestingWarningWithinComponent(VSDiagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
{
var owner = syntaxTree.GetOwner(sourceText, d.Range.Start, logger);
var owner = syntaxTree.GetOwner(sourceText, diagnostic.Range.Start, logger);
if (owner is null)
{
return false;
@ -314,9 +315,9 @@ internal class RazorTranslateDiagnosticsEndpoint :
// Ideally this would be solved instead by not emitting the "!" at the HTML backing file,
// but we don't currently have a system to accomplish that
static bool IsInvalidNestingFromBody(VSDiagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
static bool IsInvalidNestingFromBody(VSDiagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
{
var owner = syntaxTree.GetOwner(sourceText, d.Range.Start, logger);
var owner = syntaxTree.GetOwner(sourceText, diagnostic.Range.Start, logger);
if (owner is null)
{
return false;
@ -329,31 +330,31 @@ internal class RazorTranslateDiagnosticsEndpoint :
return false;
}
if (d.Message is null)
if (diagnostic.Message is null)
{
return false;
}
return d.Message.EndsWith("cannot be nested inside element 'html'.") && body.StartTag?.Bang != null;
return diagnostic.Message.EndsWith("cannot be nested inside element 'html'.") && body.StartTag?.Bang is not null;
}
}
private static bool InAttributeContainingCSharp(
VSDiagnostic d,
SourceText sourceText,
RazorSyntaxTree syntaxTree,
Dictionary<TextSpan, bool> processedAttributes,
ILogger logger)
VSDiagnostic diagnostic,
SourceText sourceText,
RazorSyntaxTree syntaxTree,
Dictionary<TextSpan, bool> processedAttributes,
ILogger logger)
{
// Examine the _end_ of the diagnostic to see if we're at the
// start of an (im/ex)plicit expression. Looking at the start
// of the diagnostic isn't sufficient.
if (d.Range is null)
if (diagnostic.Range is null)
{
return false;
}
var owner = syntaxTree.GetOwner(sourceText, d.Range.End, logger);
var owner = syntaxTree.GetOwner(sourceText, diagnostic.Range.End, logger);
if (owner is null)
{
return false;
@ -364,7 +365,7 @@ internal class RazorTranslateDiagnosticsEndpoint :
n is MarkupTagHelperAttributeSyntax ||
n is MarkupMiscAttributeContentSyntax);
if (markupAttributeNode != null)
if (markupAttributeNode is not null)
{
if (!processedAttributes.TryGetValue(markupAttributeNode.FullSpan, out var doesAttributeContainNonMarkup))
{
@ -385,6 +386,7 @@ internal class RazorTranslateDiagnosticsEndpoint :
n is MarkupSyntaxNode ||
n is GenericBlockSyntax ||
(n is SyntaxNode sn && sn.IsToken && sn.Kind != SyntaxKind.RazorCommentTransition)));
return containsNonMarkupNodes;
}
}

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

@ -80,11 +80,11 @@ internal class FormattingDiagnosticValidationPass : FormattingPassBase
{
public static IEqualityComparer<RazorDiagnostic> Instance = new LocationIgnoringDiagnosticComparer();
public bool Equals(RazorDiagnostic x, RazorDiagnostic y)
public bool Equals(RazorDiagnostic? x, RazorDiagnostic? y)
=> x is not null &&
y is not null &&
x.Severity.Equals(y.Severity) &&
x.Id.Equals(y.Id);
x.Severity == y.Severity &&
x.Id == y.Id;
public int GetHashCode(RazorDiagnostic obj)
=> obj.GetHashCode();

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the language server library assets.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -83,6 +83,8 @@ internal class MonitorProjectConfigurationFilePathEndpoint : IMonitorProjectConf
var workspaceDirectory = _workspaceDirectoryPathResolver.Resolve();
var normalizedWorkspaceDirectory = FilePathNormalizer.NormalizeDirectory(workspaceDirectory);
Assumes.NotNull(configurationDirectory);
var previousMonitorExists = _outputPathMonitors.TryGetValue(request.ProjectFilePath, out var entry);
if (normalizedConfigurationDirectory.StartsWith(normalizedWorkspaceDirectory, FilePathComparison.Instance))

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

@ -74,7 +74,7 @@ internal class OpenDocumentGenerator : ProjectSnapshotChangeTrigger, IDisposable
_workQueue.Dispose();
}
private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectSnapshotManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Don't do any work if the solution is closing
if (args.SolutionIsClosing)

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

@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.AspNetCore.Razor.LanguageServer;
@ -93,24 +94,18 @@ internal class RazorDiagnosticsPublisher : DocumentProcessedListener
private void StartWorkTimer()
{
// Access to the timer is protected by the lock in Synchronize and in Timer_Tick
if (_workTimer is null)
{
// Timer will fire after a fixed delay, but only once.
_workTimer = new Timer(WorkTimer_Tick, state: null, dueTime: _publishDelay, period: Timeout.InfiniteTimeSpan);
}
// Timer will fire after a fixed delay, but only once.
_workTimer ??= new Timer(WorkTimer_Tick, state: null, dueTime: _publishDelay, period: Timeout.InfiniteTimeSpan);
}
private void StartDocumentClosedCheckTimer()
{
if (_documentClosedTimer is null)
{
_documentClosedTimer = new Timer(DocumentClosedTimer_Tick, null, s_checkForDocumentClosedDelay, Timeout.InfiniteTimeSpan);
}
_documentClosedTimer ??= new Timer(DocumentClosedTimer_Tick, null, s_checkForDocumentClosedDelay, Timeout.InfiniteTimeSpan);
}
private void DocumentClosedTimer_Tick(object state)
private void DocumentClosedTimer_Tick(object? state)
{
_ = DocumentClosedTimer_TickAsync(CancellationToken.None);
DocumentClosedTimer_TickAsync(CancellationToken.None).Forget();
}
private async Task DocumentClosedTimer_TickAsync(CancellationToken cancellationToken)
@ -206,9 +201,9 @@ internal class RazorDiagnosticsPublisher : DocumentProcessedListener
}
}
private void WorkTimer_Tick(object state)
private void WorkTimer_Tick(object? state)
{
_ = WorkTimer_TickAsync(CancellationToken.None);
WorkTimer_TickAsync(CancellationToken.None).Forget();
}
private async Task WorkTimer_TickAsync(CancellationToken cancellationToken)
@ -232,10 +227,15 @@ internal class RazorDiagnosticsPublisher : DocumentProcessedListener
lock (_work)
{
// Suppress analyzer that suggests using DisposeAsync().
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// Resetting the timer allows another batch of work to start.
_workTimer?.Dispose();
_workTimer = null;
#pragma warning restore VSTHRD103 // Call async methods when in an async method
// If more work came in while we were running start the timer again.
if (_work.Count > 0)
{
@ -247,9 +247,15 @@ internal class RazorDiagnosticsPublisher : DocumentProcessedListener
{
lock (_work)
{
// Suppress analyzer that suggests using DisposeAsync().
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// Resetting the timer allows another batch of work to start.
_workTimer?.Dispose();
_workTimer = null;
#pragma warning restore VSTHRD103 // Call async methods when in an async method
}
throw;

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

@ -215,6 +215,8 @@ internal class RazorFileChangeDetector : IFileChangeDetector
var result = PendingNotifications.TryGetValue(physicalFilePath, out var notification);
Debug.Assert(result, "We should always have an associated notification after delaying an update.");
Assumes.NotNull(notification);
PendingNotifications.Remove(physicalFilePath);
if (notification.ChangeKind is null)

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

@ -34,31 +34,24 @@ internal class RazorLSPOptions : IEquatable<RazorLSPOptions>
public bool InsertSpaces { get; }
public static LogLevel GetLogLevelForTrace(Trace trace)
{
return trace switch
=> trace switch
{
Trace.Off => LogLevel.None,
Trace.Messages => LogLevel.Information,
Trace.Verbose => LogLevel.Trace,
_ => LogLevel.None,
};
}
public bool Equals(RazorLSPOptions? other)
{
return
other != null &&
Trace == other.Trace &&
EnableFormatting == other.EnableFormatting &&
AutoClosingTags == other.AutoClosingTags &&
InsertSpaces == other.InsertSpaces &&
TabSize == other.TabSize;
}
=> other is not null &&
Trace == other.Trace &&
EnableFormatting == other.EnableFormatting &&
AutoClosingTags == other.AutoClosingTags &&
InsertSpaces == other.InsertSpaces &&
TabSize == other.TabSize;
public override bool Equals(object obj)
{
return Equals(obj as RazorLSPOptions);
}
public override bool Equals(object? obj)
=> Equals(obj as RazorLSPOptions);
public override int GetHashCode()
{

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

@ -211,7 +211,9 @@ internal class RenameEndpoint : AbstractRazorDelegatingEndpoint<RenameParamsBrid
private static string MakeNewPath(string originalPath, string newName)
{
var newFileName = $"{newName}{Path.GetExtension(originalPath)}";
var newPath = Path.Combine(Path.GetDirectoryName(originalPath), newFileName);
var directoryName = Path.GetDirectoryName(originalPath);
Assumes.NotNull(directoryName);
var newPath = Path.Combine(directoryName, newFileName);
return newPath;
}

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

@ -21,19 +21,16 @@ internal class ProvideSemanticTokensResponse
public long? HostDocumentSyncVersion { get; }
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (obj is not ProvideSemanticTokensResponse other || other.HostDocumentSyncVersion != HostDocumentSyncVersion)
if (obj is not ProvideSemanticTokensResponse other ||
HostDocumentSyncVersion != other.HostDocumentSyncVersion)
{
return false;
}
if (other.Tokens == Tokens || (other.Tokens is not null && Tokens is not null && other.Tokens.SequenceEqual(Tokens)))
{
return true;
}
return false;
return Tokens == other.Tokens ||
(Tokens is not null && other.Tokens is not null && Tokens.SequenceEqual(other.Tokens));
}
public override int GetHashCode()

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

@ -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.Collections.Immutable;
using System.Linq;
using System.Reflection;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
@ -62,10 +63,24 @@ internal class RazorSemanticTokensLegend
public static int CSharpVariable => TokenTypesLegend["variable"];
// C# types + Razor types
public static readonly string[] TokenTypes = RazorSemanticTokensAccessor.RoslynTokenTypes.Concat(
typeof(RazorSemanticTokensLegend).GetFields(BindingFlags.NonPublic | BindingFlags.Static).Where(
field => field.GetValue(null) is string).Select(
field => (string)field.GetValue(null))).ToArray();
public static readonly ImmutableArray<string> TokenTypes = GetTokenTypes();
private static ImmutableArray<string> GetTokenTypes()
{
var builder = ImmutableArray.CreateBuilder<string>();
builder.AddRange(RazorSemanticTokensAccessor.RoslynTokenTypes);
foreach (var field in typeof(RazorSemanticTokensLegend).GetFields(BindingFlags.NonPublic | BindingFlags.Static))
{
if (field.GetValue(null) is string value)
{
builder.Add(value);
}
}
return builder.ToImmutable();
}
private static readonly string[] s_tokenModifiers = new string[] {
// Razor
@ -79,7 +94,7 @@ internal class RazorSemanticTokensLegend
public static readonly SemanticTokensLegend Instance = new()
{
TokenModifiers = s_tokenModifiers,
TokenTypes = TokenTypes,
TokenTypes = TokenTypes.ToArray(),
};
private static IReadOnlyDictionary<string, int> GetMap(IReadOnlyList<string> tokens)

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

@ -21,7 +21,7 @@ internal class SemanticRange : IComparable<SemanticRange>
public int Modifier { get; }
public int CompareTo(SemanticRange other)
public int CompareTo(SemanticRange? other)
{
if (other is null)
{
@ -29,11 +29,11 @@ internal class SemanticRange : IComparable<SemanticRange>
}
var startCompare = Range.Start.CompareTo(other.Range.Start);
return startCompare != 0 ? startCompare : Range.End.CompareTo(other.Range.End);
return startCompare != 0
? startCompare
: Range.End.CompareTo(other.Range.End);
}
public override string ToString()
{
return $"[Kind: {Kind}, Range: {Range}]";
}
=> $"[Kind: {Kind}, Range: {Range}]";
}

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

@ -19,8 +19,10 @@ internal static class ServerCapabilitiesExtensions
var dictionary = new Dictionary<string, PropertyInfo>();
foreach (var propertyInfo in propertyInfos)
{
var dataMemeberAttribute = propertyInfo.GetCustomAttribute<DataMemberAttribute>();
var serverCapability = dataMemeberAttribute.Name;
var dataMemberAttribute = propertyInfo.GetCustomAttribute<DataMemberAttribute>();
Assumes.NotNull(dataMemberAttribute);
var serverCapability = dataMemberAttribute.Name;
Assumes.NotNull(serverCapability);
dictionary[serverCapability] = propertyInfo;
}

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package exposes public shims from core Razor that are used in the OmniSharp plugin.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -9,6 +9,7 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.AspNetCore.Razor.OmniSharpPlugin.StrongNamed;
@ -90,12 +91,12 @@ public class OmniSharpWorkspaceProjectStateChangeDetector : IOmniSharpProjectSna
// thread. OmniSharp currently has an issue where they update the Solution on multiple different threads resulting
// in change events dispatching through the Workspace on multiple different threads. This normalizes
// that abnormality.
internal override void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs args)
internal override void Workspace_WorkspaceChanged(object? sender, WorkspaceChangeEventArgs args)
{
_ = Workspace_WorkspaceChangedAsync(sender, args, CancellationToken.None);
Workspace_WorkspaceChangedAsync(sender, args, CancellationToken.None).Forget();
}
private async Task Workspace_WorkspaceChangedAsync(object sender, WorkspaceChangeEventArgs args, CancellationToken cancellationToken)
private async Task Workspace_WorkspaceChangedAsync(object? sender, WorkspaceChangeEventArgs args, CancellationToken cancellationToken)
{
try
{

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding logic to pages. This package contains the Omnisharp Razor plugin that extracts Razor configuration information from projects.</Description>
<EnableApiCheck>false</EnableApiCheck>

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

@ -8,6 +8,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
@ -114,15 +115,16 @@ internal sealed class BatchingWorkQueue : IDisposable
private void StartWorker()
{
// Access to the timer is protected by the lock in Enqueue and in Timer_TickAsync
if (_timer is null)
{
// Timer will fire after a fixed delay, but only once.
_timer = NonCapturingTimer.Create(
state => _ = ((BatchingWorkQueue)state).Timer_TickAsync(),
this,
_batchingTimeSpan,
Timeout.InfiniteTimeSpan);
}
// Timer will fire after a fixed delay, but only once.
_timer ??= NonCapturingTimer.Create(
state =>
{
Assumes.NotNull(state);
((BatchingWorkQueue)state).Timer_TickAsync().Forget();
},
this,
_batchingTimeSpan,
Timeout.InfiniteTimeSpan);
}
private async Task Timer_TickAsync()
@ -164,10 +166,15 @@ internal sealed class BatchingWorkQueue : IDisposable
lock (_work)
{
// Suppress analyzer that suggests using DisposeAsync().
#pragma warning disable VSTHRD103 // Call async methods when in an async method
// Resetting the timer allows another batch of work to start.
_timer?.Dispose();
_timer = null;
#pragma warning restore VSTHRD103
// If more work came in while we were running start the worker again if we're still alive
if (_work.Count > 0 && !_disposed)
{

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

@ -2,10 +2,10 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.Extensions.Internal;
using System.Collections.Generic;
namespace Microsoft.CodeAnalysis.Razor.Completion;
@ -80,46 +80,31 @@ internal sealed class RazorCompletionItem : IEquatable<RazorCompletionItem>
}
}
public override bool Equals(object obj)
{
return Equals(obj as RazorCompletionItem);
}
public override bool Equals(object? obj)
=> Equals(obj as RazorCompletionItem);
public bool Equals(RazorCompletionItem? other)
{
if (other is null)
{
return false;
}
return other is not null &&
DisplayText == other.DisplayText &&
InsertText == other.InsertText &&
Kind == other.Kind &&
BothNullOrEqual(_items, other._items) &&
BothNullOrEqual(CommitCharacters, other.CommitCharacters);
if (!string.Equals(DisplayText, other.DisplayText, StringComparison.Ordinal))
static bool BothNullOrEqual<T>(IEnumerable<T>? first, IEnumerable<T>? second)
{
return false;
}
if (first is null)
{
return second is null;
}
else if (second is null)
{
return false;
}
if (!string.Equals(InsertText, other.InsertText, StringComparison.Ordinal))
{
return false;
return first.SequenceEqual(second);
}
if (Kind != other.Kind)
{
return false;
}
if (!Enumerable.SequenceEqual(Items, other.Items))
{
return false;
}
if ((CommitCharacters is null ^ other.CommitCharacters is null) ||
(CommitCharacters is not null && other.CommitCharacters is not null &&
!CommitCharacters.SequenceEqual(other.CommitCharacters)))
{
return false;
}
return true;
}
public override int GetHashCode()

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

@ -26,17 +26,11 @@ internal sealed class EditorSettings : IEquatable<EditorSettings>
public int IndentSize { get; }
public bool Equals(EditorSettings? other)
{
if (other is null)
{
return false;
}
=> other is not null &&
IndentWithTabs == other.IndentWithTabs &&
IndentSize == other.IndentSize;
return IndentWithTabs == other.IndentWithTabs &&
IndentSize == other.IndentSize;
}
public override bool Equals(object other)
public override bool Equals(object? other)
{
return Equals(other as EditorSettings);
}

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

@ -8,6 +8,7 @@ using System.Diagnostics;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Components;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.VisualStudio.Editor.Razor;
@ -69,7 +70,7 @@ internal class LanguageServerTagHelperCompletionService : TagHelperCompletionSer
completionContext.CurrentParentIsTagHelper);
var applicableDescriptors = applicableTagHelperBinding?.Descriptors ?? Enumerable.Empty<TagHelperDescriptor>();
var unprefixedTagName = completionContext.CurrentTagName.Substring(prefix.Length);
var unprefixedTagName = completionContext.CurrentTagName[prefix.Length..];
if (!completionContext.InHTMLSchema(unprefixedTagName) &&
applicableDescriptors.All(descriptor => descriptor.TagOutputHint is null))
@ -366,36 +367,4 @@ internal class LanguageServerTagHelperCompletionService : TagHelperCompletionSer
return filteredList;
}
private class ShortNameToFullyQualifiedComparer : IEqualityComparer<TagHelperDescriptor>
{
public static readonly ShortNameToFullyQualifiedComparer Instance = new();
public bool Equals(TagHelperDescriptor x, TagHelperDescriptor y)
{
if (object.ReferenceEquals(x, y))
{
return true;
}
if (x is null || y is null)
{
return false;
}
if (!string.Equals(x.Name, y.Name, StringComparison.Ordinal))
{
return false;
}
if (!string.Equals(x.AssemblyName, y.AssemblyName, StringComparison.Ordinal))
{
return false;
}
return true;
}
public int GetHashCode(TagHelperDescriptor obj) => obj.Name.GetHashCode();
}
}

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

@ -8,6 +8,7 @@ using System.Diagnostics;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Components;
using Microsoft.CodeAnalysis.Razor.Workspaces;
namespace Microsoft.VisualStudio.Editor.Razor;
@ -73,7 +74,7 @@ internal class LegacyTagHelperCompletionService : TagHelperCompletionService
completionContext.CurrentParentIsTagHelper);
var applicableDescriptors = applicableTagHelperBinding?.Descriptors ?? Enumerable.Empty<TagHelperDescriptor>();
var unprefixedTagName = completionContext.CurrentTagName.Substring(prefix.Length);
var unprefixedTagName = completionContext.CurrentTagName[prefix.Length..];
if (!completionContext.InHTMLSchema(unprefixedTagName) &&
applicableDescriptors.All(descriptor => descriptor.TagOutputHint is null))
@ -366,36 +367,4 @@ internal class LegacyTagHelperCompletionService : TagHelperCompletionService
return filteredList;
}
private class ShortNameToFullyQualifiedComparer : IEqualityComparer<TagHelperDescriptor>
{
public static readonly ShortNameToFullyQualifiedComparer Instance = new();
public bool Equals(TagHelperDescriptor x, TagHelperDescriptor y)
{
if (object.ReferenceEquals(x, y))
{
return true;
}
if (x is null || y is null)
{
return false;
}
if (!string.Equals(x.Name, y.Name, StringComparison.Ordinal))
{
return false;
}
if (!string.Equals(x.AssemblyName, y.AssemblyName, StringComparison.Ordinal))
{
return false;
}
return true;
}
public int GetHashCode(TagHelperDescriptor obj) => obj.Name.GetHashCode();
}
}

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

@ -12,6 +12,8 @@ namespace Microsoft.CodeAnalysis.Razor;
// We've created our own MemoryCache here, ideally we would use the one in Microsoft.Extensions.Caching.Memory,
// but until we update O# that causes an Assembly load problem.
internal class MemoryCache<TKey, TValue>
where TKey : notnull
where TValue : class
{
private const int DefaultSizeLimit = 50;
private const int DefaultConcurrencyLevel = 2;
@ -30,19 +32,15 @@ internal class MemoryCache<TKey, TValue>
public bool TryGetValue(TKey key, [NotNullWhen(returnValue: true)] out TValue? result)
{
var entryFound = _dict.TryGetValue(key, out var value);
if (entryFound)
if (_dict.TryGetValue(key, out var value))
{
value.LastAccess = DateTime.UtcNow;
result = value.Value;
}
else
{
result = default;
return true;
}
return entryFound;
result = default;
return false;
}
public void Set(TKey key, TValue value)

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

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);netstandard2.0;$(DefaultNetFxTargetFramework)</TargetFrameworks>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>

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

@ -59,7 +59,8 @@ internal class DefaultProjectSnapshot : ProjectSnapshot
_documents.Add(filePath, result);
}
return result;
// TODO: Fix nullability of ProjectSnapshot.GetDocument(...) - https://github.com/dotnet/razor/issues/7945
return result!;
}
}

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

@ -382,6 +382,7 @@ internal class DocumentState
_ = outputTask.ContinueWith(
static (task, state) =>
{
Assumes.NotNull(state);
var tcs = (TaskCompletionSource<(RazorCodeDocument, VersionStamp)>)state;
PropagateToTaskCompletionSource(task, tcs);
@ -390,19 +391,19 @@ internal class DocumentState
CancellationToken.None,
TaskContinuationOptions.ExecuteSynchronously,
TaskScheduler.Default);
}
}
}
return taskUnsafe;
return taskUnsafe;
static void PropagateToTaskCompletionSource(
Task<(RazorCodeDocument, VersionStamp)> targetTask,
TaskCompletionSource<(RazorCodeDocument, VersionStamp)> tcs)
static void PropagateToTaskCompletionSource(
Task<(RazorCodeDocument, VersionStamp)> targetTask,
TaskCompletionSource<(RazorCodeDocument, VersionStamp)> tcs)
{
if (targetTask.Status == TaskStatus.RanToCompletion)
{
if (targetTask.Status == TaskStatus.RanToCompletion)
{
#pragma warning disable VSTHRD103 // Call async methods when in an async method
tcs.SetResult(targetTask.Result);
tcs.SetResult(targetTask.Result);
#pragma warning restore VSTHRD103 // Call async methods when in an async method
}
else if (targetTask.Status == TaskStatus.Canceled)
@ -412,6 +413,7 @@ internal class DocumentState
else if (targetTask.Status == TaskStatus.Faulted)
{
// Faulted tasks area always aggregate exceptions so we need to extract the "true" exception if it's available:
Assumes.NotNull(targetTask.Exception);
var exception = targetTask.Exception.InnerException ?? targetTask.Exception;
tcs.SetException(exception);
}
@ -542,7 +544,7 @@ internal class DocumentState
_inputVersion = inputVersion;
}
public bool TryGetCachedOutput(out RazorCodeDocument codeDocument, out VersionStamp inputVersion)
public bool TryGetCachedOutput([NotNullWhen(true)] out RazorCodeDocument? codeDocument, out VersionStamp inputVersion)
{
// The goal here is to capture a weak reference to the code document so if there's ever a sub-system that's still utilizing it
// our computed output maintains its cache.

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

@ -18,7 +18,7 @@ public sealed class ProjectWorkspaceState : IEquatable<ProjectWorkspaceState>
public ProjectWorkspaceState(
IReadOnlyCollection<TagHelperDescriptor> tagHelpers,
LanguageVersion csharpLanguageVersion)
: this ((tagHelpers as IReadOnlyList<TagHelperDescriptor>) ?? tagHelpers.ToList(), csharpLanguageVersion)
: this((tagHelpers as IReadOnlyList<TagHelperDescriptor>) ?? tagHelpers.ToList(), csharpLanguageVersion)
{
}
@ -40,37 +40,21 @@ public sealed class ProjectWorkspaceState : IEquatable<ProjectWorkspaceState>
public LanguageVersion CSharpLanguageVersion { get; }
public override bool Equals(object obj)
{
return base.Equals(obj as ProjectWorkspaceState);
}
public override bool Equals(object? obj)
=> Equals(obj as ProjectWorkspaceState);
public bool Equals(ProjectWorkspaceState? other)
{
if (other is null)
{
return false;
}
if (!Enumerable.SequenceEqual(TagHelpers, other.TagHelpers))
{
return false;
}
if (CSharpLanguageVersion != other.CSharpLanguageVersion)
{
return false;
}
return true;
}
=> other is not null &&
TagHelpers.SequenceEqual(other.TagHelpers) &&
CSharpLanguageVersion == other.CSharpLanguageVersion;
public override int GetHashCode()
{
var hash = new HashCodeCombiner();
for (var i = 0; i < TagHelpers.Count; i++)
foreach (var tagHelper in TagHelpers)
{
hash.Add(TagHelpers[i].GetHashCode());
hash.Add(tagHelper.GetHashCode());
}
hash.Add(CSharpLanguageVersion);

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

@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Razor.Language.Components;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Extensions;
using Microsoft.VisualStudio.Threading;
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
@ -119,9 +120,9 @@ internal class WorkspaceProjectStateChangeDetector : ProjectSnapshotChangeTrigge
}
// Internal for testing, virtual for temporary VSCode workaround
internal virtual void Workspace_WorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
internal virtual void Workspace_WorkspaceChanged(object? sender, WorkspaceChangeEventArgs e)
{
_ = Workspace_WorkspaceChangedAsync(e, CancellationToken.None);
Workspace_WorkspaceChangedAsync(e, CancellationToken.None).Forget();
}
private async Task Workspace_WorkspaceChangedAsync(WorkspaceChangeEventArgs e, CancellationToken cancellationToken)
@ -377,7 +378,7 @@ internal class WorkspaceProjectStateChangeDetector : ProjectSnapshotChangeTrigge
}
}
private void ProjectManager_Changed(object sender, ProjectChangeEventArgs args)
private void ProjectManager_Changed(object? sender, ProjectChangeEventArgs args)
{
// Don't do any work if the solution is closing. Any work in the queue will be cancelled on disposal
if (args.SolutionIsClosing)

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

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.CodeAnalysis.Razor.Serialization.Internal;
@ -126,21 +127,22 @@ internal class StringCache
public bool IsAlive => _weakRef.TryGetTarget(out _);
public bool TryGetTarget(out string target)
public bool TryGetTarget([NotNullWhen(true)] out string? target)
{
return _weakRef.TryGetTarget(out target);
}
public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (!(obj is Entry entry))
if (obj is not Entry entry)
{
return false;
}
if (TryGetTarget(out var thisTarget) && entry.TryGetTarget(out var entryTarget))
{
return thisTarget!.GetHashCode().Equals(entryTarget.GetHashCode()) && thisTarget!.Equals(entryTarget, StringComparison.Ordinal);
return thisTarget.GetHashCode().Equals(entryTarget.GetHashCode()) &&
thisTarget == entryTarget;
}
// We lost the reference, but we need to check RefEquals to ensure that HashSet can successfully Remove items.

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

@ -0,0 +1,32 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.CodeAnalysis.Razor.Workspaces;
internal sealed class ShortNameToFullyQualifiedComparer : IEqualityComparer<TagHelperDescriptor>
{
public static readonly ShortNameToFullyQualifiedComparer Instance = new();
private ShortNameToFullyQualifiedComparer()
{
}
public bool Equals(TagHelperDescriptor? x, TagHelperDescriptor? y)
{
if (ReferenceEquals(x, y))
{
return true;
}
return x is not null &&
y is not null &&
x.Name == y.Name &&
x.AssemblyName == y.AssemblyName;
}
public int GetHashCode(TagHelperDescriptor obj)
=> obj.Name.GetHashCode();
}

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

@ -15,17 +15,22 @@ internal sealed class TagHelperResolutionResultComparer : IEqualityComparer<TagH
public bool Equals(TagHelperResolutionResult? x, TagHelperResolutionResult? y)
{
if (x is null && y is null)
if (x is null)
{
return true;
return y is null;
}
else if (x is null ^ y is null)
else if (y is null)
{
return false;
}
return x!.Descriptors.SequenceEqual(y!.Descriptors, TagHelperDescriptorComparer.Default) &&
x.Diagnostics.SequenceEqual(y.Diagnostics);
Assumes.NotNull(x.Descriptors);
Assumes.NotNull(x.Diagnostics);
Assumes.NotNull(y.Descriptors);
Assumes.NotNull(y.Diagnostics);
return x.Descriptors.SequenceEqual(y.Descriptors, TagHelperDescriptorComparer.Default) &&
x.Diagnostics.SequenceEqual(y.Diagnostics);
}
public int GetHashCode(TagHelperResolutionResult obj)

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

@ -64,7 +64,7 @@ internal abstract class TagHelperResolver : IWorkspaceService
provider.Execute(context);
stopWatch.Stop();
var propertyName = $"razor.{provider.Name}.elapsedtimems";
var propertyName = $"{provider.GetType().Name}.elapsedtimems";
Debug.Assert(!timingDictionary.ContainsKey(propertyName));
timingDictionary[propertyName] = stopWatch.ElapsedMilliseconds;
}

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

@ -44,30 +44,15 @@ internal sealed class BoundAttributeDescriptionInfo : IEquatable<BoundAttributeD
public string Documentation { get; }
public bool Equals(BoundAttributeDescriptionInfo other)
{
if (!string.Equals(ReturnTypeName, other.ReturnTypeName, StringComparison.Ordinal))
{
return false;
}
public override bool Equals(object? obj)
=> Equals(obj as BoundAttributeDescriptionInfo);
if (!string.Equals(TypeName, other.TypeName, StringComparison.Ordinal))
{
return false;
}
if (!string.Equals(PropertyName, other.PropertyName, StringComparison.Ordinal))
{
return false;
}
if (!string.Equals(Documentation, other.Documentation, StringComparison.Ordinal))
{
return false;
}
return true;
}
public bool Equals(BoundAttributeDescriptionInfo? other)
=> other is not null &&
ReturnTypeName == other.ReturnTypeName &&
TypeName == other.TypeName &&
PropertyName == other.PropertyName &&
Documentation == other.Documentation;
public override int GetHashCode()
{

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

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>Exe</OutputType>
<!-- The purpose of this project is to include all dependecies of Microsoft.CodeAnalysis.Remote.Razor targeting .Net Core -->
<IsShipping>false</IsShipping>
@ -22,8 +22,11 @@
Also only include dependencies exclusive to Razor. For any common dependencies between Roslyn and Razor, we want to share the ones
loaded in Roslyn's ALC at runtime.
-->
<_ExcludedFiles Include="$(PublishDir)**\Microsoft.CodeAnalysis.Remote.ServiceHub.CoreComponents.*" />
<_PublishedFiles Include="$(PublishDir)**\Microsoft.CodeAnalysis.Razor.*" />
<_PublishedFiles Include="$(PublishDir)**\Microsoft.CodeAnalysis.Remote.Razor.*" />
<_PublishedFiles Include="$(PublishDir)**\Microsoft.CodeAnalysis.Remote.Razor.*" Exclude="@(_ExcludedFiles)"/>
<_PublishedFiles Include="$(PublishDir)**\Microsoft.AspNetCore.*" />
<_PublishedFiles Include="$(PublishDir)**\Microsoft.Extensions.Logging.Abstractions.dll" />

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

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Visual Studio agnostic Razor design-time infrastructure.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>This package contains the Visual Studio Language Server infrastructure for interacting with contained languages.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -21,7 +21,7 @@ internal class DefaultRazorProximityExpressionResolver : RazorProximityExpressio
private readonly FileUriProvider _fileUriProvider;
private readonly LSPDocumentManager _documentManager;
private readonly LSPProximityExpressionsProvider _proximityExpressionsProvider;
private readonly MemoryCache<CacheKey, IReadOnlyList<string>?> _cache;
private readonly MemoryCache<CacheKey, IReadOnlyList<string>> _cache;
[ImportingConstructor]
public DefaultRazorProximityExpressionResolver(
@ -50,7 +50,7 @@ internal class DefaultRazorProximityExpressionResolver : RazorProximityExpressio
// 10 is a magic number where this effectively represents our ability to cache the last 10 "hit" breakpoint locations
// corresponding proximity expressions which enables us not to go "async" in those re-hit scenarios.
_cache = new MemoryCache<CacheKey, IReadOnlyList<string>?>(sizeLimit: 10);
_cache = new MemoryCache<CacheKey, IReadOnlyList<string>>(sizeLimit: 10);
}
public override async Task<IReadOnlyList<string>?> TryResolveProximityExpressionsAsync(ITextBuffer textBuffer, int lineIndex, int characterIndex, CancellationToken cancellationToken)
@ -98,7 +98,8 @@ internal class DefaultRazorProximityExpressionResolver : RazorProximityExpressio
var proximityExpressions = await _proximityExpressionsProvider.GetProximityExpressionsAsync(documentSnapshot, position, cancellationToken).ConfigureAwait(false);
// Cache range so if we're asked again for this document/line/character we don't have to go async.
_cache.Set(cacheKey, proximityExpressions);
// Note: If we didn't get any proximity expressions back--likely due to an error--we cache an empty array.
_cache.Set(cacheKey, proximityExpressions ?? Array.Empty<string>());
return proximityExpressions;
}

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Visual Studio Language Server client infrastructure for Razor files.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure for Visual Studio.</Description>
<EnableApiCheck>false</EnableApiCheck>
<RulesDirectory>$(PkgMicrosoft_NET_Sdk_Razor)\build\netstandard2.0\Rules\</RulesDirectory>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Visual Studio Live Share Razor infrastructure.</Description>
<EnableApiCheck>false</EnableApiCheck>
<IsShippingPackage>false</IsShippingPackage>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<Description>Razor is a markup syntax for adding server-side logic to web pages. This package contains the Razor design-time infrastructure for Visual Studio for Mac.</Description>
<EnableApiCheck>false</EnableApiCheck>
<NoWarn>$(NoWarn);MSB3277</NoWarn>

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

@ -2,7 +2,7 @@
<Import Project="AddinMetadata.props" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<IsMPackProject>true</IsMPackProject>
<AddinName>Microsoft.VisualStudio.Mac.RazorAddin</AddinName>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
@ -75,12 +75,12 @@
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.LanguageServices.Razor\$(Configuration)\net472\Microsoft.VisualStudio.Mac.LanguageServices.Razor.dll" />
<!-- Language Server Dependencies -->
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Common\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.Common.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServerClient.Razor\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServerClient.Razor.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.LanguageServer.ContainedLanguage\$(Configuration)\net472\Microsoft.VisualStudio.LanguageServer.ContainedLanguage.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Common\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.LanguageServer.Common.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Protocol\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Common\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Razor.Common.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Common\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.Common.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer.Protocol\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.LanguageServer\$(Configuration)\net472\Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Options.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.Primitives.dll" />
<MPackFile Include="$(ArtifactsBinDir)Microsoft.VisualStudio.Mac.RazorAddin\$(Configuration)\net472\Microsoft.Extensions.DependencyInjection.dll" />

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

@ -8,7 +8,7 @@
extra dependencies + codebases that may not be present in public VS installs.
-->
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<VSSDKTargetPlatformRegRootSuffix>RoslynDev</VSSDKTargetPlatformRegRootSuffix>

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

@ -3,11 +3,6 @@
using Microsoft.VisualStudio.Shell;
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\MediatR.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.JsonRpc.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.LanguageProtocol.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.LanguageServer.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\OmniSharp.Extensions.LanguageServer.Shared.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.CommonLanguageServerProtocol.Framework.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Options.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Primitives.dll")]
@ -18,5 +13,3 @@ using Microsoft.VisualStudio.Shell;
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Logging.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Microsoft.Extensions.Logging.Abstractions.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\System.IO.Pipelines.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\System.Reactive.dll")]
[assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\System.Threading.Channels.dll")]

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

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<VSSDKTargetPlatformRegRootSuffix>RoslynDev</VSSDKTargetPlatformRegRootSuffix>
@ -138,25 +138,15 @@
NOTE: Adding OSS components to this list must be reviewed against our component governance standards. For now this is a curated list. You can read more about the CG process at https://aka.ms/component-governance
***************************************************************************************************************************************
-->
<RazorNgendVSIXSourceItem Include="$(OutputPath)MediatR.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.JsonRpc.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.LanguageProtocol.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.LanguageServer.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)OmniSharp.Extensions.LanguageServer.Shared.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Options.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Primitives.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.DependencyInjection.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.DependencyInjection.Abstractions.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Configuration.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Configuration.Abstractions.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Configuration.Binder.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Logging.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)Microsoft.Extensions.Logging.Abstractions.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)System.IO.Pipelines.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)System.Reactive.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)System.Runtime.CompilerServices.Unsafe.dll" />
<RazorNgendVSIXSourceItem Include="$(OutputPath)System.Threading.Channels.dll" />
<VSIXSourceItem Include="$(OutputPath)Microsoft.VisualStudio.LanguageServer.Protocol.dll" />
<VSIXSourceItem Include="$(OutputPath)Microsoft.VisualStudio.LanguageServer.Protocol.Extensions.dll" />
@ -189,11 +179,24 @@
<ItemGroup>
<!-- Don't trim this list. It is used to feed into the binding redirects -->
<ProjectReference Include="$(SharedSourceRoot)\Microsoft.AspNetCore.Razor.LanguageSupport\Microsoft.AspNetCore.Razor.LanguageSupport.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Common\Microsoft.AspNetCore.Razor.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj" />
<ProjectReference Include="..\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj" />
<ProjectReference Include="$(SharedSourceRoot)\Microsoft.AspNetCore.Razor.LanguageSupport\Microsoft.AspNetCore.Razor.LanguageSupport.csproj">
<AdditionalProperties>TargetFramework=$(DefaultNetFxTargetFramework)</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Common\Microsoft.AspNetCore.Razor.Common.csproj">
<AdditionalProperties>TargetFramework=$(DefaultNetFxTargetFramework)</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj">
<AdditionalProperties>TargetFramework=$(DefaultNetFxTargetFramework)</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj">
<AdditionalProperties>TargetFramework=$(DefaultNetFxTargetFramework)</AdditionalProperties>
</ProjectReference>
<ProjectReference Include="..\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj" />
<ProjectReference Include="..\Microsoft.CodeAnalysis.Remote.Razor.CoreComponents\Microsoft.CodeAnalysis.Remote.Razor.CoreComponents.csproj">
<Name>Microsoft.CodeAnalysis.Remote.Razor.CoreComponents</Name>
<!-- This project targets netcoreapp -->
@ -213,7 +216,6 @@
<ProjectReference Include="..\Microsoft.VisualStudio.LanguageServices.Razor\Microsoft.VisualStudio.LanguageServices.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.LiveShare.Razor\Microsoft.VisualStudio.LiveShare.Razor.csproj" />
<ProjectReference Include="..\Microsoft.VisualStudio.LanguageServerClient.Razor\Microsoft.VisualStudio.LanguageServerClient.Razor.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer\Microsoft.AspNetCore.Razor.LanguageServer.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Common\Microsoft.AspNetCore.Razor.LanguageServer.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.LanguageServer.Protocol\Microsoft.AspNetCore.Razor.LanguageServer.Protocol.csproj" />
<ProjectReference Include="..\..\..\Compiler\Microsoft.AspNetCore.Razor.Language\src\Microsoft.AspNetCore.Razor.Language.csproj" />
@ -233,10 +235,6 @@
<PackageReference Include="System.Resources.Extensions" Version="$(SystemResourcesExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="$(MicrosoftVisualStudioShell150PackageVersion)" />
<!-- We need to directly reference the O# language server here because we mark it as PrivateAssets="All" in our language server itself
We don't actual use it, but for now WebTools depends on it. -->
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="$(OmniSharpExtensionsLanguageServerPackageVersion)" />
<!--
Pinning packages to avoid misaligned reference CI failures.
CI builds here: https://github.com/dotnet/razor-tooling/issues/4327
@ -287,12 +285,14 @@
<BindingRedirectAssemblies Include="$(AssemblyName)" AssemblyName="$(AssemblyName)" />
</ItemGroup>
<PropertyGroup>
<_GeneratedVSIXBindingRedirectContent><![CDATA[
<_GeneratedVSIXBindingRedirectContent>
<![CDATA[
// <auto-generated />
using Microsoft.VisualStudio.Shell;
@(BindingRedirectAssemblies->'[assembly: ProvideBindingRedirection(AssemblyName = "%(AssemblyName)", GenerateCodeBase = true, PublicKeyToken = "adb9793829ddae60", OldVersionLowerBound = "0.0.0.0", OldVersionUpperBound = "$(AssemblyVersion)", NewVersion = "$(AssemblyVersion)")]', '%0A')
]]></_GeneratedVSIXBindingRedirectContent>
]]>
</_GeneratedVSIXBindingRedirectContent>
</PropertyGroup>
<WriteLinesToFile Lines="$([MSBuild]::Escape($(_GeneratedVSIXBindingRedirectContent)))" File="$(_GeneratedVSIXBindingRedirectFile)" Overwrite="True" WriteOnlyWhenDifferent="True" />
<ItemGroup>

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

@ -35,15 +35,8 @@
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.Language.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="MediatR.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.JsonRpc.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.LanguageProtocol.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.LanguageServer.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="OmniSharp.Extensions.LanguageServer.Shared.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Configuration.Binder.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.CommonLanguageServerProtocol.Framework.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Options.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Options.ConfigurationExtensions.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Primitives.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.DependencyInjection.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.DependencyInjection.Abstractions.dll" />
@ -52,9 +45,6 @@
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Logging.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.Extensions.Logging.Abstractions.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="System.IO.Pipelines.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="System.Reactive.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="System.Runtime.CompilerServices.Unsafe.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="System.Threading.Channels.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.LanguageServer.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.LanguageSupport.dll" />
<Asset Type="Microsoft.VisualStudio.Assembly" Path="Microsoft.AspNetCore.Razor.LanguageServer.Protocol.dll" />

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

@ -6,7 +6,7 @@
We rely on launch settings to run devenv with the appropriate hive that the vsixes have been deployed to.
-->
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<VSSDKTargetPlatformRegRootSuffix>RoslynDev</VSSDKTargetPlatformRegRootSuffix>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework)</TargetFrameworks>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
</PropertyGroup>
<ItemGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<IsShipping>false</IsShipping>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreWindowsTargetFramework)</TargetFrameworks>
<TargetFramework>$(DefaultNetCoreWindowsTargetFramework)</TargetFramework>
<!-- To generate baselines, run tests with /p:GenerateBaselines=true -->
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.WebTools.Shared" Version="$(MicrosoftWebToolsSharedPackageVersion)" NoWarn="NU1701" />
<!-- Included for tests only -->
<PackageReference Include="OmniSharp.Extensions.LanguageProtocol" Version="$(OmniSharpExtensionsLanguageProtocolPackageVersion)" />
<!--
Nuget changed behaviour and now validates transitive references, so the NU1701 suppressions above don't affect those
packages dependencies. We reference them here directly in order to do so, and set ExcludeAssets and PrivateAssets so

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks>
<TargetFrameworks>$(DefaultNetFxTargetFramework)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>

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

@ -284,7 +284,9 @@ public static class ExportProviderCache
var assemblyName = new AssemblyName(assemblyFullName);
if (!string.IsNullOrEmpty(codeBasePath))
{
#pragma warning disable SYSLIB0044 // Type or member is obsolete
assemblyName.CodeBase = codeBasePath;
#pragma warning restore SYSLIB0044 // Type or member is obsolete
}
return LoadAssembly(assemblyName);

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

@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<IsShipping>false</IsShipping>
<!-- To generate baselines, run tests with /p:GenerateBaselines=true -->
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
<TargetFrameworks>net6.0;netstandard2.0;net472</TargetFrameworks>
<IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>
@ -29,7 +30,7 @@
<PackageReference Include="Xunit.Combinatorial" Version="$(XunitCombinatorialPackageVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetFxTargetFramework)'">
<Reference Include="WindowsBase" />
</ItemGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<IsShipping>false</IsShipping>
<IsApiShim>true</IsApiShim>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);net472</TargetFrameworks>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<IsShipping>false</IsShipping>
<IsApiShim>true</IsApiShim>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);net472</TargetFrameworks>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<IsShipping>false</IsShipping>
<IsApiShim>true</IsApiShim>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);net472</TargetFrameworks>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<IsShipping>false</IsShipping>
<IsApiShim>true</IsApiShim>

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

@ -1,10 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<!-- Don't warn about restoring xunit.runner.visualstudio for .NET Framework when we're compiling against netstandard2.0 -->
<NoWarn>$(NoWarn);NU1701</NoWarn>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);$(DefaultNetFxTargetFramework)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<IsShipping>false</IsShipping>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>$(DefaultNetFxTargetFramework)</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

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