Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace netstandard1.0 and netstandard1.3 with netstandard2.0 #3921

Merged
merged 2 commits into from Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 4 additions & 60 deletions scripts/build.ps1
Expand Up @@ -83,9 +83,6 @@ $TPB_TargetFramework462 = "net462"
$TPB_TargetFramework472 = "net472"
$TPB_TargetFramework48 = "net48"
$TPB_TargetFrameworkCore31 = "netcoreapp3.1"
$TPB_TargetFrameworkUap100 = "uap10.0"
$TPB_TargetFrameworkNS10 = "netstandard1.0"
$TPB_TargetFrameworkNS13 = "netstandard1.3"
$TPB_TargetFrameworkNS20 = "netstandard2.0"
$TPB_Configuration = $Configuration
$TPB_TargetRuntime = $TargetRuntime
Expand Down Expand Up @@ -421,9 +418,6 @@ function Publish-Package {
$timer = Start-Timer
Write-Log "Publish-Package: Started."
$net462PackageDir = Get-FullCLR462PackageDirectory
$uap100PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkUap100");
$netstandard10PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkNS10");
$netstandard13PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkNS13");
$netstandard20PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkNS20");
$coreCLR31PackageDir = Get-CoreCLR31PackageDirectory
$coreClrNetFrameworkTestHostDir = Join-Path $coreCLR31PackageDir "TestHostNetFramework"
Expand All @@ -441,7 +435,6 @@ function Publish-Package {
$testhostCore31PackageTempX86Dir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\publishTemp\Microsoft.TestPlatform.TestHost\$TPB_TargetFrameworkCore31\$TPB_X86_Runtime")
$testhostCore31PackageTempARM64Dir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\publishTemp\Microsoft.TestPlatform.TestHost\$TPB_TargetFrameworkCore31\$TPB_ARM64_Runtime")

$testhostUapPackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Microsoft.TestPlatform.TestHost\$TPB_TargetFrameworkUap100")
$vstestConsoleProject = Join-Path $env:TP_ROOT_DIR "src\vstest.console\vstest.console.csproj"
$settingsMigratorProject = Join-Path $env:TP_ROOT_DIR "src\SettingsMigrator\SettingsMigrator.csproj"
$dataCollectorProject = Join-Path $env:TP_ROOT_DIR "src\datacollector\datacollector.csproj"
Expand Down Expand Up @@ -474,7 +467,6 @@ function Publish-Package {
Write-Log "Package: Publish testhost\testhost.csproj"
Publish-PackageInternal $testHostProject $TPB_TargetFramework462 $testhostFullPackageDir
Publish-PackageInternal $testHostProject $TPB_TargetFrameworkCore31 $testhostCore31PackageDir
Publish-PackageInternal $testHostProject $TPB_TargetFrameworkCore31 $testhostUapPackageDir
Publish-PackageWithRuntimeInternal $testHostProject $TPB_TargetFrameworkCore31 $TPB_X64_Runtime false $testhostCore31PackageTempX64Dir

Write-Log "Package: Publish testhost.x86\testhost.x86.csproj"
Expand Down Expand Up @@ -527,23 +519,11 @@ function Publish-Package {

################################################################################
# Publish Microsoft.TestPlatform.ObjectModel

# Copy this first because for ObjectModel it puts platform abstractions NS1.3 version
# into the output folder (for some reason), and we overwrite it with actual uap10.0 version below

Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.ObjectModel\bin\$TPB_Configuration") `
-files @{
$TPB_TargetFramework462 = $net462PackageDir # net462
$TPB_TargetFrameworkCore31 = $coreCLR31PackageDir # netcoreapp3.1
$TPB_TargetFrameworkNS10 = $netstandard10PackageDir # netstandard1_0
$TPB_TargetFrameworkNS13 = $netstandard13PackageDir # netstandard1_3
$TPB_TargetFrameworkNS20 = $netstandard20PackageDir # netstandard2_0
$TPB_TargetFrameworkUap100 = $uap100PackageDir # uap10.0
}

Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.ObjectModel\bin\$TPB_Configuration") `
-files @{
$TPB_TargetFrameworkUap100 = $testhostUapPackageDir # uap10.0 - testhost
}

################################################################################
Expand All @@ -552,47 +532,30 @@ function Publish-Package {
-files @{
$TPB_TargetFramework462 = $net462PackageDir # net462
$TPB_TargetFrameworkCore31 = $coreCLR31PackageDir # netcoreapp3.1
$TPB_TargetFrameworkNS10 = $netstandard10PackageDir # netstandard1_0
$TPB_TargetFrameworkNS13 = $netstandard13PackageDir # netstandard1_3
$TPB_TargetFrameworkNS20 = $netstandard20PackageDir # netstandard2_0
$TPB_TargetFrameworkUap100 = $uap100PackageDir # uap10.0
}
Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.PlatformAbstractions\bin\$TPB_Configuration") `
-files @{
$TPB_TargetFrameworkUap100 = $testhostUapPackageDir # uap10.0 - testhost
}

################################################################################
# Publish Microsoft.TestPlatform.CoreUtilities
Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.CoreUtilities\bin\$TPB_Configuration") `
-files @{
$TPB_TargetFramework462 = $net462PackageDir # net462
$TPB_TargetFrameworkNS10 = $netstandard10PackageDir # netstandard1_0
$TPB_TargetFrameworkNS13 = $netstandard13PackageDir # netstandard1_3
$TPB_TargetFrameworkNS20 = $netstandard20PackageDir # netstandard2_0
$TPB_TargetFrameworkUap100 = $uap100PackageDir # uap10.0
}

Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.CoreUtilities\bin\$TPB_Configuration") `
-files @{
$TPB_TargetFrameworkUap100 = $testhostUapPackageDir # uap10.0 - testhost
}

################################################################################
# Publish Microsoft.TestPlatform.AdapterUtilities
Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.AdapterUtilities\bin\$TPB_Configuration") `
-files @{
"$TPB_TargetFramework462/any" = $net462PackageDir # net462
$TPB_TargetFrameworkNS10 = $netstandard10PackageDir # netstandard1_0
$TPB_TargetFrameworkNS20 = $netstandard20PackageDir # netstandard2_0
$TPB_TargetFrameworkUap100 = $uap100PackageDir # uap10.0
}

################################################################################
# Publish Microsoft.TestPlatform.CrossPlatEngine
Copy-Bulk -root (Join-Path $env:TP_ROOT_DIR "src\Microsoft.TestPlatform.CrossPlatEngine\bin\$TPB_Configuration") `
-files @{
$TPB_TargetFrameworkNS13 = $netstandard13PackageDir # netstandard1_3
$TPB_TargetFrameworkNS20 = $netstandard20PackageDir # netstandard2_0
}

################################################################################
Expand All @@ -601,7 +564,6 @@ function Publish-Package {
$comComponentsDirectory = Join-Path $env:TP_PACKAGES_DIR "Microsoft.Internal.Dia\$testPlatformMsDiaVersion\tools\net451"
Copy-Item -Recurse $comComponentsDirectory\* $testhostCore31PackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $testhostFullPackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $testhostUapPackageDir -Force
Copy-Item -Recurse $comComponentsDirectory\* $coreClrNetFrameworkTestHostDir -Force

# Copy over the logger assemblies to the Extensions folder.
Expand Down Expand Up @@ -728,7 +690,7 @@ function Publish-Package {
Write-Verbose "Copy-Item $newtonsoft $net462PackageDir -Force"
Copy-Item $newtonsoft $net462PackageDir -Force

$newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\$newtonsoftJsonVersion\lib\netstandard1.0\Newtonsoft.Json.dll"
$newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\$newtonsoftJsonVersion\lib\netstandard2.0\Newtonsoft.Json.dll"
Write-Verbose "Copy-Item $newtonsoft $coreCLR31PackageDir -Force"
Copy-Item $newtonsoft $coreCLR31PackageDir -Force

Expand Down Expand Up @@ -1026,11 +988,6 @@ function Create-NugetPackages {
# Copy licenses folder
Copy-Item (Join-Path $env:TP_PACKAGE_PROJ_DIR "licenses") $stagingDir -Force -Recurse

# Copy Uap target, & props
$testhostUapPackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Microsoft.TestPlatform.TestHost\$TPB_TargetFrameworkUap100")
Copy-Item $tpNuspecDir\uap\"Microsoft.TestPlatform.TestHost.Uap.props" $testhostUapPackageDir\Microsoft.TestPlatform.TestHost.props -Force
Copy-Item $tpNuspecDir\uap\"Microsoft.TestPlatform.TestHost.Uap.targets" $testhostUapPackageDir\Microsoft.TestPlatform.TestHost.targets -Force

$testhostCore31PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Microsoft.TestPlatform.TestHost\$TPB_TargetFrameworkCore31")
Copy-Item $tpNuspecDir\"Microsoft.TestPlatform.TestHost.NetCore.props" $testhostCore31PackageDir\Microsoft.TestPlatform.TestHost.props -Force

Expand All @@ -1045,25 +1002,14 @@ function Create-NugetPackages {
$microsoftFakesVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.MicrosoftFakesVersion
$FakesPackageDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.QualityTools.Testing.Fakes.TestRunnerHarness\$microsoftFakesVersion\contentFiles"

$uap100PackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\$TPB_TargetFrameworkUap100");

# package them from stagingDir
foreach ($file in $nuspecFiles) {
$additionalArgs = ""
if ($skipAnalysis -contains $file) {
$additionalArgs = "-NoPackageAnalysis"
}

if ($file -eq "TestPlatform.Internal.Uwp.nuspec") {
# this directory is mostly the same as the testhost10 dir, but has less libraries
# and does not have netstandard2.0 versions, so I don't copy them by mistake
$uap10Nuget = $uap100PackageDir
}
else {
$uap10Nuget = $testhostUapPackageDir
}

Invoke-Exe $nugetExe -Arguments "pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version;JsonNetVersion=$JsonNetVersion;Runtime=$TPB_TargetRuntime;NetCoreTargetFramework=$TPB_TargetFrameworkCore31;FakesPackageDir=$FakesPackageDir;NetStandard10Framework=$TPB_TargetFrameworkNS10;NetStandard13Framework=$TPB_TargetFrameworkNS13;NetStandard20Framework=$TPB_TargetFrameworkNS20;Uap10Framework=$uap10Nuget;BranchName=$TPB_BRANCH;CommitId=$TPB_COMMIT $additionalArgs"
Invoke-Exe $nugetExe -Arguments "pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version;JsonNetVersion=$JsonNetVersion;Runtime=$TPB_TargetRuntime;NetCoreTargetFramework=$TPB_TargetFrameworkCore31;FakesPackageDir=$FakesPackageDir;NetStandard20Framework=$TPB_TargetFrameworkNS20;BranchName=$TPB_BRANCH;CommitId=$TPB_COMMIT $additionalArgs"
}

foreach ($file in $projectFiles) {
Expand Down Expand Up @@ -1273,10 +1219,8 @@ function Build-SpecificProjects {
# FrameworksAndOutDirs format ("<target_framework>", "<output_dir>").
$FrameworksAndOutDirs = (
("net462", "net462\win7-x64"),
("netstandard1.0", "netstandard1.0"),
("netstandard1.3", "netstandard1.3"),
# REVIEW ME: Why do we copy netstandard2.0 into netcorecorapp2.1?
("netstandard2.0", "netcoreapp2.1"),
("netstandard2.0", "netstandard2.0"),
Haplois marked this conversation as resolved.
Show resolved Hide resolved
("netcoreapp3.1", "netcoreapp3.1")
)

Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Expand Up @@ -440,7 +440,7 @@ function publish_package()
done
#*************************************************************************************************************#

newtonsoft=$TP_PACKAGES_DIR/newtonsoft.json/$TPB_NEWTONSOFT_JSON_VERSION/lib/netstandard1.0/Newtonsoft.Json.dll
newtonsoft=$TP_PACKAGES_DIR/newtonsoft.json/$TPB_NEWTONSOFT_JSON_VERSION/lib/netstandard2.0/Newtonsoft.Json.dll
cp $newtonsoft $packageDir
done

Expand Down
10 changes: 5 additions & 5 deletions scripts/verify-nupkgs.ps1
Expand Up @@ -13,17 +13,17 @@ function Verify-Nuget-Packages($packageDirectory, $version)
Write-Log "Starting Verify-Nuget-Packages."
$expectedNumOfFiles = @{
"Microsoft.CodeCoverage" = 57;
"Microsoft.NET.Test.Sdk" = 18;
"Microsoft.NET.Test.Sdk" = 16;
"Microsoft.TestPlatform" = 607;
"Microsoft.TestPlatform.Build" = 21;
"Microsoft.TestPlatform.CLI" = 499;
"Microsoft.TestPlatform.Extensions.TrxLogger" = 35;
"Microsoft.TestPlatform.ObjectModel" = 180;
"Microsoft.TestPlatform.AdapterUtilities" = 62;
"Microsoft.TestPlatform.ObjectModel" = 93;
"Microsoft.TestPlatform.AdapterUtilities" = 34;
"Microsoft.TestPlatform.Portable" = 597;
"Microsoft.TestPlatform.TestHost" = 153;
"Microsoft.TestPlatform.TestHost" = 63;
"Microsoft.TestPlatform.TranslationLayer" = 123;
"Microsoft.TestPlatform.Internal.Uwp" = 86;
"Microsoft.TestPlatform.Internal.Uwp" = 46;
}

$nugetPackages = Get-ChildItem -Filter "*$version*.nupkg" $packageDirectory | % { $_.FullName }
Expand Down
4 changes: 2 additions & 2 deletions shared/NullableAttributes.cs
Expand Up @@ -8,7 +8,7 @@

namespace System.Diagnostics.CodeAnalysis;

#if NETFRAMEWORK || WINDOWS_UWP || NETSTANDARD && !NETSTANDARD2_1 || NETCOREAPP && !NETCOREAPP3_0_OR_GREATER
#if NETFRAMEWORK || NETSTANDARD && !NETSTANDARD2_1 || NETCOREAPP && !NETCOREAPP3_0_OR_GREATER

/// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
Expand Down Expand Up @@ -89,7 +89,7 @@ internal sealed class DoesNotReturnIfAttribute : Attribute

#endif

#if NETFRAMEWORK || WINDOWS_UWP || NETSTANDARD && !NETSTANDARD2_1 || NETCOREAPP && !NET5_0_OR_GREATER
#if NETFRAMEWORK || NETSTANDARD && !NETSTANDARD2_1 || NETCOREAPP && !NET5_0_OR_GREATER

/// <summary>Specifies that the method or property will ensure that the listed field and property members have not-null values.</summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
Expand Down
Expand Up @@ -8,48 +8,18 @@ namespace Microsoft.TestPlatform.AdapterUtilities.Helpers;

internal static partial class ReflectionHelpers
{
#if NETSTANDARD1_0 || NETSTANDARD1_3 || WINDOWS_UWP
private static readonly Type MethodBase = typeof(MethodBase);

private const string MemberTypePropertyName = "MemberType";
private const string ReflectedTypePropertyName = "ReflectedType";
private const string MethodHandlePropertyName = "MethodHandle";

private static readonly PropertyInfo MemberTypeProperty = MethodBase.GetRuntimeProperty(MemberTypePropertyName);
private static readonly PropertyInfo ReflectedTypeProperty = MethodBase.GetRuntimeProperty(ReflectedTypePropertyName);
private static readonly PropertyInfo MethodHandleProperty = MethodBase.GetRuntimeProperty(MethodHandlePropertyName);
#endif

internal static bool IsMethod(MethodBase method)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return method.MemberType == MemberTypes.Method;
#else
AssertSupport(MemberTypeProperty, MemberTypePropertyName, MethodBase.FullName);

return (int)MemberTypeProperty.GetValue(method) == 8;
#endif
}

internal static Type? GetReflectedType(MethodBase method)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return method.ReflectedType;
#else
AssertSupport(MemberTypeProperty, ReflectedTypePropertyName, MethodBase.FullName);

return ReflectedTypeProperty.GetValue(method) as Type;
#endif
}

internal static RuntimeMethodHandle GetMethodHandle(MethodBase method)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return method.MethodHandle;
#else
AssertSupport(MemberTypeProperty, MethodHandlePropertyName, MethodBase.FullName);

return (RuntimeMethodHandle)MethodHandleProperty.GetValue(method);
#endif
}
}
Expand Up @@ -10,19 +10,11 @@ internal static partial class ReflectionHelpers
{
internal static bool IsGenericType(Type type)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return type.IsGenericType;
#else
return type.GetTypeInfo().IsGenericType;
#endif
}

internal static MethodBase? GetDeclaringMethod(Type type)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return type.DeclaringMethod;
#else
return type.GetTypeInfo().DeclaringMethod;
#endif
}
}
Expand Up @@ -2,25 +2,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

#if !NETSTANDARD1_0 && !WINDOWS_UWP
using System.Runtime.Serialization;
#endif

namespace Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities;

#if !NETSTANDARD1_0 && !WINDOWS_UWP
[Serializable]
#endif
public class InvalidManagedNameException :
Exception
#if !NETSTANDARD1_0 && !WINDOWS_UWP
, ISerializable
#endif
public class InvalidManagedNameException : Exception, ISerializable
{
public InvalidManagedNameException(string? message) : base(message) { }

#if !NETSTANDARD1_0 && !WINDOWS_UWP
protected InvalidManagedNameException(SerializationInfo info, StreamingContext context) : base(info, context) { }
#endif
}
Expand Up @@ -227,19 +227,7 @@ public static MethodBase GetMethod(Assembly assembly, string managedTypeName, st
Type? type;

var parsedManagedTypeName = ReflectionHelpers.ParseEscapedString(managedTypeName);

#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
type = assembly.GetType(parsedManagedTypeName, throwOnError: false, ignoreCase: false);
#else
try
{
type = assembly.GetType(parsedManagedTypeName);
}
catch
{
type = null;
}
#endif

if (type == null)
{
Expand Down Expand Up @@ -297,12 +285,8 @@ bool Filter(MemberInfo mbr, object? param)

MemberInfo[] methods;

#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
methods = type.FindMembers(MemberTypes.Method, bindingFlags, Filter, null);
#else
methods = type.GetRuntimeMethods().Where(m => Filter(m, null)).ToArray();
#endif

return (MethodInfo?)(methods.Length switch
{
Expand Down Expand Up @@ -500,23 +484,13 @@ private static int AppendNestedTypeName(StringBuilder b, Type? type, bool closed

private static void AppendGenericMethodParameters(StringBuilder methodBuilder, MethodBase method)
{
Type[] genericArguments;

genericArguments = method.GetGenericArguments();

Type[] genericArguments = method.GetGenericArguments();
AppendGenericArguments(methodBuilder, genericArguments);
}

private static void AppendGenericTypeParameters(StringBuilder b, Type type)
{
Type[] genericArguments;

#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
genericArguments = type.GetGenericArguments();
#else
genericArguments = type.GetTypeInfo().GenericTypeArguments;
#endif

Type[] genericArguments = type.GetGenericArguments();
AppendGenericArguments(b, genericArguments);
}

Expand Down