Skip to content

Commit

Permalink
Managed TestCase Properties implemented
Browse files Browse the repository at this point in the history
* `ManagedType` and `ManagedMethod` support added to `Microsoft.TestPlatform.ObjectModel.TestCase`
  • Loading branch information
Haplois committed Nov 2, 2020
1 parent ee65f42 commit 3fec887
Show file tree
Hide file tree
Showing 54 changed files with 2,935 additions and 27 deletions.
15 changes: 15 additions & 0 deletions TestPlatform.sln
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Exte
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.collector", "test\coverlet.collector\coverlet.collector.csproj", "{074F5BD6-DC05-460B-B78F-044D125FD787}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.ObjectModel.FullyQualifiedNameUtilities.UnitTests", "test\Microsoft.TestPlatform.ObjectModel.FullyQualifiedNameUtilities.UnitTests\Microsoft.TestPlatform.ObjectModel.FullyQualifiedNameUtilities.UnitTests.csproj", "{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -781,6 +783,18 @@ Global
{074F5BD6-DC05-460B-B78F-044D125FD787}.Release|x64.Build.0 = Release|Any CPU
{074F5BD6-DC05-460B-B78F-044D125FD787}.Release|x86.ActiveCfg = Release|Any CPU
{074F5BD6-DC05-460B-B78F-044D125FD787}.Release|x86.Build.0 = Release|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Debug|x64.ActiveCfg = Debug|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Debug|x64.Build.0 = Debug|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Debug|x86.ActiveCfg = Debug|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Debug|x86.Build.0 = Debug|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Release|Any CPU.Build.0 = Release|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Release|x64.ActiveCfg = Release|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Release|x64.Build.0 = Release|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Release|x86.ActiveCfg = Release|Any CPU
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -849,6 +863,7 @@ Global
{236A71E3-01DA-4679-9DFF-16A8E079ACFF} = {5E7F18A8-F843-4C8A-AB02-4C7D9205C6CF}
{41248B96-6E15-4E5E-A78F-859897676814} = {020E15EA-731F-4667-95AF-226671E0C3AE}
{074F5BD6-DC05-460B-B78F-044D125FD787} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
{DCD0C39E-C78C-4A44-B0BD-7325254A2E97} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0541B30C-FF51-4E28-B172-83F5F3934BCD}
Expand Down
6 changes: 6 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@
<MicrosoftSourceLinkVersion>1.0.0-beta2-19554-01</MicrosoftSourceLinkVersion>
<MicrosoftDotNetSwaggerGeneratorMSBuildVersion>1.0.0-beta.20509.7</MicrosoftDotNetSwaggerGeneratorMSBuildVersion>
<XliffTasksVersion>1.0.0-beta.20055.1</XliffTasksVersion>

<!-- Roslyn -->
<!-- WARNING: Depending on Roslyn in code that also supports unmanaged scenarios (e.g. C++,
JS etc.) is risky. This can break setup authoring and cause runtime failures in workloads
where Rolsyn is not installed. -->
<MicrosoftCodeAnalysisVersion>3.8.0-3.20427.2</MicrosoftCodeAnalysisVersion>
</PropertyGroup>
</Project>
3 changes: 1 addition & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ $language = @("cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-BR", "ru", "tr
# Capture error state in any step globally to modify return code
$Script:ScriptFailed = $false

Import-Module "$($CurrentScriptDir.FullName)\verify-nupkgs.ps1"
Import-Module -Name "$($CurrentScriptDir.FullName)\verify-nupkgs.ps1" -Scope Local

# Update the version in the dependencies props to be the TPB_version version, this is not ideal but because changing how this is resolved would
# mean that we need to change the whole build process this is a solution with the least amount of impact, that does not require us to keep track of
Expand Down Expand Up @@ -253,7 +253,6 @@ function Invoke-TestAssetsBuild
Write-Log "Invoke-TestAssetsBuild: Start test assets build."
$dotnetExe = Get-DotNetPath


Write-Log ".. .. Build: Source: $TPB_TestAssets_Solution"
Write-Verbose "$dotnetExe build $TPB_TestAssets_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild"
& $dotnetExe build $TPB_TestAssets_Solution --configuration $TPB_Configuration -v:minimal -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild -bl:"$($env:TP_ROOT_DIR)\TestAssets.binlog"
Expand Down
3 changes: 1 addition & 2 deletions scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function Unzip
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}


function Verify-Nuget-Packages($packageDirectory)
{
Write-Log "Starting Verify-Nuget-Packages."
Expand Down Expand Up @@ -59,4 +58,4 @@ function Verify-Nuget-Packages($packageDirectory)
}

Write-Log "Completed Verify-Nuget-Packages."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Extensions
{
using System;
using System.Reflection;

public static partial class ReflectionExtensions
{
#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

public static bool IsMethod(this 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
}

public static Type GetReflectedType(this 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
}

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

return (RuntimeMethodHandle)methodHandleProperty.GetValue(method);
#endif
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Extensions
{
using System;
using System.Reflection;

public static partial class ReflectionExtensions
{
public static bool IsGenericType(this Type type)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return type.IsGenericType;
#else
return type.GetTypeInfo().IsGenericType;
#endif
}

public static MethodBase GetDeclaringMethod(this Type type)
{
#if !NETSTANDARD1_0 && !NETSTANDARD1_3 && !WINDOWS_UWP
return type.DeclaringMethod;
#else
return type.GetTypeInfo().DeclaringMethod;
#endif
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Extensions
{
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources;

using System;

public static partial class ReflectionExtensions
{
private static void AssertSupport<T>(T obj, string methodName, string className)
where T : class
{
if (obj == null)
{
throw new NotImplementedException(string.Format(Resources.MethodNotImplementedOnPlatform, className, methodName));
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,10 @@
<data name="Utility_ProcessNameWhenCannotGetIt" xml:space="preserve">
<value>Error getting process name.</value>
</data>
<data name="MethodNotImplementedOnPlatform" xml:space="preserve">
<value>'{0}.{1}' is not implemented on this platform!</value>
<comment>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">Hostitele {0} nešlo najít. Ujistěte se, jestli je {0} nainstalovaný na počítači a dostupný v cestě určené proměnnou prostředí PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">Der Host "{0}" wurde nicht gefunden. Stellen Sie sicher, dass "{0}" auf dem Computer installiert und in der PATH-Umgebungsvariablen verfügbar ist.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">No se pudo encontrar el host "{0}". Asegúrese de que "{0}" está instalado en el equipo y está disponible en la variable de entorno PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">L'hôte '{0}' est introuvable. Vérifiez que '{0}' est installé sur la machine et qu'il est disponible dans la variable d'environnement PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">L'host '{0}' non è stato trovato. Assicurarsi che '{0}' sia installato nel computer e che sia disponibile nella variabile di ambiente PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">'{0}' ホストが見つかりませんでした。'{0}' がコンピューターにインストールされており、PATH 環境変数で使用できることを確認してください。</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">‘{0}’ 호스트를 찾을 수 없습니다. ‘{0}’이(가) 컴퓨터에 설치되어 있고 PATH 환경 변수에서 사용할 수 있는지 확인하세요.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">Nie można znaleźć hosta „{0}”. Upewnij się, że element „{0}” jest zainstalowany na maszynie i jest dostępny w zmiennej środowiskowej PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">Não foi possível encontrar o host '{0}'. Verifique se o '{0}' está instalado no computador e está disponível na variável de ambiente PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">Не удалось найти хост "{0}". Убедитесь, что "{0}" установлен на компьютере и доступен в переменной среды PATH.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@
<target state="translated">'{0}' konağı bulunamadı. '{0}' konağının makinede yüklü olduğundan ve PATH ortam değişkeninde bulunduğundan emin olun.</target>
<note />
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
<target state="new">Could not find {0}. Make sure that the dotnet is installed on the machine.</target>
<note></note>
</trans-unit>
<trans-unit id="MethodNotImplementedOnPlatform">
<source>'{0}.{1}' is not implemented on this platform!</source>
<target state="new">'{0}.{1}' is not implemented on this platform!</target>
<note>'{className}.{methodName}' is not implemented on this platform!

Example: 'System.Reflection.MethodBase' is not implemented on this platform!</note>
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit 3fec887

Please sign in to comment.