diff --git a/.sscignore b/.sscignore
new file mode 100644
index 000000000000..532d7758ebd9
--- /dev/null
+++ b/.sscignore
@@ -0,0 +1,4 @@
+{
+ "__comment": "CFS0013 intended for src\\Assets\\TestPackages\\dotnet-new\\test_templates\\TemplateWithConditions\\nuget.config",
+ "cfs" : ["CFS0013"]
+}
diff --git a/.vsts-ci.yml b/.vsts-ci.yml
index 5eee7dcb875e..495149976450 100644
--- a/.vsts-ci.yml
+++ b/.vsts-ci.yml
@@ -26,13 +26,17 @@ variables:
- ${{ if eq(variables['System.TeamProject'], 'public') }}:
- name: _InternalRuntimeDownloadArgs
value: ''
+ - name: _OfficialBuildArgs
+ value: ''
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
- name: _DotNetPublishToBlobFeed
value: true
+ - name: _OfficialBuildArgs
+ value: /p:OfficialBuilder=Microsoft
- group: DotNetBuilds storage account read tokens
- name: _InternalRuntimeDownloadArgs
value: /p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal
- /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64)
+ /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64)
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- group: DotNet-CLI-SDLValidation-Params
diff --git a/Directory.Build.props b/Directory.Build.props
index 8ee962ab1da8..1353696a295f 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -21,6 +21,7 @@
$(DefineConstants);CI_BUILD
+ $(DefineConstants);MICROSOFT_ENABLE_TELEMETRY$(DefineConstants);DOT_NET_BUILD_FROM_SOURCE
diff --git a/NuGet.config b/NuGet.config
index 0815f41ac8a4..e42468650b96 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -20,6 +20,8 @@
+
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index d9120c14cba2..f7f339b39d14 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -1,236 +1,237 @@
-
+ https://github.com/dotnet/templating
- 9ad0acac2a252764639134bb80ce7fc663bb8c9c
+ 4c20b92abdd5793182917a55114a19146a4aa4db
+
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/msbuild
- f2d13c6261c25bfdf53b29f3b0c4f38d7274fcc4
+ 50f6081beda4c565252ff51be4ab1fe27005372b
-
+ https://github.com/dotnet/msbuild
- f2d13c6261c25bfdf53b29f3b0c4f38d7274fcc4
+ 50f6081beda4c565252ff51be4ab1fe27005372b
-
+ https://github.com/dotnet/fsharp
- 02452432ce5180092438b17df9c5788f0c1ba9cf
+ ee745b0455fe651b6f5e5f9b85fc59a7b2574395
-
+ https://github.com/dotnet/fsharp
- 02452432ce5180092438b17df9c5788f0c1ba9cf
+ ee745b0455fe651b6f5e5f9b85fc59a7b2574395
-
+ https://github.com/dotnet/format
- 0b06c70c05030f4f10339b074758d8247f87cc30
+ a4841cd2f1c9ccdb2c643e2faa61ba35dc2a8169
-
+ https://github.com/dotnet/roslyn
- 83ae84b2a99a0bb1cb83525db21d467b99fd0159
+ 65dc2845b5287ac972f7299616c13d3270720e44
-
+ https://github.com/dotnet/roslyn
- 83ae84b2a99a0bb1cb83525db21d467b99fd0159
+ 65dc2845b5287ac972f7299616c13d3270720e44
-
+ https://github.com/dotnet/roslyn
- 83ae84b2a99a0bb1cb83525db21d467b99fd0159
+ 65dc2845b5287ac972f7299616c13d3270720e44
-
+ https://github.com/dotnet/roslyn
- 83ae84b2a99a0bb1cb83525db21d467b99fd0159
+ 65dc2845b5287ac972f7299616c13d3270720e44
-
+ https://github.com/dotnet/roslyn
- 83ae84b2a99a0bb1cb83525db21d467b99fd0159
+ 65dc2845b5287ac972f7299616c13d3270720e44
-
+ https://github.com/dotnet/roslyn
- 83ae84b2a99a0bb1cb83525db21d467b99fd0159
+ 65dc2845b5287ac972f7299616c13d3270720e44
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/nuget/nuget.client
- 3ec6f02943fa8e70ea224eb31dd94288dbf179d0
+ 26a0cf27a2d4dcf52d19238606c269d6fed9ff66
-
+ https://github.com/microsoft/vstest
- 63149fdc913835956b51759399e0d0ede3ad0ac3
+ ef0aa102e9c7d5cf55af06c2747d11e07d12b69a
-
+ https://github.com/dotnet/linker
- f09bacf09ef10b61cf9f19825f8782171a816dab
+ 6252a2194dd32911db2c0669fc818555687d5570
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/linker
- f09bacf09ef10b61cf9f19825f8782171a816dab
+ 6252a2194dd32911db2c0669fc818555687d5570
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/windowsdesktop
- d5046afdd2d0e6234ae3fc5bd4ae878594079cc7
+ 9a92628f9c13edd9caf29d8bb385ddb8acef3a65
-
+ https://github.com/dotnet/windowsdesktop
- d5046afdd2d0e6234ae3fc5bd4ae878594079cc7
+ 1ce737df56e7c14e2ba7adb308d9c045d6d67a8c
-
+ https://github.com/dotnet/windowsdesktop
- d5046afdd2d0e6234ae3fc5bd4ae878594079cc7
+ 9a92628f9c13edd9caf29d8bb385ddb8acef3a65
-
+ https://github.com/dotnet/windowsdesktop
- d5046afdd2d0e6234ae3fc5bd4ae878594079cc7
+ 1ce737df56e7c14e2ba7adb308d9c045d6d67a8c
-
+ https://github.com/dotnet/wpf
- cd58f79f496337e608662e168c80ac8abd0d151b
+ d484acf21f04d612722a69026aa8e4efa584ea8e
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 77ea9ee147f495dd05a1d50906e3d455a5f4f2a0
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/razor-compiler
- 44a2657f0dec50bc531f1d27b482057055a7ef92
+ a41514681a4db83c7cae7e17debf668d12efc1bb
-
+ https://github.com/dotnet/razor-compiler
- 44a2657f0dec50bc531f1d27b482057055a7ef92
+ a41514681a4db83c7cae7e17debf668d12efc1bb
-
+ https://github.com/dotnet/razor-compiler
- 44a2657f0dec50bc531f1d27b482057055a7ef92
+ a41514681a4db83c7cae7e17debf668d12efc1bb
-
+ https://github.com/dotnet/razor-compiler
- 55e950892723d077c2707450ae8a8218bf4abc9c
+ a41514681a4db83c7cae7e17debf668d12efc1bb
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5
-
+ https://github.com/dotnet/aspnetcore
- 55616fa5b272d6d957d20059a681a68901807486
+ 7662e32548923a93fdad61f96712471fd24ca8c5https://github.com/aspnet/xdt
@@ -254,37 +255,37 @@
4b605851d45131db2374ba711f2443040521d702
-
+ https://github.com/dotnet/source-build-externals
- 85d7e996e497861648ffbfd0e929b2b627ce7f46
+ ee790b0477953dd30ea83e0e47af909a04fd0ca3
-
+ https://github.com/dotnet/arcade
- 58aed6cc9fde5155c79cf706eeccf31b03e9a8a7
+ 6a638cd0c13962ab2a1943cb1c878be5a41dd82e
-
+ https://github.com/dotnet/arcade
- 58aed6cc9fde5155c79cf706eeccf31b03e9a8a7
+ 6a638cd0c13962ab2a1943cb1c878be5a41dd82e
-
+ https://github.com/dotnet/arcade
- 58aed6cc9fde5155c79cf706eeccf31b03e9a8a7
+ 6a638cd0c13962ab2a1943cb1c878be5a41dd82e
-
+ https://github.com/dotnet/arcade
- 58aed6cc9fde5155c79cf706eeccf31b03e9a8a7
+ 6a638cd0c13962ab2a1943cb1c878be5a41dd82e
-
+ https://github.com/dotnet/runtime
- e43e31527db9f1a2dde3095a1651279b272c8c09
+ f52d8c59bb49360eb2cbeeb863c5856ebd62adda
-
+ https://github.com/dotnet/xliff-tasks
- eb60feba8e35109537c4059bf5131ea0d7ed24f3
+ 8dfdebfefc8acef481f28edadbf7f75a8d6efde4
diff --git a/eng/Versions.props b/eng/Versions.props
index 8de544bb25ec..6b72c9208f3d 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -33,14 +33,14 @@
6.0.04.0.06.0.0
- 7.0.0-beta.22405.6
+ 7.0.0-beta.22411.23.1.0
- 7.0.0-rc.1.22406.5
+ 7.0.0-rc.1.22411.124.3.04.3.04.0.56.0.0
- 7.0.0-rc.1.22406.5
+ 7.0.0-rc.1.22411.124.6.02.0.0-beta4.22402.11.0.0-preview5.1.22263.1
@@ -48,20 +48,21 @@
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.12$(MicrosoftNETCoreAppRuntimewinx64PackageVersion)
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.126.0.0-preview.7.21363.9$(MicrosoftExtensionsDependencyModelPackageVersion)
+ 6.0.07.0.0-preview.4.22201.3
- 6.4.0-preview.1.35
+ 6.4.0-preview.1.45$(NuGetBuildTasksPackageVersion)6.0.0-rc.278$(NuGetBuildTasksPackageVersion)
@@ -78,25 +79,25 @@
- 17.4.0-preview-20220727-01
+ 17.4.0-preview-20220813-01$(MicrosoftNETTestSdkPackageVersion)$(MicrosoftNETTestSdkPackageVersion)
- 7.0.100-1.22377.1
+ 7.0.100-1.22415.4$(MicrosoftNETILLinkTasksPackageVersion)
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
- 7.0.0-rc.1.22406.5
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.12
+ 7.0.0-rc.1.22411.12
- 7.0.340701
+ 7.0.341201
@@ -104,7 +105,7 @@
- 17.4.0-preview-22405-01
+ 17.4.0-preview-22414-01
- 7.0.100-rc.1.22406.1
+ 8.0.100-alpha.1.22416.12$(MicrosoftTemplateEngineAbstractionsPackageVersion)$(MicrosoftTemplateEngineAbstractionsPackageVersion)$(MicrosoftTemplateEngineAbstractionsPackageVersion)
@@ -132,37 +133,37 @@
- 12.0.6-beta.22404.7
+ 12.0.6-beta.22414.2
- 4.4.0-1.22404.1
- 4.4.0-1.22404.1
- 4.4.0-1.22404.1
- 4.4.0-1.22404.1
- 4.4.0-1.22404.1
- 4.4.0-1.22404.1
+ 4.4.0-2.22415.6
+ 4.4.0-2.22415.6
+ 4.4.0-2.22415.6
+ 4.4.0-2.22415.6
+ 4.4.0-2.22415.6
+ 4.4.0-2.22415.6$(MicrosoftNetCompilersToolsetPackageVersion)
- 7.0.0-rc.1.22405.12
- 7.0.0-rc.1.22405.12
- 7.0.0-rc.1.22405.12
- 7.0.0-rc.1.22405.12
- 7.0.0-rc.1.22405.12
- 7.0.0-rc.1.22405.12
+ 8.0.0-alpha.1.22416.14
+ 8.0.0-alpha.1.22416.14
+ 8.0.0-alpha.1.22416.14
+ 8.0.0-alpha.1.22416.14
+ 8.0.0-alpha.1.22416.14
+ 8.0.0-alpha.1.22416.14
- 7.0.0-preview.5.22364.1
- 7.0.0-preview.5.22364.1
- 7.0.0-preview.5.22364.1
- 7.0.0-preview.5.22357.2
+ 7.0.0-preview.5.22412.2
+ 7.0.0-preview.5.22412.2
+ 7.0.0-preview.5.22412.2
+ 7.0.0-preview.5.22412.2
- 7.0.0-rc.1.22379.2
+ 7.0.0-rc.2.22416.3
@@ -171,7 +172,7 @@
- 1.0.0-beta.22404.1
+ 1.0.0-beta.22409.1
@@ -181,7 +182,7 @@
4.19.24.19.0
- 7.0.0-beta.22405.6
+ 7.0.0-beta.22411.24.8.26.0.0-beta.22262.1
diff --git a/eng/build.yml b/eng/build.yml
index 335e8396b312..6fb25a126e73 100644
--- a/eng/build.yml
+++ b/eng/build.yml
@@ -15,14 +15,15 @@ parameters:
timeoutInMinutes: 180
jobs:
-- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}:
+- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main'), not(contains(parameters.agentOs, 'TemplateEngine'))) }}:
- template: /eng/common/templates/job/onelocbuild.yml
parameters:
CreatePr: true
LclSource: lclFilesfromPackage
LclPackageId: 'LCL-JUNO-PROD-DOTNETSDK'
- MirrorBranch: release/6.0.4xx
+ MirrorBranch: main
MirrorRepo: sdk
+
- ${{ if not(contains(parameters.agentOs, 'TemplateEngine')) }}:
- template: /eng/common/templates/job/job.yml
parameters:
@@ -73,6 +74,7 @@ jobs:
$(_OfficialBuildIdArgs)
/p:Test=false
$(_InternalRuntimeDownloadArgs)
+ $(_OfficialBuildArgs)
displayName: Build
env:
BuildConfig: $(_BuildConfig)
@@ -479,4 +481,4 @@ jobs:
ArtifactName: '$(_AgentOSName)_$(Agent.JobName)_$(Build.BuildNumber)'
publishLocation: Container
continueOnError: true
- condition: always()
\ No newline at end of file
+ condition: always()
diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh
index f058c98763aa..d3b0ac3ba7b6 100755
--- a/eng/common/cross/build-rootfs.sh
+++ b/eng/common/cross/build-rootfs.sh
@@ -8,11 +8,13 @@ usage()
echo "BuildArch can be: arm(default), arm64, armel, armv6, ppc64le, riscv64, s390x, x64, x86"
echo "CodeName - optional, Code name for Linux, can be: xenial(default), zesty, bionic, alpine, alpine3.13 or alpine3.14. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
echo " for FreeBSD can be: freebsd12, freebsd13"
- echo " for illumos can be: illumos."
+ echo " for illumos can be: illumos"
+ echo " for Haiku can be: haiku."
echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FreeBSD"
echo "llvmx[.y] - optional, LLVM version for LLVM related packages."
echo "--skipunmount - optional, will skip the unmount of rootfs folder."
echo "--use-mirror - optional, use mirror URL to fetch resources, when available."
+ echo "--jobs N - optional, restrict to N jobs."
exit 1
}
@@ -79,6 +81,17 @@ __IllumosPackages+=" mit-krb5-1.16.2nb4"
__IllumosPackages+=" openssl-1.1.1e"
__IllumosPackages+=" zlib-1.2.11"
+__HaikuPackages="gmp"
+__HaikuPackages+=" gmp_devel"
+__HaikuPackages+=" krb5"
+__HaikuPackages+=" krb5_devel"
+__HaikuPackages+=" libiconv"
+__HaikuPackages+=" libiconv_devel"
+__HaikuPackages+=" llvm12_libunwind"
+__HaikuPackages+=" llvm12_libunwind_devel"
+__HaikuPackages+=" mpfr"
+__HaikuPackages+=" mpfr_devel"
+
# ML.NET dependencies
__UbuntuPackages+=" libomp5"
__UbuntuPackages+=" libomp-dev"
@@ -263,6 +276,11 @@ while :; do
__CodeName=illumos
__SkipUnmount=1
;;
+ haiku)
+ __CodeName=haiku
+ __BuildArch=x64
+ __SkipUnmount=1
+ ;;
--skipunmount)
__SkipUnmount=1
;;
@@ -273,6 +291,10 @@ while :; do
--use-mirror)
__UseMirror=1
;;
+ --use-jobs)
+ shift
+ MAXJOBS=$1
+ ;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
;;
@@ -326,7 +348,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
rm -r "$__ApkToolsDir"
elif [[ "$__CodeName" == "freebsd" ]]; then
mkdir -p "$__RootfsDir"/usr/local/etc
- JOBS="$(getconf _NPROCESSORS_ONLN)"
+ JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"}
wget -O - "https://download.freebsd.org/ftp/releases/${__FreeBSDArch}/${__FreeBSDMachineArch}/${__FreeBSDBase}/base.txz" | tar -C "$__RootfsDir" -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version
echo "ABI = \"FreeBSD:${__FreeBSDABI}:${__FreeBSDMachineArch}\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > "${__RootfsDir}"/usr/local/etc/pkg.conf
echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf
@@ -344,7 +366,7 @@ elif [[ "$__CodeName" == "freebsd" ]]; then
elif [[ "$__CodeName" == "illumos" ]]; then
mkdir "$__RootfsDir/tmp"
pushd "$__RootfsDir/tmp"
- JOBS="$(getconf _NPROCESSORS_ONLN)"
+ JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"}
echo "Downloading sysroot."
wget -O - https://github.com/illumos/sysroot/releases/download/20181213-de6af22ae73b-v1/illumos-sysroot-i386-20181213-de6af22ae73b-v1.tar.gz | tar -C "$__RootfsDir" -xzf -
echo "Building binutils. Please wait.."
@@ -386,6 +408,70 @@ elif [[ "$__CodeName" == "illumos" ]]; then
wget -P "$__RootfsDir"/usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h
wget -P "$__RootfsDir"/usr/include/netpacket https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h
wget -P "$__RootfsDir"/usr/include/sys https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h
+elif [[ "$__CodeName" == "haiku" ]]; then
+ JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"}
+
+ echo "Building Haiku sysroot for x86_64"
+ mkdir -p "$__RootfsDir/tmp"
+ cd "$__RootfsDir/tmp"
+ git clone -b hrev56235 https://review.haiku-os.org/haiku
+ git clone -b btrev43195 https://review.haiku-os.org/buildtools
+ cd "$__RootfsDir/tmp/buildtools" && git checkout 7487388f5110021d400b9f3b88e1a7f310dc066d
+
+ # Fetch some unmerged patches
+ cd "$__RootfsDir/tmp/haiku"
+ ## Add development build profile (slimmer than nightly)
+ git fetch origin refs/changes/64/4164/1 && git -c commit.gpgsign=false cherry-pick FETCH_HEAD
+
+ # Build jam
+ cd "$__RootfsDir/tmp/buildtools/jam"
+ make
+
+ # Configure cross tools
+ echo "Building cross-compiler"
+ mkdir -p "$__RootfsDir/generated"
+ cd "$__RootfsDir/generated"
+ "$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools x86_64
+
+ # Build Haiku packages
+ echo "Building Haiku"
+ echo 'HAIKU_BUILD_PROFILE = "development-raw" ;' > UserProfileConfig
+ "$__RootfsDir/tmp/buildtools/jam/jam0" -j"$JOBS" -q 'package' 'Haiku'
+
+ BaseUrl="https://depot.haiku-os.org/__api/v2/pkg/get-pkg"
+
+ # Download additional packages
+ echo "Downloading additional required packages"
+ read -ra array <<<"$__HaikuPackages"
+ for package in "${array[@]}"; do
+ echo "Downloading $package..."
+ # API documented here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L60
+ # The schema here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L598
+ hpkgDownloadUrl="$(wget -qO- --post-data='{"name":"'"$package"'","repositorySourceCode":"haikuports_x86_64","versionType":"LATEST","naturalLanguageCode":"en"}' \
+ --header='Content-Type:application/json' "$BaseUrl" | jq -r '.result.versions[].hpkgDownloadURL')"
+ wget -P "$__RootfsDir/generated/download" "$hpkgDownloadUrl"
+ done
+
+ # Setup the sysroot
+ echo "Setting up sysroot and extracting needed packages"
+ mkdir -p "$__RootfsDir/boot/system"
+ for file in "$__RootfsDir/generated/objects/haiku/x86_64/packaging/packages/"*.hpkg; do
+ "$__RootfsDir/generated/objects/linux/x86_64/release/tools/package/package" extract -C "$__RootfsDir/boot/system" "$file"
+ done
+ for file in "$__RootfsDir/generated/download/"*.hpkg; do
+ "$__RootfsDir/generated/objects/linux/x86_64/release/tools/package/package" extract -C "$__RootfsDir/boot/system" "$file"
+ done
+
+ # Cleaning up temporary files
+ echo "Cleaning up temporary files"
+ rm -rf "$__RootfsDir/tmp"
+ for name in "$__RootfsDir/generated/"*; do
+ if [[ "$name" =~ "cross-tools-" ]]; then
+ : # Keep the cross-compiler
+ else
+ rm -rf "$name"
+ fi
+ done
elif [[ -n "$__CodeName" ]]; then
qemu-debootstrap $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo"
cp "$__CrossDir/$__BuildArch/sources.list.$__CodeName" "$__RootfsDir/etc/apt/sources.list"
diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake
index 909117759e61..561576be97c2 100644
--- a/eng/common/cross/toolchain.cmake
+++ b/eng/common/cross/toolchain.cmake
@@ -7,6 +7,8 @@ if(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version)
elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc)
set(CMAKE_SYSTEM_NAME SunOS)
set(ILLUMOS 1)
+elseif(EXISTS ${CROSS_ROOTFS}/boot/system/develop/headers/config/HaikuConfig.h)
+ set(CMAKE_SYSTEM_NAME Haiku)
else()
set(CMAKE_SYSTEM_NAME Linux)
set(LINUX 1)
@@ -76,6 +78,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "x64")
set(triple "x86_64-unknown-freebsd12")
elseif(ILLUMOS)
set(TOOLCHAIN "x86_64-illumos")
+ elseif(HAIKU)
+ set(TOOLCHAIN "x64_64-unknown-haiku")
endif()
elseif(TARGET_ARCH_NAME STREQUAL "x86")
set(CMAKE_SYSTEM_PROCESSOR i686)
@@ -170,6 +174,41 @@ elseif(ILLUMOS)
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp")
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp")
+elseif(HAIKU)
+ set(CMAKE_SYSROOT "${CROSS_ROOTFS}")
+
+ set(TOOLSET_PREFIX ${TOOLCHAIN}-)
+ function(locate_toolchain_exec exec var)
+ string(TOUPPER ${exec} EXEC_UPPERCASE)
+ if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
+ set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
+ return()
+ endif()
+
+ set(SEARCH_PATH "${CROSS_ROOTFS}/generated/cross-tools-x86_64/bin")
+
+ find_program(EXEC_LOCATION_${exec}
+ PATHS ${SEARCH_PATH}
+ NAMES
+ "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
+ "${TOOLSET_PREFIX}${exec}")
+
+ if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
+ message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.")
+ endif()
+ set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
+ endfunction()
+
+ set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}")
+
+ locate_toolchain_exec(gcc CMAKE_C_COMPILER)
+ locate_toolchain_exec(g++ CMAKE_CXX_COMPILER)
+
+ set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp")
+ set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp")
+
+ # let CMake set up the correct search paths
+ include(Platform/Haiku)
else()
set(CMAKE_SYSROOT "${CROSS_ROOTFS}")
@@ -229,7 +268,7 @@ endif()
# Specify compile options
-if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS)
+if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU)
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN})
set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN})
diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1
index 8d48ec5680fc..7428ef88084f 100644
--- a/eng/common/init-tools-native.ps1
+++ b/eng/common/init-tools-native.ps1
@@ -201,4 +201,4 @@ catch {
Write-Host $_.ScriptStackTrace
Write-PipelineTelemetryError -Category 'NativeToolsBootstrap' -Message $_
ExitWithExitCode 1
-}
+}
\ No newline at end of file
diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml
index 24cec0424e5d..9ff6a10a682c 100644
--- a/eng/common/templates/job/execute-sdl.yml
+++ b/eng/common/templates/job/execute-sdl.yml
@@ -54,7 +54,7 @@ jobs:
# If it's not devdiv, it's dnceng
${{ if ne(variables['System.TeamProject'], 'DevDiv') }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
steps:
- checkout: self
clean: true
diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml
index 3bcd243c46b6..6c523b714f40 100644
--- a/eng/common/templates/job/onelocbuild.yml
+++ b/eng/common/templates/job/onelocbuild.yml
@@ -41,7 +41,7 @@ jobs:
# If it's not devdiv, it's dnceng
${{ if ne(variables['System.TeamProject'], 'DevDiv') }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
variables:
- group: OneLocBuildVariables # Contains the CeapexPat and GithubPat
diff --git a/eng/common/templates/job/source-index-stage1.yml b/eng/common/templates/job/source-index-stage1.yml
index 4e37210857d1..c85044a68490 100644
--- a/eng/common/templates/job/source-index-stage1.yml
+++ b/eng/common/templates/job/source-index-stage1.yml
@@ -29,10 +29,10 @@ jobs:
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
name: NetCore1ESPool-Public
- demands: ImageOverride -equals Build.Server.Amd64.VS2019.Open
+ demands: ImageOverride -equals windows.vs2019.amd64.open
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
steps:
- ${{ each preStep in parameters.preSteps }}:
diff --git a/eng/common/templates/jobs/jobs.yml b/eng/common/templates/jobs/jobs.yml
index 2cca53c2d1d5..64e5929f2216 100644
--- a/eng/common/templates/jobs/jobs.yml
+++ b/eng/common/templates/jobs/jobs.yml
@@ -96,7 +96,7 @@ jobs:
# If it's not devdiv, it's dnceng
${{ if ne(variables['System.TeamProject'], 'DevDiv') }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
runAsPublic: ${{ parameters.runAsPublic }}
publishUsingPipelines: ${{ parameters.enablePublishUsingPipelines }}
diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml
index e0beb25d4e76..87fcae940cff 100644
--- a/eng/common/templates/post-build/post-build.yml
+++ b/eng/common/templates/post-build/post-build.yml
@@ -107,7 +107,7 @@ stages:
# If it's not devdiv, it's dnceng
${{ else }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
steps:
- template: setup-maestro-vars.yml
@@ -144,7 +144,7 @@ stages:
# If it's not devdiv, it's dnceng
${{ else }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
steps:
- template: setup-maestro-vars.yml
parameters:
@@ -204,7 +204,7 @@ stages:
# If it's not devdiv, it's dnceng
${{ else }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
steps:
- template: setup-maestro-vars.yml
parameters:
@@ -263,7 +263,7 @@ stages:
# If it's not devdiv, it's dnceng
${{ else }}:
name: NetCore1ESPool-Internal
- demands: ImageOverride -equals Build.Server.Amd64.VS2019
+ demands: ImageOverride -equals windows.vs2019.amd64
steps:
- template: setup-maestro-vars.yml
parameters:
diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1
index 9638c63c7258..f83a748c37e9 100644
--- a/eng/common/tools.ps1
+++ b/eng/common/tools.ps1
@@ -368,7 +368,14 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
# https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet-eng&package=RoslynTools.MSBuild&protocolType=NuGet&version=17.1.0&view=overview
$defaultXCopyMSBuildVersion = '17.1.0'
- if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
+ if (!$vsRequirements) {
+ if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') {
+ $vsRequirements = $GlobalJson.tools.vs
+ }
+ else {
+ $vsRequirements = New-Object PSObject -Property @{ version = $vsMinVersionReqdStr }
+ }
+ }
$vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { $vsMinVersionReqdStr }
$vsMinVersion = [Version]::new($vsMinVersionStr)
diff --git a/global.json b/global.json
index 4736a5072564..35e1e944169e 100644
--- a/global.json
+++ b/global.json
@@ -11,7 +11,7 @@
}
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22405.6",
- "Microsoft.DotNet.Helix.Sdk": "7.0.0-beta.22405.6"
+ "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22411.2",
+ "Microsoft.DotNet.Helix.Sdk": "7.0.0-beta.22411.2"
}
}
diff --git a/source-build.slnf b/source-build.slnf
index 4bd6e994b414..664ec75c76f6 100644
--- a/source-build.slnf
+++ b/source-build.slnf
@@ -2,6 +2,10 @@
"solution": {
"path": "sdk.sln",
"projects": [
+ "src\\ApiCompat\\Microsoft.DotNet.ApiCompat.Shared\\Microsoft.DotNet.ApiCompat.Shared.shproj",
+ "src\\ApiCompat\\Microsoft.DotNet.ApiCompat.Task\\Microsoft.DotNet.ApiCompat.Task.csproj",
+ "src\\ApiCompat\\Microsoft.DotNet.ApiCompatibility\\Microsoft.DotNet.ApiCompatibility.csproj",
+ "src\\ApiCompat\\Microsoft.DotNet.PackageValidation\\Microsoft.DotNet.PackageValidation.csproj",
"src\\BlazorWasmSdk\\Tasks\\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.csproj",
"src\\BlazorWasmSdk\\Tool\\Microsoft.NET.Sdk.BlazorWebAssembly.Tool.csproj",
"src\\BuiltInTools\\BrowserRefresh\\Microsoft.AspNetCore.Watch.BrowserRefresh.csproj",
@@ -12,11 +16,8 @@
"src\\Cli\\Microsoft.DotNet.Cli.Utils\\Microsoft.DotNet.Cli.Utils.csproj",
"src\\Cli\\Microsoft.DotNet.Configurer\\Microsoft.DotNet.Configurer.csproj",
"src\\Cli\\Microsoft.DotNet.InternalAbstractions\\Microsoft.DotNet.InternalAbstractions.csproj",
+ "src\\Cli\\Microsoft.TemplateEngine.Cli\\Microsoft.TemplateEngine.Cli.csproj",
"src\\Cli\\dotnet\\dotnet.csproj",
- "src\\ApiCompat\\Microsoft.DotNet.ApiCompat.Shared\\Microsoft.DotNet.ApiCompat.Shared.shproj",
- "src\\ApiCompat\\Microsoft.DotNet.ApiCompat.Task\\Microsoft.DotNet.ApiCompat.Task.csproj",
- "src\\ApiCompat\\Microsoft.DotNet.ApiCompatibility\\Microsoft.DotNet.ApiCompatibility.csproj",
- "src\\ApiCompat\\Microsoft.DotNet.PackageValidation\\Microsoft.DotNet.PackageValidation.csproj",
"src\\Layout\\redist\\redist.csproj",
"src\\Layout\\tool_fsharp\\tool_fsc.csproj",
"src\\Layout\\tool_msbuild\\tool_msbuild.csproj",
@@ -37,7 +38,9 @@
"src\\WebSdk\\ProjectSystem\\Tasks\\Microsoft.NET.Sdk.Web.ProjectSystem.Tasks.csproj",
"src\\WebSdk\\Publish\\Tasks\\Microsoft.NET.Sdk.Publish.Tasks.csproj",
"src\\WebSdk\\Web\\Tasks\\Microsoft.NET.Sdk.Web.Tasks.csproj",
- "src\\WebSdk\\Worker\\Tasks\\Microsoft.NET.Sdk.Worker.Tasks.csproj"
+ "src\\WebSdk\\Worker\\Tasks\\Microsoft.NET.Sdk.Worker.Tasks.csproj",
+ "template_feed\\Microsoft.DotNet.Common.ItemTemplates\\Microsoft.DotNet.Common.ItemTemplates.csproj",
+ "template_feed\\Microsoft.DotNet.Common.ProjectTemplates.7.0\\Microsoft.DotNet.Common.ProjectTemplates.7.0.csproj"
]
}
}
\ No newline at end of file
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/IApiCompatServiceProviderModule.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/IApiCompatServiceProviderModule.cs
new file mode 100644
index 000000000000..9d907cc07d4b
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/IApiCompatServiceProviderModule.cs
@@ -0,0 +1,30 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using Jab;
+using Microsoft.DotNet.ApiCompatibility;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
+using Microsoft.DotNet.ApiCompatibility.Logging;
+using Microsoft.DotNet.ApiCompatibility.Rules;
+using Microsoft.DotNet.ApiCompatibility.Runner;
+
+namespace Microsoft.DotNet.ApiCompat
+{
+ [ServiceProviderModule]
+ [Singleton(typeof(ISuppressionEngine), Factory = nameof(SuppressionEngineFactory))]
+ [Singleton(typeof(ICompatibilityLogger), Factory = nameof(LogFactory))]
+ [Singleton(typeof(IRuleFactory), Instance = nameof(RuleFactory))]
+ [Singleton(typeof(IApiComparerFactory), typeof(ApiComparerFactory))]
+ [Singleton(typeof(IAssemblySymbolLoaderFactory), typeof(AssemblySymbolLoaderFactory))]
+ [Singleton(typeof(IMetadataStreamProvider), typeof(MetadataStreamProvider))]
+ [Singleton(typeof(IApiCompatRunner), typeof(ApiCompatRunner))]
+ internal interface IApiCompatServiceProviderModule
+ {
+ Func SuppressionEngineFactory { get; }
+
+ Func LogFactory { get; }
+
+ RuleFactory RuleFactory { get; }
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/Microsoft.DotNet.ApiCompat.Shared.projitems b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/Microsoft.DotNet.ApiCompat.Shared.projitems
index 9f35c6a3e4dc..68c43c896c6d 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/Microsoft.DotNet.ApiCompat.Shared.projitems
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/Microsoft.DotNet.ApiCompat.Shared.projitems
@@ -9,6 +9,7 @@
Microsoft.DotNet.ApiCompat
+
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidateAssemblies.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidateAssemblies.cs
index 502163d8974b..71edcfdd1b6b 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidateAssemblies.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidateAssemblies.cs
@@ -2,35 +2,35 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
+using System.Collections.Generic;
using System.IO;
using Jab;
-using Microsoft.DotNet.ApiCompatibility;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using Microsoft.DotNet.ApiCompatibility.Logging;
+using Microsoft.DotNet.ApiCompatibility.Rules;
using Microsoft.DotNet.ApiCompatibility.Runner;
namespace Microsoft.DotNet.ApiCompat
{
- [ServiceProvider]
- [Singleton(typeof(ISuppressionEngine), Factory = nameof(SuppressionEngineFactory))]
- [Singleton(typeof(ICompatibilityLogger), Factory = nameof(LogFactory))]
- [Singleton(typeof(IApiComparerFactory), typeof(ApiComparerFactory))]
- [Singleton(typeof(IAssemblySymbolLoaderFactory), typeof(AssemblySymbolLoaderFactory))]
- [Singleton(typeof(IMetadataStreamProvider), typeof(MetadataStreamProvider))]
- [Singleton(typeof(IApiCompatRunner), typeof(ApiCompatRunner))]
- internal partial class ValidateAssembliesServiceProvider
+ [ServiceProvider(RootServices = new[] { typeof(IEnumerable) })]
+ [Import(typeof(IApiCompatServiceProviderModule))]
+ internal partial class ValidateAssembliesServiceProvider : IApiCompatServiceProviderModule
{
public Func LogFactory { get; }
public Func SuppressionEngineFactory { get; }
+ public RuleFactory RuleFactory { get; }
+
public ValidateAssembliesServiceProvider(Func logFactory,
- Func suppressionEngineFactory)
+ Func suppressionEngineFactory,
+ RuleFactory ruleFactory)
{
// It's important to use GetService here instead of directly invoking the factory
- // to avoid two suppression engine being created.
+ // to avoid two instances being created when retrieving a singleton.
LogFactory = () => logFactory(GetService());
SuppressionEngineFactory = suppressionEngineFactory;
+ RuleFactory = ruleFactory;
}
}
@@ -51,10 +51,11 @@ public static void Run(Func logFactory
{
// Configure the suppression engine. Ignore the passed in suppression file if it should be generated and doesn't yet exist.
string? suppressionFileForEngine = generateSuppressionFile && !File.Exists(suppressionFile) ? null : suppressionFile;
- Func suppressionEngineFactory = () => new SuppressionEngine(suppressionFileForEngine, noWarn, generateSuppressionFile);
// Initialize the service provider
- ValidateAssembliesServiceProvider serviceProvider = new(logFactory, suppressionEngineFactory);
+ ValidateAssembliesServiceProvider serviceProvider = new(logFactory,
+ () => new SuppressionEngine(suppressionFileForEngine, noWarn, generateSuppressionFile),
+ new RuleFactory());
IApiCompatRunner apiCompatRunner = serviceProvider.GetService();
ApiCompatRunnerOptions apiCompatOptions = new(enableStrictMode);
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidatePackage.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidatePackage.cs
index 235eee7c9f98..273e5d60e747 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidatePackage.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/ValidatePackage.cs
@@ -6,37 +6,35 @@
using System.IO;
using Jab;
using Microsoft.DotNet.ApiCompatibility.Logging;
+using Microsoft.DotNet.ApiCompatibility.Rules;
using Microsoft.DotNet.ApiCompatibility.Runner;
using Microsoft.DotNet.PackageValidation;
using Microsoft.DotNet.PackageValidation.Validators;
-using Microsoft.DotNet.ApiCompatibility;
-using Microsoft.DotNet.ApiCompatibility.Abstractions;
namespace Microsoft.DotNet.ApiCompat
{
- [ServiceProvider]
- [Singleton(typeof(ISuppressionEngine), Factory = nameof(SuppressionEngineFactory))]
- [Singleton(typeof(ICompatibilityLogger), Factory = nameof(LogFactory))]
- [Singleton(typeof(IApiComparerFactory), typeof(ApiComparerFactory))]
- [Singleton(typeof(IAssemblySymbolLoaderFactory), typeof(AssemblySymbolLoaderFactory))]
- [Singleton(typeof(IMetadataStreamProvider), typeof(MetadataStreamProvider))]
- [Singleton(typeof(IApiCompatRunner), typeof(ApiCompatRunner))]
+ [ServiceProvider(RootServices = new[] { typeof(IEnumerable) })]
+ [Import(typeof(IApiCompatServiceProviderModule))]
[Singleton(typeof(CompatibleFrameworkInPackageValidator))]
[Singleton(typeof(CompatibleTfmValidator))]
[Singleton(typeof(BaselinePackageValidator))]
- internal partial class ValidatePackageServiceProvider
+ internal partial class ValidatePackageServiceProvider : IApiCompatServiceProviderModule
{
public Func LogFactory { get; }
public Func SuppressionEngineFactory { get; }
+ public RuleFactory RuleFactory { get; }
+
public ValidatePackageServiceProvider(Func logFactory,
- Func suppressionEngineFactory)
+ Func suppressionEngineFactory,
+ RuleFactory ruleFactory)
{
// It's important to use GetService here instead of directly invoking the factory
- // to avoid two suppression engine being created.
+ // to avoid two instances being created when retrieving a singleton.
LogFactory = () => logFactory(GetService());
SuppressionEngineFactory = suppressionEngineFactory;
+ RuleFactory = ruleFactory;
}
}
@@ -58,10 +56,11 @@ public static void Run(Func logFactory
{
// Configure the suppression engine. Ignore the passed in suppression file if it should be generated and doesn't yet exist.
string? suppressionFileForEngine = generateSuppressionFile && !File.Exists(suppressionFile) ? null : suppressionFile;
- Func suppressionEngineFactory = () => new SuppressionEngine(suppressionFileForEngine, noWarn, generateSuppressionFile);
// Initialize the service provider
- ValidatePackageServiceProvider serviceProvider = new(logFactory, suppressionEngineFactory);
+ ValidatePackageServiceProvider serviceProvider = new(logFactory,
+ () => new SuppressionEngine(suppressionFileForEngine, noWarn, generateSuppressionFile),
+ new RuleFactory());
// If a runtime graph is provided, parse and use it for asset selection during the in-memory package construction.
if (runtimeGraph != null)
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/CompatDifference.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/CompatDifference.cs
index ae843522c4f0..4825c7fbb717 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/CompatDifference.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/CompatDifference.cs
@@ -10,27 +10,21 @@ namespace Microsoft.DotNet.ApiCompatibility.Abstractions
///
/// Class representing a difference of compatibility, containing detailed information about it.
///
- public class CompatDifference : IDiagnostic, IEquatable
+ public readonly struct CompatDifference : IDiagnostic, IEquatable
{
- ///
- /// The Diagnostic ID for this difference.
- ///
- public string DiagnosticId { get; }
+ ///
+ public readonly string DiagnosticId { get; }
///
/// The .
///
- public DifferenceType Type { get; }
+ public readonly DifferenceType Type { get; }
- ///
- /// A diagnostic message for the difference.
- ///
- public virtual string Message { get; }
+ ///
+ public readonly string Message { get; }
- ///
- /// A unique ID in order to identify the API that the difference was raised for.
- ///
- public string? ReferenceId { get; }
+ ///
+ public readonly string? ReferenceId { get; }
///
/// Instantiate a new object representing the compatibility difference.
@@ -65,13 +59,16 @@ public CompatDifference(string diagnosticId, string message, DifferenceType type
/// describing the difference.
public override string ToString() => $"{DiagnosticId} : {Message}";
- public bool Equals(CompatDifference? other) => other != null &&
+ ///
+ public bool Equals(CompatDifference other) =>
DiagnosticId.Equals(other.DiagnosticId, StringComparison.InvariantCultureIgnoreCase) &&
Type.Equals(other.Type) &&
string.Equals(ReferenceId, other.ReferenceId, StringComparison.InvariantCultureIgnoreCase);
+ ///
public override bool Equals(object? obj) => obj is CompatDifference difference && Equals(difference);
+ ///
public override int GetHashCode()
{
int hashCode = 1447485498;
@@ -84,5 +81,11 @@ public override int GetHashCode()
return hashCode;
}
+
+ ///
+ public static bool operator ==(CompatDifference left, CompatDifference right) => left.Equals(right);
+
+ ///
+ public static bool operator !=(CompatDifference left, CompatDifference right) => !(left == right);
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/ElementContainer.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/ElementContainer.cs
index c303ae7d3dd9..729061db693a 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/ElementContainer.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/ElementContainer.cs
@@ -14,12 +14,12 @@ public class ElementContainer where T : ISymbol
///
/// The element that the container is holding.
///
- public T Element { get; private set; }
+ public readonly T Element;
///
/// The metadata associated to the element.
///
- public MetadataInformation MetadataInformation { get; private set; }
+ public readonly MetadataInformation MetadataInformation;
///
/// Instantiates a new object with the and used.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IDiagnostic.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IDiagnostic.cs
index 1dfc53c62687..6dece78f6ffe 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IDiagnostic.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IDiagnostic.cs
@@ -14,13 +14,13 @@ public interface IDiagnostic
string DiagnosticId { get; }
///
- /// String representing the ID for the object that the diagnostic was created for.
+ /// A diagnostic message for the difference.
///
- string? ReferenceId { get; }
+ string Message { get; }
///
- /// String describing the diagnostic.
+ /// A unique ID in order to identify the API that the difference was raised for.
///
- string Message { get; }
+ string? ReferenceId { get; }
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MapperVisitor.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MapperVisitor.cs
deleted file mode 100644
index f046666faa1e..000000000000
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MapperVisitor.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) .NET Foundation and contributors. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-namespace Microsoft.DotNet.ApiCompatibility.Abstractions
-{
- ///
- /// Class that implements a visitor pattern to visit the tree for a given mapper.
- ///
- public class MapperVisitor
- {
- ///
- /// Visits the tree for the given .
- ///
- /// Underlying type for the objects that the mapper holds.
- /// to visit.
- public void Visit(ElementMapper mapper)
- {
- if (mapper is AssemblySetMapper assemblySetMapper)
- {
- Visit(assemblySetMapper);
- }
- else if (mapper is AssemblyMapper assemblyMapper)
- {
- Visit(assemblyMapper);
- }
- else if (mapper is NamespaceMapper nsMapper)
- {
- Visit(nsMapper);
- }
- else if (mapper is TypeMapper typeMapper)
- {
- Visit(typeMapper);
- }
- else if (mapper is MemberMapper memberMapper)
- {
- Visit(memberMapper);
- }
- }
-
- ///
- /// Visits the and visits each in the mapper.
- ///
- /// The to visit.
- public virtual void Visit(AssemblySetMapper mapper)
- {
- foreach (AssemblyMapper assembly in mapper.GetAssemblies())
- {
- Visit(assembly);
- }
- }
-
- ///
- /// Visits the and visits each in the mapper.
- ///
- /// The to visit.
- public virtual void Visit(AssemblyMapper mapper)
- {
- foreach (NamespaceMapper nsMapper in mapper.GetNamespaces())
- {
- Visit(nsMapper);
- }
- }
-
- ///
- /// Visits the and visits each in the mapper.
- ///
- /// The to visit.
- public virtual void Visit(NamespaceMapper mapper)
- {
- foreach (TypeMapper type in mapper.GetTypes())
- {
- Visit(type);
- }
- }
-
- ///
- /// Visits the and visits the nested types and members in the mapper.
- ///
- /// The to visit.
- public virtual void Visit(TypeMapper mapper)
- {
- foreach (TypeMapper type in mapper.GetNestedTypes())
- {
- Visit(type);
- }
-
- foreach (MemberMapper member in mapper.GetMembers())
- {
- Visit(member);
- }
- }
-
- ///
- /// Visits the .
- ///
- /// The to visit.
- public virtual void Visit(MemberMapper mapper) { }
- }
-}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblyMapper.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblyMapper.cs
index e36c8de89210..a1cd6bf78c41 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblyMapper.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblyMapper.cs
@@ -1,29 +1,49 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable disable
-
-using Microsoft.CodeAnalysis;
using System.Collections.Generic;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
///
- /// Object that represents a mapping between two objects.
+ /// Object that represents a mapping between multiple objects.
/// This also holds a list of to represent the mapping of namespaces in between
/// and .
///
- public class AssemblyMapper : ElementMapper
+ public class AssemblyMapper : ElementMapper>
{
- private Dictionary _namespaces;
+ private Dictionary? _namespaces;
+ private readonly List[] _assemblyLoadErrors;
+
+ ///
+ /// The containing assembly set of this assembly. Null if the assembly is not part of a set.
+ ///
+ public AssemblySetMapper? ContainingAssemblySet { get; }
+
+ ///
+ /// Gets the assembly load errors that happened when trying to follow type forwards.
+ ///
+ public IReadOnlyList> AssemblyLoadErrors => _assemblyLoadErrors;
///
/// Instantiates an object with the provided .
///
/// The settings used to diff the elements in the mapper.
/// The number of elements in the right set to compare.
- public AssemblyMapper(ComparingSettings settings, int rightSetSize = 1)
- : base(settings, rightSetSize) { }
+ /// The containing assembly set. Null, if the assembly isn't part of a set.
+ public AssemblyMapper(IRuleRunner ruleRunner,
+ MapperSettings settings = default,
+ int rightSetSize = 1,
+ AssemblySetMapper? containingAssemblySet = null)
+ : base(ruleRunner, settings, rightSetSize)
+ {
+ ContainingAssemblySet = containingAssemblySet;
+ _assemblyLoadErrors = new List[rightSetSize];
+ for (int i = 0; i < rightSetSize; i++)
+ _assemblyLoadErrors[i] = new List();
+ }
///
/// Gets the mappers for the namespaces contained in and
@@ -36,33 +56,27 @@ public IEnumerable GetNamespaces()
_namespaces = new Dictionary(Settings.EqualityComparer);
AddOrCreateMappers(Left, ElementSide.Left);
- if (Right.Length == 1)
+ for (int i = 0; i < Right.Length; i++)
{
- AddOrCreateMappers(Right[0], ElementSide.Right);
- }
- else
- {
- for (int i = 0; i < Right.Length; i++)
- {
- AddOrCreateMappers(Right[i], ElementSide.Right, i);
- }
+ AddOrCreateMappers(Right[i], ElementSide.Right, i);
}
- void AddOrCreateMappers(IAssemblySymbol symbol, ElementSide side, int setIndex = 0)
+ void AddOrCreateMappers(ElementContainer? assemblyContainer, ElementSide side, int setIndex = 0)
{
- if (symbol == null)
+ // Silently return if the element hasn't been added yet.
+ if (assemblyContainer == null)
{
return;
}
- Dictionary> typeForwards = ResolveTypeForwards(symbol, Settings.EqualityComparer, setIndex);
+ Dictionary> typeForwards = ResolveTypeForwards(assemblyContainer.Element, Settings.EqualityComparer, setIndex);
Stack stack = new();
- stack.Push(symbol.GlobalNamespace);
+ stack.Push(assemblyContainer.Element.GlobalNamespace);
while (stack.Count > 0)
{
INamespaceSymbol nsSymbol = stack.Pop();
- bool hasTypeForwards = typeForwards.TryGetValue(nsSymbol, out List types);
+ bool hasTypeForwards = typeForwards.TryGetValue(nsSymbol, out List? types);
if (hasTypeForwards || nsSymbol.GetTypeMembers().Length > 0)
{
NamespaceMapper mapper = AddMapper(nsSymbol);
@@ -93,9 +107,9 @@ void AddOrCreateMappers(IAssemblySymbol symbol, ElementSide side, int setIndex =
NamespaceMapper AddMapper(INamespaceSymbol ns, bool checkIfExists = false, bool typeforwardsOnly = false)
{
- if (!_namespaces.TryGetValue(ns, out NamespaceMapper mapper))
+ if (!_namespaces.TryGetValue(ns, out NamespaceMapper? mapper))
{
- mapper = new NamespaceMapper(Settings, Right.Length, typeforwardsOnly: typeforwardsOnly);
+ mapper = new NamespaceMapper(RuleRunner, this, Settings, Right.Length, typeforwardsOnly: typeforwardsOnly);
_namespaces.Add(ns, mapper);
}
else if (checkIfExists && mapper.GetElement(side, setIndex) != null)
@@ -115,7 +129,7 @@ Dictionary> ResolveTypeForwards(IAssemb
{
if (symbol.TypeKind != TypeKind.Error)
{
- if (!typeForwards.TryGetValue(symbol.ContainingNamespace, out List types))
+ if (!typeForwards.TryGetValue(symbol.ContainingNamespace, out List? types))
{
types = new List();
typeForwards.Add(symbol.ContainingNamespace, types);
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblySetMapper.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblySetMapper.cs
index aa7fd752bf8e..fa1efbdd6c37 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblySetMapper.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/AssemblySetMapper.cs
@@ -1,27 +1,28 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable disable
-
-using Microsoft.CodeAnalysis;
using System.Collections.Generic;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
///
/// Object that represents a mapping between two lists of .
///
- public class AssemblySetMapper : ElementMapper>
+ public class AssemblySetMapper : ElementMapper>>
{
- private Dictionary _assemblies;
+ private Dictionary? _assemblies;
///
/// Instantiates an object with the provided .
///
/// The settings used to diff the elements in the mapper.
/// The number of elements in the right set to compare.
- public AssemblySetMapper(ComparingSettings settings, int rightSetSize = 1)
- : base(settings, rightSetSize) { }
+ public AssemblySetMapper(IRuleRunner ruleRunner,
+ MapperSettings settings = default,
+ int rightSetSize = 1)
+ : base(ruleRunner, settings, rightSetSize) { }
///
/// Gets the assembly mappers built from the provided lists of .
@@ -33,34 +34,28 @@ public IEnumerable GetAssemblies()
_assemblies = new Dictionary(Settings.EqualityComparer);
AddOrCreateMappers(Left, ElementSide.Left);
- if (Right.Length == 1)
+ for (int i = 0; i < Right.Length; i++)
{
- AddOrCreateMappers(Right[0], ElementSide.Right);
- }
- else
- {
- for (int i = 0; i < Right.Length; i++)
- {
- AddOrCreateMappers(Right[i], ElementSide.Right, i);
- }
+ AddOrCreateMappers(Right[i], ElementSide.Right, i);
}
- void AddOrCreateMappers(IEnumerable symbols, ElementSide side, int setIndex = 0)
+ void AddOrCreateMappers(IEnumerable>? assemblyContainers, ElementSide side, int setIndex = 0)
{
- if (symbols == null)
+ // Silently return if the element hasn't been added yet.
+ if (assemblyContainers == null)
{
return;
}
- foreach (IAssemblySymbol assembly in symbols)
+ foreach (ElementContainer assemblyContainer in assemblyContainers)
{
- if (!_assemblies.TryGetValue(assembly, out AssemblyMapper mapper))
+ if (!_assemblies.TryGetValue(assemblyContainer.Element, out AssemblyMapper? mapper))
{
- mapper = new AssemblyMapper(Settings, Right.Length);
- _assemblies.Add(assembly, mapper);
+ mapper = new AssemblyMapper(RuleRunner, Settings, Right.Length, this);
+ _assemblies.Add(assemblyContainer.Element, mapper);
}
- mapper.AddElement(assembly, side, setIndex);
+ mapper.AddElement(assemblyContainer, side, setIndex);
}
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/ElementMapper.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/ElementMapper.cs
index 51f90826844c..99b42fda3cd1 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/ElementMapper.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/ElementMapper.cs
@@ -1,67 +1,63 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable disable
-
using System;
using System.Collections.Generic;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
///
/// Class that represents a mapping in between two objects of type .
///
- public class ElementMapper
+ public abstract class ElementMapper
{
- private IReadOnlyList> _differences;
- protected IList[] _assemblyLoadErrors;
+ private IReadOnlyList>? _differences;
///
/// Property representing the Left hand side of the mapping.
///
- public T Left { get; private set; }
+ public T? Left { get; private set; }
///
/// Property representing the Right hand side element(s) of the mapping.
///
- public T[] Right { get; private set; }
+ public T?[] Right { get; private set; }
+
+ ///
+ /// The used to diff and .
+ ///
+ public MapperSettings Settings { get; }
///
- /// The used to diff and .
+ /// The rule runner to perform api comparison checks.
///
- public ComparingSettings Settings { get; internal set; }
+ protected IRuleRunner RuleRunner { get; }
///
/// Instantiates an object with the provided .
///
/// The settings used to diff the elements in the mapper.
/// The number of elements in the right set to compare.
- public ElementMapper(ComparingSettings settings, int rightSetSize)
+ public ElementMapper(IRuleRunner ruleRunner,
+ MapperSettings settings = default,
+ int rightSetSize = 1)
{
- if (rightSetSize <= 0)
+ if (rightSetSize < 1)
throw new ArgumentOutOfRangeException(nameof(rightSetSize), Resources.ShouldBeGreaterThanZero);
- Settings = settings ?? throw new ArgumentNullException(nameof(settings));
+ RuleRunner = ruleRunner;
+ Settings = settings;
Right = new T[rightSetSize];
- _assemblyLoadErrors = new IList[rightSetSize];
- for (int i = 0; i < rightSetSize; i++)
- _assemblyLoadErrors[i] = new List();
}
- ///
- /// Adds an element to the given using the index 0 for .
- ///
- /// The element to add.
- /// Value representing the side of the mapping.
- public virtual void AddElement(T element, ElementSide side) => AddElement(element, side, 0);
-
///
/// Adds an element to the mapping given the and the .
///
/// The element to add to the mapping.
/// Value representing the side of the mapping.
/// Value representing the index the element is added. Only used when adding to .
- public virtual void AddElement(T element, ElementSide side, int setIndex)
+ public virtual void AddElement(T element, ElementSide side, int setIndex = 0)
{
if (side == ElementSide.Left)
{
@@ -77,23 +73,12 @@ public virtual void AddElement(T element, ElementSide side, int setIndex)
}
///
- /// Runs the rules found by the rule driver on the element mapper and returns a list of differences.
+ /// Returns the element from the specified and index.
///
- /// A list containing the list of differences for each possible combination of
- /// (, ).
- /// One list of per the number of right elements that the contains.
- public IReadOnlyList> GetDifferences()
- {
- return _differences ??= Settings.RuleRunnerFactory.GetRuleRunner().Run(this);
- }
-
- ///
- /// Gets the assembly load errors that happened when trying to follow type forwards.
- ///
- /// A list containing the assembly load errors that ocurred when following type forwards.
- public IList[] GetAssemblyLoadErrors() => _assemblyLoadErrors;
-
- internal T GetElement(ElementSide side, int setIndex)
+ /// Value representing the side of the mapping.
+ /// Value representing the index the element is retrieved. Only used when adding to .
+ ///
+ public T? GetElement(ElementSide side, int setIndex)
{
if (side == ElementSide.Left)
{
@@ -102,5 +87,16 @@ internal T GetElement(ElementSide side, int setIndex)
return Right[setIndex];
}
+
+ ///
+ /// Runs the rules found by the rule driver on the element mapper and returns a list of differences.
+ ///
+ /// A list containing the list of differences for each possible combination of
+ /// (, ).
+ /// One list of per the number of right elements that the contains.
+ public IReadOnlyList> GetDifferences()
+ {
+ return _differences ??= RuleRunner.Run(this);
+ }
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/MemberMapper.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/MemberMapper.cs
index da3dd49bbb45..53864e2729c3 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/MemberMapper.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/MemberMapper.cs
@@ -1,9 +1,8 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable disable
-
using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
@@ -12,19 +11,25 @@ namespace Microsoft.DotNet.ApiCompatibility.Abstractions
///
public class MemberMapper : ElementMapper
{
+ ///
+ /// The containg type of this member.
+ ///
+ public TypeMapper ContainingType { get; }
+
///
/// Instantiates an object with the provided .
///
/// The settings used to diff the elements in the mapper.
/// The number of elements in the right set to compare.
- public MemberMapper(ComparingSettings settings, TypeMapper containingType, int rightSetSize = 1)
- : base(settings, rightSetSize)
+ public MemberMapper(IRuleRunner ruleRunner,
+ TypeMapper containingType,
+ MapperSettings settings = default,
+ int rightSetSize = 1)
+ : base(ruleRunner, settings, rightSetSize)
{
ContainingType = containingType;
}
- internal TypeMapper ContainingType { get; }
-
// If we got to this point it means that ContainingType.Left is not null.
// Because of that we can only check ContainingType.Right.
internal bool ShouldDiffElement(int rightIndex) =>
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/NamespaceMapper.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/NamespaceMapper.cs
index 4b0b79d0ed9e..b54d3730e07b 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/NamespaceMapper.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/NamespaceMapper.cs
@@ -1,11 +1,9 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable disable
-
-using Microsoft.CodeAnalysis;
-using System;
using System.Collections.Generic;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
@@ -16,19 +14,30 @@ namespace Microsoft.DotNet.ApiCompatibility.Abstractions
///
public class NamespaceMapper : ElementMapper
{
- private Dictionary _types;
+ private readonly Dictionary _types;
private bool _expandedTree = false;
private readonly bool _typeforwardsOnly;
+ ///
+ /// The containing assembly of this namespace.
+ ///
+ public AssemblyMapper ContainingAssembly { get; }
+
///
/// Instantiates an object with the provided .
///
/// The settings used to diff the elements in the mapper.
/// The number of elements in the right set to compare.
/// Indicates if should only return typeforwards.
- public NamespaceMapper(ComparingSettings settings, int rightSetSize = 1, bool typeforwardsOnly = false)
- : base(settings, rightSetSize)
+ public NamespaceMapper(IRuleRunner ruleRunner,
+ AssemblyMapper containingAssembly,
+ MapperSettings settings = default,
+ int rightSetSize = 1,
+ bool typeforwardsOnly = false)
+ : base(ruleRunner, settings, rightSetSize)
{
+ ContainingAssembly = containingAssembly;
+ _types = new Dictionary(Settings.EqualityComparer);
_typeforwardsOnly = typeforwardsOnly;
}
@@ -40,8 +49,6 @@ public IEnumerable GetTypes()
{
if (!_expandedTree)
{
- EnsureTypesInitialized();
-
// if the typeforwardsOnly flag is specified it means this namespace is already
// populated with the resolved typeforwards by the assembly mapper and that we
// didn't find this namespace in the initial assembly. So we avoid getting the types
@@ -50,17 +57,9 @@ public IEnumerable GetTypes()
if (!_typeforwardsOnly)
{
AddOrCreateMappers(Left, ElementSide.Left);
-
- if (Right.Length == 1)
- {
- AddOrCreateMappers(Right[0], ElementSide.Right);
- }
- else
+ for (int i = 0; i < Right.Length; i++)
{
- for (int i = 0; i < Right.Length; i++)
- {
- AddOrCreateMappers(Right[i], ElementSide.Right, i);
- }
+ AddOrCreateMappers(Right[i], ElementSide.Right, i);
}
}
@@ -76,19 +75,12 @@ public IEnumerable GetTypes()
/// List containing the that represents the forwarded types.
/// Side to add the forwarded types into, 0 (Left) or 1 (Right).
/// Value representing the index on the set of elements corresponding to the compared side.
- public void AddForwardedTypes(IEnumerable forwardedTypes, ElementSide side, int setIndex)
+ public void AddForwardedTypes(IEnumerable? forwardedTypes, ElementSide side, int setIndex)
{
- EnsureTypesInitialized();
AddOrCreateMappers(forwardedTypes, side, setIndex);
}
- private void EnsureTypesInitialized()
- {
- if (_types == null)
- _types = new Dictionary(Settings.EqualityComparer);
- }
-
- private void AddOrCreateMappers(INamespaceSymbol symbol, ElementSide side, int setIndex = 0)
+ private void AddOrCreateMappers(INamespaceSymbol? symbol, ElementSide side, int setIndex = 0)
{
if (symbol == null)
{
@@ -98,8 +90,9 @@ private void AddOrCreateMappers(INamespaceSymbol symbol, ElementSide side, int s
AddOrCreateMappers(symbol.GetTypeMembers(), side, setIndex);
}
- private void AddOrCreateMappers(IEnumerable types, ElementSide side, int setIndex)
+ private void AddOrCreateMappers(IEnumerable? types, ElementSide side, int setIndex)
{
+ // Silently return if the element hasn't been added yet.
if (types == null)
return;
@@ -107,9 +100,9 @@ private void AddOrCreateMappers(IEnumerable types, ElementSide side
{
if (Settings.Filter.Include(type))
{
- if (!_types.TryGetValue(type, out TypeMapper mapper))
+ if (!_types.TryGetValue(type, out TypeMapper? mapper))
{
- mapper = new TypeMapper(Settings, null, Right.Length);
+ mapper = new TypeMapper(RuleRunner, this, Settings, null, Right.Length);
_types.Add(type, mapper);
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/TypeMapper.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/TypeMapper.cs
index 30504a5dcc90..e9023772ad3b 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/TypeMapper.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/Mappers/TypeMapper.cs
@@ -1,13 +1,11 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable disable
-
-using Microsoft.CodeAnalysis;
-using Microsoft.DotNet.ApiCompatibility.Extensions;
-using System;
using System.Collections.Generic;
using System.Diagnostics;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Extensions;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Abstractions
{
@@ -18,31 +16,45 @@ namespace Microsoft.DotNet.ApiCompatibility.Abstractions
///
public class TypeMapper : ElementMapper
{
- private readonly TypeMapper _containingType;
- private Dictionary _nestedTypes;
- private Dictionary _members;
+ private Dictionary? _nestedTypes;
+ private Dictionary? _members;
+
+ ///
+ /// The containg namespace of this type.
+ ///
+ public NamespaceMapper ContainingNamespace { get; }
+
+ ///
+ /// The containing type of this type. Null if the type isn't nested.
+ ///
+ internal TypeMapper? ContainingType { get; }
///
/// Instantiates an object with the provided .
///
/// The settings used to diff the elements in the mapper.
/// The number of elements in the right set to compare.
- public TypeMapper(ComparingSettings settings, TypeMapper containingType = null, int rightSetSize = 1)
- : base(settings, rightSetSize)
+ public TypeMapper(IRuleRunner ruleRunner,
+ NamespaceMapper containingNamespace,
+ MapperSettings settings = default,
+ TypeMapper? containingType = null,
+ int rightSetSize = 1)
+ : base(ruleRunner, settings, rightSetSize)
{
- _containingType = containingType;
+ ContainingNamespace = containingNamespace;
+ ContainingType = containingType;
}
internal bool ShouldDiffElement(int rightIndex)
{
- if (IsNested)
+ if (ContainingType != null)
{
- Debug.Assert(_containingType.ShouldDiffMembers);
+ Debug.Assert(ContainingType.ShouldDiffMembers);
// This should only be called at a point where containingType.ShouldDiffMembers is true
// So that means that containingType.Left is not null and we don't need to check.
// If containingType.Right only contains one element, we can assume it is not null.
- return _containingType.Right.Length == 1 || _containingType.Right[rightIndex] != null;
+ return ContainingType.Right.Length == 1 || ContainingType.Right[rightIndex] != null;
}
return true;
@@ -73,11 +85,6 @@ public bool ShouldDiffMembers
}
}
- ///
- /// Indicates whether a type is nested or not.
- ///
- public bool IsNested => _containingType != null;
-
///
/// Gets the nested types within the mapped types.
///
@@ -89,21 +96,14 @@ public IEnumerable GetNestedTypes()
_nestedTypes = new Dictionary(Settings.EqualityComparer);
AddOrCreateMappers(Left, ElementSide.Left);
-
- if (Right.Length == 1)
- {
- AddOrCreateMappers(Right[0], ElementSide.Right);
- }
- else
+ for (int i = 0; i < Right.Length; i++)
{
- for (int i = 0; i < Right.Length; i++)
- {
- AddOrCreateMappers(Right[i], ElementSide.Right, i);
- }
+ AddOrCreateMappers(Right[i], ElementSide.Right, i);
}
- void AddOrCreateMappers(ITypeSymbol symbol, ElementSide side, int setIndex = 0)
+ void AddOrCreateMappers(ITypeSymbol? symbol, ElementSide side, int setIndex = 0)
{
+ // Silently return if the element hasn't been added yet.
if (symbol == null)
{
return;
@@ -113,9 +113,9 @@ void AddOrCreateMappers(ITypeSymbol symbol, ElementSide side, int setIndex = 0)
{
if (Settings.Filter.Include(nestedType))
{
- if (!_nestedTypes.TryGetValue(nestedType, out TypeMapper mapper))
+ if (!_nestedTypes.TryGetValue(nestedType, out TypeMapper? mapper))
{
- mapper = new TypeMapper(Settings, this, Right.Length);
+ mapper = new TypeMapper(RuleRunner, ContainingNamespace, Settings, this, Right.Length);
_nestedTypes.Add(nestedType, mapper);
}
mapper.AddElement(nestedType, side, setIndex);
@@ -138,21 +138,14 @@ public IEnumerable GetMembers()
_members = new Dictionary(Settings.EqualityComparer);
AddOrCreateMappers(Left, ElementSide.Left);
-
- if (Right.Length == 1)
- {
- AddOrCreateMappers(Right[0], ElementSide.Right);
- }
- else
+ for (int i = 0; i < Right.Length; i++)
{
- for (int i = 0; i < Right.Length; i++)
- {
- AddOrCreateMappers(Right[i], ElementSide.Right, i);
- }
+ AddOrCreateMappers(Right[i], ElementSide.Right, i);
}
- void AddOrCreateMappers(ITypeSymbol symbol, ElementSide side, int setIndex = 0)
+ void AddOrCreateMappers(ITypeSymbol? symbol, ElementSide side, int setIndex = 0)
{
+ // Silently return if the element hasn't been added yet.
if (symbol == null)
{
return;
@@ -166,9 +159,9 @@ void AddOrCreateMappers(ITypeSymbol symbol, ElementSide side, int setIndex = 0)
// we would compare __value vs null and emit some warnings.
if (Settings.Filter.Include(member) && member is not ITypeSymbol && !IsSpecialEnumField(member))
{
- if (!_members.TryGetValue(member, out MemberMapper mapper))
+ if (!_members.TryGetValue(member, out MemberMapper? mapper))
{
- mapper = new MemberMapper(Settings, this, Right.Length);
+ mapper = new MemberMapper(RuleRunner, this, Settings, Right.Length);
_members.Add(member, mapper);
}
mapper.AddElement(member, side, setIndex);
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MetadataInformation.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MetadataInformation.cs
index ab8ec28fb7e1..206f3be786b2 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MetadataInformation.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/MetadataInformation.cs
@@ -62,10 +62,7 @@ public override int GetHashCode()
int hashCode = 1447485498;
hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(AssemblyName);
hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(AssemblyId);
- if (FullPath != null)
- {
- hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(FullPath);
- }
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(FullPath);
return hashCode;
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparer.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparer.cs
index edf50320551f..e91725daca35 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparer.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparer.cs
@@ -1,11 +1,11 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using Microsoft.CodeAnalysis;
-using Microsoft.DotNet.ApiCompatibility.Abstractions;
using System;
using System.Collections.Generic;
-using System.Linq;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility
{
@@ -14,101 +14,106 @@ namespace Microsoft.DotNet.ApiCompatibility
///
public class ApiComparer : IApiComparer
{
- ///
- public bool IncludeInternalSymbols { get; set; }
+ private readonly IDifferenceVisitorFactory _differenceVisitorFactory;
+ private readonly IElementMapperFactory _elementMapperFactory;
///
- public bool StrictMode { get; set; }
+ public ApiComparerSettings Settings { get; }
+
+ public ApiComparer(IRuleFactory ruleFactory,
+ ApiComparerSettings? settings = null,
+ IDifferenceVisitorFactory? differenceVisitorFactory = null,
+ IRuleContext? ruleContext = null,
+ Func? ruleRunnerFactory = null,
+ Func? elementMapperFactory = null)
+ {
+ ruleContext ??= new RuleContext();
+ IRuleRunner ruleRunner = ruleRunnerFactory?.Invoke(ruleFactory, ruleContext) ?? new RuleRunner(ruleFactory, ruleContext);
+
+ _differenceVisitorFactory = differenceVisitorFactory ?? new DifferenceVisitorFactory();
+ _elementMapperFactory = elementMapperFactory?.Invoke(ruleRunner) ?? new ElementMapperFactory(ruleRunner);
+ Settings = settings ?? new ApiComparerSettings();
+
+ ruleRunner.InitializeRules(Settings.ToRuleSettings());
+ }
///
- public bool WarnOnMissingReferences { get; set; }
+ public IEnumerable GetDifferences(IAssemblySymbol left,
+ IAssemblySymbol right)
+ {
+ return GetDifferences(new ElementContainer(left, new MetadataInformation()),
+ new ElementContainer(right, new MetadataInformation()));
+ }
///
- public Func? GetComparingSettings { get; set; }
+ public IEnumerable GetDifferences(ElementContainer left,
+ ElementContainer right)
+ {
+ var mapper = _elementMapperFactory.CreateAssemblyMapper(Settings.ToMapperSettings());
+ mapper.AddElement(left, ElementSide.Left);
+ mapper.AddElement(right, ElementSide.Right);
+
+ IDifferenceVisitor visitor = _differenceVisitorFactory.Create();
+ visitor.Visit(mapper);
+
+ return visitor.DiagnosticCollections[0];
+ }
///
- public IEnumerable GetDifferences(IEnumerable left,
- IEnumerable right,
- string? leftName = null,
- string? rightName = null)
+ public IEnumerable GetDifferences(IEnumerable> left,
+ IEnumerable> right)
{
- AssemblySetMapper mapper = new(GetComparingSettingsCore(leftName, rightName != null ? new[] { rightName } : null));
+ var mapper = _elementMapperFactory.CreateAssemblySetMapper(Settings.ToMapperSettings());
mapper.AddElement(left, ElementSide.Left);
mapper.AddElement(right, ElementSide.Right);
- DifferenceVisitor visitor = new();
+ IDifferenceVisitor visitor = _differenceVisitorFactory.Create();
visitor.Visit(mapper);
- return visitor.DiagnosticCollections.First();
+
+ return visitor.DiagnosticCollections[0];
}
///
- public IEnumerable GetDifferences(IAssemblySymbol left,
- IAssemblySymbol right,
- string? leftName = null,
- string? rightName = null)
+ public IEnumerable GetDifferences(IEnumerable left,
+ IEnumerable right)
{
- if (left == null)
+ List> transformedLeft = new();
+ foreach (IAssemblySymbol assemblySymbol in left)
{
- throw new ArgumentNullException(nameof(left));
+ transformedLeft.Add(new ElementContainer(assemblySymbol, new MetadataInformation()));
}
- if (right == null)
+ List> transformedRight = new();
+ foreach (IAssemblySymbol assemblySymbol in right)
{
- throw new ArgumentNullException(nameof(right));
+ transformedRight.Add(new ElementContainer(assemblySymbol, new MetadataInformation()));
}
- AssemblyMapper mapper = new(GetComparingSettingsCore(leftName, rightName != null ? new[] { rightName } : null));
- mapper.AddElement(left, ElementSide.Left);
- mapper.AddElement(right, ElementSide.Right);
-
- DifferenceVisitor visitor = new();
- visitor.Visit(mapper);
- return visitor.DiagnosticCollections.First();
+ return GetDifferences(transformedLeft, transformedRight);
}
///
public IEnumerable<(MetadataInformation left, MetadataInformation right, IEnumerable differences)> GetDifferences(ElementContainer left,
- IList> right)
+ IReadOnlyList> right)
{
int rightCount = right.Count;
- AssemblyMapper mapper = new(new ComparingSettings(), rightSetSize: rightCount);
- mapper.AddElement(left.Element, ElementSide.Left);
-
- string[] rightNames = new string[rightCount];
+ var mapper = _elementMapperFactory.CreateAssemblyMapper(Settings.ToMapperSettings(), rightCount);
+ mapper.AddElement(left, ElementSide.Left);
for (int i = 0; i < rightCount; i++)
{
- ElementContainer element = right[i];
- rightNames[i] = element.MetadataInformation.DisplayString;
- mapper.AddElement(element.Element, ElementSide.Right, i);
+ mapper.AddElement(right[i], ElementSide.Right, i);
}
- mapper.Settings = GetComparingSettingsCore(left.MetadataInformation.DisplayString, rightNames);
-
- DifferenceVisitor visitor = new(rightCount: rightCount);
+ IDifferenceVisitor visitor = _differenceVisitorFactory.Create(rightCount);
visitor.Visit(mapper);
- (MetadataInformation, MetadataInformation, IEnumerable)[] result = new(MetadataInformation, MetadataInformation, IEnumerable)[rightCount];
-
- int count = 0;
- foreach (IEnumerable collection in visitor.DiagnosticCollections)
+ var result = new(MetadataInformation, MetadataInformation, IEnumerable)[rightCount];
+ for (int i = 0; i < visitor.DiagnosticCollections.Count; i++)
{
- result[count] = (left.MetadataInformation, right[count].MetadataInformation, collection);
- count++;
+ result[i] = (left.MetadataInformation, right[i].MetadataInformation, visitor.DiagnosticCollections[i]);
}
return result;
}
-
- private ComparingSettings GetComparingSettingsCore(string? leftName, string[]? rightNames)
- {
- if (GetComparingSettings != null)
- return GetComparingSettings(leftName, rightNames);
-
- return new ComparingSettings(includeInternalSymbols: IncludeInternalSymbols,
- strictMode: StrictMode,
- leftName: leftName,
- rightNames: rightNames,
- warnOnMissingReferences: WarnOnMissingReferences);
- }
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerFactory.cs
index 4931df4df509..31c91dc202f9 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerFactory.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerFactory.cs
@@ -1,14 +1,56 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+using Microsoft.DotNet.ApiCompatibility.Rules;
+
namespace Microsoft.DotNet.ApiCompatibility
{
///
- /// Factory to create an ApiComparer
+ /// Factory to create an IApiComparer instance.
+ ///
+ public interface IApiComparerFactory
+ {
+ ///
+ /// Creates an IApiComparer with optionally provided api copmarison settings.
+ ///
+ /// Returns an ApiComparer instance
+ IApiComparer Create(ApiComparerSettings? settings = null);
+ }
+
+ ///
+ /// Factory to create an ApiComparer instance.
///
public sealed class ApiComparerFactory : IApiComparerFactory
{
+ private readonly IRuleFactory _ruleFactory;
+ private readonly IDifferenceVisitorFactory? _differenceVisitorFactory;
+ private readonly IRuleContext? _ruleContext;
+ private readonly Func? _ruleRunnerFactory;
+ private readonly Func? _elementMapperFactory;
+
+ public ApiComparerFactory(IRuleFactory ruleFactory,
+ IDifferenceVisitorFactory? differenceVisitorFactory = null,
+ IRuleContext? ruleContext = null,
+ Func? ruleRunnerFactory = null,
+ Func? elementMapperFactory = null)
+ {
+ _ruleFactory = ruleFactory;
+ _differenceVisitorFactory = differenceVisitorFactory;
+ _ruleContext = ruleContext;
+ _ruleRunnerFactory = ruleRunnerFactory;
+ _elementMapperFactory = elementMapperFactory;
+ }
+
///
- public IApiComparer Create() => new ApiComparer();
+ public IApiComparer Create(ApiComparerSettings? settings = null)
+ {
+ return new ApiComparer(_ruleFactory,
+ settings,
+ _differenceVisitorFactory,
+ _ruleContext,
+ _ruleRunnerFactory,
+ _elementMapperFactory);
+ }
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerSettings.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerSettings.cs
new file mode 100644
index 000000000000..248ff6ceffee
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ApiComparerSettings.cs
@@ -0,0 +1,57 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Rules;
+
+namespace Microsoft.DotNet.ApiCompatibility
+{
+ ///
+ /// Settings for an ApiComparer instance.
+ ///
+ public readonly struct ApiComparerSettings
+ {
+ ///
+ /// Flag indicating whether api comparison should be performed in strict mode.
+ /// If true, the behavior of some rules will change and some other rules will be
+ /// executed when getting the differences. This is useful when both sides's surface area
+ /// which are compared, should not differ.
+ ///
+ public readonly bool StrictMode;
+
+ ///
+ /// Determines if internal members should be validated.
+ ///
+ public readonly bool IncludeInternalSymbols;
+
+ ///
+ /// If true, references are available. Necessary to know for following type forwards.
+ ///
+ public readonly bool WithReferences;
+
+ public ApiComparerSettings(bool strictMode = false,
+ bool includeInternalSymbols = false,
+ bool withReferences = false,
+ IEqualityComparer? symbolComparer = null)
+ {
+ StrictMode = strictMode;
+ IncludeInternalSymbols = includeInternalSymbols;
+ WithReferences = withReferences;
+ }
+
+ ///
+ /// Transforms the api comparer settings to rule settings.
+ ///
+ /// Returns the transformed settings as rule settings.
+ public RuleSettings ToRuleSettings() =>
+ new(StrictMode, IncludeInternalSymbols, WithReferences);
+
+ ///
+ /// Transforms the api comparer settings to mapper settings.
+ ///
+ /// Returns the transformed settings as mapper settings.
+ public MapperSettings ToMapperSettings() =>
+ new(warnOnMissingReferences: WithReferences, includeInternalSymbols: IncludeInternalSymbols);
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitor.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitor.cs
index 490466e5776a..4c4f7a95cdfa 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitor.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitor.cs
@@ -1,19 +1,22 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using Microsoft.DotNet.ApiCompatibility.Abstractions;
using System;
using System.Collections.Generic;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
namespace Microsoft.DotNet.ApiCompatibility
{
///
/// The visitor that traverses the mappers' tree and gets it's differences in a .
///
- public class DifferenceVisitor : MapperVisitor
+ public class DifferenceVisitor : IDifferenceVisitor
{
private readonly HashSet[] _diagnostics;
+ ///
+ public IReadOnlyList> DiagnosticCollections => _diagnostics;
+
///
/// Instantiates the visitor with the desired settings.
///
@@ -26,69 +29,101 @@ public DifferenceVisitor(int rightCount = 1)
}
_diagnostics = new HashSet[rightCount];
-
for (int i = 0; i < rightCount; i++)
{
_diagnostics[i] = new HashSet();
}
}
- ///
- /// Visits an and adds it's differences to the .
- ///
- /// The mapper to visit.
- public override void Visit(AssemblyMapper assembly)
+ ///
+ public void Visit(ElementMapper mapper)
+ {
+ if (mapper is AssemblySetMapper assemblySetMapper)
+ {
+ Visit(assemblySetMapper);
+ }
+ else if (mapper is AssemblyMapper assemblyMapper)
+ {
+ Visit(assemblyMapper);
+ }
+ else if (mapper is NamespaceMapper nsMapper)
+ {
+ Visit(nsMapper);
+ }
+ else if (mapper is TypeMapper typeMapper)
+ {
+ Visit(typeMapper);
+ }
+ else if (mapper is MemberMapper memberMapper)
+ {
+ Visit(memberMapper);
+ }
+ }
+
+ ///
+ public void Visit(AssemblySetMapper mapper)
+ {
+ foreach (AssemblyMapper assembly in mapper.GetAssemblies())
+ {
+ Visit(assembly);
+ }
+ }
+
+ ///
+ public void Visit(AssemblyMapper assembly)
{
AddDifferences(assembly);
- base.Visit(assembly);
+
+ foreach (NamespaceMapper @namespace in assembly.GetNamespaces())
+ {
+ Visit(@namespace);
+ }
+
// After visiting the assembly, the assembly mapper will contain any assembly load errors that happened
// when trying to resolve typeforwarded types. If there were any, we add them to the diagnostic bag next.
- AddAssemblyLoadErrors(assembly);
+ AddToDiagnosticCollections(assembly.AssemblyLoadErrors);
}
- ///
- /// Visits an and adds it's differences to the .
- ///
- /// The mapper to visit.
- public override void Visit(TypeMapper type)
+ ///
+ public void Visit(NamespaceMapper @namespace)
+ {
+ foreach (TypeMapper type in @namespace.GetTypes())
+ {
+ Visit(type);
+ }
+ }
+
+ ///
+ public void Visit(TypeMapper type)
{
AddDifferences(type);
if (type.ShouldDiffMembers)
{
- base.Visit(type);
+ foreach (TypeMapper nestedType in type.GetNestedTypes())
+ {
+ Visit(nestedType);
+ }
+
+ foreach (MemberMapper member in type.GetMembers())
+ {
+ Visit(member);
+ }
}
}
- ///
- /// Visits an and adds it's differences to the .
- ///
- /// The mapper to visit.
- public override void Visit(MemberMapper member)
+ ///
+ public void Visit(MemberMapper member)
{
AddDifferences(member);
}
- ///
- /// A list of .
- /// One per element compared in the right hand side.
- ///
- public IEnumerable> DiagnosticCollections => _diagnostics;
-
private void AddDifferences(ElementMapper mapper)
{
IReadOnlyList> differences = mapper.GetDifferences();
-
AddToDiagnosticCollections(differences);
}
- private void AddAssemblyLoadErrors(ElementMapper mapper)
- {
- IReadOnlyList> assemblyLoadErrors = mapper.GetAssemblyLoadErrors();
-
- AddToDiagnosticCollections(assemblyLoadErrors);
- }
-
private void AddToDiagnosticCollections(IReadOnlyList> diagnosticsToAdd)
{
if (_diagnostics.Length != diagnosticsToAdd.Count)
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitorFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitorFactory.cs
new file mode 100644
index 000000000000..e561500e0c4c
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/DifferenceVisitorFactory.cs
@@ -0,0 +1,27 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.DotNet.ApiCompatibility
+{
+ ///
+ /// Factory to create an IDifferenceVisitor instance.
+ ///
+ public interface IDifferenceVisitorFactory
+ {
+ ///
+ /// Creates an IDifferenceVisitor with an optionally provided count of the right elements that are compared.
+ ///
+ /// The number of rights that are compared against a left.
+ ///
+ IDifferenceVisitor Create(int rightCount = 1);
+ }
+
+ ///
+ /// Factory to create an DifferenceVisitor instance.
+ ///
+ public sealed class DifferenceVisitorFactory : IDifferenceVisitorFactory
+ {
+ ///
+ public IDifferenceVisitor Create(int rightCount = 1) => new DifferenceVisitor(rightCount);
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ElementMapperFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ElementMapperFactory.cs
new file mode 100644
index 000000000000..a6de536c414b
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ElementMapperFactory.cs
@@ -0,0 +1,53 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
+using Microsoft.DotNet.ApiCompatibility.Rules;
+
+namespace Microsoft.DotNet.ApiCompatibility
+{
+ ///
+ /// Factory to create an IElementMapper instance.
+ ///
+ public interface IElementMapperFactory
+ {
+ ///
+ /// Creates an AssemblySetMapper instance with optional given mapper settings and the count of the rights that are compared.
+ ///
+ /// The mapper settings.
+ /// The number of rights that are compared.
+ /// Returns an AssemblySetMapper based on the given inputs.
+ ElementMapper>> CreateAssemblySetMapper(MapperSettings settings = default, int rightCount = 1);
+
+ ///
+ /// Creates an AssemblyMapper instance with optional given mapper assetings and the count of the rights that are compared.
+ ///
+ /// The mapper settings.
+ /// The number of rights that are compared.
+ /// Returns an AssemblyMapper based on the given inputs.
+ ElementMapper> CreateAssemblyMapper(MapperSettings settings = default, int rightCount = 1);
+ }
+
+ ///
+ /// Factory to create an ElementMapper instance.
+ ///
+ public sealed class ElementMapperFactory : IElementMapperFactory
+ {
+ private readonly IRuleRunner _ruleRunner;
+
+ public ElementMapperFactory(IRuleRunner ruleRunner)
+ {
+ _ruleRunner = ruleRunner;
+ }
+
+ ///
+ public ElementMapper>> CreateAssemblySetMapper(MapperSettings settings = default, int rightCount = 1) =>
+ new AssemblySetMapper(_ruleRunner, settings, rightCount);
+
+ ///
+ public ElementMapper> CreateAssemblyMapper(MapperSettings settings = default, int rightCount = 1) =>
+ new AssemblyMapper(_ruleRunner, settings, rightCount);
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparer.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparer.cs
index a34aabbfd3b6..298b653e30b7 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparer.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparer.cs
@@ -1,12 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#nullable enable
-
+using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
-using System;
-using System.Collections.Generic;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility
{
@@ -16,48 +14,45 @@ namespace Microsoft.DotNet.ApiCompatibility
public interface IApiComparer
{
///
- /// Flag indicating whether internal symbols should be included in the comparisons or not.
- ///
- bool IncludeInternalSymbols { get; set; }
-
- ///
- /// Flag indicating whether we should run on strict mode or not.
- /// If StrictMode is set, the behavior of some rules will change and some other rules will be
- /// executed when getting the differences. This is useful when you want both sides we are comparing
- /// to be strictly the same on their surface area.
+ /// to be used when creating the mapping and getting the differences.
///
- bool StrictMode { get; set; }
+ ApiComparerSettings Settings { get; }
///
- /// Flag indicating whether the ApiComparison will warn if there are missing references
+ /// Get's the differences when comparing a left assembly against a right based on the comparison settings.
+ /// It compares two symbols.
///
- bool WarnOnMissingReferences { get; set; }
+ /// Left assembly symbol to compare against.
+ /// Right assembly symbol to compare against.
+ /// List of found differences.
+ IEnumerable GetDifferences(IAssemblySymbol left, IAssemblySymbol right);
///
- /// Callback function to get the to be used when creating the settings to get the differences.
- /// The callback takes a string leftName and string[] rightNames parameters to indicate API Compat via the settings what the
- /// name for the left and right the user specified.
- /// This callback is called at the beginning of every overload.
+ /// Get's the differences when comparing a left assembly against a right based on the comparison settings.
+ /// It compares two symbols.
///
- Func? GetComparingSettings { get; set; }
+ /// Left assembly symbol including metadata to compare against.
+ /// Right assembly symbol including metadata to compare against.
+ /// List of found differences.
+ IEnumerable GetDifferences(ElementContainer left, ElementContainer right);
///
- /// Get's the differences when comparing Left vs Right based on the settings at the moment this method is called.
- /// It compares two lists of symbols.
+ /// Get's the differences when comparing a left assembly set against a right set based on the comparison settings.
+ /// It compares two symbol sets.
///
- /// Left symbols to compare against.
- /// Right symbols to compare against.
+ /// Left assembly symbols to compare against.
+ /// Right assembly symbols to compare against.
/// List of found differences.
- IEnumerable GetDifferences(IEnumerable left, IEnumerable right, string? leftName = null, string? rightName = null);
+ IEnumerable GetDifferences(IEnumerable left, IEnumerable right);
///
- /// Get's the differences when comparing Left vs Right based on the settings at the moment this method is called.
- /// It compares two symbols.
+ /// Get's the differences when comparing a left assembly set against a right set based on the comparison settings.
+ /// It compares two symbol sets.
///
- /// Left symbol to compare against.
- /// Right symbol to compare against.
+ /// Left assembly symbols including metadata to compare against.
+ /// Right assembly symbols including metadata to compare against.
/// List of found differences.
- IEnumerable GetDifferences(IAssemblySymbol left, IAssemblySymbol right, string? leftName = null, string? rightName = null);
+ IEnumerable GetDifferences(IEnumerable> left, IEnumerable> right);
///
/// Get the differences for all the combinations of against each
@@ -67,6 +62,6 @@ public interface IApiComparer
/// Return a list containing the (left, right) tuple and it's list of .
/// The returning list contains one element per (left, right) combination, which is the same length as .
///
- IEnumerable<(MetadataInformation left, MetadataInformation right, IEnumerable differences)> GetDifferences(ElementContainer left, IList> right);
+ IEnumerable<(MetadataInformation left, MetadataInformation right, IEnumerable differences)> GetDifferences(ElementContainer left, IReadOnlyList> right);
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparerFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparerFactory.cs
deleted file mode 100644
index 49ad58ee4068..000000000000
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IApiComparerFactory.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) .NET Foundation and contributors. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-namespace Microsoft.DotNet.ApiCompatibility
-{
- ///
- /// Factory to create an ApiComparer
- ///
- public interface IApiComparerFactory
- {
- ///
- /// Create an ApiComparer
- ///
- /// Returns an ApiComparer instance
- IApiComparer Create();
- }
-}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IDifferenceVisitor.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IDifferenceVisitor.cs
new file mode 100644
index 000000000000..f3a0b42c12f0
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/IDifferenceVisitor.cs
@@ -0,0 +1,57 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
+
+namespace Microsoft.DotNet.ApiCompatibility
+{
+ ///
+ /// The visitor that traverses the mappers' tree and gets it's differences in a .
+ ///
+ public interface IDifferenceVisitor
+ {
+ ///
+ /// A list of .
+ /// One per element compared in the right hand side.
+ ///
+ IReadOnlyList> DiagnosticCollections { get; }
+
+ ///
+ /// Visits the tree for the given .
+ ///
+ /// Underlying type for the objects that the mapper holds.
+ /// to visit.
+ void Visit(ElementMapper mapper);
+
+ ///
+ /// Visits the and visits each in the mapper.
+ ///
+ /// The to visit.
+ void Visit(AssemblySetMapper mapper);
+
+ ///
+ /// Visits an and adds it's differences to the .
+ ///
+ /// The mapper to visit.
+ void Visit(AssemblyMapper assembly);
+
+ ///
+ /// Visits the and visits each in the mapper.
+ ///
+ /// The to visit.
+ void Visit(NamespaceMapper @namespace);
+
+ ///
+ /// Visits an and adds it's differences to the .
+ ///
+ /// The mapper to visit.
+ void Visit(TypeMapper type);
+
+ ///
+ /// Visits an and adds it's differences to the .
+ ///
+ /// The mapper to visit.
+ void Visit(MemberMapper member);
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ComparingSettings.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/MapperSettings.cs
similarity index 55%
rename from src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ComparingSettings.cs
rename to src/ApiCompat/Microsoft.DotNet.ApiCompatibility/MapperSettings.cs
index 6ed2d051551d..1ada316017c6 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/ComparingSettings.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/MapperSettings.cs
@@ -1,56 +1,45 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
-using Microsoft.DotNet.ApiCompatibility.Rules;
-using System.Collections.Generic;
namespace Microsoft.DotNet.ApiCompatibility
{
///
/// Class that contains all the settings used to filter metadata, compare symbols and run rules.
///
- public class ComparingSettings
+ public readonly struct MapperSettings
{
- ///
- /// The factory to get the .
- ///
- public RuleRunnerFactory RuleRunnerFactory { get; }
-
///
/// The metadata filter to use when creating the .
///
- public ISymbolFilter Filter { get; }
+ public readonly ISymbolFilter Filter;
///
/// The comparer to map metadata.
///
- public IEqualityComparer EqualityComparer { get; }
+ public readonly IEqualityComparer EqualityComparer;
///
/// Indicates if we should warn on missing references.
///
- public bool WarnOnMissingReferences { get; }
+ public readonly bool WarnOnMissingReferences;
///
- /// Instantiate an object with the desired settings.
+ /// Instantiate an object with the desired comparison settings.
///
- /// The factory to create a
+ /// The rule runner.
/// The symbol filter.
/// The comparer to map metadata.
- public ComparingSettings(RuleRunnerFactory? ruleRunnerFactory = null,
- ISymbolFilter? filter = null,
+ public MapperSettings(ISymbolFilter? filter = null,
IEqualityComparer? equalityComparer = null,
- bool includeInternalSymbols = false,
- bool strictMode = false,
bool warnOnMissingReferences = false,
- string? leftName = null,
- string[]? rightNames = null)
+ bool includeInternalSymbols = false)
{
- Filter = filter ?? new SymbolAccessibilityBasedFilter(includeInternalSymbols: includeInternalSymbols);
+ Filter = filter ?? new SymbolAccessibilityBasedFilter(includeInternalSymbols);
EqualityComparer = equalityComparer ?? new DefaultSymbolsEqualityComparer();
- RuleRunnerFactory = ruleRunnerFactory ?? new RuleRunnerFactory(leftName, rightNames, EqualityComparer, includeInternalSymbols, strictMode, warnOnMissingReferences);
WarnOnMissingReferences = warnOnMissingReferences;
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj
index d875a6a5a43a..7b8569a72b51 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj
@@ -13,7 +13,6 @@
-
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/AssemblyIdentityMustMatch.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/AssemblyIdentityMustMatch.cs
index 4a538c6f81a8..bb93fe1f3999 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/AssemblyIdentityMustMatch.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/AssemblyIdentityMustMatch.cs
@@ -13,7 +13,7 @@ public class AssemblyIdentityMustMatch : IRule
{
private readonly RuleSettings _settings;
- public AssemblyIdentityMustMatch(RuleSettings settings, RuleRunnerContext context)
+ public AssemblyIdentityMustMatch(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnAssemblySymbolAction(RunOnAssemblySymbol);
@@ -23,13 +23,21 @@ private void RunOnAssemblySymbol(IAssemblySymbol? left, IAssemblySymbol? right,
{
if (left == null && right != null)
{
- differences.Add(new CompatDifference(DiagnosticIds.MatchingAssemblyDoesNotExist, string.Format(Resources.AssemblyNameDoesNotExist, leftName, right.Identity.Name), DifferenceType.Removed, right.Identity.GetDisplayName()));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.MatchingAssemblyDoesNotExist,
+ string.Format(Resources.AssemblyNameDoesNotExist, leftName, right.Identity.Name),
+ DifferenceType.Removed,
+ right.Identity.GetDisplayName()));
return;
}
if (left != null && right == null)
{
- differences.Add(new CompatDifference(DiagnosticIds.MatchingAssemblyDoesNotExist, string.Format(Resources.AssemblyNameDoesNotExist, rightName, left.Identity.Name), DifferenceType.Added, left.Identity.GetDisplayName()));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.MatchingAssemblyDoesNotExist,
+ string.Format(Resources.AssemblyNameDoesNotExist, rightName, left.Identity.Name),
+ DifferenceType.Added,
+ left.Identity.GetDisplayName()));
return;
}
@@ -49,21 +57,45 @@ private void RunOnAssemblySymbol(IAssemblySymbol? left, IAssemblySymbol? right,
if (leftAssemblyName != rightAssemblyName)
{
- differences.Add(CreateIdentityDifference(Resources.AssemblyNameDoesNotMatch, leftAssemblyName, rightAssemblyName, leftName, rightName, rightIdentity));
+ differences.Add(CreateIdentityDifference(
+ Resources.AssemblyNameDoesNotMatch,
+ leftAssemblyName,
+ rightAssemblyName,
+ leftName,
+ rightName,
+ rightIdentity));
}
if (leftAssemblyCulture != rightAssemblyCulture)
{
- differences.Add(CreateIdentityDifference(Resources.AssembyCultureDoesNotMatch, leftAssemblyCulture, rightAssemblyCulture, leftName, rightName, rightIdentity));
+ differences.Add(CreateIdentityDifference(
+ Resources.AssembyCultureDoesNotMatch,
+ leftAssemblyCulture,
+ rightAssemblyCulture,
+ leftName,
+ rightName,
+ rightIdentity));
}
if (rightAssemblyVersion < leftAssemblyVersion)
{
- differences.Add(CreateIdentityDifference(Resources.AssembyVersionIsNotCompatible, rightAssemblyVersion.ToString(), leftAssemblyVersion.ToString(), rightName, leftName, rightIdentity));
+ differences.Add(CreateIdentityDifference(
+ Resources.AssembyVersionIsNotCompatible,
+ rightAssemblyVersion.ToString(),
+ leftAssemblyVersion.ToString(),
+ rightName,
+ leftName,
+ rightIdentity));
}
else if (_settings.StrictMode && leftAssemblyVersion < rightAssemblyVersion)
{
- differences.Add(CreateIdentityDifference(Resources.AssembyVersionDoesNotMatch, leftAssemblyVersion.ToString(), rightAssemblyVersion.ToString(), leftName, rightName, leftIdentity));
+ differences.Add(CreateIdentityDifference(
+ Resources.AssembyVersionDoesNotMatch,
+ leftAssemblyVersion.ToString(),
+ rightAssemblyVersion.ToString(),
+ leftName,
+ rightName,
+ leftIdentity));
}
if (!leftAssemblyPublicKeyToken.IsEmpty && !leftIdentity.IsRetargetable && !leftAssemblyPublicKeyToken.SequenceEqual(rightAssemblyPublicKeyToken))
@@ -102,6 +134,9 @@ private static string GetStringRepresentation(ReadOnlySpan publicKeyToken)
}
private static CompatDifference CreateIdentityDifference(string format, string leftProperty, string rightProperty, string leftName, string rightName, AssemblyIdentity identity) =>
- new(DiagnosticIds.AssemblyIdentityMustMatch, string.Format(format, leftProperty, rightProperty, leftName, rightName), DifferenceType.Changed, identity.GetDisplayName());
+ new(DiagnosticIds.AssemblyIdentityMustMatch,
+ string.Format(format, leftProperty, rightProperty, leftName, rightName),
+ DifferenceType.Changed,
+ identity.GetDisplayName());
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddAbstractMember.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddAbstractMember.cs
index ab6f31b2181d..f9aeacbb10e1 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddAbstractMember.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddAbstractMember.cs
@@ -15,7 +15,7 @@ public class CannotAddAbstractMember : IRule
{
private readonly RuleSettings _settings;
- public CannotAddAbstractMember(RuleSettings settings, RuleRunnerContext context)
+ public CannotAddAbstractMember(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
// This rule should only run when not in strict mode.
@@ -35,7 +35,11 @@ private void RunOnMemberMapperAction(ISymbol? left, ISymbol? right, ITypeSymbol
// checking for member additions on interfaces is checked on its own rule.
if (leftContainingType.TypeKind != TypeKind.Interface && !leftContainingType.IsEffectivelySealed(_settings.IncludeInternalSymbols))
{
- differences.Add(new CompatDifference(DiagnosticIds.CannotAddAbstractMember, string.Format(Resources.CannotAddAbstractMember, right.ToDisplayString(), rightName, leftName), DifferenceType.Added, right));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.CannotAddAbstractMember,
+ string.Format(Resources.CannotAddAbstractMember, right.ToDisplayString(), rightName, leftName),
+ DifferenceType.Added,
+ right));
}
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddMemberToInterface.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddMemberToInterface.cs
index 0a7620d30c61..a58650e6bcac 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddMemberToInterface.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddMemberToInterface.cs
@@ -9,9 +9,9 @@ namespace Microsoft.DotNet.ApiCompatibility.Rules
{
public class CannotAddMemberToInterface : IRule
{
- public CannotAddMemberToInterface(RuleSettings settings, RuleRunnerContext context)
+ public CannotAddMemberToInterface(RuleSettings settings, IRuleRegistrationContext context)
{
- // StrictMode scenario should be handled by MembersMustExist rule.
+ // StrictMode scenario are handled by the MembersMustExist rule.
if (!settings.StrictMode)
{
context.RegisterOnMemberSymbolAction(RunOnMemberSymbol);
@@ -34,7 +34,11 @@ private void RunOnMemberSymbol(ISymbol? left, ISymbol? right, string leftName, s
// If there is a default implementation provided is not a breaking change to add an interface member.
if (right.ContainingType.FindImplementationForInterfaceMember(right) == null)
{
- differences.Add(new CompatDifference(DiagnosticIds.CannotAddMemberToInterface, string.Format(Resources.CannotAddMemberToInterface, right.ToDisplayString(), rightName, leftName), DifferenceType.Added, right));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.CannotAddMemberToInterface,
+ string.Format(Resources.CannotAddMemberToInterface, right.ToDisplayString(), rightName, leftName),
+ DifferenceType.Added,
+ right));
}
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddOrRemoveVirtualKeyword.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddOrRemoveVirtualKeyword.cs
index 1928aa384586..81f922b84a4f 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddOrRemoveVirtualKeyword.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotAddOrRemoveVirtualKeyword.cs
@@ -15,7 +15,7 @@ public class CannotAddOrRemoveVirtualKeyword : IRule
{
private readonly RuleSettings _settings;
- public CannotAddOrRemoveVirtualKeyword(RuleSettings settings, RuleRunnerContext context)
+ public CannotAddOrRemoveVirtualKeyword(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnMemberSymbolAction(RunOnMemberSymbol);
@@ -43,8 +43,10 @@ private void RunOnMemberSymbol(ISymbol? left, ISymbol? right, ITypeSymbol leftCo
if (!right.IsVirtual)
{
differences.Add(new CompatDifference(
- DiagnosticIds.CannotRemoveVirtualFromMember, string.Format(
- Resources.CannotRemoveVirtualFromMember, left), DifferenceType.Removed, right));
+ DiagnosticIds.CannotRemoveVirtualFromMember,
+ string.Format(Resources.CannotRemoveVirtualFromMember, left),
+ DifferenceType.Removed,
+ right));
}
}
// If the left member is not virtual, ensure that we're in strict mode.
@@ -57,8 +59,10 @@ private void RunOnMemberSymbol(ISymbol? left, ISymbol? right, ITypeSymbol leftCo
if (right.IsVirtual)
{
differences.Add(new CompatDifference(
- DiagnosticIds.CannotAddVirtualToMember, string.Format(
- Resources.CannotAddVirtualToMember, right), DifferenceType.Added, right));
+ DiagnosticIds.CannotAddVirtualToMember,
+ string.Format(Resources.CannotAddVirtualToMember, right),
+ DifferenceType.Added,
+ right));
}
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotRemoveBaseTypeOrInterface.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotRemoveBaseTypeOrInterface.cs
index f7598986eb2c..d09691755c8b 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotRemoveBaseTypeOrInterface.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotRemoveBaseTypeOrInterface.cs
@@ -12,7 +12,7 @@ public class CannotRemoveBaseTypeOrInterface : IRule
{
private readonly RuleSettings _settings;
- public CannotRemoveBaseTypeOrInterface(RuleSettings settings, RuleRunnerContext context)
+ public CannotRemoveBaseTypeOrInterface(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnTypeSymbolAction(RunOnTypeSymbol);
@@ -68,10 +68,10 @@ private void ValidateBaseTypeNotRemoved(ITypeSymbol left, ITypeSymbol right, str
}
differences.Add(new CompatDifference(
- DiagnosticIds.CannotRemoveBaseType,
- string.Format(Resources.CannotRemoveBaseType, left.ToDisplayString(), leftBaseType.ToDisplayString(), rightName, leftName),
- DifferenceType.Changed,
- right));
+ DiagnosticIds.CannotRemoveBaseType,
+ string.Format(Resources.CannotRemoveBaseType, left.ToDisplayString(), leftBaseType.ToDisplayString(), rightName, leftName),
+ DifferenceType.Changed,
+ right));
}
private void ValidateInterfaceNotRemoved(ITypeSymbol left, ITypeSymbol right, string leftName, string rightName, IList differences)
@@ -95,10 +95,10 @@ private void ValidateInterfaceNotRemoved(ITypeSymbol left, ITypeSymbol right, st
if (!rightInterfaces.Contains(leftInterface))
{
differences.Add(new CompatDifference(
- DiagnosticIds.CannotRemoveBaseInterface,
- string.Format(Resources.CannotRemoveBaseInterface, left.ToDisplayString(), leftInterface.ToDisplayString(), rightName, leftName),
- DifferenceType.Changed,
- right));
+ DiagnosticIds.CannotRemoveBaseInterface,
+ string.Format(Resources.CannotRemoveBaseInterface, left.ToDisplayString(), leftInterface.ToDisplayString(), rightName, leftName),
+ DifferenceType.Changed,
+ right));
return;
}
}
@@ -115,10 +115,10 @@ private void ValidateInterfaceNotRemoved(ITypeSymbol left, ITypeSymbol right, st
private static void AddAssemblyLoadError(IList differences, ITypeSymbol type)
{
differences.Add(new CompatDifference(
- DiagnosticIds.AssemblyReferenceNotFound,
- string.Format(Resources.MatchingAssemblyNotFound, $"{type.ContainingAssembly.Name}.dll"),
- DifferenceType.Changed,
- string.Empty));
+ DiagnosticIds.AssemblyReferenceNotFound,
+ string.Format(Resources.MatchingAssemblyNotFound, $"{type.ContainingAssembly.Name}.dll"),
+ DifferenceType.Changed,
+ string.Empty));
}
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotSealType.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotSealType.cs
index aba573301d59..c5367304a9e7 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotSealType.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/CannotSealType.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
-using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using Microsoft.DotNet.ApiCompatibility.Extensions;
@@ -13,7 +12,7 @@ public class CannotSealType : IRule
{
private readonly RuleSettings _settings;
- public CannotSealType(RuleSettings settings, RuleRunnerContext context)
+ public CannotSealType(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnTypeSymbolAction(RunOnTypeSymbol);
@@ -29,19 +28,23 @@ private void RunOnTypeSymbol(ITypeSymbol? left, ITypeSymbol? right, string leftN
if (!isLeftSealed && isRightSealed)
{
- differences.Add(CreateDifference(right, leftName, rightName));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.CannotSealType,
+ string.Format(GetResourceStringForTypeState(right), right.ToDisplayString(), rightName, leftName),
+ DifferenceType.Changed,
+ right));
}
else if (_settings.StrictMode && !isRightSealed && isLeftSealed)
{
- differences.Add(CreateDifference(left, rightName, leftName));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.CannotSealType,
+ string.Format(GetResourceStringForTypeState(left), left.ToDisplayString(), leftName, rightName),
+ DifferenceType.Changed,
+ left));
}
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private CompatDifference CreateDifference(ISymbol symbol, string leftName, string rightName) =>
- new(DiagnosticIds.CannotSealType,
- string.Format(symbol.IsSealed ? Resources.TypeIsActuallySealed : Resources.TypeIsEffectivelySealed, symbol.ToDisplayString(), rightName, leftName),
- DifferenceType.Changed,
- symbol);
+ private static string GetResourceStringForTypeState(ISymbol symbol) =>
+ symbol.IsSealed ? Resources.TypeIsActuallySealed : Resources.TypeIsEffectivelySealed;
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/EnumsMustMatch.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/EnumsMustMatch.cs
index 50f77e7d3dbd..3bb80a7732be 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/EnumsMustMatch.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/EnumsMustMatch.cs
@@ -15,7 +15,7 @@ public class EnumsMustMatch : IRule
{
private readonly RuleSettings _settings;
- public EnumsMustMatch(RuleSettings settings, RuleRunnerContext context)
+ public EnumsMustMatch(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnTypeSymbolAction(RunOnTypeSymbol);
@@ -41,40 +41,45 @@ private void RunOnTypeSymbol(ITypeSymbol? left, ITypeSymbol? right, string leftN
return;
}
- // Check that the underlying types are equal.
- if (_settings.SymbolComparer.Equals(leftType, rightType))
+ // Check that the underlying types are equal and if not, emit a diagnostic.
+ if (!_settings.SymbolComparer.Equals(leftType, rightType))
{
- // If so, compare their fields.
- // Build a map of the enum's fields, keyed by the field names.
- Dictionary leftMembers = left.GetMembers()
- .Where(a => a.Kind == SymbolKind.Field)
- .Select(a => (IFieldSymbol)a)
- .ToDictionary(a => a.Name);
- Dictionary rightMembers = right.GetMembers()
- .Where(a => a.Kind == SymbolKind.Field)
- .Select(a => (IFieldSymbol)a)
- .ToDictionary(a => a.Name);
+ differences.Add(new CompatDifference(
+ DiagnosticIds.EnumTypesMustMatch,
+ string.Format(Resources.EnumTypesMustMatch, left.Name, leftType, rightType),
+ DifferenceType.Changed,
+ right));
+ return;
+ }
+
+ // If so, compare their fields.
+ // Build a map of the enum's fields, keyed by the field names.
+ Dictionary leftMembers = left.GetMembers()
+ .Where(a => a.Kind == SymbolKind.Field)
+ .Select(a => (IFieldSymbol)a)
+ .ToDictionary(a => a.Name);
+ Dictionary rightMembers = right.GetMembers()
+ .Where(a => a.Kind == SymbolKind.Field)
+ .Select(a => (IFieldSymbol)a)
+ .ToDictionary(a => a.Name);
- // For each field that is present in the left and right, check that their constant values match.
- // Otherwise, emit a diagnostic.
- foreach (KeyValuePair lEntry in leftMembers)
+ // For each field that is present in the left and right, check that their constant values match.
+ // Otherwise, emit a diagnostic.
+ foreach (KeyValuePair lEntry in leftMembers)
+ {
+ if (!rightMembers.TryGetValue(lEntry.Key, out IFieldSymbol? rField))
{
- if (!rightMembers.TryGetValue(lEntry.Key, out IFieldSymbol? rField))
- {
- continue;
- }
- if (lEntry.Value.ConstantValue is not object lval || rField.ConstantValue is not object rval || !lval.Equals(rval))
- {
- string msg = string.Format(Resources.EnumValuesMustMatch, left.Name, lEntry.Key, lEntry.Value.ConstantValue, rField.ConstantValue);
- differences.Add(new CompatDifference(DiagnosticIds.EnumValuesMustMatch, msg, DifferenceType.Changed, rField));
- }
+ continue;
+ }
+
+ if (lEntry.Value.ConstantValue is not object lval || rField.ConstantValue is not object rval || !lval.Equals(rval))
+ {
+ differences.Add(new CompatDifference(
+ DiagnosticIds.EnumValuesMustMatch,
+ string.Format(Resources.EnumValuesMustMatch, left.Name, lEntry.Key, lEntry.Value.ConstantValue, rField.ConstantValue),
+ DifferenceType.Changed,
+ rField));
}
- }
- else
- {
- // Otherwise, emit a diagnostic.
- string msg = string.Format(Resources.EnumTypesMustMatch, left.Name, leftType, rightType);
- differences.Add(new CompatDifference(DiagnosticIds.EnumTypesMustMatch, msg, DifferenceType.Changed, right));
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IRule.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRule.cs
similarity index 67%
rename from src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IRule.cs
rename to src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRule.cs
index dfa3c7bcb1d1..f48a58f6534d 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IRule.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRule.cs
@@ -1,12 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using Microsoft.DotNet.ApiCompatibility.Rules;
-
-namespace Microsoft.DotNet.ApiCompatibility.Abstractions
+namespace Microsoft.DotNet.ApiCompatibility.Rules
{
///
- /// Interface for Rules to use in order to be discovered and instantiated by the
+ /// Interface for Rules to use in order to be discovered and instantiated by the
///
public interface IRule
{
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleContext.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleContext.cs
new file mode 100644
index 000000000000..c17f07816778
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleContext.cs
@@ -0,0 +1,62 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using Microsoft.CodeAnalysis;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
+
+namespace Microsoft.DotNet.ApiCompatibility.Rules
+{
+ ///
+ /// Interface representing the context of the used to register and run rule actions.
+ ///
+ public interface IRuleContext : IRuleRegistrationContext, IRuleRunnerContext
+ {
+ }
+
+ ///
+ /// Interface representing the context of the used to register rule actions.
+ /// This is provided to each rule when instantiating them to add events for the rules to be invoked.
+ ///
+ public interface IRuleRegistrationContext
+ {
+ ///
+ /// Registers a callback to invoke when two are compared.
+ ///
+ /// The action to invoke.
+ void RegisterOnAssemblySymbolAction(Action> action);
+
+ ///
+ /// Registers a callback to invoke when two are compared.
+ ///
+ /// The action to invoke.
+ void RegisterOnTypeSymbolAction(Action> action);
+
+ ///
+ /// Registers a callback to invoke when two members of a are compared.
+ ///
+ /// The action to invoke.
+ void RegisterOnMemberSymbolAction(Action> action);
+
+ ///
+ /// Register a callback to invoke when two members of a
+ /// The action to register is invoked with the containing types for left and right. Sometimes this information
+ /// is needed by some rules regardless of left or right being null.
+ ///
+ /// The action to invoke
+ void RegisterOnMemberSymbolAction(Action> action);
+ }
+
+ ///
+ /// Interface representing the context of the used to run registered rule actions.
+ ///
+ public interface IRuleRunnerContext
+ {
+ void RunOnAssemblySymbolActions(IAssemblySymbol? left, IAssemblySymbol? right, string leftName, string rightName, IList differences);
+
+ void RunOnTypeSymbolActions(ITypeSymbol? left, ITypeSymbol? right, string leftName, string rightName, IList differences);
+
+ void RunOnMemberSymbolActions(ISymbol? left, ISymbol? right, ITypeSymbol leftContainingType, ITypeSymbol rightContainingType, string leftName, string rightName, IList differences);
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleFactory.cs
new file mode 100644
index 000000000000..2199fe903554
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleFactory.cs
@@ -0,0 +1,21 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+
+namespace Microsoft.DotNet.ApiCompatibility.Rules
+{
+ ///
+ /// Factory to create api comparison rules.
+ ///
+ public interface IRuleFactory
+ {
+ ///
+ /// Creates api copmarison rules based on the given settings and registers actions via the provided context.
+ ///
+ /// The rule settings.
+ /// The rule registration context that allows rules to register actions.
+ ///
+ IRule[] CreateRules(RuleSettings settings, IRuleRegistrationContext context);
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IRuleRunner.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleRunner.cs
similarity index 67%
rename from src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IRuleRunner.cs
rename to src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleRunner.cs
index d56d766ed0ae..bd0ed5759c45 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Abstractions/IRuleRunner.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/IRuleRunner.cs
@@ -2,14 +2,21 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.s
using System.Collections.Generic;
+using Microsoft.DotNet.ApiCompatibility.Abstractions;
-namespace Microsoft.DotNet.ApiCompatibility.Abstractions
+namespace Microsoft.DotNet.ApiCompatibility.Rules
{
///
- /// Interface for rule drivers to implement in order to be used returned by the
+ /// Rule runner interface that exposes functionality to initialize rules and run element mapper objects.
///
public interface IRuleRunner
{
+ ///
+ /// Initializes the rules provided by the based on given rule settings.
+ ///
+ /// The rule settings.
+ void InitializeRules(RuleSettings settings);
+
///
/// Runs the registered rules on the mapper.
///
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/MembersMustExist.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/MembersMustExist.cs
index c7e5cd3918b2..010c7ad080b4 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/MembersMustExist.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/MembersMustExist.cs
@@ -1,11 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System.Collections.Generic;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using Microsoft.DotNet.ApiCompatibility.Extensions;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
namespace Microsoft.DotNet.ApiCompatibility.Rules
{
@@ -17,7 +16,7 @@ public class MembersMustExist : IRule
{
private readonly RuleSettings _settings;
- public MembersMustExist(RuleSettings settings, RuleRunnerContext context)
+ public MembersMustExist(RuleSettings settings, IRuleRegistrationContext context)
{
_settings = settings;
context.RegisterOnTypeSymbolAction(RunOnTypeSymbol);
@@ -33,11 +32,19 @@ private void RunOnTypeSymbol(ITypeSymbol? left, ITypeSymbol? right, string leftN
{
if (left != null && right == null)
{
- differences.Add(CreateDifference(left, DiagnosticIds.TypeMustExist, DifferenceType.Removed, Resources.TypeExistsOnLeft, leftName, rightName));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.TypeMustExist,
+ string.Format(Resources.TypeExistsOnLeft, left.ToDisplayString(), leftName, rightName),
+ DifferenceType.Removed,
+ left));
}
else if (_settings.StrictMode && left == null && right != null)
{
- differences.Add(CreateDifference(right, DiagnosticIds.TypeMustExist, DifferenceType.Added, Resources.TypeExistsOnRight, leftName, rightName));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.TypeMustExist,
+ string.Format(Resources.TypeExistsOnRight, right.ToDisplayString(), leftName, rightName),
+ DifferenceType.Added,
+ right));
}
}
@@ -52,22 +59,26 @@ private void RunOnMemberSymbol(ISymbol? left, ISymbol? right, ITypeSymbol leftCo
{
if (ShouldReportMissingMember(left, rightContainingType))
{
- differences.Add(CreateDifference(left, DiagnosticIds.MemberMustExist, DifferenceType.Removed, Resources.MemberExistsOnLeft, leftName, rightName));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.MemberMustExist,
+ string.Format(Resources.MemberExistsOnLeft, left.ToDisplayString(), leftName, rightName),
+ DifferenceType.Removed,
+ left));
}
}
else if (_settings.StrictMode && left == null && right != null)
{
if (ShouldReportMissingMember(right, leftContainingType))
{
- differences.Add(CreateDifference(right, DiagnosticIds.MemberMustExist, DifferenceType.Added, Resources.MemberExistsOnRight, leftName, rightName));
+ differences.Add(new CompatDifference(
+ DiagnosticIds.MemberMustExist,
+ string.Format(Resources.MemberExistsOnRight, right.ToDisplayString(), leftName, rightName),
+ DifferenceType.Added,
+ right));
}
}
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static CompatDifference CreateDifference(ISymbol symbol, string id, DifferenceType type, string format, string leftName, string rightName) =>
- new(id, string.Format(format, symbol.ToDisplayString(), leftName, rightName), type, symbol);
-
private static bool ShouldReportMissingMember(ISymbol symbol, ITypeSymbol containingType)
{
// Events and properties are handled via their accessors.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunnerContext.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleContext.cs
similarity index 62%
rename from src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunnerContext.cs
rename to src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleContext.cs
index 3725880a0c31..a01f64c76c57 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunnerContext.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleContext.cs
@@ -9,54 +9,41 @@
namespace Microsoft.DotNet.ApiCompatibility.Rules
{
///
- /// Class representing the context of the used to run the rules.
- /// This is provided to each rule when initializing them to add events for the rules to be invoked.
+ /// Class representing the context of the used to register and run rule actions.
///
- public class RuleRunnerContext
+ public class RuleContext : IRuleContext
{
private readonly List>> _onAssemblySymbolActions = new();
private readonly List>> _onTypeSymbolActions = new();
private readonly List>> _onMemberSymbolActions = new();
private readonly List>> _onMemberSymbolWithContainingTypeActions = new();
- ///
- /// Registers a callback to invoke when two are compared.
- ///
- /// The action to invoke.
+ /// />
public void RegisterOnAssemblySymbolAction(Action> action)
{
_onAssemblySymbolActions.Add(action);
}
- ///
- /// Registers a callback to invoke when two are compared.
- ///
- /// The action to invoke.
+ /// />
public void RegisterOnTypeSymbolAction(Action> action)
{
_onTypeSymbolActions.Add(action);
}
- ///
- /// Registers a callback to invoke when two members of a are compared.
- ///
- /// The action to invoke.
+ /// />
public void RegisterOnMemberSymbolAction(Action> action)
{
_onMemberSymbolActions.Add(action);
}
- ///
- /// Register a callback to invoke when two members of a
- /// The action to register is invoked with the containing types for left and right. Sometimes this information
- /// is needed by some rules regardless of left or right being null.
- ///
- /// The action to invoke
+
+ /// />
public void RegisterOnMemberSymbolAction(Action> action)
{
_onMemberSymbolWithContainingTypeActions.Add(action);
}
- internal void RunOnAssemblySymbolActions(IAssemblySymbol? left, IAssemblySymbol? right, string leftName, string rightName, List differences)
+ /// />
+ public void RunOnAssemblySymbolActions(IAssemblySymbol? left, IAssemblySymbol? right, string leftName, string rightName, IList differences)
{
foreach (Action> action in _onAssemblySymbolActions)
{
@@ -64,7 +51,8 @@ internal void RunOnAssemblySymbolActions(IAssemblySymbol? left, IAssemblySymbol?
}
}
- internal void RunOnTypeSymbolActions(ITypeSymbol? left, ITypeSymbol? right, string leftName, string rightName, List differences)
+ /// />
+ public void RunOnTypeSymbolActions(ITypeSymbol? left, ITypeSymbol? right, string leftName, string rightName, IList differences)
{
foreach (Action> action in _onTypeSymbolActions)
{
@@ -72,7 +60,8 @@ internal void RunOnTypeSymbolActions(ITypeSymbol? left, ITypeSymbol? right, stri
}
}
- internal void RunOnMemberSymbolActions(ISymbol? left, ISymbol? right, ITypeSymbol leftContainingType, ITypeSymbol rightContainingType, string leftName, string rightName, List differences)
+ /// />
+ public void RunOnMemberSymbolActions(ISymbol? left, ISymbol? right, ITypeSymbol leftContainingType, ITypeSymbol rightContainingType, string leftName, string rightName, IList differences)
{
foreach (Action> action in _onMemberSymbolActions)
{
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleFactory.cs
new file mode 100644
index 000000000000..a4dd2d3d0c80
--- /dev/null
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleFactory.cs
@@ -0,0 +1,27 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.DotNet.ApiCompatibility.Rules
+{
+ ///
+ /// The default rule factory that returns all available rules with the given input settings.
+ ///
+ public class RuleFactory : IRuleFactory
+ {
+ ///
+ public IRule[] CreateRules(RuleSettings settings, IRuleRegistrationContext context)
+ {
+ return new IRule[]
+ {
+ new AssemblyIdentityMustMatch(settings, context),
+ new CannotAddAbstractMember(settings, context),
+ new CannotAddMemberToInterface(settings, context),
+ new CannotAddOrRemoveVirtualKeyword(settings, context),
+ new CannotRemoveBaseTypeOrInterface(settings, context),
+ new CannotSealType(settings, context),
+ new EnumsMustMatch(settings, context),
+ new MembersMustExist(settings, context)
+ };
+ }
+ }
+}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleLocator.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleLocator.cs
deleted file mode 100644
index c76cca26a979..000000000000
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleLocator.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) .NET Foundation and contributors. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-using System.Collections.Generic;
-using Jab;
-using Microsoft.DotNet.ApiCompatibility.Abstractions;
-
-namespace Microsoft.DotNet.ApiCompatibility.Rules
-{
- [ServiceProvider(RootServices = new[] { typeof(IEnumerable) })]
- [Singleton(typeof(RuleSettings), Instance = nameof(RuleSettings))]
- [Singleton(typeof(RuleRunnerContext), Instance = nameof(RuleRunnerContext))]
- [Singleton(typeof(IRule), typeof(AssemblyIdentityMustMatch))]
- [Singleton(typeof(IRule), typeof(CannotAddAbstractMember))]
- [Singleton(typeof(IRule), typeof(CannotAddMemberToInterface))]
- [Singleton(typeof(IRule), typeof(CannotAddOrRemoveVirtualKeyword))]
- [Singleton(typeof(IRule), typeof(CannotRemoveBaseTypeOrInterface))]
- [Singleton(typeof(IRule), typeof(CannotSealType))]
- [Singleton(typeof(IRule), typeof(EnumsMustMatch))]
- [Singleton(typeof(IRule), typeof(MembersMustExist))]
- internal partial class RuleLocator
- {
- public readonly RuleRunnerContext RuleRunnerContext;
- public readonly RuleSettings RuleSettings;
-
- public RuleLocator(RuleRunnerContext ruleRunnerContext, RuleSettings ruleSettings)
- {
- RuleRunnerContext = ruleRunnerContext;
- RuleSettings = ruleSettings;
- }
- }
-}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunner.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunner.cs
index ac1fc95d1c6e..81df8a613b2a 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunner.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunner.cs
@@ -1,32 +1,38 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.s
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
-using System.Collections.Generic;
namespace Microsoft.DotNet.ApiCompatibility.Rules
{
+ ///
+ /// Rule runner that exposes functionality to initialize rules and run element mapper objects.
+ ///
public class RuleRunner : IRuleRunner
{
- private readonly RuleRunnerContext _context;
- private readonly RuleSettings _settings;
- private readonly string _leftName;
- private readonly string[] _rightNames;
- internal const string DEFAULT_LEFT_NAME = "left";
- internal const string DEFAULT_RIGHT_NAME = "right";
+ private readonly IRuleContext _context;
+ private readonly IRuleFactory _ruleFactory;
+ private const string DEFAULT_LEFT_NAME = "left";
+ private const string DEFAULT_RIGHT_NAME = "right";
- internal RuleRunner(string leftName, string[] rightNames, bool strictMode, IEqualityComparer symbolComparer, bool includeInternalSymbols, bool withReferences)
+ public RuleRunner(IRuleFactory ruleFactory, IRuleContext context)
{
- _context = new RuleRunnerContext();
- _settings = new RuleSettings(strictMode, symbolComparer, includeInternalSymbols, withReferences);
- _leftName = leftName;
- _rightNames = rightNames;
+ _ruleFactory = ruleFactory;
+ _context = context;
+ }
- // Initialize registered rules but don't invoke anything on them as they register themselves on "events" inside their constructor.
- new RuleLocator(_context, _settings).GetService>();
+ ///
+ public void InitializeRules(RuleSettings settings)
+ {
+ // Instantiate the rules but don't invoke anything on them as they register themselves on "events" inside their constructor.
+ _ = _ruleFactory.CreateRules(settings, _context);
}
+ ///
public IReadOnlyList> Run(ElementMapper mapper)
{
int rightLength = mapper.Right.Length;
@@ -34,30 +40,48 @@ public IReadOnlyList> Run(ElementMapper mapp
for (int rightIndex = 0; rightIndex < rightLength; rightIndex++)
{
- string leftName = _leftName;
- string rightName = rightIndex < _rightNames.Length ? _rightNames[rightIndex] : DEFAULT_RIGHT_NAME;
List differences = new();
if (mapper is AssemblyMapper am)
{
- _context.RunOnAssemblySymbolActions(am.Left, am.Right[rightIndex], leftName, rightName, differences);
+ _context.RunOnAssemblySymbolActions(am.Left?.Element,
+ am.Right[rightIndex]?.Element,
+ GetAssemblyName(am.Left, ElementSide.Left),
+ GetAssemblyName(am.Right[rightIndex], ElementSide.Right),
+ differences);
}
else if (mapper is TypeMapper tm)
{
if (tm.ShouldDiffElement(rightIndex))
- _context.RunOnTypeSymbolActions(tm.Left, tm.Right[rightIndex], leftName, rightName, differences);
+ {
+ _context.RunOnTypeSymbolActions(tm.Left,
+ tm.Right[rightIndex],
+ GetAssemblyName(tm.ContainingNamespace.ContainingAssembly.Left, ElementSide.Left),
+ GetAssemblyName(tm.ContainingNamespace.ContainingAssembly.Right[rightIndex], ElementSide.Right),
+ differences);
+ }
}
else if (mapper is MemberMapper mm)
{
if (mm.ShouldDiffElement(rightIndex))
+ {
+ // ContainingType Left and Right cannot be null, as otherwise, the above condition would be false.
+ Debug.Assert(mm.ContainingType.Left != null);
+ Debug.Assert(mm.ContainingType.Right[rightIndex] != null);
+
_context.RunOnMemberSymbolActions(
mm.Left,
mm.Right[rightIndex],
- mm.ContainingType.Left,
- mm.ContainingType.Right[rightIndex],
- leftName,
- rightName,
+ mm.ContainingType.Left!,
+ mm.ContainingType.Right[rightIndex]!,
+ GetAssemblyName(mm.ContainingType.ContainingNamespace.ContainingAssembly.Left, ElementSide.Left),
+ GetAssemblyName(mm.ContainingType.ContainingNamespace.ContainingAssembly.Right[rightIndex], ElementSide.Right),
differences);
+ }
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException(nameof(mapper));
}
result[rightIndex] = differences;
@@ -65,5 +89,17 @@ public IReadOnlyList> Run(ElementMapper mapp
return result;
}
+
+ private static string GetAssemblyName(ElementContainer? assemblyContainer, ElementSide side) =>
+ side switch
+ {
+ ElementSide.Left => string.IsNullOrEmpty(assemblyContainer?.MetadataInformation.DisplayString) ?
+ DEFAULT_LEFT_NAME :
+ assemblyContainer!.MetadataInformation.DisplayString,
+ ElementSide.Right => string.IsNullOrEmpty(assemblyContainer?.MetadataInformation.DisplayString) ?
+ DEFAULT_RIGHT_NAME :
+ assemblyContainer!.MetadataInformation.DisplayString,
+ _ => throw new ArgumentOutOfRangeException(nameof(side)),
+ };
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunnerFactory.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunnerFactory.cs
deleted file mode 100644
index 932d9ff48383..000000000000
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleRunnerFactory.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) .NET Foundation and contributors. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.s
-
-using System;
-using System.Collections.Generic;
-using Microsoft.CodeAnalysis;
-using Microsoft.DotNet.ApiCompatibility.Abstractions;
-
-namespace Microsoft.DotNet.ApiCompatibility.Rules
-{
- public class RuleRunnerFactory
- {
- private readonly Lazy _runner;
-
- public RuleRunnerFactory(string? leftName, string[]? rightNames, IEqualityComparer equalityComparer, bool includeInternalSymbols, bool strictMode, bool withReferences)
- {
- if (string.IsNullOrEmpty(leftName))
- leftName = RuleRunner.DEFAULT_LEFT_NAME;
-
- rightNames ??= new string[] { RuleRunner.DEFAULT_RIGHT_NAME };
- if (rightNames.Length == 0)
- {
- throw new ArgumentException(Resources.RightNamesAtLeastOne, nameof(rightNames));
- }
-
- for (int i = 0; i < rightNames.Length; i++)
- {
- if (string.IsNullOrEmpty(rightNames[i]))
- {
- rightNames[i] = RuleRunner.DEFAULT_RIGHT_NAME;
- }
- }
-
- _runner = new Lazy(() => new RuleRunner(leftName!, rightNames, strictMode, equalityComparer, includeInternalSymbols, withReferences));
- }
-
- public virtual IRuleRunner GetRuleRunner()
- {
- return _runner.Value;
- }
- }
-}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleSettings.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleSettings.cs
index a223190fa6e0..05b21b5a963a 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleSettings.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Rules/RuleSettings.cs
@@ -6,22 +6,43 @@
namespace Microsoft.DotNet.ApiCompatibility.Rules
{
- public class RuleSettings
+ ///
+ /// General rule settings that are passed to the rules.
+ ///
+ public readonly struct RuleSettings
{
- public bool StrictMode { get; }
+ ///
+ /// Flag indicating whether api comparison should be performed in strict mode.
+ /// If true, the behavior of some rules will change and some other rules will be
+ /// executed when getting the differences. This is useful when both sides's surface area
+ /// which are compared, should not differ.
+ ///
+ public readonly bool StrictMode;
- public IEqualityComparer SymbolComparer { get; }
+ ///
+ /// Determines if internal members should be validated.
+ ///
+ public readonly bool IncludeInternalSymbols;
- public bool IncludeInternalSymbols { get; }
+ ///
+ /// If true, references are available. Necessary to know for following type forwards.
+ ///
+ public readonly bool WithReferences;
- public bool WithReferences { get; }
+ ///
+ /// The symbol comparer to check for equality of a given left and right.
+ ///
+ public readonly IEqualityComparer SymbolComparer;
- public RuleSettings(bool strictMode, IEqualityComparer symbolComparer, bool includeInternalSymbols, bool withReferences)
+ public RuleSettings(bool strictMode = false,
+ bool includeInternalSymbols = false,
+ bool withReferences = false,
+ IEqualityComparer? symbolComparer = null)
{
StrictMode = strictMode;
- SymbolComparer = symbolComparer;
IncludeInternalSymbols = includeInternalSymbols;
WithReferences = withReferences;
+ SymbolComparer = symbolComparer ?? new DefaultSymbolsEqualityComparer();
}
}
}
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Runner/ApiCompatRunner.cs b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Runner/ApiCompatRunner.cs
index 3b3dd3a3172f..0ccf88fbb8f8 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Runner/ApiCompatRunner.cs
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Runner/ApiCompatRunner.cs
@@ -1,12 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using Microsoft.DotNet.ApiCompatibility.Logging;
+using Microsoft.DotNet.ApiCompatibility.Rules;
namespace Microsoft.DotNet.ApiCompatibility.Runner
{
@@ -91,9 +91,9 @@ public void ExecuteWorkItems()
continue;
// Create and configure the work item specific api comparer
- IApiComparer apiComparer = _apiComparerFactory.Create();
- apiComparer.StrictMode = workItem.Options.EnableStrictMode;
- apiComparer.WarnOnMissingReferences = runWithReferences;
+ IApiComparer apiComparer = _apiComparerFactory.Create(new ApiComparerSettings(
+ strictMode: workItem.Options.EnableStrictMode,
+ withReferences: runWithReferences));
// TODO: Support passing in multiple lefts in ApiComparer: https://github.com/dotnet/sdk/issues/17364.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.cs.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.cs.xlf
index 27737962fda2..1d2b3e73d01b 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.cs.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.cs.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Spouští se pracovní položky ({0})...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Provedlo se ověření rozhraní API pro {0} ({2}) a {1} ({3}).API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Chyby kompatibility rozhraní API mezi {0} ({2}) a {1} ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Nepovedlo se načíst symboly sestavení pro {0}. Sestavení se přeskočí.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Do člena {0} nelze přidat virtuální klíčové slovo.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Nelze odebrat virtuální klíčové slovo ze člena {0}.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ Element by neměl mít hodnotu null. V indexu byla nalezena hodnota null: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Základní typ výčtu{0}se změnil z {1} na {2}.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ Hodnota pole {1} ve výčtu {0} se změnila z {2} na {3}.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.de.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.de.xlf
index 792822a102fd..a16a19b9c928 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.de.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.de.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ {0} Arbeitselement(e) wird/werden ausgeführt...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ API-Überprüfung für „{0}“ ({2}) und „{1}“ ({3}) wurde durchgeführt.API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ API-Kompatibilitätsfehler zwischen „{0}“ ({2}) und „{1}“ ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Die Assemblysymbole für „{0}“ konnten nicht geladen werden. Assembly wird übersprungen.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Das virtuelle Schlüsselwort kann dem Member „{0}“ nicht hinzugefügt werden.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Das virtuelle Schlüsselwort kann nicht aus dem Member „{0}“ entfernt werden.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ Das Element darf nicht NULL sein. NULL gefunden bei Index: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Der zugrunde liegende Typ der Enumeration „{0}“ wurde von „{1}“ in „{2}“ geändert.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ Wert des Felds „{1}2 in der Enumeration „{0}2 wurde von „{2}“ in „{3}“ geändert.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.es.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.es.xlf
index 40f6d2b16d2b..d548d015f6cc 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.es.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.es.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Ejecutando {0} elemento(s) de trabajo....Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Se realizó la validación de API en "{0}" ({2}) y "{1}" ({3}).API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Errores de compatibilidad de API entre "{0}" ({2}) y "{1}" ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ No se pudieron cargar los símbolos de ensamblado para "{0}". Omitiendo el ensamblado.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ No se puede agregar la palabra clave virtual al miembro "{0}".
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ No se puede quitar la palabra clave virtual del miembro "{0}".
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ El elemento no debe ser nulo. Se encontró un valor nulo en el índice: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ El tipo subyacente de la enumeración "{0}" ha cambiado de "{1}" a "{2}".Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ El valor del campo "{1}" en la enumeración "{0}" ha cambiado de "{2}" a "{3}".
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.fr.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.fr.xlf
index 17cd2a3b3880..907deea43ba9 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.fr.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.fr.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Exécution {0} d'élément(s) de travail...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Validation de l’API effectuée sur '{0}' ({2}) et '{1}' ({3})API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Erreurs de compatibilité des API entre '{0}' ({2}) et '{1}' ({3}) :Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Nous n’avons pas pu charger les symboles d’assembly pour '{0}'. Assembly ignoré.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Impossible d'ajouter le mot-clé virtuel au membre '{0}'.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Impossible de supprimer le mot-clé virtuel du membre '{0}'.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ L’élément ne doit pas être null. Null trouvé à l’index : {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Le type sous-jacent d'énumération '{0}' est passé de '{1}' à '{2}'.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ La valeur du champ '{1}' dans l'énumération '{0}' est passée de '{2}' à '{3}'.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.it.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.it.xlf
index 179ddfe3273d..a70435d08fc1 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.it.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.it.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Esecuzione {0} elementi di lavoro in corso...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Convalida API eseguita su '{0}' ({2}) e '{1}' ({3}).API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Errori di compatibilità dell'API tra '{0}' ({2}) e '{1}' ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Non è stato possibile caricare i simboli di assembly per '{0}'. L'assembly verrà ignorato.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Non è possibile aggiungere la parola chiave virtuale nel membro '{0}'.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Non è possibile rimuovere la parola chiave virtuale dal membro '{0}'.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ L'elemento non deve essere null. Trovato valore null all'indice: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Il tipo sottostante dell'enumerazione '{0}' è stato modificato da '{1}' a '{2}'.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ Il valore del campo '{1}' nell'enumerazione '{0}' è stato modificato da '{2}' a '{3}'.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ja.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ja.xlf
index 2c594e6571ce..bd60a75f06bc 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ja.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ja.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ {0} 件の作業項目を移動しています...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ '{0}' ({2}) と '{1}' ({3}) に API 検証を実行しました。API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ '{0}' ({2}) と '{1}' ({3}) の API 互換性エラーは、以下のとおりです。Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ '{0}' のアセンブリ シンボルを読み込めませんでした。アセンブリをスキップしています。
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ メンバー '{0}' に仮想キーワードを追加できません。
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ メンバー '{0}' から仮想キーワードを削除できません。
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ 要素を null にすることはできません。インデックスに null が見つかりました: {0}。Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ 基になる列挙型 '{0}' が '{1}' から '{2}' に変更されました。Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ 列挙型 '{0}' のフィールド '{1}' の値が '{2}' から '{3}' に変更されました。
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ko.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ko.xlf
index f5092d42a257..df5eba30ba8c 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ko.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ko.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ {0} 작업 항목을 실행하는 중...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ '{0}'({2}) 및 '{1}'({3})에서 API 유효성 검사를 수행했습니다.API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ '{0}'({2}) 및 '{1}'({3}) 사이의 API 호환성 오류:Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ '{0}'에 대한 어셈블리 기호를 로드할 수 없습니다. 어셈블리를 건너뛰는 중입니다.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ '{0}' 구성원에 가상 키워드를 추가할 수 없습니다.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ 구성원 '{0}'에서 가상 키워드를 제거할 수 없습니다.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ 요소는 Null이 아니어야 합니다. 인덱스 {0}에 Null이 있습니다.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ 열거형 '{0}'의 기본 유형이 '{1}'에서 '{2}'(으)로 변경되었습니다.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ 열거형 '{0}'의 필드 '{1}' 값이 '{2}'에서 '{3}'(으)로 변경되었습니다.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pl.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pl.xlf
index d8d21a3b189a..2f4ec47daf8f 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pl.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pl.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Trwa wykonywanie następującej liczby elementów roboczych: {0}Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Wykonano weryfikację interfejsu API dla elementu „{0}” ({2}) i „{1}” ({3}).API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Błędy zgodności interfejsu API między elementem „{0}” ({2}) i „{1}” ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Nie można załadować symboli zestawu dla elementu „{0}”. Pomijanie zestawu.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Nie można dodać wirtualnego słowa kluczowego do składowej „{0}”.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Nie można usunąć wirtualnego słowa kluczowego z składowej „{0}”.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ Element nie może mieć wartości null. Znaleziono wartość null w indeksie: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Bazowy typ wyliczenia „{0}” został zmieniony z „{1}” na „{2}”.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ Wartość pola „{1}” w wyliczeniu „{0}” zmieniona z „{2}” na „{3}”.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pt-BR.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pt-BR.xlf
index a01118deab47..c1ea8179ad40 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pt-BR.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.pt-BR.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Executando {0} item(ns) de trabalho...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Validação de API realizada em '{0}' ({2}) e '{1}' ({3}).API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Erros de compatibilidade de API entre '{0}' ({2}) e '{1}' ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Não foi possível carregar símbolos de montagem para '{0}'. Ignorando a montagem.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Não é possível adicionar palavra-chave virtual ao membro '{0}'.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Não é possível remover a palavra-chave virtual do membro '{0}'.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ O elemento não deve ser nulo. Nulo encontrado no índice: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Tipo subjacente de enum '{0}' alterado de '{1}' para '{2}'.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ Valor do campo '{1}' na enumeração '{0}' alterado de '{2}' para '{3}'.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ru.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ru.xlf
index 597ad3c1d415..0fb484adfc6b 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ru.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.ru.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ Выполнение рабочих элементов:{0}....Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ Выполнена проверка API для "{0}" ({2} ) и "{1}" ({3}).API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ Ошибки совместимости API между "{0}" ({2} >) и "{1}" ({3}):Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ Не удалось загрузить символы сборки для "{0}". Сборка пропускается.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Не удается добавить виртуальную клавиатуру в элемент "{0}".
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Не удается удалить виртуальное ключевое слово из элемента "{0}".
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ Элемент не должен иметь значение NULL. Обнаружено значение NULL в индексе: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Базовый тип перечисления "{0}" изменен с "{1}" на "{2}".Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ Значение поля "{1}" в перечислении "{0}" изменено с "{2}" на "{3}".
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.tr.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.tr.xlf
index a74bba5fa961..989bbb9b9b08 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.tr.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.tr.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ {0} iş öğesi yürütülüyor...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ '{0}' ({2}) ve '{1}' ({3}) üzerinde API doğrulaması gerçekleştirildi.API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ '{0}' ({2}) ile '{1}' ({3}) arasında API uyumluluğu hataları var:Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ '{0}' için bütünleştirilmiş kod sembolleri yüklenemedi. Bütünleştirilmiş kod atlanıyor.
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ Sanal anahtar sözcük, '{0}' üyesine eklenemiyor.
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ Sanal anahtar sözcük, '{0}' üyesinden kaldırılamıyor.
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ Öğe null olmamalıdır. Dizinde null bulundu: {0}.Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ Temel alınan '{0}' sabit listesi türü, '{1}' öğesinden '{2}' öğesine değiştirildi.Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ '{0}' sabit listesindeki '{1}' alan değeri, '{2}' öğesinden '{3}' öğesine değiştirildi.
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hans.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hans.xlf
index 95baa9a6028d..115cc2dc7e56 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hans.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hans.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ 正在执行 {0} 工作项...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ 已对“{0}”({2})和“{1}”({3})执行 API 验证。API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ “{0}”({2})和“{1}”({3})之间的 API 兼容性错误:Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ 无法加载“{0}”的程序集符号。正在跳过程序集。
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ 无法将虚拟关键字添加到成员“{0}”。
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ 无法从成员“{0}”中删除虚拟关键字。
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ 元素不应为 null。在索引 {0} 找到 null。Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ 枚举“{0}”的基础类型已从“{1}”更改为“{2}”。Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ 枚举“{0}”中字段“{1}”的值已从“{2}”更改为“{3}”。
diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hant.xlf b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hant.xlf
index 7c5e8fc01094..a689d16dddcd 100644
--- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hant.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/xlf/Resources.zh-Hant.xlf
@@ -4,22 +4,22 @@
Executing {0} work item(s)...
- Executing {0} work item(s)...
+ 正在執行 {0} 工作項目...Performed api validation on '{0}' ({2}) and '{1}' ({3}).
- Performed api validation on '{0}' ({2}) and '{1}' ({3}).
+ 已在 '{0}' ({2}) 與 '{1}' ({3}) 上執行 API 驗證。API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
- API compatibility errors between '{0}' ({2}) and '{1}' ({3}):
+ '{0}' ({2}) 與 '{1}' ({3}) 之間的 API 相容性錯誤:Could not load assembly symbols for '{0}'. Skipping the assembly.
- Could not load assembly symbols for '{0}'. Skipping the assembly.
+ 無法載入 '{0}' 的組件符號。正在略過組件。
@@ -69,7 +69,7 @@
Cannot add virtual keyword to member '{0}'.
- Cannot add virtual keyword to member '{0}'.
+ 無法將虛擬關鍵字新增至成員 '{0}'。
@@ -84,7 +84,7 @@
Cannot remove virtual keyword from member '{0}'.
- Cannot remove virtual keyword from member '{0}'.
+ 無法從成員 '{0}' 移除虛擬關鍵字。
@@ -94,17 +94,17 @@
Element should not be null. Found null at index: {0}.
- Element should not be null. Found null at index: {0}.
+ 元素不應為 Null。在索引找到 Null: {0}。Underlying type of enum '{0}' changed from '{1}' to '{2}'.
- Underlying type of enum '{0}' changed from '{1}' to '{2}'.
+ 列舉 '{0}' 的基礎類型已從 '{1}' 變更為 '{2}'。Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
- Value of field '{1}' in enum '{0}' changed from '{2}' to '{3}'.
+ 列舉 '{1}' 中的欄位 '{0}' 值已從 '{2}' 變更為 '{3}'。
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf
index e21fc21e9f73..6722505270cc 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.cs.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ Při načítání {1} se nepovedlo najít referenční adresář v zadaných adresářích pro TargetFramework {0}. Další informace najdete zde: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf
index 02da4161767e..6688aea7a055 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.de.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ In den bereitgestellten Verzeichnissen für TargetFramework „{0}“ wurde beim Laden von „{1}“kein Referenzverzeichnis gefunden. Weitere Informationen finden Sie unter https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf
index 2115a81f6614..f686a822cc1f 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.es.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ No se ha encontrado un directorio de referencia en los directorios proporcionados para TargetFramework '{0}' al cargar '{1}'. Para obtener más información, consulte: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf
index 86e6569e2915..822f0ba4ef79 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.fr.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ Répertoire de référence introuvable dans les répertoires fournis pour le « {0} » pour le chargement de « {1} ». Pour plus d’informations, consultez : https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf
index 2b754f6a53dd..8232974176d0 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.it.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ Non è stato possibile trovare una directory di riferimento nelle directory fornite per TargetFramework '{0}' durante il caricamento di '{1}'. Per altre informazioni, vedere: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf
index 8f63df3dda29..0afded39779e 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ja.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ '{1}' を読み込むときに、TargetFramework '{0}' 用に指定されたディレクトリで参照ディレクトリが見つかりませんでした。詳細については、以下を参照してください: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf
index 22fee7182854..94a3a72703fe 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ko.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ '{1}'을(를) 로드할 때 TargetFramework '{0}'에 대해 제공된 디렉터리에서 참조 디렉터리를 찾을 수 없습니다. 자세한 내용은 다음을 참조하세요. https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf
index 470e5f7f5a96..a875ef83e2f5 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pl.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ Nie można odnaleźć katalogu referencyjnego w podanych katalogach dla elementu TargetFramework „{0}” podczas ładowania elementu „{1}”. Aby uzyskać więcej informacji, zobacz: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf
index c5e19f8e29fe..7684ce0fe71e 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.pt-BR.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ Não foi possível encontrar um diretório de referência nos diretórios fornecidos para TargetFramework '{0}' ao carregar '{1}'. Para obter mais informações, consulte: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf
index e8f7e2a67ab7..59825e7528bb 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.ru.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ Не удалось найти справочный каталог в указанных каталогах для TargetFramework "{0}" при загрузке "{1}". Дополнительные сведения см. по адресу: https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf
index ae92e1907e98..1fd09a60d13a 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.tr.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ '{1}' yüklenirken '{0}' TargetFramework için sağlanan dizinlerde başvuru dizini bulunamadı. Daha fazla bilgi için bkz. https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf
index 005f3e2ed3ec..a4562f21cf38 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hans.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ 加载“{1}”时,在提供的目录中找不到 TargetFramework“{0}”的引用目录。有关详细信息,请参阅 https://aka.ms/dotnetpackagevalidation
diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf
index f11909eb0e1a..a6f5bd734b89 100644
--- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf
+++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/xlf/Resources.zh-Hant.xlf
@@ -14,7 +14,7 @@
Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
- Could not find a reference directory in the provided directories for TargetFramework '{0}' when loading '{1}'. For more information see: https://aka.ms/dotnetpackagevalidation
+ 載入 '{1}' 時,無法在提供的 TargetFramework '{0}' 目錄中找到參考目錄。如需詳細資訊,請參閱: https://aka.ms/dotnetpackagevalidation
diff --git a/src/Assets/TestPackages/dotnet-new/test_templates/TemplateWithConditions/nuget.config b/src/Assets/TestPackages/dotnet-new/test_templates/TemplateWithConditions/nuget.config
index 70125a73910d..bd3045ae46ab 100644
--- a/src/Assets/TestPackages/dotnet-new/test_templates/TemplateWithConditions/nuget.config
+++ b/src/Assets/TestPackages/dotnet-new/test_templates/TemplateWithConditions/nuget.config
@@ -2,8 +2,12 @@
foo
-
+
bar
-#endif -->
+
baz
+
+
+
+
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/Interop.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/Interop.cs
index 3885bac59461..6986fca46489 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/Interop.cs
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/Interop.cs
@@ -72,59 +72,4 @@ interface IEnumString
[MethodImpl(MethodImplOptions.InternalCall)]
void Clone([MarshalAs(UnmanagedType.Interface)] out IEnumString ppenum);
}
-
- // Decompiled from WUA typelib
- [ComImport]
- [Guid("ADE87BF7-7B56-4275-8FAB-B9B0E591844B")]
- [TypeLibType(4304)]
- public interface ISystemInformation
- {
- [DispId(1610743809)]
- string OemHardwareSupportLink
- {
- [MethodImpl(MethodImplOptions.InternalCall)]
- [DispId(1610743809)]
- [return: MarshalAs(UnmanagedType.BStr)]
- get;
- }
-
- [DispId(1610743810)]
- bool RebootRequired
- {
- [MethodImpl(MethodImplOptions.InternalCall)]
- [DispId(1610743810)]
- get;
- }
- }
-
- [ComImport]
- [Guid("ADE87BF7-7B56-4275-8FAB-B9B0E591844B")]
- [CoClass(typeof(SystemInformationClass))]
- public interface SystemInformation : ISystemInformation
- {
- }
-
- [ComImport]
- [Guid("C01B9BA0-BEA7-41BA-B604-D0A36F469133")]
- [TypeLibType(2)]
- [ClassInterface(ClassInterfaceType.None)]
- public class SystemInformationClass : ISystemInformation, SystemInformation
- {
- [DispId(1610743809)]
- public extern virtual string OemHardwareSupportLink
- {
- [MethodImpl(MethodImplOptions.InternalCall)]
- [DispId(1610743809)]
- [return: MarshalAs(UnmanagedType.BStr)]
- get;
- }
-
- [DispId(1610743810)]
- public extern virtual bool RebootRequired
- {
- [MethodImpl(MethodImplOptions.InternalCall)]
- [DispId(1610743810)]
- get;
- }
- }
}
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildPropertyParser.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildPropertyParser.cs
new file mode 100644
index 000000000000..505178a7f58d
--- /dev/null
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildPropertyParser.cs
@@ -0,0 +1,93 @@
+// Copyright (c) .NET Foundation and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+
+#nullable enable
+
+namespace Microsoft.DotNet.Cli.Utils;
+
+public static class MSBuildPropertyParser {
+ public static IEnumerable<(string key, string value)> ParseProperties(string input) {
+ var currentPos = 0;
+ StringBuilder currentKey = new StringBuilder();
+ StringBuilder currentValue = new StringBuilder();
+
+ (string key, string value) EmitAndReset() {
+ var key = currentKey.ToString();
+ var value= currentValue.ToString();
+ currentKey.Clear();
+ currentValue.Clear();
+ return (key, value);
+ }
+
+ char? Peek() => currentPos < input.Length ? input[currentPos] : null;
+
+ bool TryConsume(out char? consumed) {
+ if(input.Length > currentPos) {
+ consumed = input[currentPos];
+ currentPos++;
+ return true;
+ } else {
+ consumed = null;
+ return false;
+ }
+ }
+
+ void ParseKey() {
+ while (TryConsume(out var c) && c != '=') {
+ currentKey.Append(c);
+ }
+ }
+
+ void ParseQuotedValue() {
+ TryConsume(out var leadingQuote); // consume the leading quote, which we know is there
+ currentValue.Append(leadingQuote);
+ while(TryConsume(out char? c)) {
+ currentValue.Append(c);
+ if (c == '"') {
+ // we're done
+ return;
+ }
+ if (c == '\\' && Peek() == '"')
+ {
+ // consume the escaped quote
+ TryConsume(out var c2);
+ currentValue.Append(c2);
+ }
+ }
+ }
+
+ void ParseUnquotedValue() {
+ while(TryConsume(out char? c) && c != ';') {
+ currentValue.Append(c);
+ }
+ }
+
+ void ParseValue() {
+ if (Peek() == '"') {
+ ParseQuotedValue();
+ } else {
+ ParseUnquotedValue();
+ }
+ }
+
+ (string key, string value) ParseKeyValue() {
+ ParseKey();
+ ParseValue();
+ return EmitAndReset();
+ }
+
+ bool AtEnd() => currentPos == input.Length;
+
+ while (!(AtEnd())) {
+ yield return ParseKeyValue();
+ if (Peek() is char c && (c == ';' || c== ',')) {
+ TryConsume(out _); // swallow the next semicolon or comma delimiter
+ }
+ }
+ }
+}
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/Windows.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/Windows.cs
index 5bdc5ee3bf96..4e2b74351554 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/Windows.cs
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/Windows.cs
@@ -39,19 +39,6 @@ public static bool InstallRunning()
return !Mutex.TryOpenExisting(@"Global\_MSIExecute", out _);
}
- ///
- /// Queries the Windows Update Agent API to determine if there is a pending reboot.
- ///
- /// if there is a pending reboot; otherwise.
- ///
- /// See this
- /// for more information.
- ///
- public static bool RebootRequired()
- {
- return new SystemInformationClass().RebootRequired;
- }
-
///
/// Returns the commandline of the currently executing process.
///
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.cs.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.cs.xlf
index 21936ee731ca..f8c110d4f01a 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.cs.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.cs.xlf
@@ -77,7 +77,7 @@ Mezi možné příčiny patří toto:
.NET SDK:
- SADA .NET SDK:
+ SADA .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.de.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.de.xlf
index 0e7254d3e262..f9afa89a6bf4 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.de.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.de.xlf
@@ -77,7 +77,7 @@ Mögliche Ursachen:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.es.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.es.xlf
index 9a47b6e8b9ff..f77e887c2b58 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.es.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.es.xlf
@@ -77,7 +77,7 @@ Algunas de las posibles causas son :
.NET SDK:
- SDK DE .NET:
+ SDK DE .NET:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.fr.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.fr.xlf
index 18aa9d9403a3..6ceba12646e8 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.fr.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.fr.xlf
@@ -77,7 +77,7 @@ Raisons possibles :
.NET SDK:
- SDK .NET :
+ SDK .NET :
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.it.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.it.xlf
index 51795059416d..87ec2c18edf9 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.it.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.it.xlf
@@ -77,7 +77,7 @@ Motivi possibili:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ja.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ja.xlf
index 28d6610ce095..5249c20c6cc5 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ja.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ja.xlf
@@ -77,7 +77,7 @@ Possible reasons for this include:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ko.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ko.xlf
index 44dea377e04a..8b02bcda1534 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ko.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ko.xlf
@@ -77,7 +77,7 @@ Possible reasons for this include:
.NET SDK:
- .NET SDK (reflecting any global.json):
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pl.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pl.xlf
index ef60a1d6ffa3..4449cff1052d 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pl.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pl.xlf
@@ -77,7 +77,7 @@ Możliwe przyczyny:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pt-BR.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pt-BR.xlf
index 26ba7d54fb68..e085bb22e6e2 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pt-BR.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.pt-BR.xlf
@@ -77,7 +77,7 @@ Possíveis motivos para isso incluem:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ru.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ru.xlf
index f9e7e9c4acd4..0ebf4969bd2e 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ru.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.ru.xlf
@@ -77,7 +77,7 @@ Possible reasons for this include:
.NET SDK:
- ПАКЕТ SDK ДЛЯ .NET:
+ ПАКЕТ SDK ДЛЯ .NET:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.tr.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.tr.xlf
index f729be471002..5602fad87b49 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.tr.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.tr.xlf
@@ -77,7 +77,7 @@ Bunun nedeni şunlardan biri olabilir:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hans.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hans.xlf
index 48c1dad02399..50ab968bdd7e 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hans.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hans.xlf
@@ -77,7 +77,7 @@ Possible reasons for this include:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hant.xlf b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hant.xlf
index 4bba6d947f3a..41d0a2a37613 100644
--- a/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hant.xlf
+++ b/src/Cli/Microsoft.DotNet.Cli.Utils/xlf/LocalizableStrings.zh-Hant.xlf
@@ -77,7 +77,7 @@ Possible reasons for this include:
.NET SDK:
- .NET SDK:
+ .NET SDK:
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/AnsiColorExtensions.cs b/src/Cli/Microsoft.TemplateEngine.Cli/AnsiColorExtensions.cs
deleted file mode 100644
index 1877eee20974..000000000000
--- a/src/Cli/Microsoft.TemplateEngine.Cli/AnsiColorExtensions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace Microsoft.TemplateEngine.Cli
-{
- internal static class AnsiColorExtensions
- {
- internal static string Black(this string text)
- {
- return "\x1B[30m" + text + "\x1B[39m";
- }
-
- internal static string Red(this string text)
- {
- return "\x1B[31m" + text + "\x1B[39m";
- }
-
- internal static string Green(this string text)
- {
- return "\x1B[32m" + text + "\x1B[39m";
- }
-
- internal static string Yellow(this string text)
- {
- return "\x1B[33m" + text + "\x1B[39m";
- }
-
- internal static string Blue(this string text)
- {
- return "\x1B[34m" + text + "\x1B[39m";
- }
-
- internal static string Magenta(this string text)
- {
- return "\x1B[35m" + text + "\x1B[39m";
- }
-
- internal static string Cyan(this string text)
- {
- return "\x1B[36m" + text + "\x1B[39m";
- }
-
- internal static string White(this string text)
- {
- return "\x1B[37m" + text + "\x1B[39m";
- }
-
- internal static string Bold(this string text)
- {
- return "\x1B[1m" + text + "\x1B[22m";
- }
- }
-}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/AnsiConsole.cs b/src/Cli/Microsoft.TemplateEngine.Cli/AnsiConsole.cs
deleted file mode 100644
index 9c0c04be6e06..000000000000
--- a/src/Cli/Microsoft.TemplateEngine.Cli/AnsiConsole.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace Microsoft.TemplateEngine.Cli
-{
- internal class AnsiConsole
- {
- private int _boldRecursion;
-
- internal AnsiConsole(TextWriter writer)
- {
- Writer = writer;
-
- OriginalForegroundColor = Console.ForegroundColor;
- }
-
- internal TextWriter Writer { get; }
-
- internal ConsoleColor OriginalForegroundColor { get; }
-
- internal static AnsiConsole GetOutput()
- {
- return new AnsiConsole(Console.Out);
- }
-
- internal static AnsiConsole GetError()
- {
- return new AnsiConsole(Console.Error);
- }
-
- internal void WriteLine(string message)
- {
- Write(message);
- Writer.WriteLine();
- }
-
- internal void Write(string message)
- {
- var escapeScan = 0;
- for (; ; )
- {
- var escapeIndex = message.IndexOf("\x1b[", escapeScan, StringComparison.Ordinal);
- if (escapeIndex == -1)
- {
- var text = message.Substring(escapeScan);
- Writer.Write(text);
- break;
- }
- else
- {
- var startIndex = escapeIndex + 2;
- var endIndex = startIndex;
- while (endIndex != message.Length &&
- message[endIndex] >= 0x20 &&
- message[endIndex] <= 0x3f)
- {
- endIndex += 1;
- }
-
- var text = message.Substring(escapeScan, escapeIndex - escapeScan);
- Writer.Write(text);
- if (endIndex == message.Length)
- {
- break;
- }
-
- switch (message[endIndex])
- {
- case 'm':
- int value;
- if (int.TryParse(message.Substring(startIndex, endIndex - startIndex), out value))
- {
- switch (value)
- {
- case 1:
- SetBold(true);
- break;
- case 22:
- SetBold(false);
- break;
- case 30:
- SetColor(ConsoleColor.Black);
- break;
- case 31:
- SetColor(ConsoleColor.Red);
- break;
- case 32:
- SetColor(ConsoleColor.Green);
- break;
- case 33:
- SetColor(ConsoleColor.Yellow);
- break;
- case 34:
- SetColor(ConsoleColor.Blue);
- break;
- case 35:
- SetColor(ConsoleColor.Magenta);
- break;
- case 36:
- SetColor(ConsoleColor.Cyan);
- break;
- case 37:
- SetColor(ConsoleColor.Gray);
- break;
- case 39:
- Console.ForegroundColor = OriginalForegroundColor;
- break;
- }
- }
- break;
- }
-
- escapeScan = endIndex + 1;
- }
- }
- }
-
- private void SetColor(ConsoleColor color)
- {
- const int Light = 0x08;
- int c = (int)color;
-
- Console.ForegroundColor =
- c < 0 ? color : // unknown, just use it
- _boldRecursion > 0 ? (ConsoleColor)(c | Light) : // ensure color is light
- (ConsoleColor)(c & ~Light); // ensure color is dark
- }
-
- private void SetBold(bool bold)
- {
- _boldRecursion += bold ? 1 : -1;
- if (_boldRecursion > 1 || (_boldRecursion == 1 && !bold))
- {
- return;
- }
-
- // switches on _boldRecursion to handle boldness
- SetColor(Console.ForegroundColor);
- }
- }
-}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/BaseCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/BaseCommand.cs
index 4ce95e23f1b6..475cb4146e2b 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/BaseCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/BaseCommand.cs
@@ -6,12 +6,14 @@
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.Reflection;
+using Microsoft.DotNet.Cli.Utils;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Abstractions.Mount;
using Microsoft.TemplateEngine.Cli.TabularOutput;
using Microsoft.TemplateEngine.Edge;
using Microsoft.TemplateEngine.Edge.Settings;
using Microsoft.TemplateEngine.Utils;
+using Command = System.CommandLine.Command;
namespace Microsoft.TemplateEngine.Cli.Commands
{
@@ -23,19 +25,14 @@ internal abstract class BaseCommand : Command
protected BaseCommand(
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string name,
string description)
: base(name, description)
{
_hostBuilder = hostBuilder;
_telemetryLoggerBuilder = telemetryLoggerBuilder;
- Callbacks = callbacks;
-
}
- internal NewCommandCallbacks Callbacks { get; }
-
protected internal virtual IEnumerable GetCompletions(CompletionContext context, IEngineEnvironmentSettings environmentSettings)
{
return base.GetCompletions(context);
@@ -82,10 +79,9 @@ internal abstract class BaseCommand : BaseCommand, ICommandHandler where
internal BaseCommand(
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string name,
string description)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, name, description)
+ : base(hostBuilder, telemetryLoggerBuilder, name, description)
{
this.Handler = this;
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.Legacy.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.Legacy.cs
index 9f51ad19c86b..0dd80b91233b 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.Legacy.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.Legacy.cs
@@ -123,7 +123,7 @@ private static void ValidateArgumentUsage(CommandResult commandResult, params Ar
}
}
- private void BuildLegacySymbols(Func hostBuilder, Func telemetryLoggerBuilder, NewCommandCallbacks callbacks)
+ private void BuildLegacySymbols(Func hostBuilder, Func telemetryLoggerBuilder)
{
this.AddArgument(ShortNameArgument);
this.AddArgument(RemainingArguments);
@@ -144,14 +144,14 @@ private void BuildLegacySymbols(Func hostBuild
this.TreatUnmatchedTokensAsErrors = true;
- this.Add(new LegacyInstallCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacyUninstallCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacyUpdateCheckCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacyUpdateApplyCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacySearchCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacyListCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacyAliasAddCommand(hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new LegacyAliasShowCommand(hostBuilder, telemetryLoggerBuilder, callbacks));
+ this.Add(new LegacyInstallCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacyUninstallCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacyUpdateCheckCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacyUpdateApplyCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacySearchCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacyListCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacyAliasAddCommand(hostBuilder, telemetryLoggerBuilder));
+ this.Add(new LegacyAliasShowCommand(hostBuilder, telemetryLoggerBuilder));
}
}
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.cs
index a51a8c78f4c5..4c86841a2d4a 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/NewCommand.cs
@@ -15,22 +15,21 @@ internal partial class NewCommand : BaseCommand, ICustomHelp
internal NewCommand(
string commandName,
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, commandName, SymbolStrings.Command_New_Description)
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, commandName, SymbolStrings.Command_New_Description)
{
this.TreatUnmatchedTokensAsErrors = true;
//it is important that legacy commands are built before non-legacy, as non legacy commands are building validators that rely on legacy stuff
- BuildLegacySymbols(hostBuilder, telemetryLoggerBuilder, callbacks);
-
- this.Add(new InstantiateCommand(hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new InstallCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new UninstallCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new UpdateCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new SearchCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new ListCommand(this, hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new AliasCommand(hostBuilder, telemetryLoggerBuilder, callbacks));
+ BuildLegacySymbols(hostBuilder, telemetryLoggerBuilder);
+
+ this.Add(new InstantiateCommand(hostBuilder, telemetryLoggerBuilder));
+ this.Add(new InstallCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new UninstallCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new UpdateCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new SearchCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new ListCommand(this, hostBuilder, telemetryLoggerBuilder));
+ this.Add(new AliasCommand(hostBuilder, telemetryLoggerBuilder));
this.AddGlobalOption(DebugCustomSettingsLocationOption);
this.AddGlobalOption(DebugVirtualizeSettingsOption);
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasAddCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasAddCommand.cs
index 524af318ccdf..39e6f3bfc9a6 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasAddCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasAddCommand.cs
@@ -11,9 +11,8 @@ internal class AliasAddCommand : BaseAliasAddCommand
{
internal AliasAddCommand(
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, "add")
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, "add")
{
IsHidden = true;
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasCommand.cs
index 9c0549646110..1b78b27a9c89 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasCommand.cs
@@ -12,13 +12,12 @@ internal class AliasCommand : BaseCommand
{
internal AliasCommand(
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, "alias", SymbolStrings.Command_Alias_Description)
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, "alias", SymbolStrings.Command_Alias_Description)
{
IsHidden = true;
- this.Add(new AliasAddCommand(hostBuilder, telemetryLoggerBuilder, callbacks));
- this.Add(new AliasShowCommand(hostBuilder, telemetryLoggerBuilder, callbacks));
+ this.Add(new AliasAddCommand(hostBuilder, telemetryLoggerBuilder));
+ this.Add(new AliasShowCommand(hostBuilder, telemetryLoggerBuilder));
}
protected override Task ExecuteAsync(
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasShowCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasShowCommand.cs
index 648cdcd13fb3..70a2d636e9aa 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasShowCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/AliasShowCommand.cs
@@ -11,9 +11,8 @@ internal class AliasShowCommand : BaseAliasShowCommand
{
internal AliasShowCommand(
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, "show")
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, "show")
{
IsHidden = true;
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasAddCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasAddCommand.cs
index d9c5a7320be3..e049515dd582 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasAddCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasAddCommand.cs
@@ -13,9 +13,8 @@ internal class BaseAliasAddCommand : BaseCommand
internal BaseAliasAddCommand(
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string commandName)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, commandName, SymbolStrings.Command_AliasAdd_Description) { }
+ : base(hostBuilder, telemetryLoggerBuilder, commandName, SymbolStrings.Command_AliasAdd_Description) { }
protected override Task ExecuteAsync(
AliasAddCommandArgs args,
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasShowCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasShowCommand.cs
index 4052b1027732..bea4f51a664a 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasShowCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/BaseAliasShowCommand.cs
@@ -13,9 +13,8 @@ internal class BaseAliasShowCommand : BaseCommand
internal BaseAliasShowCommand(
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string commandName)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, commandName, SymbolStrings.Command_AliasShow_Description) { }
+ : base(hostBuilder, telemetryLoggerBuilder, commandName, SymbolStrings.Command_AliasShow_Description) { }
protected override Task ExecuteAsync(
AliasShowCommandArgs args,
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasAddCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasAddCommand.cs
index e638191f641a..4e60732d963f 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasAddCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasAddCommand.cs
@@ -11,9 +11,8 @@ internal class LegacyAliasAddCommand : BaseAliasAddCommand
{
internal LegacyAliasAddCommand(
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, "--alias")
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, "--alias")
{
AddAlias("-a");
IsHidden = true;
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasShowCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasShowCommand.cs
index bf92c1b4d502..e25c4405c2ae 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasShowCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/alias/LegacyAliasShowCommand.cs
@@ -11,9 +11,8 @@ internal class LegacyAliasShowCommand : BaseAliasShowCommand
{
internal LegacyAliasShowCommand(
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, "--show-alias")
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, "--show-alias")
{
IsHidden = true;
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.Help.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.Help.cs
index 58327684b1d3..401206a266d6 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.Help.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.Help.cs
@@ -5,9 +5,11 @@
using System.CommandLine.Help;
using System.CommandLine.Parsing;
using System.Diagnostics.CodeAnalysis;
+using Microsoft.DotNet.Cli.Utils;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Edge.Settings;
using Microsoft.TemplateEngine.Utils;
+using Command = System.CommandLine.Command;
namespace Microsoft.TemplateEngine.Cli.Commands
{
@@ -97,7 +99,7 @@ public IEnumerable CustomHelpLayout()
internal static bool VerifyMatchingTemplates(
IEngineEnvironmentSettings environmentSettings,
IEnumerable matchingTemplates,
- Reporter reporter,
+ IReporter reporter,
[NotNullWhen(true)]
out IEnumerable? filteredTemplates)
{
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.NoMatchHandling.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.NoMatchHandling.cs
index 221bf4141f2e..3364d7d0f201 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.NoMatchHandling.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.NoMatchHandling.cs
@@ -4,8 +4,10 @@
using System.CommandLine;
using System.CommandLine.Parsing;
using System.Text;
+using Microsoft.DotNet.Cli.Utils;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Edge.Settings;
+using Command = System.CommandLine.Command;
namespace Microsoft.TemplateEngine.Cli.Commands
{
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs
index 9b69b55c3b11..7ed535027b6e 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.TabCompletion.cs
@@ -4,6 +4,7 @@
using System.CommandLine;
using System.CommandLine.Completions;
using System.CommandLine.Parsing;
+using Microsoft.DotNet.Cli.Utils;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Edge;
using Microsoft.TemplateEngine.Edge.Settings;
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.cs
index c644bc676cc9..a725fedb08b1 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/InstantiateCommand.cs
@@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
-using System.CommandLine.Help;
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.Linq;
+using Microsoft.DotNet.Cli.Utils;
using Microsoft.Extensions.Logging;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Abstractions.TemplatePackage;
@@ -19,9 +19,8 @@ internal partial class InstantiateCommand : BaseCommand,
{
internal InstantiateCommand(
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, "create", SymbolStrings.Command_Instantiate_Description)
+ Func telemetryLoggerBuilder)
+ : base(hostBuilder, telemetryLoggerBuilder, "create", SymbolStrings.Command_Instantiate_Description)
{
this.AddArgument(ShortNameArgument);
this.AddArgument(RemainingArguments);
@@ -227,7 +226,7 @@ private static async Task ExecuteIntAsync(
private static NewCommandStatus HandleAmbiguousLanguage(
IEngineEnvironmentSettings environmentSettings,
IEnumerable templates,
- Reporter reporter)
+ IReporter reporter)
{
reporter.WriteLine(HelpStrings.TableHeader_AmbiguousTemplatesList);
TemplateGroupDisplay.DisplayTemplateList(
@@ -242,7 +241,7 @@ private static NewCommandStatus HandleAmbiguousLanguage(
private static NewCommandStatus HandleAmbiguousType(
IEngineEnvironmentSettings environmentSettings,
IEnumerable templates,
- Reporter reporter)
+ IReporter reporter)
{
reporter.WriteLine(HelpStrings.TableHeader_AmbiguousTemplatesList);
TemplateGroupDisplay.DisplayTemplateList(
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/TemplateCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/TemplateCommand.cs
index ba8829ff4a5f..254a4eb67d86 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/TemplateCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/create/TemplateCommand.cs
@@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
-using System.CommandLine.Invocation;
-using System.CommandLine.Parsing;
-using System.Threading;
+using Microsoft.DotNet.Cli.Utils;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Abstractions.Constraints;
using Microsoft.TemplateEngine.Abstractions.Installer;
@@ -12,6 +10,7 @@
using Microsoft.TemplateEngine.Edge;
using Microsoft.TemplateEngine.Edge.Settings;
using Microsoft.TemplateEngine.Utils;
+using Command = System.CommandLine.Command;
namespace Microsoft.TemplateEngine.Cli.Commands
{
@@ -174,7 +173,7 @@ internal static async Task> ValidateCons
internal async Task InvokeAsync(ParseResult parseResult, ITelemetryLogger telemetryLogger, CancellationToken cancellationToken)
{
TemplateCommandArgs args = new TemplateCommandArgs(this, _instantiateCommand, parseResult);
- TemplateInvoker invoker = new TemplateInvoker(_environmentSettings, telemetryLogger, () => Console.ReadLine() ?? string.Empty, _instantiateCommand.Callbacks);
+ TemplateInvoker invoker = new TemplateInvoker(_environmentSettings, telemetryLogger, () => Console.ReadLine() ?? string.Empty);
TemplatePackageCoordinator packageCoordinator = new TemplatePackageCoordinator(telemetryLogger, _environmentSettings, _templatePackageManager);
TemplateConstraintManager constraintManager = new TemplateConstraintManager(_environmentSettings);
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/BaseInstallCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/BaseInstallCommand.cs
index ff99d885b889..aee2d396d694 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/BaseInstallCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/BaseInstallCommand.cs
@@ -15,9 +15,8 @@ internal BaseInstallCommand(
NewCommand parentCommand,
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string commandName)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, commandName, SymbolStrings.Command_Install_Description)
+ : base(hostBuilder, telemetryLoggerBuilder, commandName, SymbolStrings.Command_Install_Description)
{
ParentCommand = parentCommand;
this.AddArgument(NameArgument);
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/InstallCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/InstallCommand.cs
index b064d627050c..392c730e8f7a 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/InstallCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/InstallCommand.cs
@@ -12,9 +12,8 @@ internal class InstallCommand : BaseInstallCommand
public InstallCommand(
NewCommand parentCommand,
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(parentCommand, hostBuilder, telemetryLoggerBuilder, callbacks, "install")
+ Func telemetryLoggerBuilder)
+ : base(parentCommand, hostBuilder, telemetryLoggerBuilder, "install")
{
parentCommand.AddNoLegacyUsageValidators(this);
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/LegacyInstallCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/LegacyInstallCommand.cs
index 5f69a8db509a..30b5f44df7bd 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/LegacyInstallCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/install/LegacyInstallCommand.cs
@@ -10,8 +10,8 @@ namespace Microsoft.TemplateEngine.Cli.Commands
{
internal class LegacyInstallCommand : BaseInstallCommand
{
- public LegacyInstallCommand(NewCommand parentCommand, Func hostBuilder, Func telemetryLoggerBuilder, NewCommandCallbacks callbacks)
- : base(parentCommand, hostBuilder, telemetryLoggerBuilder, callbacks, "--install")
+ public LegacyInstallCommand(NewCommand parentCommand, Func hostBuilder, Func telemetryLoggerBuilder)
+ : base(parentCommand, hostBuilder, telemetryLoggerBuilder, "--install")
{
this.IsHidden = true;
this.AddAlias("-i");
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/BaseListCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/BaseListCommand.cs
index 98ddf7a460f4..b3e62bf96be6 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/BaseListCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/BaseListCommand.cs
@@ -24,9 +24,8 @@ internal BaseListCommand(
NewCommand parentCommand,
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string commandName)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, commandName, SymbolStrings.Command_List_Description)
+ : base(hostBuilder, telemetryLoggerBuilder, commandName, SymbolStrings.Command_List_Description)
{
ParentCommand = parentCommand;
Filters = SetupFilterOptions(SupportedFilters);
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/LegacyListCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/LegacyListCommand.cs
index 2da044c278c5..b75cf009a075 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/LegacyListCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/LegacyListCommand.cs
@@ -13,9 +13,8 @@ internal class LegacyListCommand : BaseListCommand
public LegacyListCommand(
NewCommand parentCommand,
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(parentCommand, hostBuilder, telemetryLoggerBuilder, callbacks, "--list")
+ Func telemetryLoggerBuilder)
+ : base(parentCommand, hostBuilder, telemetryLoggerBuilder, "--list")
{
this.IsHidden = true;
this.AddAlias("-l");
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/ListCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/ListCommand.cs
index 782a99e617fc..2f0756631af8 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/ListCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/list/ListCommand.cs
@@ -12,9 +12,8 @@ internal class ListCommand : BaseListCommand
public ListCommand(
NewCommand parentCommand,
Func hostBuilder,
- Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks)
- : base(parentCommand, hostBuilder, telemetryLoggerBuilder, callbacks, "list")
+ Func telemetryLoggerBuilder)
+ : base(parentCommand, hostBuilder, telemetryLoggerBuilder, "list")
{
parentCommand.AddNoLegacyUsageValidators(this);
}
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/BaseSearchCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/BaseSearchCommand.cs
index 701b5aab5ee8..31b1f12dee17 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/BaseSearchCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/BaseSearchCommand.cs
@@ -26,9 +26,8 @@ internal BaseSearchCommand(
NewCommand parentCommand,
Func hostBuilder,
Func telemetryLoggerBuilder,
- NewCommandCallbacks callbacks,
string commandName)
- : base(hostBuilder, telemetryLoggerBuilder, callbacks, commandName, SymbolStrings.Command_Search_Description)
+ : base(hostBuilder, telemetryLoggerBuilder, commandName, SymbolStrings.Command_Search_Description)
{
ParentCommand = parentCommand;
Filters = SetupFilterOptions(SupportedFilters);
diff --git a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/LegacySearchCommand.cs b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/LegacySearchCommand.cs
index 6bb8d29c5fa0..766166245edb 100644
--- a/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/LegacySearchCommand.cs
+++ b/src/Cli/Microsoft.TemplateEngine.Cli/Commands/search/LegacySearchCommand.cs
@@ -10,8 +10,8 @@ namespace Microsoft.TemplateEngine.Cli.Commands
{
internal class LegacySearchCommand : BaseSearchCommand
{
- public LegacySearchCommand(NewCommand parentCommand, Func hostBuilder, Func