зеркало из https://github.com/dotnet/razor.git
Merge branch 'main' into RoslynCohost
This commit is contained in:
Коммит
82356ebac7
|
@ -5,9 +5,9 @@
|
|||
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
|
||||
<Sha>839cdfb0ecca5e0be3dbccd926e7651ef50fdf10</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.23618.2">
|
||||
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.23627.2">
|
||||
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
|
||||
<Sha>c49c1f4e461b4b57d6d3449671942786bf8fcbb6</Sha>
|
||||
<Sha>2a008ae4f42c0db384db5a4864752b2ff52d720b</Sha>
|
||||
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.9.0-3.23613.4">
|
||||
|
@ -90,14 +90,15 @@
|
|||
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
|
||||
<Sha>3a25a7f1cc446b60678ed25c9d829420d6321eba</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.23613.3">
|
||||
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23620.2">
|
||||
<Uri>https://github.com/dotnet/arcade</Uri>
|
||||
<Sha>b6349a217d7e2f6b5c1831702f8beef5c171da3f</Sha>
|
||||
<Sha>84129325171e65373edef24019e1171feeb19cbc</Sha>
|
||||
<SourceBuild RepoName="arcade" ManagedOnly="true" />
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="9.0.0-beta.23613.3">
|
||||
<Uri>https://github.com/dotnet/arcade</Uri>
|
||||
<Sha>b6349a217d7e2f6b5c1831702f8beef5c171da3f</Sha>
|
||||
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23475.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
|
||||
<Uri>https://github.com/dotnet/xliff-tasks</Uri>
|
||||
<Sha>73f0850939d96131c28cf6ea6ee5aacb4da0083a</Sha>
|
||||
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
|
||||
</Dependency>
|
||||
<!-- Necessary for source-build. This allows Microsoft.Extensions.ObjectPool and System.Collections.Immutable packages
|
||||
to be retrieved from live source-build and their content consumed by packages produced by razor.
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<PropertyGroup Label="Automated">
|
||||
<MicrosoftNETCoreBrowserDebugHostTransportPackageVersion>6.0.2-servicing.22064.6</MicrosoftNETCoreBrowserDebugHostTransportPackageVersion>
|
||||
<MicrosoftNETCorePlatformsPackageVersion>6.0.1</MicrosoftNETCorePlatformsPackageVersion>
|
||||
<MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesPackageVersion>9.0.0-alpha.1.23618.2</MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesPackageVersion>
|
||||
<MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesPackageVersion>9.0.0-alpha.1.23627.2</MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesPackageVersion>
|
||||
<MicrosoftNetCompilersToolsetPackageVersion>4.9.0-3.23613.4</MicrosoftNetCompilersToolsetPackageVersion>
|
||||
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.9.0-3.23613.4</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
|
||||
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
|
||||
|
|
|
@ -19,7 +19,6 @@ Param(
|
|||
[switch] $pack,
|
||||
[switch] $publish,
|
||||
[switch] $clean,
|
||||
[switch] $verticalBuild,
|
||||
[switch][Alias('bl')]$binaryLog,
|
||||
[switch][Alias('nobl')]$excludeCIBinarylog,
|
||||
[switch] $ci,
|
||||
|
@ -59,7 +58,6 @@ function Print-Usage() {
|
|||
Write-Host " -sign Sign build outputs"
|
||||
Write-Host " -publish Publish artifacts (e.g. symbols)"
|
||||
Write-Host " -clean Clean the solution"
|
||||
Write-Host " -verticalBuild Run in 'vertical build' infra mode."
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "Advanced settings:"
|
||||
|
@ -122,7 +120,6 @@ function Build {
|
|||
/p:Deploy=$deploy `
|
||||
/p:Test=$test `
|
||||
/p:Pack=$pack `
|
||||
/p:ArcadeBuildVertical=$verticalBuild `
|
||||
/p:IntegrationTest=$integrationTest `
|
||||
/p:PerformanceTest=$performanceTest `
|
||||
/p:Sign=$sign `
|
||||
|
|
|
@ -59,7 +59,6 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
|
|||
restore=false
|
||||
build=false
|
||||
source_build=false
|
||||
vertical_build=false
|
||||
rebuild=false
|
||||
test=false
|
||||
integration_test=false
|
||||
|
@ -106,7 +105,7 @@ while [[ $# > 0 ]]; do
|
|||
-binarylog|-bl)
|
||||
binary_log=true
|
||||
;;
|
||||
-excludecibinarylog|-nobl)
|
||||
-excludeCIBinarylog|-nobl)
|
||||
exclude_ci_binary_log=true
|
||||
;;
|
||||
-pipelineslog|-pl)
|
||||
|
@ -130,12 +129,6 @@ while [[ $# > 0 ]]; do
|
|||
restore=true
|
||||
pack=true
|
||||
;;
|
||||
-verticalbuild|-vb)
|
||||
build=true
|
||||
vertical_build=true
|
||||
restore=true
|
||||
pack=true
|
||||
;;
|
||||
-test|-t)
|
||||
test=true
|
||||
;;
|
||||
|
@ -227,7 +220,6 @@ function Build {
|
|||
/p:Restore=$restore \
|
||||
/p:Build=$build \
|
||||
/p:ArcadeBuildFromSource=$source_build \
|
||||
/p:ArcadeBuildVertical=$vertical_build \
|
||||
/p:Rebuild=$rebuild \
|
||||
/p:Test=$test \
|
||||
/p:Pack=$pack \
|
||||
|
|
|
@ -487,7 +487,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
|
|||
-X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \
|
||||
-X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \
|
||||
-U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \
|
||||
search 'llvm*-libs' | grep -E '^llvm' | sort | tail -1 | sed 's/-[^-]*//2g')"
|
||||
search 'llvm*-libs' | sort | tail -1 | sed 's/-[^-]*//2g')"
|
||||
fi
|
||||
|
||||
# install all packages in one go
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
|
||||
--- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900
|
||||
+++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900
|
||||
@@ -2,4 +2,4 @@
|
||||
Use the shared library, but some functions are only in
|
||||
the static library, so try that secondarily. */
|
||||
OUTPUT_FORMAT(elf64-littleriscv)
|
||||
-GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-riscv64-lp64d.so.1 ) )
|
||||
+GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-riscv64-lp64d.so.1 ) )
|
|
@ -22,10 +22,6 @@ case "$ARCH" in
|
|||
TIZEN_ARCH="x86_64"
|
||||
LINK_ARCH="x86"
|
||||
;;
|
||||
riscv64)
|
||||
TIZEN_ARCH="riscv64"
|
||||
LINK_ARCH="riscv"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture for tizen: $ARCH"
|
||||
exit 1
|
||||
|
@ -62,21 +58,4 @@ rm -rf $TIZEN_TMP_DIR
|
|||
echo ">>Start configuring Tizen rootfs"
|
||||
ln -sfn asm-${LINK_ARCH} ./usr/include/asm
|
||||
patch -p1 < $__TIZEN_CROSSDIR/tizen.patch
|
||||
if [[ "$TIZEN_ARCH" == "riscv64" ]]; then
|
||||
echo "Fixing broken symlinks in $PWD"
|
||||
rm ./usr/lib64/libresolv.so
|
||||
ln -s ../../lib64/libresolv.so.2 ./usr/lib64/libresolv.so
|
||||
rm ./usr/lib64/libpthread.so
|
||||
ln -s ../../lib64/libpthread.so.0 ./usr/lib64/libpthread.so
|
||||
rm ./usr/lib64/libdl.so
|
||||
ln -s ../../lib64/libdl.so.2 ./usr/lib64/libdl.so
|
||||
rm ./usr/lib64/libutil.so
|
||||
ln -s ../../lib64/libutil.so.1 ./usr/lib64/libutil.so
|
||||
rm ./usr/lib64/libm.so
|
||||
ln -s ../../lib64/libm.so.6 ./usr/lib64/libm.so
|
||||
rm ./usr/lib64/librt.so
|
||||
ln -s ../../lib64/librt.so.1 ./usr/lib64/librt.so
|
||||
rm ./lib/ld-linux-riscv64-lp64d.so.1
|
||||
ln -s ../lib64/ld-linux-riscv64-lp64d.so.1 ./lib/ld-linux-riscv64-lp64d.so.1
|
||||
fi
|
||||
echo "<<Finish configuring Tizen rootfs"
|
||||
|
|
|
@ -156,28 +156,17 @@ fetch_tizen_pkgs()
|
|||
done
|
||||
}
|
||||
|
||||
if [ "$TIZEN_ARCH" == "riscv64" ]; then
|
||||
BASE="Tizen-Base-RISCV"
|
||||
UNIFIED="Tizen-Unified-RISCV"
|
||||
else
|
||||
BASE="Tizen-Base"
|
||||
UNIFIED="Tizen-Unified"
|
||||
fi
|
||||
|
||||
Inform "Initialize ${TIZEN_ARCH} base"
|
||||
fetch_tizen_pkgs_init standard $BASE
|
||||
fetch_tizen_pkgs_init standard Tizen-Base
|
||||
Inform "fetch common packages"
|
||||
fetch_tizen_pkgs ${TIZEN_ARCH} gcc gcc-devel-static glibc glibc-devel libicu libicu-devel libatomic linux-glibc-devel keyutils keyutils-devel libkeyutils
|
||||
Inform "fetch coreclr packages"
|
||||
fetch_tizen_pkgs ${TIZEN_ARCH} libgcc libstdc++ libstdc++-devel libunwind libunwind-devel lttng-ust-devel lttng-ust userspace-rcu-devel userspace-rcu
|
||||
if [ "$TIZEN_ARCH" != "riscv64" ]; then
|
||||
fetch_tizen_pkgs ${TIZEN_ARCH} lldb lldb-devel
|
||||
fi
|
||||
fetch_tizen_pkgs ${TIZEN_ARCH} lldb lldb-devel libgcc libstdc++ libstdc++-devel libunwind libunwind-devel lttng-ust-devel lttng-ust userspace-rcu-devel userspace-rcu
|
||||
Inform "fetch corefx packages"
|
||||
fetch_tizen_pkgs ${TIZEN_ARCH} libcom_err libcom_err-devel zlib zlib-devel libopenssl11 libopenssl1.1-devel krb5 krb5-devel
|
||||
|
||||
Inform "Initialize standard unified"
|
||||
fetch_tizen_pkgs_init standard $UNIFIED
|
||||
fetch_tizen_pkgs_init standard Tizen-Unified
|
||||
Inform "fetch corefx packages"
|
||||
fetch_tizen_pkgs ${TIZEN_ARCH} gssdp gssdp-devel tizen-release
|
||||
|
||||
|
|
|
@ -80,9 +80,6 @@ elseif(TARGET_ARCH_NAME STREQUAL "riscv64")
|
|||
set(TOOLCHAIN "riscv64-alpine-linux-musl")
|
||||
else()
|
||||
set(TOOLCHAIN "riscv64-linux-gnu")
|
||||
if(TIZEN)
|
||||
set(TIZEN_TOOLCHAIN "riscv64-tizen-linux-gnu/13.1.0")
|
||||
endif()
|
||||
endif()
|
||||
elseif(TARGET_ARCH_NAME STREQUAL "s390x")
|
||||
set(CMAKE_SYSTEM_PROCESSOR s390x)
|
||||
|
@ -147,10 +144,6 @@ if(TIZEN)
|
|||
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
|
||||
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/x86_64-tizen-linux-gnu)
|
||||
endif()
|
||||
if(TARGET_ARCH_NAME STREQUAL "riscv64")
|
||||
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
|
||||
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/riscv64-tizen-linux-gnu)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
|
@ -277,7 +270,7 @@ if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$")
|
|||
add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib")
|
||||
add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
|
||||
endif()
|
||||
elseif(TARGET_ARCH_NAME MATCHES "^(arm64|x64|riscv64)$")
|
||||
elseif(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
|
||||
if(TIZEN)
|
||||
add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
|
||||
add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib64")
|
||||
|
@ -288,8 +281,6 @@ elseif(TARGET_ARCH_NAME MATCHES "^(arm64|x64|riscv64)$")
|
|||
add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/usr/lib64")
|
||||
add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
|
||||
endif()
|
||||
elseif(TARGET_ARCH_NAME STREQUAL "s390x")
|
||||
add_toolchain_linker_flag("--target=${TOOLCHAIN}")
|
||||
elseif(TARGET_ARCH_NAME STREQUAL "x86")
|
||||
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl)
|
||||
add_toolchain_linker_flag("--target=${TOOLCHAIN}")
|
||||
|
@ -337,8 +328,6 @@ if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$")
|
|||
if(TARGET_ARCH_NAME STREQUAL "armel")
|
||||
add_compile_options(-mfloat-abi=softfp)
|
||||
endif()
|
||||
elseif(TARGET_ARCH_NAME STREQUAL "s390x")
|
||||
add_compile_options("--target=${TOOLCHAIN}")
|
||||
elseif(TARGET_ARCH_NAME STREQUAL "x86")
|
||||
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl)
|
||||
add_compile_options(--target=${TOOLCHAIN})
|
||||
|
|
|
@ -7,7 +7,7 @@ try {
|
|||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
if ($PromoteToChannels -eq "") {
|
||||
Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
|
||||
Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
|
||||
ExitWithExitCode 0
|
||||
}
|
||||
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
[CmdletBinding(PositionalBinding=$False)]
|
||||
param(
|
||||
[Parameter(Mandatory=$true, Position=0)][string] $InputPath,
|
||||
[Parameter(Mandatory=$true)][string] $BinlogToolVersion,
|
||||
[Parameter(Mandatory=$false)][string] $DotnetPath,
|
||||
[Parameter(Mandatory=$false)][string] $PackageFeed = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json',
|
||||
# File with strings to redact - separated by newlines.
|
||||
# For comments start the line with '# ' - such lines are ignored
|
||||
[Parameter(Mandatory=$false)][string] $TokensFilePath,
|
||||
[Parameter(ValueFromRemainingArguments=$true)][String[]]$TokensToRedact
|
||||
)
|
||||
|
||||
try {
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
$packageName = 'binlogtool'
|
||||
|
||||
$dotnet = $DotnetPath
|
||||
|
||||
if (!$dotnet) {
|
||||
$dotnetRoot = InitializeDotNetCli -install:$true
|
||||
$dotnet = "$dotnetRoot\dotnet.exe"
|
||||
}
|
||||
|
||||
$toolList = & "$dotnet" tool list -g
|
||||
|
||||
if ($toolList -like "*$packageName*") {
|
||||
& "$dotnet" tool uninstall $packageName -g
|
||||
}
|
||||
|
||||
$toolPath = "$PSScriptRoot\..\..\..\.tools"
|
||||
$verbosity = 'minimal'
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $toolPath
|
||||
|
||||
Push-Location -Path $toolPath
|
||||
|
||||
try {
|
||||
Write-Host "Installing Binlog redactor CLI..."
|
||||
Write-Host "'$dotnet' new tool-manifest"
|
||||
& "$dotnet" new tool-manifest
|
||||
Write-Host "'$dotnet' tool install $packageName --local --add-source '$PackageFeed' -v $verbosity --version $BinlogToolVersion"
|
||||
& "$dotnet" tool install $packageName --local --add-source "$PackageFeed" -v $verbosity --version $BinlogToolVersion
|
||||
|
||||
if (Test-Path $TokensFilePath) {
|
||||
Write-Host "Adding additional sensitive data for redaction from file: " $TokensFilePath
|
||||
$TokensToRedact += Get-Content -Path $TokensFilePath | Foreach {$_.Trim()} | Where { $_ -notmatch "^# " }
|
||||
}
|
||||
|
||||
$optionalParams = [System.Collections.ArrayList]::new()
|
||||
|
||||
Foreach ($p in $TokensToRedact)
|
||||
{
|
||||
if($p -match '^\$\(.*\)$')
|
||||
{
|
||||
Write-Host ("Ignoring token {0} as it is probably unexpanded AzDO variable" -f $p)
|
||||
}
|
||||
elseif($p)
|
||||
{
|
||||
$optionalParams.Add("-p:" + $p) | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
& $dotnet binlogtool redact --input:$InputPath --recurse --in-place `
|
||||
@optionalParams
|
||||
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-PipelineTelemetryError -Category 'Redactor' -Type 'warning' -Message "Problems using Redactor tool (exit code: $LastExitCode). But ignoring them now."
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Host 'done.'
|
||||
}
|
||||
catch {
|
||||
Write-Host $_
|
||||
Write-PipelineTelemetryError -Category 'Redactor' -Message "There was an error while trying to redact logs. Error: $_"
|
||||
ExitWithExitCode 1
|
||||
}
|
|
@ -136,7 +136,7 @@ jobs:
|
|||
condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
|
||||
|
||||
- ${{ if and(eq(parameters.runAsPublic, 'false'), eq(variables['System.TeamProject'], 'internal')) }}:
|
||||
- task: NuGetAuthenticate@0
|
||||
- task: NuGetAuthenticate@1
|
||||
|
||||
- ${{ if and(ne(parameters.artifacts.download, 'false'), ne(parameters.artifacts.download, '')) }}:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
|
@ -154,7 +154,7 @@ jobs:
|
|||
displayName: RichCodeNav Upload
|
||||
inputs:
|
||||
languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }}
|
||||
environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'internal') }}
|
||||
environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }}
|
||||
richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin
|
||||
uploadRichNavArtifacts: ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }}
|
||||
continueOnError: true
|
||||
|
|
|
@ -48,8 +48,8 @@ jobs:
|
|||
- group: AzureDevOps-Artifact-Feeds-Pats
|
||||
- name: runCodesignValidationInjection
|
||||
value: false
|
||||
# unconditional - needed for logs publishing (redactor tool version)
|
||||
- template: /eng/common/templates/post-build/common-variables.yml
|
||||
- ${{ if eq(parameters.publishAssetsImmediately, 'true') }}:
|
||||
- template: /eng/common/templates/post-build/common-variables.yml
|
||||
|
||||
pool:
|
||||
# We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
|
||||
|
@ -72,7 +72,7 @@ jobs:
|
|||
condition: ${{ parameters.condition }}
|
||||
continueOnError: ${{ parameters.continueOnError }}
|
||||
|
||||
- task: NuGetAuthenticate@0
|
||||
- task: NuGetAuthenticate@1
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: Publish Build Assets
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
parameters:
|
||||
runAsPublic: false
|
||||
sourceIndexPackageVersion: 1.0.1-20231213.4
|
||||
sourceIndexPackageVersion: 1.0.1-20230228.2
|
||||
sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
|
||||
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
|
||||
preSteps: []
|
||||
|
@ -30,20 +30,20 @@ jobs:
|
|||
pool:
|
||||
${{ if eq(variables['System.TeamProject'], 'public') }}:
|
||||
name: $(DncEngPublicBuildPool)
|
||||
demands: ImageOverride -equals windows.vs2022.amd64.open
|
||||
demands: ImageOverride -equals windows.vs2019.amd64.open
|
||||
${{ if eq(variables['System.TeamProject'], 'internal') }}:
|
||||
name: $(DncEngInternalBuildPool)
|
||||
demands: ImageOverride -equals windows.vs2022.amd64
|
||||
demands: ImageOverride -equals windows.vs2019.amd64
|
||||
|
||||
steps:
|
||||
- ${{ each preStep in parameters.preSteps }}:
|
||||
- ${{ preStep }}
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: Use .NET 8 SDK
|
||||
displayName: Use .NET Core SDK 6
|
||||
inputs:
|
||||
packageType: sdk
|
||||
version: 8.0.x
|
||||
version: 6.0.x
|
||||
installationPath: $(Agent.TempDirectory)/dotnet
|
||||
workingDirectory: $(Agent.TempDirectory)
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ variables:
|
|||
value: 3.0.0
|
||||
- name: SymbolToolVersion
|
||||
value: 1.0.1
|
||||
- name: BinlogToolVersion
|
||||
value: 1.0.8
|
||||
|
||||
- name: runCodesignValidationInjection
|
||||
value: false
|
||||
|
|
|
@ -169,7 +169,7 @@ stages:
|
|||
# This is necessary whenever we want to publish/restore to an AzDO private feed
|
||||
# Since sdk-task.ps1 tries to restore packages we need to do this authentication here
|
||||
# otherwise it'll complain about accessing a private feed.
|
||||
- task: NuGetAuthenticate@0
|
||||
- task: NuGetAuthenticate@1
|
||||
displayName: 'Authenticate to AzDO Feeds'
|
||||
|
||||
# Signing validation will optionally work with the buildmanifest file which is downloaded from
|
||||
|
@ -187,7 +187,6 @@ stages:
|
|||
parameters:
|
||||
StageLabel: 'Validation'
|
||||
JobLabel: 'Signing'
|
||||
BinlogToolVersion: $(BinlogToolVersion)
|
||||
|
||||
- job:
|
||||
displayName: SourceLink Validation
|
||||
|
@ -267,7 +266,7 @@ stages:
|
|||
BARBuildId: ${{ parameters.BARBuildId }}
|
||||
PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}
|
||||
|
||||
- task: NuGetAuthenticate@0
|
||||
- task: NuGetAuthenticate@1
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: Publish Using Darc
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
parameters:
|
||||
StageLabel: ''
|
||||
JobLabel: ''
|
||||
CustomSensitiveDataList: ''
|
||||
# A default - in case value from eng/common/templates/post-build/common-variables.yml is not passed
|
||||
BinlogToolVersion: '1.0.8'
|
||||
|
||||
steps:
|
||||
- task: Powershell@2
|
||||
|
@ -15,30 +12,7 @@ steps:
|
|||
Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/
|
||||
continueOnError: true
|
||||
condition: always()
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: Redact Logs
|
||||
inputs:
|
||||
filePath: $(Build.SourcesDirectory)/eng/common/post-build/redact-logs.ps1
|
||||
# For now this needs to have explicit list of all sensitive data. Taken from eng/publishing/v3/publish.yml
|
||||
# Sensitive data can as well be added to $(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt'
|
||||
# If the file exists - sensitive data for redaction will be sourced from it
|
||||
# (single entry per line, lines starting with '# ' are considered comments and skipped)
|
||||
arguments: -InputPath '$(Build.SourcesDirectory)/PostBuildLogs'
|
||||
-BinlogToolVersion ${{parameters.BinlogToolVersion}}
|
||||
-TokensFilePath '$(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt'
|
||||
'$(publishing-dnceng-devdiv-code-r-build-re)'
|
||||
'$(MaestroAccessToken)'
|
||||
'$(dn-bot-all-orgs-artifact-feeds-rw)'
|
||||
'$(akams-client-id)'
|
||||
'$(akams-client-secret)'
|
||||
'$(microsoft-symbol-server-pat)'
|
||||
'$(symweb-symbol-server-pat)'
|
||||
'$(dn-bot-all-orgs-build-rw-code-rw)'
|
||||
${{parameters.CustomSensitiveDataList}}
|
||||
continueOnError: true
|
||||
condition: always()
|
||||
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
displayName: Publish Logs
|
||||
inputs:
|
||||
|
|
|
@ -158,13 +158,18 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
|
|||
$env:DOTNET_MULTILEVEL_LOOKUP=0
|
||||
|
||||
# Disable first run since we do not need all ASP.NET packages restored.
|
||||
$env:DOTNET_NOLOGO=1
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
# Disable telemetry on CI.
|
||||
if ($ci) {
|
||||
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
}
|
||||
|
||||
# Source Build uses DotNetCoreSdkDir variable
|
||||
if ($env:DotNetCoreSdkDir -ne $null) {
|
||||
$env:DOTNET_INSTALL_DIR = $env:DotNetCoreSdkDir
|
||||
}
|
||||
|
||||
# Find the first path on %PATH% that contains the dotnet.exe
|
||||
if ($useInstalledDotNetCli -and (-not $globalJsonHasRuntimes) -and ($env:DOTNET_INSTALL_DIR -eq $null)) {
|
||||
$dotnetExecutable = GetExecutableFileName 'dotnet'
|
||||
|
@ -223,7 +228,7 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
|
|||
Write-PipelinePrependPath -Path $dotnetRoot
|
||||
|
||||
Write-PipelineSetVariable -Name 'DOTNET_MULTILEVEL_LOOKUP' -Value '0'
|
||||
Write-PipelineSetVariable -Name 'DOTNET_NOLOGO' -Value '1'
|
||||
Write-PipelineSetVariable -Name 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' -Value '1'
|
||||
|
||||
return $global:_DotNetInstallDir = $dotnetRoot
|
||||
}
|
||||
|
@ -822,8 +827,7 @@ function MSBuild-Core() {
|
|||
}
|
||||
}
|
||||
|
||||
# Be sure quote the path in case there are spaces in the dotnet installation location.
|
||||
$env:ARCADE_BUILD_TOOL_COMMAND = "`"$($buildTool.Path)`" $cmdArgs"
|
||||
$env:ARCADE_BUILD_TOOL_COMMAND = "$($buildTool.Path) $cmdArgs"
|
||||
|
||||
$exitCode = Exec-Process $buildTool.Path $cmdArgs
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ function InitializeDotNetCli {
|
|||
export DOTNET_MULTILEVEL_LOOKUP=0
|
||||
|
||||
# Disable first run since we want to control all package sources
|
||||
export DOTNET_NOLOGO=1
|
||||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
# Disable telemetry on CI
|
||||
if [[ $ci == true ]]; then
|
||||
|
@ -123,6 +123,11 @@ function InitializeDotNetCli {
|
|||
# so it doesn't output warnings to the console.
|
||||
export LTTNG_HOME="$HOME"
|
||||
|
||||
# Source Build uses DotNetCoreSdkDir variable
|
||||
if [[ -n "${DotNetCoreSdkDir:-}" ]]; then
|
||||
export DOTNET_INSTALL_DIR="$DotNetCoreSdkDir"
|
||||
fi
|
||||
|
||||
# Find the first path on $PATH that contains the dotnet.exe
|
||||
if [[ "$use_installed_dotnet_cli" == true && $global_json_has_runtimes == false && -z "${DOTNET_INSTALL_DIR:-}" ]]; then
|
||||
local dotnet_path=`command -v dotnet`
|
||||
|
@ -160,7 +165,7 @@ function InitializeDotNetCli {
|
|||
Write-PipelinePrependPath -path "$dotnet_root"
|
||||
|
||||
Write-PipelineSetVariable -name "DOTNET_MULTILEVEL_LOOKUP" -value "0"
|
||||
Write-PipelineSetVariable -name "DOTNET_NOLOGO" -value "1"
|
||||
Write-PipelineSetVariable -name "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" -value "1"
|
||||
|
||||
# return value
|
||||
_InitializeDotNetCli="$dotnet_root"
|
||||
|
@ -305,7 +310,7 @@ function GetDotNetInstallScript {
|
|||
curl "$install_script_url" -sSL --retry 10 --create-dirs -o "$install_script" || {
|
||||
if command -v openssl &> /dev/null; then
|
||||
echo "Curl failed; dumping some information about dotnet.microsoft.com for later investigation"
|
||||
echo | openssl s_client -showcerts -servername dotnet.microsoft.com -connect dotnet.microsoft.com:443 || true
|
||||
echo | openssl s_client -showcerts -servername dotnet.microsoft.com -connect dotnet.microsoft.com:443
|
||||
fi
|
||||
echo "Will now retry the same URL with verbose logging."
|
||||
with_retries curl "$install_script_url" -sSL --verbose --retry 10 --create-dirs -o "$install_script" || {
|
||||
|
@ -336,12 +341,7 @@ function InitializeBuildTool {
|
|||
# return values
|
||||
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
|
||||
_InitializeBuildToolCommand="msbuild"
|
||||
# use override if it exists - commonly set by source-build
|
||||
if [[ "${_OverrideArcadeInitializeBuildToolFramework:-x}" == "x" ]]; then
|
||||
_InitializeBuildToolFramework="net8.0"
|
||||
else
|
||||
_InitializeBuildToolFramework="${_OverrideArcadeInitializeBuildToolFramework}"
|
||||
fi
|
||||
_InitializeBuildToolFramework="net8.0"
|
||||
}
|
||||
|
||||
# Set RestoreNoCache as a workaround for https://github.com/NuGet/Home/issues/3116
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
],
|
||||
"vsBranch": "main",
|
||||
"vsMajorVersion": 17,
|
||||
"insertionCreateDraftPR": false,
|
||||
"insertionTitlePrefix": "[17.9P3]"
|
||||
"insertionCreateDraftPR": true,
|
||||
"insertionTitlePrefix": "[17.10 Validation]"
|
||||
},
|
||||
"release/dev17.5": {
|
||||
"nugetKind": [
|
||||
|
@ -51,9 +51,9 @@
|
|||
"Shipping",
|
||||
"NonShipping"
|
||||
],
|
||||
"vsBranch": "rel/d17.9",
|
||||
"vsBranch": "main",
|
||||
"vsMajorVersion": 17,
|
||||
"insertionTitlePrefix": "[17.9P2]"
|
||||
"insertionTitlePrefix": "[17.9]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
"rollForward": "latestPatch"
|
||||
},
|
||||
"msbuild-sdks": {
|
||||
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.23613.3"
|
||||
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23620.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RazorLanguageServerBenchmarkBase : ProjectSnapshotManagerBenchmarkB
|
|||
var projectSnapshotManager = CreateProjectSnapshotManager();
|
||||
projectSnapshotManager.ProjectAdded(hostProject);
|
||||
var tagHelpers = CommonResources.LegacyTagHelpers;
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.CSharp11);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.CSharp11);
|
||||
projectSnapshotManager.ProjectWorkspaceStateChanged(hostProject.Key, projectWorkspaceState);
|
||||
projectSnapshotManager.DocumentAdded(hostProject.Key, hostDocument, textLoader);
|
||||
var projectSnapshot = projectSnapshotManager.GetLoadedProject(hostProject.Key);
|
||||
|
|
|
@ -85,7 +85,7 @@ internal static class RazorProjectInfoSerializer
|
|||
var resolver = new CompilationTagHelperResolver(NoOpTelemetryReporter.Instance);
|
||||
var tagHelpers = await resolver.GetTagHelpersAsync(project, engine, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, csharpLanguageVersion);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers, csharpLanguageVersion);
|
||||
|
||||
var configurationFilePath = Path.Combine(intermediateOutputPath, configurationFileName);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ internal sealed class ProjectWorkspaceState : IEquatable<ProjectWorkspaceState>
|
|||
public ImmutableArray<TagHelperDescriptor> TagHelpers { get; }
|
||||
public LanguageVersion CSharpLanguageVersion { get; }
|
||||
|
||||
public ProjectWorkspaceState(
|
||||
private ProjectWorkspaceState(
|
||||
ImmutableArray<TagHelperDescriptor> tagHelpers,
|
||||
LanguageVersion csharpLanguageVersion)
|
||||
{
|
||||
|
@ -25,6 +25,18 @@ internal sealed class ProjectWorkspaceState : IEquatable<ProjectWorkspaceState>
|
|||
CSharpLanguageVersion = csharpLanguageVersion;
|
||||
}
|
||||
|
||||
public static ProjectWorkspaceState Create(
|
||||
ImmutableArray<TagHelperDescriptor> tagHelpers,
|
||||
LanguageVersion csharpLanguageVersion = LanguageVersion.Default)
|
||||
=> tagHelpers.IsEmpty && csharpLanguageVersion == LanguageVersion.Default
|
||||
? Default
|
||||
: new(tagHelpers, csharpLanguageVersion);
|
||||
|
||||
public static ProjectWorkspaceState Create(LanguageVersion csharpLanguageVersion)
|
||||
=> csharpLanguageVersion == LanguageVersion.Default
|
||||
? Default
|
||||
: new(ImmutableArray<TagHelperDescriptor>.Empty, csharpLanguageVersion);
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is ProjectWorkspaceState other && Equals(other);
|
||||
|
||||
|
|
|
@ -21,19 +21,19 @@ internal sealed class RazorProjectInfo
|
|||
|
||||
public string SerializedFilePath { get; }
|
||||
public string FilePath { get; }
|
||||
public RazorConfiguration? Configuration { get; }
|
||||
public RazorConfiguration Configuration { get; }
|
||||
public string? RootNamespace { get; }
|
||||
public string DisplayName { get; }
|
||||
public ProjectWorkspaceState? ProjectWorkspaceState { get; }
|
||||
public ProjectWorkspaceState ProjectWorkspaceState { get; }
|
||||
public ImmutableArray<DocumentSnapshotHandle> Documents { get; }
|
||||
|
||||
public RazorProjectInfo(
|
||||
string serializedFilePath,
|
||||
string filePath,
|
||||
RazorConfiguration? configuration,
|
||||
RazorConfiguration configuration,
|
||||
string? rootNamespace,
|
||||
string displayName,
|
||||
ProjectWorkspaceState? projectWorkspaceState,
|
||||
ProjectWorkspaceState projectWorkspaceState,
|
||||
ImmutableArray<DocumentSnapshotHandle> documents)
|
||||
{
|
||||
SerializedFilePath = serializedFilePath;
|
||||
|
|
|
@ -79,7 +79,7 @@ internal static partial class ObjectReaders
|
|||
public static ProjectSnapshotHandle ReadProjectSnapshotHandleFromProperties(JsonDataReader reader)
|
||||
{
|
||||
var projectIdString = reader.ReadNonNullString(nameof(ProjectSnapshotHandle.ProjectId));
|
||||
var configuration = reader.ReadObjectOrNull(nameof(ProjectSnapshotHandle.Configuration), ReadConfigurationFromProperties);
|
||||
var configuration = reader.ReadObjectOrNull(nameof(ProjectSnapshotHandle.Configuration), ReadConfigurationFromProperties) ?? RazorConfiguration.Default;
|
||||
var rootNamespace = reader.ReadStringOrNull(nameof(ProjectSnapshotHandle.RootNamespace));
|
||||
|
||||
var projectId = ProjectId.CreateFromSerialized(Guid.Parse(projectIdString));
|
||||
|
@ -101,7 +101,7 @@ internal static partial class ObjectReaders
|
|||
var tagHelpers = reader.ReadImmutableArrayOrEmpty(nameof(ProjectWorkspaceState.TagHelpers), static r => ReadTagHelper(r, useCache: true));
|
||||
var csharpLanguageVersion = (LanguageVersion)reader.ReadInt32OrZero(nameof(ProjectWorkspaceState.CSharpLanguageVersion));
|
||||
|
||||
return new ProjectWorkspaceState(tagHelpers, csharpLanguageVersion);
|
||||
return ProjectWorkspaceState.Create(tagHelpers, csharpLanguageVersion);
|
||||
}
|
||||
|
||||
public static TagHelperDescriptor ReadTagHelper(JsonDataReader reader, bool useCache)
|
||||
|
@ -342,8 +342,8 @@ internal static partial class ObjectReaders
|
|||
|
||||
var serializedFilePath = reader.ReadNonNullString(nameof(RazorProjectInfo.SerializedFilePath));
|
||||
var filePath = reader.ReadNonNullString(nameof(RazorProjectInfo.FilePath));
|
||||
var configuration = reader.ReadObject(nameof(RazorProjectInfo.Configuration), ReadConfigurationFromProperties);
|
||||
var projectWorkspaceState = reader.ReadObject(nameof(RazorProjectInfo.ProjectWorkspaceState), ReadProjectWorkspaceStateFromProperties);
|
||||
var configuration = reader.ReadObject(nameof(RazorProjectInfo.Configuration), ReadConfigurationFromProperties) ?? RazorConfiguration.Default;
|
||||
var projectWorkspaceState = reader.ReadObject(nameof(RazorProjectInfo.ProjectWorkspaceState), ReadProjectWorkspaceStateFromProperties) ?? ProjectWorkspaceState.Default;
|
||||
var rootNamespace = reader.ReadString(nameof(RazorProjectInfo.RootNamespace));
|
||||
var documents = reader.ReadImmutableArray(nameof(RazorProjectInfo.Documents), static r => r.ReadNonNullObject(ReadDocumentSnapshotHandleFromProperties));
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ internal static class ObjectWriters
|
|||
public static void WriteProperties(JsonDataWriter writer, ProjectSnapshotHandle value)
|
||||
{
|
||||
writer.Write(nameof(value.ProjectId), value.ProjectId.Id.ToString());
|
||||
writer.WriteObjectIfNotNull(nameof(value.Configuration), value.Configuration, WriteProperties);
|
||||
writer.WriteObject(nameof(value.Configuration), value.Configuration, WriteProperties);
|
||||
writer.WriteIfNotNull(nameof(value.RootNamespace), value.RootNamespace);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ internal sealed class ProjectSnapshotHandleFormatter : TopLevelFormatter<Project
|
|||
var id = GuidFormatter.Instance.Deserialize(ref reader, options);
|
||||
var projectId = ProjectId.CreateFromSerialized(id);
|
||||
|
||||
var configuration = reader.DeserializeOrNull<RazorConfiguration>(options);
|
||||
var configuration = reader.DeserializeOrNull<RazorConfiguration>(options) ?? RazorConfiguration.Default;
|
||||
var rootNamespace = CachedStringFormatter.Instance.Deserialize(ref reader, options);
|
||||
|
||||
return new(projectId, configuration, rootNamespace);
|
||||
|
|
|
@ -49,7 +49,7 @@ internal sealed class ProjectWorkspaceStateFormatter : ValueFormatter<ProjectWor
|
|||
var tagHelpers = builder.DrainToImmutable();
|
||||
var csharpLanguageVersion = (LanguageVersion)reader.ReadInt32();
|
||||
|
||||
return new ProjectWorkspaceState(tagHelpers, csharpLanguageVersion);
|
||||
return ProjectWorkspaceState.Create(tagHelpers, csharpLanguageVersion);
|
||||
}
|
||||
|
||||
public override void Serialize(ref MessagePackWriter writer, ProjectWorkspaceState value, SerializerCachingOptions options)
|
||||
|
|
|
@ -29,8 +29,8 @@ internal sealed class RazorProjectInfoFormatter : TopLevelFormatter<RazorProject
|
|||
|
||||
var serializedFilePath = CachedStringFormatter.Instance.Deserialize(ref reader, options).AssumeNotNull();
|
||||
var filePath = CachedStringFormatter.Instance.Deserialize(ref reader, options).AssumeNotNull();
|
||||
var configuration = reader.DeserializeOrNull<RazorConfiguration>(options);
|
||||
var projectWorkspaceState = reader.DeserializeOrNull<ProjectWorkspaceState>(options);
|
||||
var configuration = reader.DeserializeOrNull<RazorConfiguration>(options) ?? RazorConfiguration.Default;
|
||||
var projectWorkspaceState = reader.DeserializeOrNull<ProjectWorkspaceState>(options) ?? ProjectWorkspaceState.Default;
|
||||
var rootNamespace = CachedStringFormatter.Instance.Deserialize(ref reader, options);
|
||||
var displayName = CachedStringFormatter.Instance.Deserialize(ref reader, options).AssumeNotNull();
|
||||
var documents = reader.Deserialize<ImmutableArray<DocumentSnapshotHandle>>(options);
|
||||
|
|
|
@ -10,13 +10,13 @@ namespace Microsoft.AspNetCore.Razor.Serialization;
|
|||
internal record ProjectSnapshotHandle
|
||||
{
|
||||
public ProjectId ProjectId { get; }
|
||||
public RazorConfiguration? Configuration { get; }
|
||||
public RazorConfiguration Configuration { get; }
|
||||
public string? RootNamespace { get; }
|
||||
|
||||
public ProjectSnapshotHandle(ProjectId projectId, RazorConfiguration? configuration, string? rootNamespace)
|
||||
public ProjectSnapshotHandle(ProjectId projectId, RazorConfiguration configuration, string? rootNamespace)
|
||||
{
|
||||
ProjectId = projectId ?? throw new ArgumentNullException(nameof(projectId));
|
||||
Configuration = configuration;
|
||||
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
RootNamespace = rootNamespace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ internal class DefaultProjectSnapshotProjectEngineFactory : ProjectSnapshotProje
|
|||
throw new ArgumentNullException(nameof(project));
|
||||
}
|
||||
|
||||
return SelectFactory(project.Configuration ?? s_defaultConfiguration, requireSerializable: false);
|
||||
return SelectFactory(project.Configuration, requireSerializable: false);
|
||||
}
|
||||
|
||||
public override IProjectEngineFactory FindSerializableFactory(IProjectSnapshot project)
|
||||
|
@ -81,7 +81,7 @@ internal class DefaultProjectSnapshotProjectEngineFactory : ProjectSnapshotProje
|
|||
throw new ArgumentNullException(nameof(project));
|
||||
}
|
||||
|
||||
return SelectFactory(project.Configuration ?? s_defaultConfiguration, requireSerializable: true);
|
||||
return SelectFactory(project.Configuration, requireSerializable: true);
|
||||
}
|
||||
|
||||
private IProjectEngineFactory SelectFactory(RazorConfiguration configuration, bool requireSerializable = false)
|
||||
|
|
|
@ -129,7 +129,7 @@ internal class DefaultProjectWorkspaceStateGenerator(ProjectSnapshotManagerDispa
|
|||
var telemetryId = Guid.NewGuid();
|
||||
_telemetryReporter.ReportEvent("taghelperresolve/begin", Severity.Normal,
|
||||
new Property("id", telemetryId),
|
||||
new Property("tagHelperCount", projectSnapshot.ProjectWorkspaceState?.TagHelpers.Length ?? 0));
|
||||
new Property("tagHelperCount", projectSnapshot.ProjectWorkspaceState.TagHelpers.Length));
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ internal class DefaultProjectWorkspaceStateGenerator(ProjectSnapshotManagerDispa
|
|||
new Property("result", "success"),
|
||||
new Property("tagHelperCount", tagHelpers.Length));
|
||||
|
||||
workspaceState = new ProjectWorkspaceState(tagHelpers, csharpLanguageVersion);
|
||||
workspaceState = ProjectWorkspaceState.Create(tagHelpers, csharpLanguageVersion);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
|
|
@ -442,7 +442,12 @@ internal class DefaultProjectSnapshotManager : ProjectSnapshotManagerBase
|
|||
return false;
|
||||
}
|
||||
|
||||
var state = ProjectState.Create(Workspace.Services, projectAddedAction.HostProject);
|
||||
var projectEngineFactory = Workspace.Services.GetRequiredService<ProjectSnapshotProjectEngineFactory>();
|
||||
|
||||
var state = ProjectState.Create(
|
||||
projectEngineFactory,
|
||||
projectAddedAction.HostProject,
|
||||
ProjectWorkspaceState.Default);
|
||||
var newEntry = new Entry(state);
|
||||
|
||||
oldSnapshot = newSnapshot = newEntry.GetSnapshot();
|
||||
|
|
|
@ -8,7 +8,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -31,32 +30,24 @@ internal class DocumentState
|
|||
private VersionStamp? _version;
|
||||
|
||||
public static DocumentState Create(
|
||||
HostWorkspaceServices services,
|
||||
HostDocument hostDocument,
|
||||
Func<Task<TextAndVersion>>? loader)
|
||||
{
|
||||
if (services is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(services));
|
||||
}
|
||||
|
||||
if (hostDocument is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(hostDocument));
|
||||
}
|
||||
|
||||
return new DocumentState(services, hostDocument, null, null, loader);
|
||||
return new DocumentState(hostDocument, null, null, loader);
|
||||
}
|
||||
|
||||
// Internal for testing
|
||||
internal DocumentState(
|
||||
HostWorkspaceServices services,
|
||||
HostDocument hostDocument,
|
||||
SourceText? text,
|
||||
VersionStamp? version,
|
||||
Func<Task<TextAndVersion>>? loader)
|
||||
{
|
||||
Services = services;
|
||||
HostDocument = hostDocument;
|
||||
_sourceText = text;
|
||||
_version = version;
|
||||
|
@ -66,8 +57,6 @@ internal class DocumentState
|
|||
|
||||
public HostDocument HostDocument { get; }
|
||||
|
||||
public HostWorkspaceServices Services { get; }
|
||||
|
||||
public bool IsGeneratedOutputResultAvailable => ComputedState.IsResultAvailable == true;
|
||||
|
||||
private ComputedStateTracker ComputedState
|
||||
|
@ -168,7 +157,7 @@ internal class DocumentState
|
|||
|
||||
public virtual DocumentState WithConfigurationChange()
|
||||
{
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader)
|
||||
var state = new DocumentState(HostDocument, _sourceText, _version, _loader)
|
||||
{
|
||||
// The source could not have possibly changed.
|
||||
_sourceText = _sourceText,
|
||||
|
@ -183,7 +172,7 @@ internal class DocumentState
|
|||
|
||||
public virtual DocumentState WithImportsChange()
|
||||
{
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader)
|
||||
var state = new DocumentState(HostDocument, _sourceText, _version, _loader)
|
||||
{
|
||||
// The source could not have possibly changed.
|
||||
_sourceText = _sourceText,
|
||||
|
@ -199,7 +188,7 @@ internal class DocumentState
|
|||
|
||||
public virtual DocumentState WithProjectWorkspaceStateChange()
|
||||
{
|
||||
var state = new DocumentState(Services, HostDocument, _sourceText, _version, _loader)
|
||||
var state = new DocumentState(HostDocument, _sourceText, _version, _loader)
|
||||
{
|
||||
// The source could not have possibly changed.
|
||||
_sourceText = _sourceText,
|
||||
|
@ -222,7 +211,7 @@ internal class DocumentState
|
|||
|
||||
// Do not cache the computed state
|
||||
|
||||
return new DocumentState(Services, HostDocument, sourceText, version, null);
|
||||
return new DocumentState(HostDocument, sourceText, version, null);
|
||||
}
|
||||
|
||||
public virtual DocumentState WithTextLoader(Func<Task<TextAndVersion>> loader)
|
||||
|
@ -234,7 +223,7 @@ internal class DocumentState
|
|||
|
||||
// Do not cache the computed state
|
||||
|
||||
return new DocumentState(Services, HostDocument, null, null, loader);
|
||||
return new DocumentState(HostDocument, null, null, loader);
|
||||
}
|
||||
|
||||
private ImmutableArray<IDocumentSnapshot> GetImportsCore(ProjectSnapshot project)
|
||||
|
|
|
@ -13,7 +13,7 @@ internal interface IProjectSnapshot
|
|||
{
|
||||
ProjectKey Key { get; }
|
||||
|
||||
RazorConfiguration? Configuration { get; }
|
||||
RazorConfiguration Configuration { get; }
|
||||
IEnumerable<string> DocumentFilePaths { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -31,7 +31,7 @@ internal interface IProjectSnapshot
|
|||
VersionStamp Version { get; }
|
||||
LanguageVersion CSharpLanguageVersion { get; }
|
||||
ImmutableArray<TagHelperDescriptor> TagHelpers { get; }
|
||||
ProjectWorkspaceState? ProjectWorkspaceState { get; }
|
||||
ProjectWorkspaceState ProjectWorkspaceState { get; }
|
||||
|
||||
RazorProjectEngine GetProjectEngine();
|
||||
IDocumentSnapshot? GetDocument(string filePath);
|
||||
|
|
|
@ -31,7 +31,7 @@ internal class ProjectSnapshot : IProjectSnapshot
|
|||
|
||||
public ProjectState State { get; }
|
||||
|
||||
public RazorConfiguration? Configuration => HostProject.Configuration;
|
||||
public RazorConfiguration Configuration => HostProject.Configuration;
|
||||
|
||||
public IEnumerable<string> DocumentFilePaths => State.Documents.Keys;
|
||||
|
||||
|
@ -53,7 +53,7 @@ internal class ProjectSnapshot : IProjectSnapshot
|
|||
|
||||
public ImmutableArray<TagHelperDescriptor> TagHelpers => State.TagHelpers;
|
||||
|
||||
public ProjectWorkspaceState? ProjectWorkspaceState => State.ProjectWorkspaceState;
|
||||
public ProjectWorkspaceState ProjectWorkspaceState => State.ProjectWorkspaceState;
|
||||
|
||||
public virtual IDocumentSnapshot? GetDocument(string filePath)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
@ -13,7 +11,6 @@ using Microsoft.AspNetCore.Razor.Language;
|
|||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -36,16 +33,17 @@ internal class ProjectState
|
|||
private static readonly ImmutableDictionary<string, ImmutableArray<string>> s_emptyImportsToRelatedDocuments = ImmutableDictionary.Create<string, ImmutableArray<string>>(FilePathNormalizer.Comparer);
|
||||
private readonly object _lock;
|
||||
|
||||
private RazorProjectEngine _projectEngine;
|
||||
private readonly ProjectSnapshotProjectEngineFactory _projectEngineFactory;
|
||||
private RazorProjectEngine? _projectEngine;
|
||||
|
||||
public static ProjectState Create(
|
||||
HostWorkspaceServices services,
|
||||
ProjectSnapshotProjectEngineFactory projectEngineFactory,
|
||||
HostProject hostProject,
|
||||
ProjectWorkspaceState projectWorkspaceState = null)
|
||||
ProjectWorkspaceState projectWorkspaceState)
|
||||
{
|
||||
if (services is null)
|
||||
if (projectEngineFactory is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(services));
|
||||
throw new ArgumentNullException(nameof(projectEngineFactory));
|
||||
}
|
||||
|
||||
if (hostProject is null)
|
||||
|
@ -53,20 +51,26 @@ internal class ProjectState
|
|||
throw new ArgumentNullException(nameof(hostProject));
|
||||
}
|
||||
|
||||
return new ProjectState(services, hostProject, projectWorkspaceState);
|
||||
if (projectWorkspaceState is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectWorkspaceState));
|
||||
}
|
||||
|
||||
return new ProjectState(projectEngineFactory, hostProject, projectWorkspaceState);
|
||||
}
|
||||
|
||||
private ProjectState(
|
||||
HostWorkspaceServices services,
|
||||
ProjectSnapshotProjectEngineFactory projectEngineFactory,
|
||||
HostProject hostProject,
|
||||
ProjectWorkspaceState projectWorkspaceState)
|
||||
{
|
||||
Services = services;
|
||||
_projectEngineFactory = projectEngineFactory;
|
||||
HostProject = hostProject;
|
||||
ProjectWorkspaceState = projectWorkspaceState;
|
||||
Documents = s_emptyDocuments;
|
||||
ImportsToRelatedDocuments = s_emptyImportsToRelatedDocuments;
|
||||
Version = VersionStamp.Create();
|
||||
ProjectWorkspaceStateVersion = Version;
|
||||
DocumentCollectionVersion = Version;
|
||||
|
||||
_lock = new object();
|
||||
|
@ -100,7 +104,12 @@ internal class ProjectState
|
|||
throw new ArgumentNullException(nameof(importsToRelatedDocuments));
|
||||
}
|
||||
|
||||
Services = older.Services;
|
||||
if (projectWorkspaceState is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectWorkspaceState));
|
||||
}
|
||||
|
||||
_projectEngineFactory = older._projectEngineFactory;
|
||||
Version = older.Version.GetNewerVersion();
|
||||
|
||||
HostProject = hostProject;
|
||||
|
@ -133,7 +142,7 @@ internal class ProjectState
|
|||
|
||||
if ((difference & ClearProjectWorkspaceStateVersionMask) == 0 ||
|
||||
ProjectWorkspaceState == older.ProjectWorkspaceState ||
|
||||
ProjectWorkspaceState?.Equals(older.ProjectWorkspaceState) == true)
|
||||
ProjectWorkspaceState.Equals(older.ProjectWorkspaceState))
|
||||
{
|
||||
ProjectWorkspaceStateVersion = older.ProjectWorkspaceStateVersion;
|
||||
}
|
||||
|
@ -161,11 +170,9 @@ internal class ProjectState
|
|||
|
||||
public ProjectWorkspaceState ProjectWorkspaceState { get; }
|
||||
|
||||
public HostWorkspaceServices Services { get; }
|
||||
public ImmutableArray<TagHelperDescriptor> TagHelpers => ProjectWorkspaceState.TagHelpers;
|
||||
|
||||
public ImmutableArray<TagHelperDescriptor> TagHelpers => ProjectWorkspaceState?.TagHelpers ?? ImmutableArray<TagHelperDescriptor>.Empty;
|
||||
|
||||
public LanguageVersion CSharpLanguageVersion => ProjectWorkspaceState?.CSharpLanguageVersion ?? LanguageVersion.Default;
|
||||
public LanguageVersion CSharpLanguageVersion => ProjectWorkspaceState.CSharpLanguageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the version of this project, INCLUDING content changes. The <see cref="Version"/> is
|
||||
|
@ -190,6 +197,19 @@ internal class ProjectState
|
|||
}
|
||||
|
||||
return _projectEngine;
|
||||
|
||||
RazorProjectEngine CreateProjectEngine()
|
||||
{
|
||||
return _projectEngineFactory.Create(
|
||||
HostProject.Configuration,
|
||||
Path.GetDirectoryName(HostProject.FilePath),
|
||||
configure: builder =>
|
||||
{
|
||||
builder.SetRootNamespace(HostProject.RootNamespace);
|
||||
builder.SetCSharpLanguageVersion(CSharpLanguageVersion);
|
||||
builder.SetSupportLocalizedComponentNames();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +241,7 @@ internal class ProjectState
|
|||
return this;
|
||||
}
|
||||
|
||||
var documents = Documents.Add(hostDocument.FilePath, DocumentState.Create(Services, hostDocument, loader));
|
||||
var documents = Documents.Add(hostDocument.FilePath, DocumentState.Create(hostDocument, loader));
|
||||
|
||||
// Compute the effect on the import map
|
||||
var importTargetPaths = GetImportDocumentTargetPaths(hostDocument);
|
||||
|
@ -360,7 +380,7 @@ internal class ProjectState
|
|||
return this;
|
||||
}
|
||||
|
||||
if (ProjectWorkspaceState != null && ProjectWorkspaceState.Equals(projectWorkspaceState))
|
||||
if (ProjectWorkspaceState.Equals(projectWorkspaceState))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
@ -409,20 +429,6 @@ internal class ProjectState
|
|||
return importsToRelatedDocuments;
|
||||
}
|
||||
|
||||
private RazorProjectEngine CreateProjectEngine()
|
||||
{
|
||||
var factory = Services.GetRequiredService<ProjectSnapshotProjectEngineFactory>();
|
||||
return factory.Create(
|
||||
HostProject.Configuration,
|
||||
Path.GetDirectoryName(HostProject.FilePath),
|
||||
configure: builder =>
|
||||
{
|
||||
builder.SetRootNamespace(HostProject.RootNamespace);
|
||||
builder.SetCSharpLanguageVersion(CSharpLanguageVersion);
|
||||
builder.SetSupportLocalizedComponentNames();
|
||||
});
|
||||
}
|
||||
|
||||
public List<string> GetImportDocumentTargetPaths(HostDocument hostDocument)
|
||||
{
|
||||
var projectEngine = ProjectEngine;
|
||||
|
|
|
@ -22,8 +22,6 @@ internal partial class TagHelperResolverFactory
|
|||
Project workspaceProject,
|
||||
IProjectSnapshot projectSnapshot,
|
||||
CancellationToken cancellationToken)
|
||||
=> projectSnapshot.Configuration is not null
|
||||
? _resolver.GetTagHelpersAsync(workspaceProject, projectSnapshot.GetProjectEngine(), cancellationToken)
|
||||
: new(ImmutableArray<TagHelperDescriptor>.Empty);
|
||||
=> _resolver.GetTagHelpersAsync(workspaceProject, projectSnapshot.GetProjectEngine(), cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,11 +41,6 @@ internal class OOPTagHelperResolver : ITagHelperResolver
|
|||
IProjectSnapshot projectSnapshot,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (projectSnapshot.Configuration is null)
|
||||
{
|
||||
return ImmutableArray<TagHelperDescriptor>.Empty;
|
||||
}
|
||||
|
||||
// Not every custom factory supports the OOP host. Our priority system should work like this:
|
||||
//
|
||||
// 1. Use custom factory out of process
|
||||
|
|
|
@ -44,7 +44,7 @@ internal class EphemeralProjectSnapshot : IProjectSnapshot
|
|||
|
||||
public ProjectKey Key { get; }
|
||||
|
||||
public RazorConfiguration? Configuration => FallbackRazorConfiguration.Latest;
|
||||
public RazorConfiguration Configuration => FallbackRazorConfiguration.Latest;
|
||||
|
||||
public IEnumerable<string> DocumentFilePaths => Array.Empty<string>();
|
||||
|
||||
|
@ -58,11 +58,11 @@ internal class EphemeralProjectSnapshot : IProjectSnapshot
|
|||
|
||||
public VersionStamp Version => VersionStamp.Default;
|
||||
|
||||
public LanguageVersion CSharpLanguageVersion => LanguageVersion.Default;
|
||||
public LanguageVersion CSharpLanguageVersion => ProjectWorkspaceState.CSharpLanguageVersion;
|
||||
|
||||
public ImmutableArray<TagHelperDescriptor> TagHelpers => ImmutableArray<TagHelperDescriptor>.Empty;
|
||||
public ImmutableArray<TagHelperDescriptor> TagHelpers => ProjectWorkspaceState.TagHelpers;
|
||||
|
||||
public ProjectWorkspaceState? ProjectWorkspaceState => null;
|
||||
public ProjectWorkspaceState ProjectWorkspaceState => ProjectWorkspaceState.Default;
|
||||
|
||||
public IDocumentSnapshot? GetDocument(string filePath)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -125,10 +124,10 @@ internal class DefaultProjectSnapshotManagerProxy : IProjectSnapshotManagerProxy
|
|||
return null;
|
||||
}
|
||||
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(project.TagHelpers, project.CSharpLanguageVersion);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(project.TagHelpers, project.CSharpLanguageVersion);
|
||||
var projectFilePath = _session.ConvertLocalPathToSharedUri(project.FilePath);
|
||||
var intermediateOutputPath = _session.ConvertLocalPathToSharedUri(project.IntermediateOutputPath);
|
||||
var projectHandleProxy = new ProjectSnapshotHandleProxy(projectFilePath, intermediateOutputPath, project.Configuration.AssumeNotNull(), project.RootNamespace, projectWorkspaceState);
|
||||
var projectHandleProxy = new ProjectSnapshotHandleProxy(projectFilePath, intermediateOutputPath, project.Configuration, project.RootNamespace, projectWorkspaceState);
|
||||
return projectHandleProxy;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,47 +94,47 @@
|
|||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelCritical">
|
||||
<source>Critical</source>
|
||||
<target state="new">Critical</target>
|
||||
<target state="translated">Crítico</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelDebug">
|
||||
<source>Debug</source>
|
||||
<target state="new">Debug</target>
|
||||
<target state="translated">Depurar</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelDescription">
|
||||
<source>Sets the level of logging to show in the Razor Logger Output catregory of the Output Window.</source>
|
||||
<target state="new">Sets the level of logging to show in the Razor Logger Output catregory of the Output Window.</target>
|
||||
<target state="translated">Define o nível de registro em log a ser exibido na categoria Saída do Razor Logger da Janela de Saída.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelDisplayName">
|
||||
<source>Output Window Log Level</source>
|
||||
<target state="new">Output Window Log Level</target>
|
||||
<target state="translated">Nível de log da janela de saída</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelError">
|
||||
<source>Error</source>
|
||||
<target state="new">Error</target>
|
||||
<target state="translated">Erro</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelInformation">
|
||||
<source>Information</source>
|
||||
<target state="new">Information</target>
|
||||
<target state="translated">Informação</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelNone">
|
||||
<source>None</source>
|
||||
<target state="new">None</target>
|
||||
<target state="translated">Nenhum</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelTrace">
|
||||
<source>Trace</source>
|
||||
<target state="new">Trace</target>
|
||||
<target state="translated">Traço</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_LogLevelWarning">
|
||||
<source>Warning</source>
|
||||
<target state="new">Warning</target>
|
||||
<target state="translated">Aviso</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="Setting_SnippetsAll">
|
||||
|
|
|
@ -1178,7 +1178,7 @@ public class CodeActionEndToEndTest(ITestOutputHelper testOutput) : SingleServer
|
|||
return null;
|
||||
}
|
||||
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(_tagHelperDescriptors.ToImmutableArray(), LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(_tagHelperDescriptors.ToImmutableArray());
|
||||
var testDocumentSnapshot = TestDocumentSnapshot.Create(FilePath, CodeDocument.GetSourceText().ToString(), CodeAnalysis.VersionStamp.Default, projectWorkspaceState);
|
||||
testDocumentSnapshot.With(CodeDocument);
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ There is no xml, but I got you this < and the >.
|
|||
var tagHelperTypeName = "TestNamespace.TestTagHelper";
|
||||
builder.Metadata(TypeName(tagHelperTypeName));
|
||||
var tagHelpers = ImmutableArray.Create(builder.Build());
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers);
|
||||
|
||||
var baseDirectory = PathUtilities.CreateRootedPath("path", "to");
|
||||
var razorFilePath = Path.Combine(baseDirectory, "file.razor");
|
||||
|
@ -383,7 +383,7 @@ There is no xml, but I got you this < and the >.
|
|||
var tagHelperTypeName = "TestNamespace.TestTagHelper";
|
||||
builder.Metadata(TypeName(tagHelperTypeName));
|
||||
var tagHelpers = ImmutableArray.Create(builder.Build());
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers);
|
||||
|
||||
var baseDirectory = PathUtilities.CreateRootedPath("path", "to");
|
||||
var razorFilePath = Path.Combine(baseDirectory, "file.razor");
|
||||
|
@ -420,7 +420,7 @@ There is no xml, but I got you this < and the >.
|
|||
var tagHelperTypeName = "TestNamespace.TestTagHelper";
|
||||
builder.Metadata(TypeName(tagHelperTypeName));
|
||||
var tagHelpers = ImmutableArray.Create(builder.Build());
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers);
|
||||
|
||||
var baseDirectory = PathUtilities.CreateRootedPath("path", "to");
|
||||
var razorFilePath = Path.Combine(baseDirectory, "file.razor");
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DefaultRazorProjectServiceTest(ITestOutputHelper testOutput) : Lang
|
|||
var hostProject = new HostProject("C:/path/to/project.csproj", "C:/path/to/obj", RazorConfiguration.Default, "TestRootNamespace");
|
||||
projectManager.ProjectAdded(hostProject);
|
||||
var projectService = CreateProjectService(new TestSnapshotResolver(), projectManager);
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.LatestMajor);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(LanguageVersion.LatestMajor);
|
||||
|
||||
// Act
|
||||
await RunOnDispatcherThreadAsync(() =>
|
||||
|
|
|
@ -975,7 +975,7 @@ public class HoverInfoServiceTest(ITestOutputHelper testOutput) : TagHelperServi
|
|||
""";
|
||||
var path = "C:/text.razor";
|
||||
var codeDocument = CreateCodeDocument(txt, path, DefaultTagHelpers);
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(DefaultTagHelpers, LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(DefaultTagHelpers);
|
||||
var projectSnapshot = TestProjectSnapshot.Create("C:/project.csproj", projectWorkspaceState);
|
||||
var sourceText = SourceText.From(txt);
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class OpenDocumentGeneratorTest : LanguageServerTestBase
|
|||
|
||||
// Act
|
||||
projectManager.ProjectWorkspaceStateChanged(_hostProject1.Key,
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp8));
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp8));
|
||||
}, DisposalToken);
|
||||
|
||||
// Assert
|
||||
|
@ -162,7 +162,7 @@ public class OpenDocumentGeneratorTest : LanguageServerTestBase
|
|||
|
||||
// Act
|
||||
projectManager.ProjectWorkspaceStateChanged(_hostProject1.Key,
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp8));
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp8));
|
||||
}, DisposalToken);
|
||||
|
||||
// Assert
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
|
@ -25,10 +26,10 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
.Returns(new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.bin",
|
||||
"c:/path/to/project.csproj",
|
||||
configuration: null,
|
||||
configuration: RazorConfiguration.Default,
|
||||
rootNamespace: null,
|
||||
displayName: "project",
|
||||
projectWorkspaceState: null,
|
||||
projectWorkspaceState: ProjectWorkspaceState.Default,
|
||||
documents: ImmutableArray<DocumentSnapshotHandle>.Empty));
|
||||
|
||||
var args = new ProjectConfigurationFileChangeEventArgs(
|
||||
|
@ -53,10 +54,10 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/ORIGINAL/obj/project.razor.bin",
|
||||
"c:/path/to/project.csproj",
|
||||
configuration: null,
|
||||
configuration: RazorConfiguration.Default,
|
||||
rootNamespace: null,
|
||||
displayName: "project",
|
||||
projectWorkspaceState: null,
|
||||
projectWorkspaceState: ProjectWorkspaceState.Default,
|
||||
documents: ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
|
||||
deserializerMock
|
||||
|
@ -84,10 +85,10 @@ public class ProjectConfigurationFileChangeEventArgsTest(ITestOutputHelper testO
|
|||
var projectInfo = new RazorProjectInfo(
|
||||
"/path/to/obj/project.razor.bin",
|
||||
"c:/path/to/project.csproj",
|
||||
configuration: null,
|
||||
configuration: RazorConfiguration.Default,
|
||||
rootNamespace: null,
|
||||
displayName: "project",
|
||||
projectWorkspaceState: null,
|
||||
projectWorkspaceState: ProjectWorkspaceState.Default,
|
||||
documents: ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
|
||||
deserializerMock
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(FilePathNormalizer.Normalize(projectInfo.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
|
@ -148,7 +148,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(FilePathNormalizer.Normalize(projectInfo.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
|
@ -196,7 +196,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(FilePathNormalizer.Normalize(projectInfo.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
|
@ -264,7 +264,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(FilePathNormalizer.Normalize(initialProjectInfo.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
|
@ -295,7 +295,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
Array.Empty<RazorExtension>()),
|
||||
rootNamespace: "TestRootNamespace2",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp6),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp6),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
projectService
|
||||
.Setup(service => service.UpdateProject(
|
||||
|
@ -348,7 +348,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(FilePathNormalizer.Normalize(initialProjectInfo.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
|
@ -379,7 +379,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
Array.Empty<RazorExtension>()),
|
||||
rootNamespace: "TestRootNamespace2",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp6),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp6),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
|
||||
// This is the request that happens when the server is reset
|
||||
|
@ -463,7 +463,7 @@ public class ProjectConfigurationStateSynchronizerTest(ITestOutputHelper testOut
|
|||
RazorConfiguration.Default,
|
||||
rootNamespace: "TestRootNamespace",
|
||||
displayName: "project",
|
||||
new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, LanguageVersion.CSharp5),
|
||||
ProjectWorkspaceState.Create(LanguageVersion.CSharp5),
|
||||
ImmutableArray<DocumentSnapshotHandle>.Empty);
|
||||
var intermediateOutputPath = Path.GetDirectoryName(FilePathNormalizer.Normalize(projectInfo.SerializedFilePath));
|
||||
var projectKey = TestProjectKey.Create(intermediateOutputPath);
|
||||
|
|
|
@ -609,7 +609,7 @@ public class RenameEndpointTest : LanguageServerTestBase
|
|||
namespaceNode.Content = rootNamespaceName;
|
||||
|
||||
var sourceText = SourceText.From(item.Content);
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers);
|
||||
var projectSnapshot = TestProjectSnapshot.Create("C:/project.csproj", projectWorkspaceState);
|
||||
var snapshot = Mock.Of<IDocumentSnapshot>(d =>
|
||||
d.GetGeneratedOutputAsync() == Task.FromResult(codeDocument) &&
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ProjectSnapshotHandleSerializationTest(ITestOutputHelper testOutput
|
|||
{
|
||||
// Arrange
|
||||
var projectId = ProjectId.CreateNewId();
|
||||
var expectedSnapshot = new ProjectSnapshotHandle(projectId, null, null);
|
||||
var expectedSnapshot = new ProjectSnapshotHandle(projectId, RazorConfiguration.Default, null);
|
||||
|
||||
// Act
|
||||
var bytes = MessagePackConvert.Serialize(expectedSnapshot, s_options);
|
||||
|
@ -71,7 +71,7 @@ public class ProjectSnapshotHandleSerializationTest(ITestOutputHelper testOutput
|
|||
// Assert
|
||||
Assert.NotNull(actualSnapshot);
|
||||
Assert.Equal(expectedSnapshot.ProjectId, actualSnapshot.ProjectId);
|
||||
Assert.Null(actualSnapshot.Configuration);
|
||||
Assert.NotNull(actualSnapshot.Configuration);
|
||||
Assert.Null(actualSnapshot.RootNamespace);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SerializationTest : ToolingTestBase
|
|||
};
|
||||
|
||||
_configuration = RazorConfiguration.Create(languageVersion, "Custom", extensions);
|
||||
_projectWorkspaceState = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
_projectWorkspaceState = ProjectWorkspaceState.Create(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("Test", "TestAssembly").Build()),
|
||||
csharpLanguageVersion: LanguageVersion.LatestMajor);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ using System.IO;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -33,8 +32,6 @@ internal class TestDocumentSnapshot : DocumentSnapshot
|
|||
|
||||
public static TestDocumentSnapshot Create(string filePath, string text, VersionStamp version, TestProjectSnapshot projectSnapshot)
|
||||
{
|
||||
using var testWorkspace = TestWorkspace.Create();
|
||||
|
||||
var targetPath = Path.GetDirectoryName(projectSnapshot.FilePath) is string projectDirectory && filePath.StartsWith(projectDirectory)
|
||||
? filePath[projectDirectory.Length..]
|
||||
: filePath;
|
||||
|
@ -42,7 +39,6 @@ internal class TestDocumentSnapshot : DocumentSnapshot
|
|||
var hostDocument = new HostDocument(filePath, targetPath);
|
||||
var sourceText = SourceText.From(text);
|
||||
var documentState = new DocumentState(
|
||||
testWorkspace.Services,
|
||||
hostDocument,
|
||||
SourceText.From(text),
|
||||
version,
|
||||
|
@ -52,7 +48,7 @@ internal class TestDocumentSnapshot : DocumentSnapshot
|
|||
return testDocument;
|
||||
}
|
||||
|
||||
internal static TestDocumentSnapshot Create(Workspace workspace, ProjectSnapshot projectSnapshot, string filePath, string text = "", VersionStamp? version = null)
|
||||
internal static TestDocumentSnapshot Create(ProjectSnapshot projectSnapshot, string filePath, string text = "", VersionStamp? version = null)
|
||||
{
|
||||
version ??= VersionStamp.Default;
|
||||
|
||||
|
@ -66,7 +62,6 @@ internal class TestDocumentSnapshot : DocumentSnapshot
|
|||
var hostDocument = new HostDocument(filePath, targetPath);
|
||||
var sourceText = SourceText.From(text);
|
||||
var documentState = new DocumentState(
|
||||
workspace.Services,
|
||||
hostDocument,
|
||||
SourceText.From(text),
|
||||
version,
|
||||
|
|
|
@ -2,14 +2,11 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
|
@ -28,31 +25,19 @@ internal class TestProjectSnapshot : ProjectSnapshot
|
|||
string intermediateOutputPath,
|
||||
string[] documentFilePaths,
|
||||
RazorConfiguration configuration,
|
||||
ProjectWorkspaceState? projectWorkspaceState,
|
||||
ProjectWorkspaceState? projectWorkspaceState = null,
|
||||
string? displayName = null)
|
||||
{
|
||||
var workspaceServices = new List<IWorkspaceService>()
|
||||
{
|
||||
new TestProjectSnapshotProjectEngineFactory(),
|
||||
};
|
||||
|
||||
var languageServices = new List<ILanguageService>();
|
||||
|
||||
var hostServices = TestServices.Create(workspaceServices, languageServices);
|
||||
using var workspace = TestWorkspace.Create(hostServices);
|
||||
var projectEngineFactory = new TestProjectSnapshotProjectEngineFactory();
|
||||
var hostProject = new HostProject(filePath, intermediateOutputPath, configuration, "TestRootNamespace", displayName);
|
||||
var state = ProjectState.Create(workspace.Services, hostProject);
|
||||
var state = ProjectState.Create(projectEngineFactory, hostProject, projectWorkspaceState ?? ProjectWorkspaceState.Default);
|
||||
|
||||
foreach (var documentFilePath in documentFilePaths)
|
||||
{
|
||||
var hostDocument = new HostDocument(documentFilePath, documentFilePath);
|
||||
state = state.WithAddedHostDocument(hostDocument, () => Task.FromResult(TextAndVersion.Create(SourceText.From(string.Empty), VersionStamp.Default)));
|
||||
}
|
||||
|
||||
if (projectWorkspaceState is not null)
|
||||
{
|
||||
state = state.WithProjectWorkspaceState(projectWorkspaceState);
|
||||
}
|
||||
|
||||
var testProject = new TestProjectSnapshot(state);
|
||||
|
||||
return testProject;
|
||||
|
|
|
@ -38,7 +38,7 @@ internal class TestProjectSnapshotManager : DefaultProjectSnapshotManager
|
|||
|
||||
public TestDocumentSnapshot CreateAndAddDocument(ProjectSnapshot projectSnapshot, string filePath)
|
||||
{
|
||||
var documentSnapshot = TestDocumentSnapshot.Create(Workspace, projectSnapshot, filePath);
|
||||
var documentSnapshot = TestDocumentSnapshot.Create(projectSnapshot, filePath);
|
||||
DocumentAdded(projectSnapshot.Key, documentSnapshot.HostDocument, new DocumentSnapshotTextLoader(documentSnapshot));
|
||||
|
||||
return documentSnapshot;
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
@ -40,7 +41,7 @@ public abstract class DocumentExcerptServiceTestBase(ITestOutputHelper testOutpu
|
|||
private (IDocumentSnapshot primary, Document secondary) InitializeDocument(SourceText sourceText)
|
||||
{
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(sourceText, VersionStamp.Create()))));
|
||||
|
||||
var primary = project.GetDocument(_hostDocument.FilePath).AssumeNotNull();
|
||||
|
|
|
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Razor.Language;
|
|||
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
|
@ -16,6 +17,7 @@ public abstract class WorkspaceTestBase : ToolingTestBase
|
|||
private bool _initialized;
|
||||
private HostServices? _hostServices;
|
||||
private Workspace? _workspace;
|
||||
private ProjectSnapshotProjectEngineFactory? _projectEngineFactory;
|
||||
|
||||
protected WorkspaceTestBase(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
|
@ -40,6 +42,15 @@ public abstract class WorkspaceTestBase : ToolingTestBase
|
|||
}
|
||||
}
|
||||
|
||||
private protected ProjectSnapshotProjectEngineFactory ProjectEngineFactory
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _projectEngineFactory;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ConfigureWorkspaceServices(List<IWorkspaceService> services)
|
||||
{
|
||||
}
|
||||
|
@ -56,22 +67,25 @@ public abstract class WorkspaceTestBase : ToolingTestBase
|
|||
{
|
||||
}
|
||||
|
||||
[MemberNotNull(nameof(_hostServices), nameof(_workspace))]
|
||||
[MemberNotNull(nameof(_hostServices), nameof(_workspace), nameof(_projectEngineFactory))]
|
||||
private void EnsureInitialized()
|
||||
{
|
||||
if (_initialized)
|
||||
{
|
||||
_hostServices.AssumeNotNull();
|
||||
_workspace.AssumeNotNull();
|
||||
_projectEngineFactory.AssumeNotNull();
|
||||
return;
|
||||
}
|
||||
|
||||
_projectEngineFactory = new TestProjectSnapshotProjectEngineFactory()
|
||||
{
|
||||
Configure = ConfigureProjectEngine,
|
||||
};
|
||||
|
||||
var workspaceServices = new List<IWorkspaceService>()
|
||||
{
|
||||
new TestProjectSnapshotProjectEngineFactory()
|
||||
{
|
||||
Configure = ConfigureProjectEngine,
|
||||
},
|
||||
_projectEngineFactory,
|
||||
};
|
||||
ConfigureWorkspaceServices(workspaceServices);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
@ -41,21 +42,21 @@ public class DefaultDocumentSnapshotTest : WorkspaceTestBase
|
|||
_legacyHostDocument = new HostDocument(TestProjectData.SomeProjectFile1);
|
||||
_nestedComponentHostDocument = new HostDocument(TestProjectData.SomeProjectNestedComponentFile3);
|
||||
|
||||
var projectState = ProjectState.Create(Workspace.Services, TestProjectData.SomeProject);
|
||||
var projectState = ProjectState.Create(ProjectEngineFactory, TestProjectData.SomeProject, ProjectWorkspaceState.Default);
|
||||
var project = new ProjectSnapshot(projectState);
|
||||
|
||||
var textAndVersion = TextAndVersion.Create(_sourceText, _version);
|
||||
|
||||
var documentState = DocumentState.Create(Workspace.Services, _legacyHostDocument, () => Task.FromResult(textAndVersion));
|
||||
var documentState = DocumentState.Create(_legacyHostDocument, () => Task.FromResult(textAndVersion));
|
||||
_legacyDocument = new DocumentSnapshot(project, documentState);
|
||||
|
||||
documentState = DocumentState.Create(Workspace.Services, _componentHostDocument, () => Task.FromResult(textAndVersion));
|
||||
documentState = DocumentState.Create(_componentHostDocument, () => Task.FromResult(textAndVersion));
|
||||
_componentDocument = new DocumentSnapshot(project, documentState);
|
||||
|
||||
documentState = DocumentState.Create(Workspace.Services, _componentCshtmlHostDocument, () => Task.FromResult(textAndVersion));
|
||||
documentState = DocumentState.Create(_componentCshtmlHostDocument, () => Task.FromResult(textAndVersion));
|
||||
_componentCshtmlDocument = new DocumentSnapshot(project, documentState);
|
||||
|
||||
documentState = DocumentState.Create(Workspace.Services, _nestedComponentHostDocument, () => Task.FromResult(textAndVersion));
|
||||
documentState = DocumentState.Create(_nestedComponentHostDocument, () => Task.FromResult(textAndVersion));
|
||||
_nestedComponentDocument = new DocumentSnapshot(project, documentState);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,8 @@ public class DefaultProjectSnapshotTest : WorkspaceTestBase
|
|||
_tagHelperResolver = new TestTagHelperResolver();
|
||||
|
||||
_hostProject = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_2_0, TestProjectData.SomeProject.RootNamespace);
|
||||
_projectWorkspaceState = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
_projectWorkspaceState = ProjectWorkspaceState.Create(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()));
|
||||
|
||||
_documents =
|
||||
[
|
||||
|
@ -57,7 +56,7 @@ public class DefaultProjectSnapshotTest : WorkspaceTestBase
|
|||
public void ProjectSnapshot_CachesDocumentSnapshots()
|
||||
{
|
||||
// Arrange
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader);
|
||||
|
@ -78,7 +77,7 @@ public class DefaultProjectSnapshotTest : WorkspaceTestBase
|
|||
public void IsImportDocument_NonImportDocument_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader);
|
||||
var snapshot = new ProjectSnapshot(state);
|
||||
|
||||
|
@ -95,7 +94,7 @@ public class DefaultProjectSnapshotTest : WorkspaceTestBase
|
|||
public void IsImportDocument_ImportDocument_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader);
|
||||
var snapshot = new ProjectSnapshot(state);
|
||||
|
@ -113,7 +112,7 @@ public class DefaultProjectSnapshotTest : WorkspaceTestBase
|
|||
public void GetRelatedDocuments_NonImportDocument_ReturnsEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader);
|
||||
var snapshot = new ProjectSnapshot(state);
|
||||
|
||||
|
@ -130,7 +129,7 @@ public class DefaultProjectSnapshotTest : WorkspaceTestBase
|
|||
public void GetRelatedDocuments_ImportDocument_ReturnsRelated()
|
||||
{
|
||||
// Arrange
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader);
|
||||
|
|
|
@ -1,60 +1,34 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
||||
public class DocumentStateTest : WorkspaceTestBase
|
||||
public class DocumentStateTest : ToolingTestBase
|
||||
{
|
||||
private readonly HostDocument _hostDocument;
|
||||
private readonly HostProject _hostProject;
|
||||
private readonly HostProject _hostProjectWithConfigurationChange;
|
||||
private readonly ProjectWorkspaceState _projectWorkspaceState;
|
||||
private readonly TestTagHelperResolver _tagHelperResolver;
|
||||
private readonly Func<Task<TextAndVersion>> _textLoader;
|
||||
private readonly SourceText _text;
|
||||
|
||||
public DocumentStateTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
_tagHelperResolver = new TestTagHelperResolver();
|
||||
|
||||
_hostProject = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_2_0, TestProjectData.SomeProject.RootNamespace);
|
||||
_hostProjectWithConfigurationChange = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, TestProjectData.SomeProject.RootNamespace);
|
||||
_projectWorkspaceState = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
|
||||
_hostDocument = TestProjectData.SomeProjectFile1;
|
||||
|
||||
_text = SourceText.From("Hello, world!");
|
||||
_textLoader = () => Task.FromResult(TextAndVersion.Create(_text, VersionStamp.Create()));
|
||||
}
|
||||
|
||||
protected override void ConfigureWorkspaceServices(List<IWorkspaceService> services)
|
||||
{
|
||||
services.Add(_tagHelperResolver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DocumentState_CreatedNew_HasEmptyText()
|
||||
{
|
||||
// Arrange & Act
|
||||
var state = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader);
|
||||
var state = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
// Assert
|
||||
var text = await state.GetTextAsync();
|
||||
|
@ -65,7 +39,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public async Task DocumentState_WithText_CreatesNewState()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader);
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
// Act
|
||||
var state = original.WithText(_text, VersionStamp.Create());
|
||||
|
@ -79,7 +53,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public async Task DocumentState_WithTextLoader_CreatesNewState()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader);
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
// Act
|
||||
var state = original.WithTextLoader(_textLoader);
|
||||
|
@ -93,7 +67,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public void DocumentState_WithConfigurationChange_CachesSnapshotText()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader)
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithText(_text, VersionStamp.Create());
|
||||
|
||||
// Act
|
||||
|
@ -108,7 +82,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public async Task DocumentState_WithConfigurationChange_CachesLoadedText()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader)
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithTextLoader(_textLoader);
|
||||
|
||||
await original.GetTextAsync();
|
||||
|
@ -125,7 +99,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public void DocumentState_WithImportsChange_CachesSnapshotText()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader)
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithText(_text, VersionStamp.Create());
|
||||
|
||||
// Act
|
||||
|
@ -140,7 +114,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public async Task DocumentState_WithImportsChange_CachesLoadedText()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader)
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithTextLoader(_textLoader);
|
||||
|
||||
await original.GetTextAsync();
|
||||
|
@ -157,7 +131,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public void DocumentState_WithProjectWorkspaceStateChange_CachesSnapshotText()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader)
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithText(_text, VersionStamp.Create());
|
||||
|
||||
// Act
|
||||
|
@ -172,7 +146,7 @@ public class DocumentStateTest : WorkspaceTestBase
|
|||
public async Task DocumentState_WithProjectWorkspaceStateChange_CachesLoadedText()
|
||||
{
|
||||
// Arrange
|
||||
var original = DocumentState.Create(Workspace.Services, _hostDocument, DocumentState.EmptyLoader)
|
||||
var original = DocumentState.Create(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithTextLoader(_textLoader);
|
||||
|
||||
await original.GetTextAsync();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
@ -30,7 +31,7 @@ public class GeneratedDocumentTextLoaderTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(SourceText.From(""), VersionStamp.Create()))));
|
||||
|
||||
var document = project.GetDocument(_hostDocument.FilePath);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument);
|
||||
|
@ -77,7 +77,7 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument);
|
||||
|
@ -97,7 +97,7 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectImportFile, DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -162,12 +162,11 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader)
|
||||
.WithProjectWorkspaceState(ProjectWorkspaceState.Default);
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument);
|
||||
var changed = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, csharpLanguageVersion: default);
|
||||
var changed = ProjectWorkspaceState.Default;
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changed);
|
||||
|
@ -176,7 +175,6 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
var (actualOutput, actualInputVersion) = await GetOutputAsync(state, _hostDocument);
|
||||
Assert.Same(originalOutput, actualOutput);
|
||||
Assert.Equal(originalInputVersion, actualInputVersion);
|
||||
Assert.Equal(state.ProjectWorkspaceStateVersion, actualInputVersion);
|
||||
}
|
||||
|
||||
// The generated code's text doesn't change as a result, so the output version does not change
|
||||
|
@ -185,11 +183,11 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument);
|
||||
var changed = new ProjectWorkspaceState(_someTagHelpers, default);
|
||||
var changed = ProjectWorkspaceState.Create(_someTagHelpers);
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changed);
|
||||
|
@ -207,11 +205,11 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
// Arrange
|
||||
var csharp8ValidConfiguration = RazorConfiguration.Create(RazorLanguageVersion.Version_3_0, _hostProject.Configuration.ConfigurationName, _hostProject.Configuration.Extensions);
|
||||
var hostProject = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, csharp8ValidConfiguration, TestProjectData.SomeProject.RootNamespace);
|
||||
var originalWorkspaceState = new ProjectWorkspaceState(_someTagHelpers, LanguageVersion.CSharp7);
|
||||
var originalWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, LanguageVersion.CSharp7);
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, hostProject, originalWorkspaceState)
|
||||
ProjectState.Create(ProjectEngineFactory, hostProject, originalWorkspaceState)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(SourceText.From("@DateTime.Now"), VersionStamp.Default)));
|
||||
var changedWorkspaceState = new ProjectWorkspaceState(_someTagHelpers, LanguageVersion.CSharp8);
|
||||
var changedWorkspaceState = ProjectWorkspaceState.Create(_someTagHelpers, LanguageVersion.CSharp8);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument);
|
||||
|
||||
|
@ -230,7 +228,7 @@ public class ProjectStateGeneratedOutputTest : WorkspaceTestBase
|
|||
{
|
||||
// Arrange
|
||||
var original =
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, DocumentState.EmptyLoader);
|
||||
|
||||
var (originalOutput, originalInputVersion) = await GetOutputAsync(original, _hostDocument);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -26,20 +25,21 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
private readonly HostProject _hostProject;
|
||||
private readonly HostProject _hostProjectWithConfigurationChange;
|
||||
private readonly ProjectWorkspaceState _projectWorkspaceState;
|
||||
private TestTagHelperResolver _tagHelperResolver;
|
||||
private readonly ImmutableArray<TagHelperDescriptor> _someTagHelpers;
|
||||
private readonly Func<Task<TextAndVersion>> _textLoader;
|
||||
private readonly SourceText _text;
|
||||
|
||||
[AllowNull]
|
||||
private TestTagHelperResolver _tagHelperResolver;
|
||||
|
||||
public ProjectStateTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
_hostProject = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_2_0, TestProjectData.SomeProject.RootNamespace);
|
||||
_hostProjectWithConfigurationChange = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, TestProjectData.SomeProject.RootNamespace);
|
||||
_projectWorkspaceState = new ProjectWorkspaceState(
|
||||
_projectWorkspaceState = ProjectWorkspaceState.Create(
|
||||
ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()));
|
||||
|
||||
_someTagHelpers = ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("Test1", "TestAssembly").Build());
|
||||
|
@ -72,7 +72,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void GetImportDocumentTargetPaths_DoesNotIncludeCurrentImport()
|
||||
{
|
||||
// Arrange
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
|
||||
// Act
|
||||
var paths = state.GetImportDocumentTargetPaths(TestProjectData.SomeProjectComponentImportFile1);
|
||||
|
@ -87,7 +87,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
// Arrange
|
||||
|
||||
// Act
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
|
||||
// Assert
|
||||
Assert.Empty(state.Documents);
|
||||
|
@ -98,7 +98,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_AddHostDocument_ToEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
|
||||
// Act
|
||||
var state = original.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader);
|
||||
|
@ -116,7 +116,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public async Task ProjectState_AddHostDocument_DocumentIsEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
|
||||
// Act
|
||||
var state = original.WithAddedHostDocument(_documents[0], DocumentState.EmptyLoader);
|
||||
|
@ -130,7 +130,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_AddHostDocument_ToProjectWithDocuments()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
// Arrange
|
||||
|
||||
// Act
|
||||
var state = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var state = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader)
|
||||
|
@ -193,7 +193,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_AddHostDocument_TracksImports_AddImportFile()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader)
|
||||
|
@ -236,7 +236,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_AddHostDocument_RetainsComputedState()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -269,7 +269,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_AddHostDocument_DuplicateNoops()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -284,7 +284,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public async Task ProjectState_WithChangedHostDocument_Loader()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -304,7 +304,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public async Task ProjectState_WithChangedHostDocument_Snapshot()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -324,7 +324,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithChangedHostDocument_Loader_RetainsComputedState()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -356,7 +356,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithChangedHostDocument_Snapshot_RetainsComputedState()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -388,7 +388,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithChangedHostDocument_Loader_NotFoundNoops()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -403,7 +403,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithChangedHostDocument_Snapshot_NotFoundNoops()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -418,7 +418,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_RemoveHostDocument_FromProjectWithDocuments()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -439,7 +439,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_RemoveHostDocument_TracksImports()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader)
|
||||
|
@ -479,7 +479,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_RemoveHostDocument_TracksImports_RemoveAllDocuments()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectFile2, DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(TestProjectData.SomeProjectNestedFile3, DocumentState.EmptyLoader)
|
||||
|
@ -501,7 +501,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_RemoveHostDocument_RetainsComputedState()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -533,7 +533,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_RemoveHostDocument_NotFoundNoops()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -548,7 +548,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithHostProject_ConfigurationChange_UpdatesConfigurationState()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -588,7 +588,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithHostProject_RootNamespaceChange_UpdatesConfigurationState()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
var hostProjectWithRootNamespaceChange = new HostProject(
|
||||
|
@ -614,7 +614,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithHostProject_NoConfigurationChange_Noops()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -635,10 +635,10 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var callCount = 0;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[_documents[1].FilePath] = TestDocumentState.Create(Workspace.Services, _documents[1], onConfigurationChange: () => callCount++);
|
||||
documents[_documents[2].FilePath] = TestDocumentState.Create(Workspace.Services, _documents[2], onConfigurationChange: () => callCount++);
|
||||
documents[_documents[1].FilePath] = TestDocumentState.Create(_documents[1], onConfigurationChange: () => callCount++);
|
||||
documents[_documents[2].FilePath] = TestDocumentState.Create(_documents[2], onConfigurationChange: () => callCount++);
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
|
||||
// Act
|
||||
|
@ -654,7 +654,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithHostProject_ResetsImportedDocuments()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original = original.WithAddedHostDocument(TestProjectData.SomeProjectFile1, DocumentState.EmptyLoader);
|
||||
|
||||
// Act
|
||||
|
@ -666,87 +666,11 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
Assert.Equal(TestProjectData.SomeProjectFile1.FilePath, documentFilePath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectState_WithProjectWorkspaceState_Removed()
|
||||
{
|
||||
// Arrange
|
||||
var emptyProjectWorkspaceState = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, csharpLanguageVersion: default);
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, emptyProjectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
// Force init
|
||||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(null);
|
||||
|
||||
// Assert
|
||||
Assert.NotEqual(original.Version, state.Version);
|
||||
Assert.Null(state.ProjectWorkspaceState);
|
||||
|
||||
var actualTagHelpers = state.TagHelpers;
|
||||
var actualProjectWorkspaceStateVersion = state.ProjectWorkspaceStateVersion;
|
||||
|
||||
// The configuration didn't change, and the tag helpers didn't actually change
|
||||
Assert.Same(original.ProjectEngine, state.ProjectEngine);
|
||||
|
||||
Assert.Equal(originalTagHelpers.Length, actualTagHelpers.Length);
|
||||
for (var i = 0; i < originalTagHelpers.Length; i++)
|
||||
{
|
||||
Assert.Same(originalTagHelpers[i], actualTagHelpers[i]);
|
||||
}
|
||||
|
||||
Assert.NotEqual(originalProjectWorkspaceStateVersion, actualProjectWorkspaceStateVersion);
|
||||
|
||||
Assert.NotSame(original.Documents[_documents[1].FilePath], state.Documents[_documents[1].FilePath]);
|
||||
Assert.NotSame(original.Documents[_documents[2].FilePath], state.Documents[_documents[2].FilePath]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectState_WithProjectWorkspaceState_Added()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, null)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
// Force init
|
||||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
var newProjectWorkspaceState = ProjectWorkspaceState.Default;
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(newProjectWorkspaceState);
|
||||
|
||||
// Assert
|
||||
Assert.NotEqual(original.Version, state.Version);
|
||||
Assert.Same(newProjectWorkspaceState, state.ProjectWorkspaceState);
|
||||
|
||||
var actualTagHelpers = state.TagHelpers;
|
||||
var actualProjectWorkspaceStateVersion = state.ProjectWorkspaceStateVersion;
|
||||
|
||||
// The configuration didn't change, and the tag helpers didn't actually change
|
||||
Assert.Same(original.ProjectEngine, state.ProjectEngine);
|
||||
|
||||
Assert.Equal(originalTagHelpers.Length, actualTagHelpers.Length);
|
||||
for (var i = 0; i < originalTagHelpers.Length; i++)
|
||||
{
|
||||
Assert.Same(originalTagHelpers[i], actualTagHelpers[i]);
|
||||
}
|
||||
|
||||
Assert.NotEqual(originalProjectWorkspaceStateVersion, actualProjectWorkspaceStateVersion);
|
||||
|
||||
Assert.NotSame(original.Documents[_documents[1].FilePath], state.Documents[_documents[1].FilePath]);
|
||||
Assert.NotSame(original.Documents[_documents[1].FilePath], state.Documents[_documents[1].FilePath]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectState_WithProjectWorkspaceState_Changed()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -754,7 +678,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
var changed = new ProjectWorkspaceState(_projectWorkspaceState.TagHelpers, LanguageVersion.CSharp6);
|
||||
var changed = ProjectWorkspaceState.Create(_projectWorkspaceState.TagHelpers, LanguageVersion.CSharp6);
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changed);
|
||||
|
@ -785,7 +709,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithProjectWorkspaceState_Changed_TagHelpersChanged()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -793,7 +717,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var originalTagHelpers = original.TagHelpers;
|
||||
var originalProjectWorkspaceStateVersion = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
var changed = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, csharpLanguageVersion: default);
|
||||
var changed = ProjectWorkspaceState.Default;
|
||||
|
||||
// Now create some tag helpers
|
||||
_tagHelperResolver.TagHelpers = _someTagHelpers;
|
||||
|
@ -822,7 +746,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
public void ProjectState_WithProjectWorkspaceState_IdenticalState_Caches()
|
||||
{
|
||||
// Arrange
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState)
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState)
|
||||
.WithAddedHostDocument(_documents[2], DocumentState.EmptyLoader)
|
||||
.WithAddedHostDocument(_documents[1], DocumentState.EmptyLoader);
|
||||
|
||||
|
@ -830,7 +754,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
_ = original.TagHelpers;
|
||||
_ = original.ProjectWorkspaceStateVersion;
|
||||
|
||||
var changed = new ProjectWorkspaceState(original.TagHelpers, original.CSharpLanguageVersion);
|
||||
var changed = ProjectWorkspaceState.Create(original.TagHelpers, original.CSharpLanguageVersion);
|
||||
|
||||
// Now create some tag helpers
|
||||
_tagHelperResolver.TagHelpers = _someTagHelpers;
|
||||
|
@ -849,13 +773,13 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var callCount = 0;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[_documents[1].FilePath] = TestDocumentState.Create(Workspace.Services, _documents[1], onProjectWorkspaceStateChange: () => callCount++);
|
||||
documents[_documents[2].FilePath] = TestDocumentState.Create(Workspace.Services, _documents[2], onProjectWorkspaceStateChange: () => callCount++);
|
||||
documents[_documents[1].FilePath] = TestDocumentState.Create(_documents[1], onProjectWorkspaceStateChange: () => callCount++);
|
||||
documents[_documents[2].FilePath] = TestDocumentState.Create(_documents[2], onProjectWorkspaceStateChange: () => callCount++);
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
|
||||
var changed = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, csharpLanguageVersion: default);
|
||||
var changed = ProjectWorkspaceState.Default;
|
||||
|
||||
// Act
|
||||
var state = original.WithProjectWorkspaceState(changed);
|
||||
|
@ -877,10 +801,10 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var document4 = TestProjectData.AnotherProjectNestedFile4;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(Workspace.Services, document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(Workspace.Services, document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(Workspace.Services, document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(Workspace.Services, document4, onImportsChange: () => callCount++);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(document4, onImportsChange: () => callCount++);
|
||||
|
||||
var importsToRelatedDocuments = ImmutableDictionary.CreateBuilder<string, ImmutableArray<string>>(FilePathComparer.Instance);
|
||||
importsToRelatedDocuments.Add(
|
||||
|
@ -896,7 +820,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
TestProjectData.SomeProjectNestedFile3.FilePath,
|
||||
TestProjectData.AnotherProjectNestedFile4.FilePath));
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable();
|
||||
|
||||
|
@ -920,10 +844,10 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var document4 = TestProjectData.AnotherProjectNestedFile4;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(Workspace.Services, document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(Workspace.Services, document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(Workspace.Services, document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(Workspace.Services, document4, onImportsChange: () => callCount++);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(document4, onImportsChange: () => callCount++);
|
||||
|
||||
var importsToRelatedDocuments = ImmutableDictionary.CreateBuilder<string, ImmutableArray<string>>(FilePathComparer.Instance);
|
||||
importsToRelatedDocuments.Add(
|
||||
|
@ -939,7 +863,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
TestProjectData.SomeProjectNestedFile3.FilePath,
|
||||
TestProjectData.AnotherProjectNestedFile4.FilePath));
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable();
|
||||
|
||||
|
@ -964,11 +888,11 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var document5 = TestProjectData.AnotherProjectNestedImportFile;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(Workspace.Services, document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(Workspace.Services, document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(Workspace.Services, document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(Workspace.Services, document4, onImportsChange: () => callCount++);
|
||||
documents[document5.FilePath] = TestDocumentState.Create(Workspace.Services, document5, onImportsChange: () => callCount++);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(document4, onImportsChange: () => callCount++);
|
||||
documents[document5.FilePath] = TestDocumentState.Create(document5, onImportsChange: () => callCount++);
|
||||
|
||||
var importsToRelatedDocuments = ImmutableDictionary.CreateBuilder<string, ImmutableArray<string>>(FilePathComparer.Instance);
|
||||
importsToRelatedDocuments.Add(
|
||||
|
@ -985,7 +909,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
TestProjectData.SomeProjectNestedFile3.FilePath,
|
||||
TestProjectData.AnotherProjectNestedFile4.FilePath));
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable();
|
||||
|
||||
|
@ -1010,11 +934,11 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var document5 = TestProjectData.AnotherProjectNestedImportFile;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(Workspace.Services, document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(Workspace.Services, document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(Workspace.Services, document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(Workspace.Services, document4, onImportsChange: () => callCount++);
|
||||
documents[document5.FilePath] = TestDocumentState.Create(Workspace.Services, document5, onImportsChange: () => callCount++);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(document4, onImportsChange: () => callCount++);
|
||||
documents[document5.FilePath] = TestDocumentState.Create(document5, onImportsChange: () => callCount++);
|
||||
|
||||
var importsToRelatedDocuments = ImmutableDictionary.CreateBuilder<string, ImmutableArray<string>>(FilePathComparer.Instance);
|
||||
importsToRelatedDocuments.Add(
|
||||
|
@ -1031,7 +955,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
TestProjectData.SomeProjectNestedFile3.FilePath,
|
||||
TestProjectData.AnotherProjectNestedFile4.FilePath));
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable();
|
||||
|
||||
|
@ -1056,11 +980,11 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
var document5 = TestProjectData.AnotherProjectNestedImportFile;
|
||||
|
||||
var documents = ImmutableDictionary.CreateBuilder<string, DocumentState>(FilePathComparer.Instance);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(Workspace.Services, document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(Workspace.Services, document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(Workspace.Services, document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(Workspace.Services, document4, onImportsChange: () => callCount++);
|
||||
documents[document5.FilePath] = TestDocumentState.Create(Workspace.Services, document5, onImportsChange: () => callCount++);
|
||||
documents[document1.FilePath] = TestDocumentState.Create(document1, onImportsChange: () => callCount++);
|
||||
documents[document2.FilePath] = TestDocumentState.Create(document2, onImportsChange: () => callCount++);
|
||||
documents[document3.FilePath] = TestDocumentState.Create(document3, onImportsChange: () => callCount++);
|
||||
documents[document4.FilePath] = TestDocumentState.Create(document4, onImportsChange: () => callCount++);
|
||||
documents[document5.FilePath] = TestDocumentState.Create(document5, onImportsChange: () => callCount++);
|
||||
|
||||
var importsToRelatedDocuments = ImmutableDictionary.CreateBuilder<string, ImmutableArray<string>>(FilePathComparer.Instance);
|
||||
importsToRelatedDocuments.Add(
|
||||
|
@ -1077,7 +1001,7 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
TestProjectData.SomeProjectNestedFile3.FilePath,
|
||||
TestProjectData.AnotherProjectNestedFile4.FilePath));
|
||||
|
||||
var original = ProjectState.Create(Workspace.Services, _hostProject, _projectWorkspaceState);
|
||||
var original = ProjectState.Create(ProjectEngineFactory, _hostProject, _projectWorkspaceState);
|
||||
original.Documents = documents.ToImmutable();
|
||||
original.ImportsToRelatedDocuments = importsToRelatedDocuments.ToImmutable();
|
||||
|
||||
|
@ -1092,17 +1016,15 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
private class TestDocumentState : DocumentState
|
||||
{
|
||||
public static TestDocumentState Create(
|
||||
HostWorkspaceServices services,
|
||||
HostDocument hostDocument,
|
||||
Func<Task<TextAndVersion>> loader = null,
|
||||
Action onTextChange = null,
|
||||
Action onTextLoaderChange = null,
|
||||
Action onConfigurationChange = null,
|
||||
Action onImportsChange = null,
|
||||
Action onProjectWorkspaceStateChange = null)
|
||||
Func<Task<TextAndVersion>>? loader = null,
|
||||
Action? onTextChange = null,
|
||||
Action? onTextLoaderChange = null,
|
||||
Action? onConfigurationChange = null,
|
||||
Action? onImportsChange = null,
|
||||
Action? onProjectWorkspaceStateChange = null)
|
||||
{
|
||||
return new TestDocumentState(
|
||||
services,
|
||||
hostDocument,
|
||||
null,
|
||||
null,
|
||||
|
@ -1114,24 +1036,23 @@ public class ProjectStateTest : WorkspaceTestBase
|
|||
onProjectWorkspaceStateChange);
|
||||
}
|
||||
|
||||
private readonly Action _onTextChange;
|
||||
private readonly Action _onTextLoaderChange;
|
||||
private readonly Action _onConfigurationChange;
|
||||
private readonly Action _onImportsChange;
|
||||
private readonly Action _onProjectWorkspaceStateChange;
|
||||
private readonly Action? _onTextChange;
|
||||
private readonly Action? _onTextLoaderChange;
|
||||
private readonly Action? _onConfigurationChange;
|
||||
private readonly Action? _onImportsChange;
|
||||
private readonly Action? _onProjectWorkspaceStateChange;
|
||||
|
||||
private TestDocumentState(
|
||||
HostWorkspaceServices services,
|
||||
HostDocument hostDocument,
|
||||
SourceText text,
|
||||
SourceText? text,
|
||||
VersionStamp? version,
|
||||
Func<Task<TextAndVersion>> loader,
|
||||
Action onTextChange,
|
||||
Action onTextLoaderChange,
|
||||
Action onConfigurationChange,
|
||||
Action onImportsChange,
|
||||
Action onProjectWorkspaceStateChange)
|
||||
: base(services, hostDocument, text, version, loader)
|
||||
Func<Task<TextAndVersion>>? loader,
|
||||
Action? onTextChange,
|
||||
Action? onTextLoaderChange,
|
||||
Action? onConfigurationChange,
|
||||
Action? onImportsChange,
|
||||
Action? onProjectWorkspaceStateChange)
|
||||
: base(hostDocument, text, version, loader)
|
||||
{
|
||||
_onTextChange = onTextChange;
|
||||
_onTextLoaderChange = onTextLoaderChange;
|
||||
|
|
|
@ -7,6 +7,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
|
@ -36,7 +37,7 @@ public class RazorSpanMappingServiceTest(ITestOutputHelper testOutput) : Workspa
|
|||
");
|
||||
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(sourceText, VersionStamp.Create()))));
|
||||
|
||||
var document = project.GetDocument(_hostDocument.FilePath);
|
||||
|
@ -68,7 +69,7 @@ public class RazorSpanMappingServiceTest(ITestOutputHelper testOutput) : Workspa
|
|||
");
|
||||
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(sourceText, VersionStamp.Create()))));
|
||||
|
||||
var document = project.GetDocument(_hostDocument.FilePath);
|
||||
|
@ -101,7 +102,7 @@ public class RazorSpanMappingServiceTest(ITestOutputHelper testOutput) : Workspa
|
|||
");
|
||||
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(sourceText, VersionStamp.Create()))));
|
||||
|
||||
var document = project.GetDocument(_hostDocument.FilePath);
|
||||
|
@ -133,7 +134,7 @@ public class RazorSpanMappingServiceTest(ITestOutputHelper testOutput) : Workspa
|
|||
");
|
||||
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, _hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, _hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(_hostDocument, () => Task.FromResult(TextAndVersion.Create(sourceText, VersionStamp.Create()))));
|
||||
|
||||
var document = project.GetDocument(_hostDocument.FilePath);
|
||||
|
|
|
@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Razor;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Serialization;
|
||||
using Microsoft.AspNetCore.Razor.Telemetry;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
@ -24,7 +25,6 @@ public partial class OOPTagHelperResolverTest : TagHelperDescriptorTestBase
|
|||
{
|
||||
private readonly ProjectSnapshotProjectEngineFactory _engineFactory;
|
||||
private readonly Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>[] _customFactories;
|
||||
private readonly IFallbackProjectEngineFactory _fallbackFactory;
|
||||
private readonly HostProject _hostProject_For_2_0;
|
||||
private readonly HostProject _hostProject_For_NonSerializableConfiguration;
|
||||
private readonly ProjectSnapshotManagerBase _projectManager;
|
||||
|
@ -37,10 +37,10 @@ public partial class OOPTagHelperResolverTest : TagHelperDescriptorTestBase
|
|||
_hostProject_For_2_0 = new HostProject("Test.csproj", "/obj", FallbackRazorConfiguration.MVC_2_0, rootNamespace: null);
|
||||
_hostProject_For_NonSerializableConfiguration = new HostProject(
|
||||
"Test.csproj", "/obj",
|
||||
new ProjectSystemRazorConfiguration(RazorLanguageVersion.Version_2_1, "Random-0.1", Array.Empty<RazorExtension>()), rootNamespace: null);
|
||||
new ProjectSystemRazorConfiguration(RazorLanguageVersion.Version_2_1, "Random-0.1", []), rootNamespace: null);
|
||||
|
||||
_customFactories = new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>[]
|
||||
{
|
||||
_customFactories =
|
||||
[
|
||||
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>(
|
||||
() => Mock.Of<IProjectEngineFactory>(MockBehavior.Strict),
|
||||
new ExportCustomProjectEngineFactoryAttribute("MVC-2.0") { SupportsSerialization = true, }),
|
||||
|
@ -49,18 +49,20 @@ public partial class OOPTagHelperResolverTest : TagHelperDescriptorTestBase
|
|||
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>(
|
||||
() => Mock.Of<IProjectEngineFactory>(MockBehavior.Strict),
|
||||
new ExportCustomProjectEngineFactoryAttribute("Test-2") { SupportsSerialization = false, }),
|
||||
};
|
||||
];
|
||||
|
||||
_fallbackFactory = new FallbackProjectEngineFactory();
|
||||
var fallbackFactory = new FallbackProjectEngineFactory();
|
||||
|
||||
_workspace = new AdhocWorkspace();
|
||||
_engineFactory = new DefaultProjectSnapshotProjectEngineFactory(fallbackFactory, _customFactories);
|
||||
var testServices = TestServices.Create([_engineFactory], []);
|
||||
|
||||
_workspace = new AdhocWorkspace(testServices);
|
||||
AddDisposable(_workspace);
|
||||
|
||||
var info = ProjectInfo.Create(ProjectId.CreateNewId("Test"), VersionStamp.Default, "Test", "Test", LanguageNames.CSharp, filePath: "Test.csproj");
|
||||
_workspaceProject = _workspace.CurrentSolution.AddProject(info).GetProject(info.Id).AssumeNotNull();
|
||||
|
||||
_projectManager = new TestProjectSnapshotManager(_workspace);
|
||||
_engineFactory = new DefaultProjectSnapshotProjectEngineFactory(_fallbackFactory, _customFactories);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -8,9 +8,9 @@ using System.Reflection;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Mvc1_X = Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X;
|
||||
|
@ -24,56 +24,45 @@ public class DefaultProjectSnapshotProjectEngineFactoryTest : ToolingTestBase
|
|||
{
|
||||
private readonly Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>[] _customFactories;
|
||||
private readonly IFallbackProjectEngineFactory _fallbackFactory;
|
||||
private readonly HostProject _hostProject_For_1_0;
|
||||
private readonly HostProject _hostProject_For_1_1;
|
||||
private readonly HostProject _hostProject_For_2_0;
|
||||
private readonly HostProject _hostProject_For_2_1;
|
||||
private readonly HostProject _hostProject_For_3_0;
|
||||
private readonly HostProject _hostProject_For_UnknownConfiguration;
|
||||
private readonly IProjectSnapshot _snapshot_For_1_0;
|
||||
private readonly IProjectSnapshot _snapshot_For_1_1;
|
||||
private readonly IProjectSnapshot _snapshot_For_2_0;
|
||||
private readonly IProjectSnapshot _snapshot_For_2_1;
|
||||
private readonly IProjectSnapshot _snapshot_For_3_0;
|
||||
private readonly IProjectSnapshot _snapshot_For_UnknownConfiguration;
|
||||
private readonly ProjectWorkspaceState _projectWorkspaceState;
|
||||
private readonly Workspace _workspace;
|
||||
|
||||
public DefaultProjectSnapshotProjectEngineFactoryTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
_workspace = TestWorkspace.Create();
|
||||
AddDisposable(_workspace);
|
||||
|
||||
_projectWorkspaceState = ProjectWorkspaceState.Default;
|
||||
|
||||
var projectFilePath = "/TestPath/SomePath/Test.csproj";
|
||||
var intermediateOutputPath = "/TestPath/SomePath/obj";
|
||||
_hostProject_For_1_0 = new HostProject(projectFilePath, intermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, "Test");
|
||||
_hostProject_For_1_1 = new HostProject(projectFilePath, intermediateOutputPath, FallbackRazorConfiguration.MVC_1_1, "Test");
|
||||
_hostProject_For_2_0 = new HostProject(projectFilePath, intermediateOutputPath, FallbackRazorConfiguration.MVC_2_0, "Test");
|
||||
var hostProject_For_1_0 = new HostProject(projectFilePath, intermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, "Test");
|
||||
var hostProject_For_1_1 = new HostProject(projectFilePath, intermediateOutputPath, FallbackRazorConfiguration.MVC_1_1, "Test");
|
||||
var hostProject_For_2_0 = new HostProject(projectFilePath, intermediateOutputPath, FallbackRazorConfiguration.MVC_2_0, "Test");
|
||||
|
||||
_hostProject_For_2_1 = new HostProject(
|
||||
var hostProject_For_2_1 = new HostProject(
|
||||
projectFilePath, intermediateOutputPath,
|
||||
new ProjectSystemRazorConfiguration(RazorLanguageVersion.Version_2_1, "MVC-2.1", Array.Empty<RazorExtension>()), "Test");
|
||||
|
||||
_hostProject_For_3_0 = new HostProject(
|
||||
var hostProject_For_3_0 = new HostProject(
|
||||
projectFilePath, intermediateOutputPath,
|
||||
new ProjectSystemRazorConfiguration(RazorLanguageVersion.Version_3_0, "MVC-3.0", Array.Empty<RazorExtension>()), "Test");
|
||||
|
||||
_hostProject_For_UnknownConfiguration = new HostProject(
|
||||
var hostProject_For_UnknownConfiguration = new HostProject(
|
||||
projectFilePath, intermediateOutputPath,
|
||||
new ProjectSystemRazorConfiguration(RazorLanguageVersion.Version_2_1, "Random-0.1", Array.Empty<RazorExtension>()), rootNamespace: null);
|
||||
|
||||
_snapshot_For_1_0 = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _hostProject_For_1_0, _projectWorkspaceState));
|
||||
_snapshot_For_1_1 = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _hostProject_For_1_1, _projectWorkspaceState));
|
||||
_snapshot_For_2_0 = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _hostProject_For_2_0, _projectWorkspaceState));
|
||||
_snapshot_For_2_1 = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _hostProject_For_2_1, _projectWorkspaceState));
|
||||
_snapshot_For_3_0 = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _hostProject_For_3_0, _projectWorkspaceState));
|
||||
_snapshot_For_UnknownConfiguration = new ProjectSnapshot(ProjectState.Create(_workspace.Services, _hostProject_For_UnknownConfiguration, _projectWorkspaceState));
|
||||
var projectEngineFactory = Mock.Of<ProjectSnapshotProjectEngineFactory>(MockBehavior.Strict);
|
||||
|
||||
_customFactories = new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>[]
|
||||
{
|
||||
_snapshot_For_1_0 = new ProjectSnapshot(ProjectState.Create(projectEngineFactory, hostProject_For_1_0, ProjectWorkspaceState.Default));
|
||||
_snapshot_For_1_1 = new ProjectSnapshot(ProjectState.Create(projectEngineFactory, hostProject_For_1_1, ProjectWorkspaceState.Default));
|
||||
_snapshot_For_2_0 = new ProjectSnapshot(ProjectState.Create(projectEngineFactory, hostProject_For_2_0, ProjectWorkspaceState.Default));
|
||||
_snapshot_For_2_1 = new ProjectSnapshot(ProjectState.Create(projectEngineFactory, hostProject_For_2_1, ProjectWorkspaceState.Default));
|
||||
_snapshot_For_3_0 = new ProjectSnapshot(ProjectState.Create(projectEngineFactory, hostProject_For_3_0, ProjectWorkspaceState.Default));
|
||||
_snapshot_For_UnknownConfiguration = new ProjectSnapshot(ProjectState.Create(projectEngineFactory, hostProject_For_UnknownConfiguration, ProjectWorkspaceState.Default));
|
||||
|
||||
_customFactories =
|
||||
[
|
||||
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>(
|
||||
() => new LegacyProjectEngineFactory_1_0(),
|
||||
typeof(LegacyProjectEngineFactory_1_0).GetCustomAttribute<ExportCustomProjectEngineFactoryAttribute>()),
|
||||
|
@ -89,7 +78,7 @@ public class DefaultProjectSnapshotProjectEngineFactoryTest : ToolingTestBase
|
|||
new Lazy<IProjectEngineFactory, ICustomProjectEngineFactoryMetadata>(
|
||||
() => new LegacyProjectEngineFactory_3_0(),
|
||||
typeof(LegacyProjectEngineFactory_3_0).GetCustomAttribute<ExportCustomProjectEngineFactoryAttribute>()),
|
||||
};
|
||||
];
|
||||
|
||||
_fallbackFactory = new FallbackProjectEngineFactory();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
|
|||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Host;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
@ -34,13 +35,15 @@ public class DefaultProjectWorkspaceStateGeneratorTest : ProjectSnapshotManagerD
|
|||
public DefaultProjectWorkspaceStateGeneratorTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
var projectEngineFactory = Mock.Of<ProjectSnapshotProjectEngineFactory>(MockBehavior.Strict);
|
||||
|
||||
var tagHelperResolver = new TestTagHelperResolver()
|
||||
{
|
||||
TagHelpers = ImmutableArray.Create(TagHelperDescriptorBuilder.Create("ResolvableTagHelper", "TestAssembly").Build())
|
||||
};
|
||||
|
||||
_resolvableTagHelpers = tagHelperResolver.TagHelpers;
|
||||
var workspaceServices = new List<IWorkspaceService>() { tagHelperResolver };
|
||||
var workspaceServices = new List<IWorkspaceService>() { tagHelperResolver, projectEngineFactory };
|
||||
var testServices = TestServices.Create(workspaceServices, Enumerable.Empty<ILanguageService>());
|
||||
_workspace = TestWorkspace.Create(testServices);
|
||||
AddDisposable(_workspace);
|
||||
|
@ -53,10 +56,10 @@ public class DefaultProjectWorkspaceStateGeneratorTest : ProjectSnapshotManagerD
|
|||
LanguageNames.CSharp,
|
||||
TestProjectData.SomeProject.FilePath));
|
||||
_workspaceProject = solution.GetProject(projectId);
|
||||
_projectSnapshot = new ProjectSnapshot(ProjectState.Create(_workspace.Services, TestProjectData.SomeProject));
|
||||
_projectWorkspaceStateWithTagHelpers = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
_projectSnapshot = new ProjectSnapshot(
|
||||
ProjectState.Create(projectEngineFactory, TestProjectData.SomeProject, ProjectWorkspaceState.Default));
|
||||
_projectWorkspaceStateWithTagHelpers = ProjectWorkspaceState.Create(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()));
|
||||
}
|
||||
|
||||
[UIFact]
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Formatting;
|
||||
|
@ -103,7 +104,7 @@ public class RazorDocumentOptionsServiceTest : WorkspaceTestBase
|
|||
Path.Combine(baseDirectory, "SomeProject", "File1.cshtml"), "File1.cshtml", FileKinds.Legacy);
|
||||
|
||||
var project = new ProjectSnapshot(
|
||||
ProjectState.Create(Workspace.Services, hostProject)
|
||||
ProjectState.Create(ProjectEngineFactory, hostProject, ProjectWorkspaceState.Default)
|
||||
.WithAddedHostDocument(hostDocument, () => Task.FromResult(TextAndVersion.Create(sourceText, VersionStamp.Create()))));
|
||||
|
||||
var documentSnapshot = project.GetDocument(hostDocument.FilePath);
|
||||
|
|
|
@ -36,8 +36,8 @@ public class RazorProjectInfoPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
new TagHelperDescriptor(FileKinds.Component, "Namespace.FileNameOther", "Assembly", "FileName", "FileName document", "FileName hint",
|
||||
caseSensitive: false, tagMatchingRules: default, attributeDescriptors: default, allowedChildTags: default, metadata: null, diagnostics: default));
|
||||
|
||||
var initialProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.Preview));
|
||||
var expectedProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.Preview));
|
||||
var initialProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", ProjectWorkspaceState.Create(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.Preview));
|
||||
var expectedProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", ProjectWorkspaceState.Create(CodeAnalysis.CSharp.LanguageVersion.Preview));
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.bin";
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
projectConfigurationFilePathStore,
|
||||
|
@ -220,7 +220,7 @@ public class RazorProjectInfoPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
var projectConfigurationFilePathStore = new DefaultProjectConfigurationFilePathStore();
|
||||
|
||||
var serializationSuccessful = false;
|
||||
var projectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.CSharp7_3));
|
||||
var projectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", ProjectWorkspaceState.Create(CodeAnalysis.CSharp.LanguageVersion.CSharp7_3));
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.bin";
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
projectConfigurationFilePathStore,
|
||||
|
@ -255,8 +255,8 @@ public class RazorProjectInfoPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
var projectConfigurationFilePathStore = new DefaultProjectConfigurationFilePathStore();
|
||||
|
||||
var serializationSuccessful = false;
|
||||
var projectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.Default));
|
||||
var changedProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.CSharp8));
|
||||
var projectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", ProjectWorkspaceState.Default);
|
||||
var changedProjectSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", ProjectWorkspaceState.Create(CodeAnalysis.CSharp.LanguageVersion.CSharp8));
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.bin";
|
||||
var aboutToChange = false;
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
|
@ -414,9 +414,10 @@ public class RazorProjectInfoPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
new TagHelperDescriptor(FileKinds.Component, "Namespace.FileNameOther", "Assembly", "FileName", "FileName document", "FileName hint",
|
||||
caseSensitive: false, tagMatchingRules: default, attributeDescriptors: default, allowedChildTags: default, metadata: null, diagnostics: default));
|
||||
|
||||
var secondSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", new ProjectWorkspaceState(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.CSharp8), new string[]{
|
||||
var secondSnapshot = CreateProjectSnapshot(@"C:\path\to\project.csproj", ProjectWorkspaceState.Create(tagHelpers, CodeAnalysis.CSharp.LanguageVersion.CSharp8),
|
||||
[
|
||||
"FileName.razor"
|
||||
});
|
||||
]);
|
||||
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.bin";
|
||||
var publisher = new TestRazorProjectInfoPublisher(
|
||||
projectConfigurationFilePathStore,
|
||||
|
@ -517,7 +518,7 @@ public class RazorProjectInfoPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
var projectFilePath = @"C:\path\to\project.csproj";
|
||||
var hostProject = new HostProject(projectFilePath, Path.Combine(Path.GetDirectoryName(projectFilePath), "obj"), RazorConfiguration.Default, "TestRootNamespace");
|
||||
projectConfigurationFilePathStore.Set(hostProject.Key, expectedConfigurationFilePath);
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Default;
|
||||
|
||||
// Act
|
||||
await RunOnDispatcherThreadAsync(() =>
|
||||
|
@ -610,7 +611,7 @@ public class RazorProjectInfoPublisherTest(ITestOutputHelper testOutput) : Langu
|
|||
var projectFilePath = @"C:\path\to\project.csproj";
|
||||
var hostProject = new HostProject(projectFilePath, Path.Combine(Path.GetDirectoryName(projectFilePath), "obj"), RazorConfiguration.Default, "TestRootNamespace");
|
||||
projectConfigurationFilePathStore.Set(hostProject.Key, expectedConfigurationFilePath);
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(ImmutableArray<TagHelperDescriptor>.Empty, CodeAnalysis.CSharp.LanguageVersion.Default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Default;
|
||||
|
||||
// Act
|
||||
await RunOnDispatcherThreadAsync(() =>
|
||||
|
|
|
@ -61,7 +61,7 @@ public class DefaultProjectSnapshotManagerTest : ProjectSnapshotManagerDispatche
|
|||
|
||||
_projectManager = new TestProjectSnapshotManager(Enumerable.Empty<IProjectSnapshotChangeTrigger>(), Workspace, Dispatcher);
|
||||
|
||||
_projectWorkspaceStateWithTagHelpers = new ProjectWorkspaceState(_tagHelperResolver.TagHelpers, default);
|
||||
_projectWorkspaceStateWithTagHelpers = ProjectWorkspaceState.Create(_tagHelperResolver.TagHelpers);
|
||||
|
||||
_sourceText = SourceText.From("Hello world");
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Collections.Immutable;
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
|
@ -39,14 +40,24 @@ public class VsSolutionUpdatesProjectSnapshotChangeTriggerTest : ToolingTestBase
|
|||
_someProject = new HostProject(TestProjectData.SomeProject.FilePath, TestProjectData.SomeProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_1_0, TestProjectData.SomeProject.RootNamespace);
|
||||
_someOtherProject = new HostProject(TestProjectData.AnotherProject.FilePath, TestProjectData.AnotherProject.IntermediateOutputPath, FallbackRazorConfiguration.MVC_2_0, TestProjectData.AnotherProject.RootNamespace);
|
||||
|
||||
_workspace = TestWorkspace.Create(w => _someWorkspaceProject = w.AddProject(ProjectInfo.Create(
|
||||
ProjectId.CreateNewId(),
|
||||
VersionStamp.Create(),
|
||||
"SomeProject",
|
||||
"SomeProject",
|
||||
LanguageNames.CSharp,
|
||||
filePath: _someProject.FilePath).WithCompilationOutputInfo(new CompilationOutputInfo().WithAssemblyPath(Path.Combine(_someProject.IntermediateOutputPath, "SomeProject.dll")))));
|
||||
var projectEngineFactory = Mock.Of<ProjectSnapshotProjectEngineFactory>(MockBehavior.Strict);
|
||||
var testServices = TestServices.Create([projectEngineFactory], []);
|
||||
|
||||
_workspace = TestWorkspace.Create(testServices,
|
||||
w =>
|
||||
{
|
||||
_someWorkspaceProject = w.AddProject(
|
||||
ProjectInfo.Create(
|
||||
ProjectId.CreateNewId(),
|
||||
VersionStamp.Create(),
|
||||
"SomeProject",
|
||||
"SomeProject",
|
||||
LanguageNames.CSharp,
|
||||
filePath: _someProject.FilePath)
|
||||
.WithCompilationOutputInfo(
|
||||
new CompilationOutputInfo()
|
||||
.WithAssemblyPath(Path.Combine(_someProject.IntermediateOutputPath, "SomeProject.dll"))));
|
||||
});
|
||||
AddDisposable(_workspace);
|
||||
}
|
||||
|
||||
|
@ -189,11 +200,17 @@ public class VsSolutionUpdatesProjectSnapshotChangeTriggerTest : ToolingTestBase
|
|||
.Returns(VSConstants.S_OK);
|
||||
|
||||
var services = new Mock<IServiceProvider>(MockBehavior.Strict);
|
||||
services.Setup(s => s.GetService(It.Is<Type>(f => f == typeof(SVsSolutionBuildManager)))).Returns(buildManager.Object);
|
||||
services
|
||||
.Setup(s => s.GetService(It.Is<Type>(f => f == typeof(SVsSolutionBuildManager))))
|
||||
.Returns(buildManager.Object);
|
||||
|
||||
var projectEngineFactory = Mock.Of<ProjectSnapshotProjectEngineFactory>(MockBehavior.Strict);
|
||||
|
||||
var projectSnapshot = new ProjectSnapshot(
|
||||
ProjectState.Create(
|
||||
_workspace.Services,
|
||||
new HostProject("/Some/Unknown/Path.csproj", "/Some/Unknown/obj", RazorConfiguration.Default, "Path")));
|
||||
projectEngineFactory,
|
||||
new HostProject("/Some/Unknown/Path.csproj", "/Some/Unknown/obj", RazorConfiguration.Default, "Path"),
|
||||
ProjectWorkspaceState.Default));
|
||||
var expectedProjectPath = projectSnapshot.FilePath;
|
||||
|
||||
var projectService = new Mock<TextBufferProjectService>(MockBehavior.Strict);
|
||||
|
|
|
@ -34,9 +34,8 @@ public class ProjectSnapshotSynchronizationServiceTest : WorkspaceTestBase
|
|||
|
||||
_projectSnapshotManager = new TestProjectSnapshotManager(Workspace, new TestProjectSnapshotManagerDispatcher());
|
||||
|
||||
_projectWorkspaceStateWithTagHelpers = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
_projectWorkspaceStateWithTagHelpers = ProjectWorkspaceState.Create(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -9,10 +9,11 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.VisualStudio.LiveShare.Razor.Test;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
@ -20,33 +21,29 @@ namespace Microsoft.VisualStudio.LiveShare.Razor.Host;
|
|||
|
||||
public class DefaultProjectSnapshotManagerProxyTest : ProjectSnapshotManagerDispatcherTestBase
|
||||
{
|
||||
private readonly CodeAnalysis.Workspace _workspace;
|
||||
private readonly IProjectSnapshot _projectSnapshot1;
|
||||
private readonly IProjectSnapshot _projectSnapshot2;
|
||||
|
||||
public DefaultProjectSnapshotManagerProxyTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
_workspace = TestWorkspace.Create();
|
||||
AddDisposable(_workspace);
|
||||
var projectEngineFactory = Mock.Of<ProjectSnapshotProjectEngineFactory>(MockBehavior.Strict);
|
||||
|
||||
var projectWorkspaceState1 = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("test1", "TestAssembly1").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
var projectWorkspaceState1 = ProjectWorkspaceState.Create(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("test1", "TestAssembly1").Build()));
|
||||
|
||||
_projectSnapshot1 = new ProjectSnapshot(
|
||||
ProjectState.Create(
|
||||
_workspace.Services,
|
||||
projectEngineFactory,
|
||||
new HostProject("/host/path/to/project1.csproj", "/host/path/to/obj", RazorConfiguration.Default, "project1"),
|
||||
projectWorkspaceState1));
|
||||
|
||||
var projectWorkspaceState2 = new ProjectWorkspaceState(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("test2", "TestAssembly2").Build()),
|
||||
csharpLanguageVersion: default);
|
||||
var projectWorkspaceState2 = ProjectWorkspaceState.Create(ImmutableArray.Create(
|
||||
TagHelperDescriptorBuilder.Create("test2", "TestAssembly2").Build()));
|
||||
|
||||
_projectSnapshot2 = new ProjectSnapshot(
|
||||
ProjectState.Create(
|
||||
_workspace.Services,
|
||||
projectEngineFactory,
|
||||
new HostProject("/host/path/to/project2.csproj", "/host/path/to/obj", RazorConfiguration.Default, "project2"),
|
||||
projectWorkspaceState2));
|
||||
}
|
||||
|
@ -196,13 +193,9 @@ public class DefaultProjectSnapshotManagerProxyTest : ProjectSnapshotManagerDisp
|
|||
Assert.Same(state1, state2);
|
||||
}
|
||||
|
||||
private class TestProjectSnapshotManager : ProjectSnapshotManager
|
||||
private class TestProjectSnapshotManager(params IProjectSnapshot[] projects) : ProjectSnapshotManager
|
||||
{
|
||||
private ImmutableArray<IProjectSnapshot> _projects;
|
||||
public TestProjectSnapshotManager(params IProjectSnapshot[] projects)
|
||||
{
|
||||
_projects = projects.ToImmutableArray();
|
||||
}
|
||||
private ImmutableArray<IProjectSnapshot> _projects = projects.ToImmutableArray();
|
||||
|
||||
public override ImmutableArray<IProjectSnapshot> GetProjects() => _projects;
|
||||
|
||||
|
|
|
@ -13,13 +13,8 @@ using Xunit.Abstractions;
|
|||
|
||||
namespace Microsoft.VisualStudio.LiveShare.Razor;
|
||||
|
||||
public class SerializationTest : ToolingTestBase
|
||||
public class SerializationTest(ITestOutputHelper testOutput) : ToolingTestBase(testOutput)
|
||||
{
|
||||
public SerializationTest(ITestOutputHelper testOutput)
|
||||
: base(testOutput)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectSnapshotHandleProxy_RoundTripsProperly()
|
||||
{
|
||||
|
@ -28,7 +23,7 @@ public class SerializationTest : ToolingTestBase
|
|||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly").Build(),
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper2", "TestAssembly2").Build());
|
||||
|
||||
var projectWorkspaceState = new ProjectWorkspaceState(tagHelpers, default);
|
||||
var projectWorkspaceState = ProjectWorkspaceState.Create(tagHelpers);
|
||||
var expectedConfiguration = RazorConfiguration.Default;
|
||||
var expectedRootNamespace = "project";
|
||||
var handle = new ProjectSnapshotHandleProxy(new Uri("vsls://some/path/project.csproj"), new Uri("vsls://some/path/obj"), RazorConfiguration.Default, expectedRootNamespace, projectWorkspaceState);
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -26,6 +27,12 @@ public abstract class AbstractRazorEditorTest(ITestOutputHelper testOutputHelper
|
|||
private readonly ITestOutputHelper _testOutputHelper = testOutputHelper;
|
||||
private ILogger? _testLogger;
|
||||
|
||||
protected virtual bool ComponentClassificationExpected => true;
|
||||
|
||||
protected virtual string TargetFramework => "net8.0";
|
||||
|
||||
protected virtual string TargetFrameworkElement => $"""<TargetFramework>{TargetFramework}</TargetFramework>""";
|
||||
|
||||
public override async Task InitializeAsync()
|
||||
{
|
||||
await base.InitializeAsync();
|
||||
|
@ -59,7 +66,11 @@ public abstract class AbstractRazorEditorTest(ITestOutputHelper testOutputHelper
|
|||
EnsureMEFCompositionSuccessForRazor();
|
||||
|
||||
await TestServices.Editor.PlaceCaretAsync("</PageTitle>", charsOffset: 1, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken, count: 3);
|
||||
|
||||
if (ComponentClassificationExpected)
|
||||
{
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken, count: 3);
|
||||
}
|
||||
|
||||
// Making a code change gets us flowing new generated code versions around the system
|
||||
// which seems to have a positive effect on Web Tools in particular. Given the relatively
|
||||
|
@ -87,14 +98,34 @@ public abstract class AbstractRazorEditorTest(ITestOutputHelper testOutputHelper
|
|||
using var zip = new ZipArchive(zipStream);
|
||||
zip.ExtractToDirectory(solutionPath);
|
||||
|
||||
var slnFile = Directory.EnumerateFiles(solutionPath, "*.sln").First();
|
||||
var projectFile = Directory.EnumerateFiles(solutionPath, "*.csproj", SearchOption.AllDirectories).First();
|
||||
var slnFile = Directory.EnumerateFiles(solutionPath, "*.sln").Single();
|
||||
var projectFile = Directory.EnumerateFiles(solutionPath, "*.csproj", SearchOption.AllDirectories).Single();
|
||||
|
||||
PrepareProjectForFirstOpen(projectFile);
|
||||
|
||||
await TestServices.SolutionExplorer.OpenSolutionAsync(slnFile, cancellationToken);
|
||||
|
||||
return projectFile;
|
||||
}
|
||||
|
||||
protected virtual void PrepareProjectForFirstOpen(string projectFileName)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var line in File.ReadAllLines(projectFileName))
|
||||
{
|
||||
if (line.Contains("<TargetFramework"))
|
||||
{
|
||||
sb.AppendLine(TargetFrameworkElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(projectFileName, sb.ToString());
|
||||
}
|
||||
|
||||
private static string CreateTemporaryPath()
|
||||
{
|
||||
return Path.Combine(Path.GetTempPath(), "razor-test", Path.GetRandomFileName());
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion;
|
||||
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data;
|
||||
using Microsoft.VisualStudio.Text.Editor;
|
||||
using Roslyn.Test.Utilities;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
@ -50,8 +46,6 @@ public class CompletionIntegrationTests(ITestOutputHelper testOutputHelper) : Ab
|
|||
TestServices.Input.Send("d");
|
||||
TestServices.Input.Send("d");
|
||||
|
||||
|
||||
|
||||
await CommitCompletionAndVerifyAsync("""
|
||||
@page "Test"
|
||||
|
||||
|
@ -101,7 +95,7 @@ public class CompletionIntegrationTests(ITestOutputHelper testOutputHelper) : Ab
|
|||
|
||||
// Wait until completion comes up before validating
|
||||
// that space does not commit
|
||||
await WaitForCompletionSessionAsync(textView);
|
||||
await TestServices.Editor.WaitForCompletionSessionAsync(HangMitigatingCancellationToken);
|
||||
|
||||
TestServices.Input.Send(" ");
|
||||
|
||||
|
@ -143,7 +137,7 @@ public class CompletionIntegrationTests(ITestOutputHelper testOutputHelper) : Ab
|
|||
TestServices.Input.Send("{DELETE}");
|
||||
|
||||
// Make sure completion doesn't come up for 15 seconds
|
||||
var completionSession = await WaitForCompletionSessionAsync(textView, SnippetTimeout);
|
||||
var completionSession = await TestServices.Editor.WaitForCompletionSessionAsync(SnippetTimeout, HangMitigatingCancellationToken);
|
||||
Assert.Null(completionSession);
|
||||
}
|
||||
|
||||
|
@ -176,7 +170,7 @@ public class CompletionIntegrationTests(ITestOutputHelper testOutputHelper) : Ab
|
|||
TestServices.Input.Send("dd");
|
||||
|
||||
// Make sure completion doesn't come up for 15 seconds
|
||||
var completionSession = await WaitForCompletionSessionAsync(textView, SnippetTimeout);
|
||||
var completionSession = await TestServices.Editor.WaitForCompletionSessionAsync(SnippetTimeout, HangMitigatingCancellationToken);
|
||||
var items = completionSession?.GetComputedItems(HangMitigatingCancellationToken);
|
||||
|
||||
if (items is null)
|
||||
|
@ -212,6 +206,9 @@ public class CompletionIntegrationTests(ITestOutputHelper testOutputHelper) : Ab
|
|||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Editor.PlaceCaretAsync("@MyEnum.", charsOffset: 1, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await Task.Delay(500, HangMitigatingCancellationToken);
|
||||
|
||||
TestServices.Input.Send("O");
|
||||
|
||||
await CommitCompletionAndVerifyAsync("""
|
||||
|
@ -230,37 +227,16 @@ public class CompletionIntegrationTests(ITestOutputHelper testOutputHelper) : Ab
|
|||
|
||||
private async Task CommitCompletionAndVerifyAsync(string expected)
|
||||
{
|
||||
var textView = await TestServices.Editor.GetActiveTextViewAsync(HangMitigatingCancellationToken);
|
||||
var session = await WaitForCompletionSessionAsync(textView);
|
||||
var session = await TestServices.Editor.WaitForCompletionSessionAsync(HangMitigatingCancellationToken);
|
||||
|
||||
Assert.NotNull(session);
|
||||
Assert.True(session.CommitIfUnique(HangMitigatingCancellationToken));
|
||||
|
||||
var textView = await TestServices.Editor.GetActiveTextViewAsync(HangMitigatingCancellationToken);
|
||||
var text = textView.TextBuffer.CurrentSnapshot.GetText();
|
||||
|
||||
// Snippets may have slight whitespace differences due to line endings. These
|
||||
// tests allow for it as long as the content is correct
|
||||
AssertEx.AssertEqualToleratingWhitespaceDifferences(expected, text);
|
||||
}
|
||||
|
||||
private async Task<IAsyncCompletionSession?> WaitForCompletionSessionAsync(IWpfTextView textView, TimeSpan? timeOut = null)
|
||||
{
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
var asyncCompletion = await TestServices.Shell.GetComponentModelServiceAsync<IAsyncCompletionBroker>(HangMitigatingCancellationToken);
|
||||
var session = asyncCompletion.TriggerCompletion(textView, new CompletionTrigger(CompletionTriggerReason.Insertion, textView.TextSnapshot), textView.Caret.Position.BufferPosition, HangMitigatingCancellationToken);
|
||||
|
||||
// Loop until completion comes up
|
||||
while (session is null || session.IsDismissed)
|
||||
{
|
||||
if (timeOut is not null && stopWatch.ElapsedMilliseconds >= timeOut.Value.TotalMilliseconds)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), HangMitigatingCancellationToken);
|
||||
session = asyncCompletion.TriggerCompletion(textView, new CompletionTrigger(CompletionTriggerReason.Insertion, textView.TextSnapshot), textView.Caret.Position.BufferPosition, HangMitigatingCancellationToken);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion;
|
||||
using Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data;
|
||||
|
||||
namespace Microsoft.VisualStudio.Extensibility.Testing;
|
||||
|
||||
|
@ -22,4 +25,34 @@ internal partial class EditorInProcess
|
|||
session.Dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IAsyncCompletionSession?> WaitForCompletionSessionAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return WaitForCompletionSessionAsync(TimeSpan.FromSeconds(10), cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<IAsyncCompletionSession?> WaitForCompletionSessionAsync(TimeSpan timeOut, CancellationToken cancellationToken)
|
||||
{
|
||||
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
|
||||
|
||||
var textView = await GetActiveTextViewAsync(cancellationToken);
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
var asyncCompletion = await TestServices.Shell.GetComponentModelServiceAsync<IAsyncCompletionBroker>(cancellationToken);
|
||||
var session = asyncCompletion.TriggerCompletion(textView, new CompletionTrigger(CompletionTriggerReason.Insertion, textView.TextSnapshot), textView.Caret.Position.BufferPosition, cancellationToken);
|
||||
|
||||
// Loop until completion comes up
|
||||
while (session is null || session.IsDismissed)
|
||||
{
|
||||
if (stopWatch.ElapsedMilliseconds >= timeOut.TotalMilliseconds)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
|
||||
session = asyncCompletion.TriggerCompletion(textView, new CompletionTrigger(CompletionTriggerReason.Insertion, textView.TextSnapshot), textView.Caret.Position.BufferPosition, cancellationToken);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,9 @@ internal partial class RazorProjectSystemInProcess
|
|||
{
|
||||
if (snapshot.TryGetVirtualDocument<CSharpVirtualDocumentSnapshot>(out var virtualDocument))
|
||||
{
|
||||
return Task.FromResult(virtualDocument.ProjectKey.Id is not null);
|
||||
var result = virtualDocument.ProjectKey.Id is not null &&
|
||||
virtualDocument.Snapshot.Length > 0;
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.VisualStudio.Razor.IntegrationTests;
|
||||
|
||||
public class MultiTargetProjectTests(ITestOutputHelper testOutputHelper) : AbstractRazorEditorTest(testOutputHelper)
|
||||
{
|
||||
protected override string TargetFrameworkElement => $"""<TargetFrameworks>net7.0;{TargetFramework}</TargetFrameworks>""";
|
||||
|
||||
[IdeFact]
|
||||
public async Task ValidateMultipleJsonFiles()
|
||||
{
|
||||
var solutionPath = await TestServices.SolutionExplorer.GetDirectoryNameAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// This is a little odd, but there is no "real" way to check this via VS, and one of the most important things this test can do
|
||||
// is ensure that each target framework gets its own project.razor.bin file, and doesn't share one from a cache or anything.
|
||||
Assert.Equal(2, GetProjectRazorJsonFileCount());
|
||||
|
||||
int GetProjectRazorJsonFileCount()
|
||||
=> Directory.EnumerateFiles(solutionPath, "project.razor.*.bin", SearchOption.AllDirectories).Count();
|
||||
}
|
||||
|
||||
[IdeFact]
|
||||
public async Task OpenExistingProject()
|
||||
{
|
||||
var solutionPath = await TestServices.SolutionExplorer.GetDirectoryNameAsync(ControlledHangMitigatingCancellationToken);
|
||||
var expectedProjectFileName = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ProjectFile, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.SolutionExplorer.CloseSolutionAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
var solutionFileName = Path.Combine(solutionPath, RazorProjectConstants.BlazorSolutionName + ".sln");
|
||||
await TestServices.SolutionExplorer.OpenSolutionAsync(solutionFileName, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Workspace.WaitForProjectSystemAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// We open the Index.razor file, and wait for 3 RazorComponentElement's to be classified, as that
|
||||
// way we know the LSP server is up, running, and has processed both local and library-sourced Components
|
||||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.IndexRazorFile, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Workspace.WaitForProjectSystemAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Editor.PlaceCaretAsync("</PageTitle>", charsOffset: 1, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken, count: 3);
|
||||
|
||||
// Make sure the test framework didn't do something weird and create new project
|
||||
var actualProjectFileName = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ProjectFile, ControlledHangMitigatingCancellationToken);
|
||||
Assert.Equal(expectedProjectFileName, actualProjectFileName);
|
||||
}
|
||||
|
||||
[IdeTheory]
|
||||
[CombinatorialData]
|
||||
public async Task OpenExistingProject_WithReopenedFile(bool deleteProjectRazorJson)
|
||||
{
|
||||
var solutionPath = await TestServices.SolutionExplorer.GetDirectoryNameAsync(ControlledHangMitigatingCancellationToken);
|
||||
var expectedProjectFileName = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ProjectFile, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// Open SurveyPrompt and make sure its all up and running
|
||||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ErrorCshtmlFile, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.WaitForSemanticClassificationAsync("class name", ControlledHangMitigatingCancellationToken, count: 1);
|
||||
|
||||
await TestServices.SolutionExplorer.CloseSolutionAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
if (deleteProjectRazorJson)
|
||||
{
|
||||
// Clear out the project.razor.bin file which ensures our restored file will have to be in the Misc Project
|
||||
var projectRazorJsonFileName = Directory.EnumerateFiles(solutionPath, "project.razor.*.bin", SearchOption.AllDirectories).First();
|
||||
File.Delete(projectRazorJsonFileName);
|
||||
}
|
||||
|
||||
var solutionFileName = Path.Combine(solutionPath, RazorProjectConstants.BlazorSolutionName + ".sln");
|
||||
await TestServices.SolutionExplorer.OpenSolutionAsync(solutionFileName, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Workspace.WaitForProjectSystemAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Editor.WaitForSemanticClassificationAsync("class name", ControlledHangMitigatingCancellationToken, count: 1);
|
||||
|
||||
TestServices.Input.Send("1");
|
||||
|
||||
// Make sure the test framework didn't do something weird and create new project
|
||||
var actualProjectFileName = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ProjectFile, ControlledHangMitigatingCancellationToken);
|
||||
Assert.Equal(expectedProjectFileName, actualProjectFileName);
|
||||
|
||||
await TestServices.Editor.CloseCodeFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ErrorCshtmlFile, saveFile: false, ControlledHangMitigatingCancellationToken);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.VisualStudio.Razor.IntegrationTests;
|
||||
|
||||
public class NonRazorSdkTests(ITestOutputHelper testOutputHelper) : AbstractRazorEditorTest(testOutputHelper)
|
||||
{
|
||||
protected override bool ComponentClassificationExpected => false;
|
||||
|
||||
protected override void PrepareProjectForFirstOpen(string projectFileName)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var line in File.ReadAllLines(projectFileName))
|
||||
{
|
||||
if (line.Contains("Sdk="))
|
||||
{
|
||||
sb.AppendLine("""<Project Sdk="Microsoft.NET.Sdk">""");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(projectFileName, sb.ToString());
|
||||
|
||||
base.PrepareProjectForFirstOpen(projectFileName);
|
||||
}
|
||||
|
||||
[IdeFact]
|
||||
public async Task Completion_DateTime()
|
||||
{
|
||||
// We open the Index.razor file, and wait for 3 RazorComponentElement's to be classified, as that
|
||||
// way we know the LSP server is up, running, and has processed both local and library-sourced Components
|
||||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.IndexRazorFile, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.RazorProjectSystem.WaitForLSPServerActivatedAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Workspace.WaitForProjectSystemAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Editor.PlaceCaretAsync("</PageTitle>", charsOffset: 1, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await Task.Delay(500, HangMitigatingCancellationToken);
|
||||
|
||||
TestServices.Input.Send("@");
|
||||
|
||||
var completionSession = await TestServices.Editor.WaitForCompletionSessionAsync(HangMitigatingCancellationToken);
|
||||
var items = completionSession?.GetComputedItems(HangMitigatingCancellationToken);
|
||||
|
||||
Assert.Contains("DateTime", items.AssumeNotNull().Items.Select(i => i.DisplayText));
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
@ -61,62 +60,6 @@ public class ProjectTests(ITestOutputHelper testOutputHelper) : AbstractRazorEdi
|
|||
=> Directory.EnumerateFiles(solutionPath, "project.razor.*.bin", SearchOption.AllDirectories).Count();
|
||||
}
|
||||
|
||||
[IdeFact]
|
||||
public async Task MultiTargetProject()
|
||||
{
|
||||
var solutionPath = await TestServices.SolutionExplorer.GetDirectoryNameAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
Assert.Equal(1, GetProjectRazorJsonFileCount());
|
||||
|
||||
var projectFileName = await TestServices.SolutionExplorer.GetAbsolutePathForProjectRelativeFilePathAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ProjectFile, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// CPS doesn't support changing from single targeting to multi-targeting while a project is open
|
||||
await TestServices.SolutionExplorer.CloseSolutionAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.RazorProjectSystem.WaitForLSPServerDeactivatedAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach (var line in File.ReadAllLines(projectFileName))
|
||||
{
|
||||
if (line.Contains("<TargetFramework>"))
|
||||
{
|
||||
sb.AppendLine("<TargetFrameworks>net6.0;net7.0</TargetFrameworks>");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(projectFileName, sb.ToString());
|
||||
|
||||
var projectFolder = Path.GetDirectoryName(projectFileName);
|
||||
// Clear out the obj folder, so we don't break the test when the default project is updated in the project template, resulting in 3 .json files
|
||||
Directory.Delete(Path.Combine(projectFolder, "obj"), recursive: true);
|
||||
var solutionFileName = Path.Combine(solutionPath, RazorProjectConstants.BlazorSolutionName + ".sln");
|
||||
await TestServices.SolutionExplorer.OpenSolutionAsync(solutionFileName, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Workspace.WaitForProjectSystemAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
// We open the Index.razor file, and wait for 3 RazorComponentElement's to be classified, as that
|
||||
// way we know the LSP server is up, running, and has processed both local and library-sourced Components
|
||||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.IndexRazorFile, ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.RazorProjectSystem.WaitForLSPServerActivatedAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Workspace.WaitForProjectSystemAsync(ControlledHangMitigatingCancellationToken);
|
||||
|
||||
await TestServices.Editor.PlaceCaretAsync("</PageTitle>", charsOffset: 1, ControlledHangMitigatingCancellationToken);
|
||||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken, count: 3);
|
||||
|
||||
// This is a little odd, but there is no "real" way to check this via VS, and one of the most important things this test can do
|
||||
// is ensure that each target framework gets its own project.razor.bin file, and doesn't share one from a cache or anything.
|
||||
Assert.Equal(2, GetProjectRazorJsonFileCount());
|
||||
|
||||
int GetProjectRazorJsonFileCount()
|
||||
=> Directory.EnumerateFiles(solutionPath, "project.razor.*.bin", SearchOption.AllDirectories).Count();
|
||||
}
|
||||
|
||||
[IdeFact]
|
||||
public async Task OpenExistingProject()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче