From d78e9ef7742204c255b7e99bf9bc6355f5a48aee Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:26:42 +0000 Subject: [PATCH] [main] Update dependencies from dotnet/arcade (dotnet/linker#3177) [main] Update dependencies from dotnet/arcade - Analyzer fix - Update to net8 - Update import order - Add net8 handling - Analyzer fixes - Merge branch 'main' into darc-main-328ee272-9fb8-4717-bae0-5575b14d7744 - More analyzer fixes - Port fix from runtime - Update failing test - verbose test - Fix formatting - Fix the task to look for net8.0 location. Revert test changes. - Workaround a possible issue in the new SDK Commit migrated from https://github.com/dotnet/linker/commit/2bd23e198227c95774ce9068ed94f617843212fd --- src/tools/illink/Directory.Build.props | 10 ++--- src/tools/illink/NuGet.config | 1 + src/tools/illink/eng/Version.Details.xml | 8 ++-- src/tools/illink/eng/Versions.props | 4 +- .../illink/eng/common/cross/build-rootfs.sh | 18 +++++--- .../illink/eng/common/generate-locproject.ps1 | 45 ++++++++++++++++++- .../illink/eng/common/templates/job/job.yml | 10 +++++ .../templates/job/source-index-stage1.yml | 6 +-- .../templates/variables/pool-providers.yml | 4 +- src/tools/illink/eng/common/tools.ps1 | 4 +- src/tools/illink/eng/common/tools.sh | 4 +- src/tools/illink/global.json | 6 +-- .../DynamicallyAccessedMembersAnalyzer.cs | 2 +- .../TrimAnalysis/ParameterProxy.cs | 2 +- .../DataFlow/DefaultValueDictionary.cs | 3 ++ .../ILLink.Shared/DataFlow/MaybeLattice.cs | 3 ++ .../src/ILLink.Shared/DataFlow/ValueSet.cs | 3 ++ .../TypeSystemProxy/WellKnownType.cs | 1 + .../src/ILLink.Tasks/ILLink.Tasks.csproj | 2 + src/tools/illink/src/ILLink.Tasks/LinkTask.cs | 2 +- .../linker/Linker.Dataflow/HoistedLocalKey.cs | 3 ++ .../src/linker/Linker.Dataflow/ValueNode.cs | 3 ++ .../illink/src/linker/Mono.Linker.csproj | 2 + .../RequiresAssemblyFilesAnalyzerTests.cs | 4 ++ .../TestCaseUtils.cs | 6 +-- .../Verifiers/CSharpAnalyzerVerifier`1.cs | 4 +- .../ExpectedInstructionSequenceAttribute.cs | 3 +- ...tionSequenceOnMemberInAssemblyAttribute.cs | 9 ++-- .../ExpectedLocalsSequenceAttribute.cs | 6 +-- .../Assertions/IgnoreTestCaseAttribute.cs | 3 +- .../Assertions/KeptAttributeAttribute.cs | 3 +- ...KeptAttributeOnFixedBufferTypeAttribute.cs | 3 +- .../KeptBaseOnTypeInAssemblyAttribute.cs | 3 +- .../Assertions/KeptBaseTypeAttribute.cs | 9 ++-- .../Assertions/KeptExportedTypeAttribute.cs | 3 +- .../Assertions/KeptInitializerData.cs | 3 +- .../Assertions/KeptInterfaceAttribute.cs | 9 ++-- .../KeptInterfaceOnTypeInAssemblyAttribute.cs | 3 +- .../KeptMemberInAssemblyAttribute.cs | 12 ++--- .../Assertions/KeptOverrideAttribute.cs | 3 +- .../KeptReferencesInAssemblyAttribute.cs | 3 +- .../Assertions/KeptSecurityAttribute.cs | 3 +- .../Assertions/KeptTypeInAssemblyAttribute.cs | 3 +- ...movedInterfaceOnTypeInAssemblyAttribute.cs | 3 +- .../RemovedMemberInAssemblyAttribute.cs | 12 ++--- .../RemovedTypeInAssemblyAttribute.cs | 3 +- .../TestCaseRequirementsAttribute.cs | 3 +- .../Metadata/SetupCompileAfterAttribute.cs | 3 +- .../Metadata/SetupCompileBeforeAttribute.cs | 6 +-- .../Mono.Linker.Tests/Extensions/NiceIO.cs | 3 +- .../TestCasesRunner/AssemblyChecker.cs | 2 +- .../TestCasesRunner/PathUtilities.cs | 4 +- .../TestCasesRunner/TestCaseCompiler.cs | 4 +- 53 files changed, 165 insertions(+), 119 deletions(-) diff --git a/src/tools/illink/Directory.Build.props b/src/tools/illink/Directory.Build.props index fd92a0f7f4645..f80f6f9039258 100644 --- a/src/tools/illink/Directory.Build.props +++ b/src/tools/illink/Directory.Build.props @@ -1,14 +1,17 @@ + + + false true true - net7.0 + $(NetCurrent) - net7.0 + $(NetCurrent) true @@ -18,9 +21,6 @@ false false - - - false MIT diff --git a/src/tools/illink/NuGet.config b/src/tools/illink/NuGet.config index e50a0328b5ff6..3ea744d297335 100644 --- a/src/tools/illink/NuGet.config +++ b/src/tools/illink/NuGet.config @@ -6,6 +6,7 @@ + diff --git a/src/tools/illink/eng/Version.Details.xml b/src/tools/illink/eng/Version.Details.xml index fd8cf6a393bda..cca31d3301159 100644 --- a/src/tools/illink/eng/Version.Details.xml +++ b/src/tools/illink/eng/Version.Details.xml @@ -3,14 +3,14 @@ - + https://github.com/dotnet/arcade - e82404fca08383513e0b0b3c5308d4a9b18b7c7a + 3600aa80a01e90f38a7b86b9d7c1264e091aa5a8 - + https://github.com/dotnet/arcade - e82404fca08383513e0b0b3c5308d4a9b18b7c7a + 3600aa80a01e90f38a7b86b9d7c1264e091aa5a8 https://github.com/dotnet/runtime diff --git a/src/tools/illink/eng/Versions.props b/src/tools/illink/eng/Versions.props index 21861f23f4179..a4efb9fe85271 100644 --- a/src/tools/illink/eng/Versions.props +++ b/src/tools/illink/eng/Versions.props @@ -18,14 +18,14 @@ 5.0.0 17.0.0-preview-21267-01 17.0.0-preview-21267-01 - 8.0.0-beta.22630.1 + 8.0.0-beta.23067.5 6.0.0-beta.21271.1 3.10.0-2.final 4.5.0-1.22517.9 $(MicrosoftCodeAnalysisVersion) 1.0.1-beta1.* 3.3.2 - 7.0.0-preview.7.22375.6 + 8.0.0-alpha.1.23067.11 diff --git a/src/tools/illink/eng/common/cross/build-rootfs.sh b/src/tools/illink/eng/common/cross/build-rootfs.sh index b04d3b3806575..1ebf454f3cf28 100755 --- a/src/tools/illink/eng/common/cross/build-rootfs.sh +++ b/src/tools/illink/eng/common/cross/build-rootfs.sh @@ -48,12 +48,14 @@ __UbuntuPackages+=" symlinks" __UbuntuPackages+=" libicu-dev" __UbuntuPackages+=" liblttng-ust-dev" __UbuntuPackages+=" libunwind8-dev" +__UbuntuPackages+=" libnuma-dev" __AlpinePackages+=" gettext-dev" __AlpinePackages+=" icu-dev" __AlpinePackages+=" libunwind-dev" __AlpinePackages+=" lttng-ust-dev" __AlpinePackages+=" compiler-rt-static" +__AlpinePackages+=" numactl-dev" # runtime libraries' dependencies __UbuntuPackages+=" libcurl4-openssl-dev" @@ -147,9 +149,9 @@ while :; do __BuildArch=ppc64le __UbuntuArch=ppc64el __UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/" - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libunwind8-dev//') - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp-dev//') - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp5//') + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp5/}" unset __LLDB_Package ;; riscv64) @@ -157,7 +159,7 @@ while :; do __UbuntuArch=riscv64 __UbuntuRepo="http://deb.debian.org/debian-ports" __CodeName=sid - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libunwind8-dev//') + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" unset __LLDB_Package if [[ -e "/usr/share/keyrings/debian-ports-archive-keyring.gpg" ]]; then @@ -168,9 +170,9 @@ while :; do __BuildArch=s390x __UbuntuArch=s390x __UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/" - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libunwind8-dev//') - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp-dev//') - __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp5//') + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp5/}" unset __LLDB_Package ;; x64) @@ -310,6 +312,8 @@ done if [[ "$__BuildArch" == "armel" ]]; then __LLDB_Package="lldb-3.5-dev" +elif [[ "$__BuildArch" == "arm" && "$__AlpineVersion" == "3.13" ]]; then + __AlpinePackages="${__AlpinePackages//numactl-dev/}" fi __UbuntuPackages+=" ${__LLDB_Package:-}" diff --git a/src/tools/illink/eng/common/generate-locproject.ps1 b/src/tools/illink/eng/common/generate-locproject.ps1 index dbf2ab4ee7d17..69e65eeae7de0 100644 --- a/src/tools/illink/eng/common/generate-locproject.ps1 +++ b/src/tools/illink/eng/common/generate-locproject.ps1 @@ -34,6 +34,25 @@ $jsonTemplateFiles | ForEach-Object { $jsonWinformsTemplateFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "en\\strings\.json" } # current winforms pattern $wxlFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\\.+\.wxl" -And -Not( $_.Directory.Name -Match "\d{4}" ) } # localized files live in four digit lang ID directories; this excludes them +if (-not $wxlFiles) { + $wxlEnFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\\1033\\.+\.wxl" } # pick up en files (1033 = en) specifically so we can copy them to use as the neutral xlf files + if ($wxlEnFiles) { + $wxlFiles = @() + $wxlEnFiles | ForEach-Object { + $destinationFile = "$($_.Directory.Parent.FullName)\$($_.Name)" + $wxlFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru + } + } +} + +$macosHtmlEnFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "en\.lproj\\.+\.html" } # add installer HTML files +$macosHtmlFiles = @() +if ($macosHtmlEnFiles) { + $macosHtmlEnFiles | ForEach-Object { + $destinationFile = "$($_.Directory.Parent.FullName)\$($_.Name)" + $macosHtmlFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru + } +} $xlfFiles = @() @@ -99,8 +118,7 @@ $locJson = @{ $outputPath = "$($_.Directory.FullName | Resolve-Path -Relative)\" $continue = $true foreach ($exclusion in $exclusions.Exclusions) { - if ($_.FullName.Contains($exclusion)) - { + if ($_.FullName.Contains($exclusion)) { $continue = $false } } @@ -115,6 +133,29 @@ $locJson = @{ } } ) + }, + @{ + LanguageSet = $LanguageSet + CloneLanguageSet = "VS_macOS_CloneLanguages" + LocItems = @( + $macosHtmlFiles | ForEach-Object { + $outputPath = "$($_.Directory.FullName | Resolve-Path -Relative)\" + $continue = $true + foreach ($exclusion in $exclusions.Exclusions) { + if ($_.FullName.Contains($exclusion)) { + $continue = $false + } + } + $sourceFile = ($_.FullName | Resolve-Path -Relative) + if ($continue) { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnPath" + OutputPath = $outputPath + } + } + } + ) } ) } diff --git a/src/tools/illink/eng/common/templates/job/job.yml b/src/tools/illink/eng/common/templates/job/job.yml index 0549e4c71ce3e..f0af425d9f68a 100644 --- a/src/tools/illink/eng/common/templates/job/job.yml +++ b/src/tools/illink/eng/common/templates/job/job.yml @@ -88,6 +88,16 @@ jobs: - ${{ if ne(variable.group, '') }}: - group: ${{ variable.group }} + # handle template variable syntax + # example: + # - template: path/to/template.yml + # parameters: + # [key]: [value] + - ${{ if ne(variable.template, '') }}: + - template: ${{ variable.template }} + ${{ if ne(variable.parameters, '') }}: + parameters: ${{ variable.parameters }} + # handle key-value variable syntax. # example: # - [key]: [value] diff --git a/src/tools/illink/eng/common/templates/job/source-index-stage1.yml b/src/tools/illink/eng/common/templates/job/source-index-stage1.yml index 09c506d11855d..71b66aeb8a5c5 100644 --- a/src/tools/illink/eng/common/templates/job/source-index-stage1.yml +++ b/src/tools/illink/eng/common/templates/job/source-index-stage1.yml @@ -1,6 +1,6 @@ parameters: runAsPublic: false - sourceIndexPackageVersion: 1.0.1-20220804.1 + sourceIndexPackageVersion: 1.0.1-20221220.2 sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci" preSteps: [] @@ -40,10 +40,10 @@ jobs: - ${{ preStep }} - task: UseDotNet@2 - displayName: Use .NET Core sdk 3.1 + displayName: Use .NET Core SDK 6 inputs: packageType: sdk - version: 3.1.x + version: 6.0.x installationPath: $(Agent.TempDirectory)/dotnet workingDirectory: $(Agent.TempDirectory) diff --git a/src/tools/illink/eng/common/templates/variables/pool-providers.yml b/src/tools/illink/eng/common/templates/variables/pool-providers.yml index a7b943c2fa4c1..1b820b4160577 100644 --- a/src/tools/illink/eng/common/templates/variables/pool-providers.yml +++ b/src/tools/illink/eng/common/templates/variables/pool-providers.yml @@ -16,7 +16,7 @@ # First, import the template in an arcade-ified repo to pick up the variables, e.g.: # # variables: -# - template: eng/common/templates/variables/pool-providers.yml +# - template: /eng/common/templates/variables/pool-providers.yml # # ... then anywhere specifying the pool provider use the runtime variables, # $(DncEngInternalBuildPool) and $ (DncEngPublicBuildPool), e.g.: @@ -45,4 +45,4 @@ variables: - name: DncEngPublicBuildPool value: NetCore-Svc-Public - name: DncEngInternalBuildPool - value: NetCore1ESPool-Svc-Internal \ No newline at end of file + value: NetCore1ESPool-Svc-Internal diff --git a/src/tools/illink/eng/common/tools.ps1 b/src/tools/illink/eng/common/tools.ps1 index 1a8c16c56e566..7caacc6de2e1f 100644 --- a/src/tools/illink/eng/common/tools.ps1 +++ b/src/tools/illink/eng/common/tools.ps1 @@ -581,7 +581,7 @@ function InitializeBuildTool() { ExitWithExitCode 1 } $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') - $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net7.0' } + $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net8.0' } } elseif ($msbuildEngine -eq "vs") { try { $msbuildPath = InitializeVisualStudioMSBuild -install:$restore @@ -743,6 +743,8 @@ function MSBuild() { (Join-Path $basePath (Join-Path netcoreapp2.1 'Microsoft.DotNet.Arcade.Sdk.dll')) (Join-Path $basePath (Join-Path netcoreapp3.1 'Microsoft.DotNet.ArcadeLogging.dll')), (Join-Path $basePath (Join-Path netcoreapp3.1 'Microsoft.DotNet.Arcade.Sdk.dll')) + (Join-Path $basePath (Join-Path net7.0 'Microsoft.DotNet.ArcadeLogging.dll')), + (Join-Path $basePath (Join-Path net7.0 'Microsoft.DotNet.Arcade.Sdk.dll')) ) $selectedPath = $null foreach ($path in $possiblePaths) { diff --git a/src/tools/illink/eng/common/tools.sh b/src/tools/illink/eng/common/tools.sh index 2f27d7453cd49..cf9fb1ea2d32b 100755 --- a/src/tools/illink/eng/common/tools.sh +++ b/src/tools/illink/eng/common/tools.sh @@ -312,7 +312,7 @@ function InitializeBuildTool { # return values _InitializeBuildTool="$_InitializeDotNetCli/dotnet" _InitializeBuildToolCommand="msbuild" - _InitializeBuildToolFramework="net7.0" + _InitializeBuildToolFramework="net8.0" } # Set RestoreNoCache as a workaround for https://github.com/NuGet/Home/issues/3116 @@ -428,6 +428,8 @@ function MSBuild { possiblePaths+=( "$toolset_dir/netcoreapp2.1/Microsoft.DotNet.Arcade.Sdk.dll" ) possiblePaths+=( "$toolset_dir/netcoreapp3.1/Microsoft.DotNet.ArcadeLogging.dll" ) possiblePaths+=( "$toolset_dir/netcoreapp3.1/Microsoft.DotNet.Arcade.Sdk.dll" ) + possiblePaths+=( "$toolset_dir/net7.0/Microsoft.DotNet.ArcadeLogging.dll" ) + possiblePaths+=( "$toolset_dir/net7.0/Microsoft.DotNet.Arcade.Sdk.dll" ) for path in "${possiblePaths[@]}"; do if [[ -f $path ]]; then selectedPath=$path diff --git a/src/tools/illink/global.json b/src/tools/illink/global.json index 06e0b987ce9c1..c752cf9f67443 100644 --- a/src/tools/illink/global.json +++ b/src/tools/illink/global.json @@ -1,14 +1,14 @@ { "sdk": { - "version": "7.0.100", + "version": "8.0.100-alpha.1.23061.8", "allowPrerelease": true, "rollForward": "major" }, "tools": { - "dotnet": "7.0.100" + "dotnet": "8.0.100-alpha.1.23061.8" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22630.1", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23067.5", "Microsoft.FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", "Microsoft.NET.Sdk.IL": "7.0.0-rtm.22507.1" } diff --git a/src/tools/illink/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs b/src/tools/illink/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs index 1c8ee148389c9..b372d4f3fdce1 100644 --- a/src/tools/illink/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs +++ b/src/tools/illink/src/ILLink.RoslynAnalyzer/DynamicallyAccessedMembersAnalyzer.cs @@ -164,7 +164,7 @@ invocationExpression.Expression is IdentifierNameSyntax ident1 && } } - static IEnumerable GetDynamicallyAccessedMembersDiagnostics (SingleValue sourceValue, SingleValue targetValue, Location location) + static List GetDynamicallyAccessedMembersDiagnostics (SingleValue sourceValue, SingleValue targetValue, Location location) { // The target should always be an annotated value, but the visitor design currently prevents // declaring this in the type system. diff --git a/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs b/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs index fe01aeaf5187a..27b47d4f3b4e9 100644 --- a/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs +++ b/src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs @@ -11,7 +11,7 @@ partial struct ParameterProxy { public ParameterProxy (IParameterSymbol parameter) { - Method = (new ((IMethodSymbol) parameter.ContainingSymbol)); + Method = new ((IMethodSymbol) parameter.ContainingSymbol); Index = (ParameterIndex) parameter.Ordinal + (Method.HasImplicitThis () ? 1 : 0); } diff --git a/src/tools/illink/src/ILLink.Shared/DataFlow/DefaultValueDictionary.cs b/src/tools/illink/src/ILLink.Shared/DataFlow/DefaultValueDictionary.cs index 599e7d3b9871c..0c2ce21ad6701 100644 --- a/src/tools/illink/src/ILLink.Shared/DataFlow/DefaultValueDictionary.cs +++ b/src/tools/illink/src/ILLink.Shared/DataFlow/DefaultValueDictionary.cs @@ -108,5 +108,8 @@ public DefaultValueDictionary Clone () // Prevent warning CS0659 https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0659. // This type should never be used as a dictionary key. public override int GetHashCode () => throw new NotImplementedException (); + + public static bool operator == (DefaultValueDictionary left, DefaultValueDictionary right) => left.Equals (right); + public static bool operator != (DefaultValueDictionary left, DefaultValueDictionary right) => !(left == right); } } diff --git a/src/tools/illink/src/ILLink.Shared/DataFlow/MaybeLattice.cs b/src/tools/illink/src/ILLink.Shared/DataFlow/MaybeLattice.cs index 4e77f96347ef0..6c2e6d60309c1 100644 --- a/src/tools/illink/src/ILLink.Shared/DataFlow/MaybeLattice.cs +++ b/src/tools/illink/src/ILLink.Shared/DataFlow/MaybeLattice.cs @@ -26,6 +26,9 @@ public Maybe Clone () return new (copyValue.DeepCopy ()); return new (value); } + + public static bool operator == (Maybe left, Maybe right) => left.Equals (right); + public static bool operator != (Maybe left, Maybe right) => !(left == right); } public struct MaybeLattice : ILattice> diff --git a/src/tools/illink/src/ILLink.Shared/DataFlow/ValueSet.cs b/src/tools/illink/src/ILLink.Shared/DataFlow/ValueSet.cs index c47397d5af258..d4d5af4a362c6 100644 --- a/src/tools/illink/src/ILLink.Shared/DataFlow/ValueSet.cs +++ b/src/tools/illink/src/ILLink.Shared/DataFlow/ValueSet.cs @@ -120,6 +120,9 @@ public bool Equals (ValueSet other) } } + public static bool operator == (ValueSet left, ValueSet right) => left.Equals (right); + public static bool operator != (ValueSet left, ValueSet right) => !(left == right); + public override int GetHashCode () { if (_values == null) diff --git a/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs b/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs index 999f8f4dc95f2..d673f5c0b3e24 100644 --- a/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs +++ b/src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs @@ -38,6 +38,7 @@ public static (string Namespace, string Name) GetNamespaceAndName (this WellKnow WellKnownType.System_NotSupportedException => ("System", "NotSupportedException"), WellKnownType.System_Runtime_CompilerServices_DisablePrivateReflectionAttribute => ("System.Runtime.CompilerServices", "DisablePrivateReflectionAttribute"), WellKnownType.System_Void => ("System", "Void"), + _ => throw new System.ArgumentException (type.ToString ()) }; } public static string GetNamespace (this WellKnownType type) => GetNamespaceAndName (type).Namespace; diff --git a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj index bd69b155788b0..8d82be6429b9b 100644 --- a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj +++ b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj @@ -22,6 +22,8 @@ disable $(NoWarn);NU5129 + + true diff --git a/src/tools/illink/src/ILLink.Tasks/LinkTask.cs b/src/tools/illink/src/ILLink.Tasks/LinkTask.cs index b89b893be681d..256bc4e51e3bb 100644 --- a/src/tools/illink/src/ILLink.Tasks/LinkTask.cs +++ b/src/tools/illink/src/ILLink.Tasks/LinkTask.cs @@ -260,7 +260,7 @@ public string ILLinkPath { var taskDirectory = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location); // The linker always runs on .NET Core, even when using desktop MSBuild to host ILLink.Tasks. - _illinkPath = Path.Combine (Path.GetDirectoryName (taskDirectory), "net7.0", "illink.dll"); + _illinkPath = Path.Combine (Path.GetDirectoryName (taskDirectory), "net8.0", "illink.dll"); return _illinkPath; } set => _illinkPath = value; diff --git a/src/tools/illink/src/linker/Linker.Dataflow/HoistedLocalKey.cs b/src/tools/illink/src/linker/Linker.Dataflow/HoistedLocalKey.cs index b721df288b408..503bdc6bbb840 100644 --- a/src/tools/illink/src/linker/Linker.Dataflow/HoistedLocalKey.cs +++ b/src/tools/illink/src/linker/Linker.Dataflow/HoistedLocalKey.cs @@ -26,5 +26,8 @@ public HoistedLocalKey (FieldDefinition field) public override bool Equals (object? obj) => obj is HoistedLocalKey other && Equals (other); public override int GetHashCode () => Field.GetHashCode (); + + public static bool operator == (HoistedLocalKey left, HoistedLocalKey right) => left.Equals (right); + public static bool operator != (HoistedLocalKey left, HoistedLocalKey right) => !(left == right); } } \ No newline at end of file diff --git a/src/tools/illink/src/linker/Linker.Dataflow/ValueNode.cs b/src/tools/illink/src/linker/Linker.Dataflow/ValueNode.cs index 81d5e0581c2f9..3374ca3317af9 100644 --- a/src/tools/illink/src/linker/Linker.Dataflow/ValueNode.cs +++ b/src/tools/illink/src/linker/Linker.Dataflow/ValueNode.cs @@ -64,5 +64,8 @@ public ValueBasicBlockPair (MultiValue value, int basicBlockIndex) public override bool Equals (object? obj) => obj is ValueBasicBlockPair other && Equals (other); public override int GetHashCode () => HashUtils.Combine (Value.GetHashCode (), BasicBlockIndex); + + public static bool operator == (ValueBasicBlockPair left, ValueBasicBlockPair right) => left.Equals (right); + public static bool operator != (ValueBasicBlockPair left, ValueBasicBlockPair right) => !(left == right); } } diff --git a/src/tools/illink/src/linker/Mono.Linker.csproj b/src/tools/illink/src/linker/Mono.Linker.csproj index 6e6b5a002c308..bb67a442d678c 100644 --- a/src/tools/illink/src/linker/Mono.Linker.csproj +++ b/src/tools/illink/src/linker/Mono.Linker.csproj @@ -17,6 +17,8 @@ false $(NoWarn);CS8524 + + true diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs index 6d4db46a46a45..89c8f461e3faf 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs @@ -287,6 +287,10 @@ public void M() } """; return VerifyRequiresAssemblyFilesAnalyzer (src, + // (7,7): warning SYSLIB0044: 'AssemblyName.CodeBase' is obsolete: 'AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete. Using them for loading an assembly is not supported.' + DiagnosticResult.CompilerWarning ("SYSLIB0044").WithSpan (7, 7, 7, 17).WithArguments ("System.Reflection.AssemblyName.CodeBase", "AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete. Using them for loading an assembly is not supported."), + // (8,7): warning SYSLIB0044: 'AssemblyName.EscapedCodeBase' is obsolete: 'AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete. Using them for loading an assembly is not supported.' + DiagnosticResult.CompilerWarning ("SYSLIB0044").WithSpan (8, 7, 8, 24).WithArguments ("System.Reflection.AssemblyName.EscapedCodeBase", "AssemblyName.CodeBase and AssemblyName.EscapedCodeBase are obsolete. Using them for loading an assembly is not supported."), // (7,7): warning IL3002: Using member 'System.Reflection.AssemblyName.CodeBase.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. The code will return an empty string for assemblies embedded in a single-file app. VerifyCS.Diagnostic (DiagnosticId.RequiresAssemblyFiles).WithSpan (7, 7, 7, 17).WithArguments ("System.Reflection.AssemblyName.CodeBase.get", " The code will return an empty string for assemblies embedded in a single-file app.", ""), // (7,7): warning IL3000: 'System.Reflection.AssemblyName.CodeBase' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs index 9c00b2773602c..d24c939728730 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/TestCaseUtils.cs @@ -26,9 +26,9 @@ public abstract class TestCaseUtils public static readonly ReferenceAssemblies Net6PreviewAssemblies = new ReferenceAssemblies ( - "net7.0", - new PackageIdentity ("Microsoft.NETCore.App.Ref", "7.0.0-preview.5.22301.12"), - Path.Combine ("ref", "net7.0")) + "net8.0", + new PackageIdentity ("Microsoft.NETCore.App.Ref", "8.0.0-alpha.1.23060.19"), + Path.Combine ("ref", "net8.0")) .WithNuGetConfigFilePath (Path.Combine (TestCaseUtils.GetRepoRoot (), "NuGet.config")); private static ImmutableArray s_net6Refs; diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs index 17e3a1fa27b7b..32f60660d3fd7 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs @@ -585,9 +585,7 @@ static bool IsMessageMatch (Diagnostic actual, ImmutableArray actualArgu public MatchQuality (int value) { - if (value < 0) { - throw new ArgumentOutOfRangeException (nameof (value)); - } + ArgumentOutOfRangeException.ThrowIfNegative (value); _value = value; } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs index 35ead6966a4f6..101e1be0288cc 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs @@ -10,8 +10,7 @@ public class ExpectedInstructionSequenceAttribute : BaseInAssemblyAttribute { public ExpectedInstructionSequenceAttribute (string[] opCodes) { - if (opCodes == null) - throw new ArgumentNullException (nameof (opCodes)); + ArgumentNullException.ThrowIfNull (opCodes); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs index 899b979c5211e..124bbab5bac75 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs @@ -12,12 +12,10 @@ public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFi { if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentNullException (nameof (assemblyFileName)); - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); if (string.IsNullOrEmpty (memberName)) throw new ArgumentNullException (nameof (memberName)); - if (opCodes == null) - throw new ArgumentNullException (nameof (opCodes)); + ArgumentNullException.ThrowIfNull (opCodes); } public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFileName, string typeName, string memberName, string[] opCodes) @@ -28,8 +26,7 @@ public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFi throw new ArgumentNullException (nameof (typeName)); if (string.IsNullOrEmpty (memberName)) throw new ArgumentNullException (nameof (memberName)); - if (opCodes == null) - throw new ArgumentNullException (nameof (opCodes)); + ArgumentNullException.ThrowIfNull (opCodes); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs index fdd3441b71f44..2016d26a0dbd1 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs @@ -10,14 +10,12 @@ public class ExpectedLocalsSequenceAttribute : BaseInAssemblyAttribute { public ExpectedLocalsSequenceAttribute (string[] types) { - if (types == null) - throw new ArgumentNullException (nameof (types)); + ArgumentNullException.ThrowIfNull (types); } public ExpectedLocalsSequenceAttribute (Type[] types) { - if (types == null) - throw new ArgumentNullException (nameof (types)); + ArgumentNullException.ThrowIfNull (types); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs index 78fd0e4537423..a9b11ebd3f32b 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs @@ -11,8 +11,7 @@ public class IgnoreTestCaseAttribute : Attribute public IgnoreTestCaseAttribute (string reason) { - if (reason == null) - throw new ArgumentNullException (nameof (reason)); + ArgumentNullException.ThrowIfNull (reason); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeAttribute.cs index 0b5943a5a1a5e..e558f304720aa 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeAttribute.cs @@ -17,8 +17,7 @@ public KeptAttributeAttribute (string attributeName) public KeptAttributeAttribute (Type type) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs index 0fc56741a8ca4..559e81bdad164 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs @@ -16,8 +16,7 @@ public KeptAttributeOnFixedBufferTypeAttribute (string attributeName) public KeptAttributeOnFixedBufferTypeAttribute (Type type) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs index acac5d575bbce..5d454d806eec9 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs @@ -10,8 +10,7 @@ public class KeptBaseOnTypeInAssemblyAttribute : BaseInAssemblyAttribute { public KeptBaseOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string baseAssemblyFileName, Type baseType) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs index c4e4a24889542..c98ad9abcbe39 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs @@ -10,16 +10,13 @@ public sealed class KeptBaseTypeAttribute : KeptAttribute { public KeptBaseTypeAttribute (Type baseType) { - if (baseType == null) - throw new ArgumentNullException (nameof (baseType)); + ArgumentNullException.ThrowIfNull (baseType); } public KeptBaseTypeAttribute (Type baseType, params object[] typeArguments) { - if (baseType == null) - throw new ArgumentNullException (nameof (baseType)); - if (typeArguments == null) - throw new ArgumentNullException (nameof (typeArguments)); + ArgumentNullException.ThrowIfNull (baseType); + ArgumentNullException.ThrowIfNull (typeArguments); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptExportedTypeAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptExportedTypeAttribute.cs index 76dbe921c9457..2e4ba1903e1a7 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptExportedTypeAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptExportedTypeAttribute.cs @@ -13,8 +13,7 @@ public class KeptExportedTypeAttribute : KeptAttribute { public KeptExportedTypeAttribute (Type type) { - if (type is null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs index 25b8c8261f16c..9b98ef46e4515 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs @@ -15,8 +15,7 @@ public KeptInitializerData () public KeptInitializerData (int occurrenceIndexInBody) { - if (occurrenceIndexInBody < 0) - throw new ArgumentOutOfRangeException (nameof (occurrenceIndexInBody)); + ArgumentOutOfRangeException.ThrowIfNegative (occurrenceIndexInBody); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs index 85279abcd83f6..abbf5784e99bf 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs @@ -11,16 +11,13 @@ public class KeptInterfaceAttribute : KeptAttribute public KeptInterfaceAttribute (Type interfaceType) { - if (interfaceType == null) - throw new ArgumentNullException (nameof (interfaceType)); + ArgumentNullException.ThrowIfNull (interfaceType); } public KeptInterfaceAttribute (Type interfaceType, params object[] typeArguments) { - if (interfaceType == null) - throw new ArgumentNullException (nameof (interfaceType)); - if (typeArguments == null) - throw new ArgumentNullException (nameof (typeArguments)); + ArgumentNullException.ThrowIfNull (interfaceType); + ArgumentNullException.ThrowIfNull (typeArguments); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs index 2741439facc88..88bfd654ad75c 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs @@ -10,8 +10,7 @@ public class KeptInterfaceOnTypeInAssemblyAttribute : BaseInAssemblyAttribute { public KeptInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string interfaceAssemblyFileName, Type interfaceType) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberInAssemblyAttribute.cs index b8e38f5788c05..a756d8d24704f 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberInAssemblyAttribute.cs @@ -13,20 +13,16 @@ public KeptMemberInAssemblyAttribute (string assemblyFileName, Type type, params { if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentNullException (nameof (assemblyFileName)); - if (type == null) - throw new ArgumentNullException (nameof (type)); - if (memberNames == null) - throw new ArgumentNullException (nameof (memberNames)); + ArgumentNullException.ThrowIfNull (type); + ArgumentNullException.ThrowIfNull (memberNames); } public KeptMemberInAssemblyAttribute (string assemblyFileName, string typeName, params string[] memberNames) { if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentNullException (nameof (assemblyFileName)); - if (typeName == null) - throw new ArgumentNullException (nameof (typeName)); - if (memberNames == null) - throw new ArgumentNullException (nameof (memberNames)); + ArgumentNullException.ThrowIfNull (typeName); + ArgumentNullException.ThrowIfNull (memberNames); } public string ExpectationAssemblyName { get; set; } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptOverrideAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptOverrideAttribute.cs index 62bfd0c157947..3c02278ea9142 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptOverrideAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptOverrideAttribute.cs @@ -19,8 +19,7 @@ public class KeptOverrideAttribute : KeptAttribute public KeptOverrideAttribute (Type typeWithOverriddenMethod) { - if (typeWithOverriddenMethod == null) - throw new ArgumentNullException (nameof (typeWithOverriddenMethod)); + ArgumentNullException.ThrowIfNull (typeWithOverriddenMethod); TypeWithOverriddenMethodDeclaration = typeWithOverriddenMethod; } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs index 0265b9f3a40d9..e046c3935df9b 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs @@ -13,8 +13,7 @@ public KeptReferencesInAssemblyAttribute (string assemblyFileName, string[] expe if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentNullException (nameof (assemblyFileName)); - if (expectedReferenceAssemblyNames == null) - throw new ArgumentNullException (nameof (expectedReferenceAssemblyNames)); + ArgumentNullException.ThrowIfNull (expectedReferenceAssemblyNames); } } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSecurityAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSecurityAttribute.cs index 05519377252dc..828bc4b64a0c3 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSecurityAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSecurityAttribute.cs @@ -16,8 +16,7 @@ public KeptSecurityAttribute (string attributeName) public KeptSecurityAttribute (Type type) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptTypeInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptTypeInAssemblyAttribute.cs index 5be0adc4aa108..a9eb31c5bc81a 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptTypeInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptTypeInAssemblyAttribute.cs @@ -10,8 +10,7 @@ public class KeptTypeInAssemblyAttribute : BaseInAssemblyAttribute { public KeptTypeInAssemblyAttribute (string assemblyFileName, Type type) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs index 70465fc3d6035..a733a9a180086 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedInterfaceOnTypeInAssemblyAttribute.cs @@ -10,8 +10,7 @@ public class RemovedInterfaceOnTypeInAssemblyAttribute : BaseInAssemblyAttribute { public RemovedInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string interfaceAssemblyFileName, Type interfaceType) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedMemberInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedMemberInAssemblyAttribute.cs index fe0deb6374aaf..bd54db71ba811 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedMemberInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedMemberInAssemblyAttribute.cs @@ -13,20 +13,16 @@ public RemovedMemberInAssemblyAttribute (string assemblyFileName, Type type, par { if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentNullException (nameof (assemblyFileName)); - if (type == null) - throw new ArgumentNullException (nameof (type)); - if (memberNames == null) - throw new ArgumentNullException (nameof (memberNames)); + ArgumentNullException.ThrowIfNull (type); + ArgumentNullException.ThrowIfNull (memberNames); } public RemovedMemberInAssemblyAttribute (string assemblyFileName, string typeName, params string[] memberNames) { if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentNullException (nameof (assemblyFileName)); - if (typeName == null) - throw new ArgumentNullException (nameof (typeName)); - if (memberNames == null) - throw new ArgumentNullException (nameof (memberNames)); + ArgumentNullException.ThrowIfNull (typeName); + ArgumentNullException.ThrowIfNull (memberNames); } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedTypeInAssemblyAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedTypeInAssemblyAttribute.cs index 079ba5d1f0b7d..fe98db51bfc0f 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedTypeInAssemblyAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedTypeInAssemblyAttribute.cs @@ -10,8 +10,7 @@ public class RemovedTypeInAssemblyAttribute : BaseInAssemblyAttribute { public RemovedTypeInAssemblyAttribute (string assemblyFileName, Type type) { - if (type == null) - throw new ArgumentNullException (nameof (type)); + ArgumentNullException.ThrowIfNull (type); if (string.IsNullOrEmpty (assemblyFileName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName)); } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/TestCaseRequirementsAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/TestCaseRequirementsAttribute.cs index 9e766c9ce05c6..caf60a23abe0f 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/TestCaseRequirementsAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/TestCaseRequirementsAttribute.cs @@ -10,8 +10,7 @@ public class TestCaseRequirementsAttribute : BaseExpectedLinkedBehaviorAttribute { public TestCaseRequirementsAttribute (TestRunCharacteristics targetFrameworkCharacteristics, string reason) { - if (reason == null) - throw new ArgumentNullException (nameof (reason)); + ArgumentNullException.ThrowIfNull (reason); } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAfterAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAfterAttribute.cs index 71f9f7a3854bb..a81898225225b 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAfterAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileAfterAttribute.cs @@ -13,8 +13,7 @@ public class SetupCompileAfterAttribute : BaseMetadataAttribute { public SetupCompileAfterAttribute (string outputName, string[] sourceFiles, string[] references = null, string[] defines = null, object[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false) { - if (sourceFiles == null) - throw new ArgumentNullException (nameof (sourceFiles)); + ArgumentNullException.ThrowIfNull (sourceFiles); if (string.IsNullOrEmpty (outputName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName)); diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs index 0021300c8403e..73e5c69c20ca0 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupCompileBeforeAttribute.cs @@ -13,8 +13,7 @@ public class SetupCompileBeforeAttribute : BaseMetadataAttribute { public SetupCompileBeforeAttribute (string outputName, string[] sourceFiles, string[] references = null, string[] defines = null, object[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false, string outputSubFolder = null) { - if (sourceFiles == null) - throw new ArgumentNullException (nameof (sourceFiles)); + ArgumentNullException.ThrowIfNull (sourceFiles); if (string.IsNullOrEmpty (outputName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName)); @@ -35,8 +34,7 @@ public SetupCompileBeforeAttribute (string outputName, string[] sourceFiles, str public SetupCompileBeforeAttribute (string outputName, Type[] typesToIncludeSourceFor, string[] references = null, string[] defines = null, object[] resources = null, string additionalArguments = null, string compilerToUse = null, bool addAsReference = true, bool removeFromLinkerInput = false) { - if (typesToIncludeSourceFor == null) - throw new ArgumentNullException (nameof (typesToIncludeSourceFor)); + ArgumentNullException.ThrowIfNull (typesToIncludeSourceFor); if (string.IsNullOrEmpty (outputName)) throw new ArgumentException ("Value cannot be null or empty.", nameof (outputName)); diff --git a/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs b/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs index ffc24695eb803..4fde1084de42d 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/Extensions/NiceIO.cs @@ -47,8 +47,7 @@ public class NPath : IEquatable, IComparable public NPath (string path) { - if (path == null) - throw new ArgumentNullException (nameof (path)); + ArgumentNullException.ThrowIfNull (path); path = ParseDriveLetter (path, out _driveLetter); diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index f5d4ad15a4586..3bc3625143382 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -325,7 +325,7 @@ void VerifyOverrides (MethodDefinition original, MethodDefinition linked) Assert.True (linked.DeclaringType.Interfaces.Select (i => i.InterfaceType).Contains (overriddenMethod.DeclaringType), $"Method {linked} overrides method {overriddenMethod}, but {linked.DeclaringType} does not implement interface {overriddenMethod.DeclaringType}"); } else { - TypeReference baseType = linked.DeclaringType; + TypeDefinition baseType = linked.DeclaringType; TypeReference overriddenType = overriddenMethod.DeclaringType; while (baseType is not null) { if (baseType.Equals (overriddenType)) diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs index 4a02b50ac9097..a0b87e6ad7480 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs @@ -14,7 +14,9 @@ public static class PathUtilities public const string ConfigDirectoryName = "Release"; #endif -#if NET7_0 +#if NET8_0 + public const string TFMDirectoryName = "net8.0"; +#elif NET7_0 public const string TFMDirectoryName = "net7.0"; #elif NET6_0 public const string TFMDirectoryName = "net6.0"; diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs index e41c2b8e74618..04f56ef3f3d03 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs @@ -106,7 +106,7 @@ protected virtual CompilerOptions CreateOptionsForSupportingAssembly (SetupCompi }; } - private IEnumerable CompileBeforeTestCaseAssemblies (NPath outputDirectory, NPath[] references, string[] defines, IList removeFromLinkerInputAssemblies) + private IEnumerable CompileBeforeTestCaseAssemblies (NPath outputDirectory, NPath[] references, string[] defines, List removeFromLinkerInputAssemblies) { foreach (var setupCompileInfo in _metadataProvider.GetSetupCompileAssembliesBefore ()) { NPath outputFolder; @@ -134,7 +134,7 @@ private IEnumerable CompileBeforeTestCaseAssemblies (NPath outputDirector } } - private void CompileAfterTestCaseAssemblies (NPath outputDirectory, NPath[] references, string[] defines, IList removeFromLinkerInputAssemblies) + private void CompileAfterTestCaseAssemblies (NPath outputDirectory, NPath[] references, string[] defines, List removeFromLinkerInputAssemblies) { foreach (var setupCompileInfo in _metadataProvider.GetSetupCompileAssembliesAfter ()) { var options = CreateOptionsForSupportingAssembly (