Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private static void GetManagedNameAndHierarchy(MethodBase method, bool useClosed
hierarchyValues[HierarchyConstants.Levels.ClassIndex] = managedTypeName.Substring(hierarchyPos[1] + 1, hierarchyPos[2] - hierarchyPos[1] - 1);
hierarchyValues[HierarchyConstants.Levels.NamespaceIndex] = managedTypeName.Substring(hierarchyPos[0], hierarchyPos[1] - hierarchyPos[0]);
}
hierarchyValues[HierarchyConstants.Levels.ContainerIndex] = method.DeclaringType?.GetTypeInfo()?.Assembly?.GetName()?.Name ?? string.Empty;
hierarchyValues[HierarchyConstants.Levels.ContainerIndex] = method.DeclaringType?.Assembly?.GetName()?.Name ?? string.Empty;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.TestPlatform.Client/TestPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private static void AddExtensionAssembliesFromExtensionDirectory()
}

string extensionsFolder = Path.Combine(
Path.GetDirectoryName(typeof(TestPlatform).GetTypeInfo().Assembly.GetAssemblyLocation())!,
Path.GetDirectoryName(typeof(TestPlatform).Assembly.GetAssemblyLocation())!,
"Extensions");
if (!fileHelper.DirectoryExists(extensionsFolder))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,6 @@ private static object[] GetAttributes(Type dataCollectorType, Type attributeType

// If any attribute constructor on the type throws, the exception will bubble up through
// the "GetCustomAttributes" method.
return dataCollectorType.GetTypeInfo().GetCustomAttributes(attributeType, true).ToArray();
return dataCollectorType.GetCustomAttributes(attributeType, true).ToArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ internal static IList<string> GetResolutionPaths(string extensionAssembly)
var extensionDirectory = Path.GetDirectoryName(Path.GetFullPath(extensionAssembly))!;
resolutionPaths.Add(extensionDirectory);

var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.GetAssemblyLocation())!;
var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).Assembly.GetAssemblyLocation())!;
if (!resolutionPaths.Contains(currentDirectory))
{
resolutionPaths.Add(currentDirectory);
Expand All @@ -374,7 +374,7 @@ internal IList<string> GetDefaultResolutionPaths()
}

// Keep current directory for resolution
var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.GetAssemblyLocation())!;
var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).Assembly.GetAssemblyLocation())!;
if (!resolutionPaths.Contains(currentDirectory))
{
resolutionPaths.Add(currentDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static void GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(Assem

if (types.Count == 0)
{
types.AddRange(assembly.GetTypes().Where(type => type.GetTypeInfo() is { } typeInfo && typeInfo.IsClass && !typeInfo.IsAbstract));
types.AddRange(assembly.GetTypes().Where(type => type.IsClass && !type.IsAbstract));
}
}
catch (ReflectionTypeLoadException e)
Expand All @@ -166,7 +166,7 @@ private static void GetTestExtensionsFromAssembly<TPluginInfo, TExtension>(Assem
if (e.Types?.Length > 0)
{
// Unloaded types on e.Types are null, make sure we skip them.
types.AddRange(e.Types.Where(type => type != null && type.GetTypeInfo().IsClass && !type.GetTypeInfo().IsAbstract)!);
types.AddRange(e.Types.Where(type => type != null && type.IsClass && !type.IsAbstract)!);
}

if (e.LoaderExceptions != null)
Expand Down Expand Up @@ -209,7 +209,7 @@ private static void GetTestExtensionFromType<TPluginInfo>(
string filePath)
where TPluginInfo : TestPluginInformation
{
if (!extensionType.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
if (!extensionType.IsAssignableFrom(type))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static List<string> GetFileExtensions(Type testDiscovererType)
{
var fileExtensions = new List<string>();

var attributes = testDiscovererType.GetTypeInfo().GetCustomAttributes(typeof(FileExtensionAttribute), inherit: false).ToArray();
var attributes = testDiscovererType.GetCustomAttributes(typeof(FileExtensionAttribute), inherit: false).ToArray();
if (attributes != null && attributes.Length > 0)
{
foreach (var attribute in attributes)
Expand All @@ -115,7 +115,7 @@ private static string GetDefaultExecutorUri(Type testDiscovererType)
{
var result = string.Empty;

var attributes = testDiscovererType.GetTypeInfo().GetCustomAttributes(typeof(DefaultExecutorUriAttribute), inherit: false).ToArray();
var attributes = testDiscovererType.GetCustomAttributes(typeof(DefaultExecutorUriAttribute), inherit: false).ToArray();
if (attributes != null && attributes.Length > 0)
{
DefaultExecutorUriAttribute executorUriAttribute = (DefaultExecutorUriAttribute)attributes[0];
Expand All @@ -138,7 +138,7 @@ private static AssemblyType GetAssemblyType(Type testDiscovererType)
{

// Get Category
var attribute = testDiscovererType.GetTypeInfo().GetCustomAttribute(typeof(CategoryAttribute));
var attribute = testDiscovererType.GetCustomAttribute(typeof(CategoryAttribute));
var category = (attribute as CategoryAttribute)?.Category;

// Get assembly type from category.
Expand All @@ -153,7 +153,7 @@ private static AssemblyType GetAssemblyType(Type testDiscovererType)
/// <param name="testDiscovererType">Data type of the test discoverer</param>
private static bool GetIsDirectoryBased(Type testDiscovererType)
{
var attribute = testDiscovererType.GetTypeInfo().GetCustomAttribute(typeof(DirectoryBasedTestDiscovererAttribute), inherit: false);
var attribute = testDiscovererType.GetCustomAttribute(typeof(DirectoryBasedTestDiscovererAttribute), inherit: false);
return attribute is DirectoryBasedTestDiscovererAttribute;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static string GetExtensionUri(Type testLoggerType)
{
string extensionUri = string.Empty;

object[] attributes = testLoggerType.GetTypeInfo().GetCustomAttributes(typeof(ExtensionUriAttribute), false).ToArray();
object[] attributes = testLoggerType.GetCustomAttributes(typeof(ExtensionUriAttribute), false).ToArray();
if (attributes.Length > 0)
{
ExtensionUriAttribute extensionUriAttribute = (ExtensionUriAttribute)attributes[0];
Expand All @@ -81,7 +81,7 @@ private static string GetExtensionUri(Type testLoggerType)

if (extensionUri.IsNullOrEmpty())
{
EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.GetTypeInfo().Module.Name);
EqtTrace.Error("The type \"{0}\" defined in \"{1}\" does not have ExtensionUri attribute.", testLoggerType.ToString(), testLoggerType.Module.Name);
}

return extensionUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ internal static Dictionary<string, TPluginInfo> GetExtensionsDiscoveredFromAssem
var testPluginInformation = extension.Value as TestPluginInformation;
// TODO: Avoid ArgumentNullException here
var extensionType = Type.GetType(testPluginInformation?.AssemblyQualifiedName!);
if (string.Equals(extensionType?.GetTypeInfo().Assembly.GetAssemblyLocation(), extensionAssembly))
if (string.Equals(extensionType?.Assembly.GetAssemblyLocation(), extensionAssembly))
{
extensions.Add(extension.Key, extension.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static string GetFriendlyName(Type testLoggerType)
{
string friendlyName = string.Empty;

object[] attributes = testLoggerType.GetTypeInfo().GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray();
object[] attributes = testLoggerType.GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray();
if (attributes.Length > 0)
{
FriendlyNameAttribute friendlyNameAttribute = (FriendlyNameAttribute)attributes[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static string GetFriendlyName(Type? testHostType)
{
string friendlyName = string.Empty;

object[]? attributes = testHostType?.GetTypeInfo().GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray();
object[]? attributes = testHostType?.GetCustomAttributes(typeof(FriendlyNameAttribute), false).ToArray();
if (attributes != null && attributes.Length > 0)
{
FriendlyNameAttribute friendlyNameAttribute = (FriendlyNameAttribute)attributes[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static string GetTestSettingsName(Type testSettingsProviderType)
{
string settingName = string.Empty;

object[] attributes = testSettingsProviderType.GetTypeInfo().GetCustomAttributes(typeof(SettingsNameAttribute), false).ToArray();
object[] attributes = testSettingsProviderType.GetCustomAttributes(typeof(SettingsNameAttribute), false).ToArray();
if (attributes != null && attributes.Length > 0)
{
SettingsNameAttribute settingsNameAttribute = (SettingsNameAttribute)attributes[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public InstallationContext(IFileHelper fileHelper)

public bool TryGetVisualStudioDirectory(out string visualStudioDirectory)
{
var vsInstallPath = new DirectoryInfo(typeof(InstallationContext).GetTypeInfo().Assembly.GetAssemblyLocation()).Parent?.Parent?.Parent?.FullName;
var vsInstallPath = new DirectoryInfo(typeof(InstallationContext).Assembly.GetAssemblyLocation()).Parent?.Parent?.Parent?.FullName;
if (!vsInstallPath.IsNullOrEmpty())
{
var pathToDevenv = Path.Combine(vsInstallPath, DevenvExe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal DefaultDataCollectionLauncher(IProcessHelper processHelper, IMessageLog
/// <returns>ProcessId of launched Process. 0 means not launched.</returns>
public override int LaunchDataCollector(IDictionary<string, string?>? environmentVariables, IList<string> commandLineArguments)
{
var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation());
var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).Assembly.GetAssemblyLocation());
TPDebug.Assert(dataCollectorDirectory is not null, "dataCollectorDirectory is not null");

var currentProcessPath = _processHelper.GetCurrentProcessFileName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal DotnetDataCollectionLauncher(IProcessHelper processHelper, IFileHelper
/// <returns>ProcessId of launched Process. 0 means not launched.</returns>
public override int LaunchDataCollector(IDictionary<string, string?>? environmentVariables, IList<string> commandLineArguments)
{
var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation());
var dataCollectorDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).Assembly.GetAssemblyLocation());
TPDebug.Assert(dataCollectorDirectory is not null, "dataCollectorDirectory is null");

var dataCollectorAssemblyPath = Path.Combine(dataCollectorDirectory, DataCollectorProcessName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ protected InProcDataCollectionExtensionManager(string? runSettings, ITestEventsP
/// <returns>
/// The <see cref="IInProcDataCollector"/>.
/// </returns>
protected virtual IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, TypeInfo interfaceTypeInfo)
protected virtual IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, Type interfaceType)
{
var inProcDataCollector = new InProcDataCollector(
codebase,
assemblyQualifiedName,
interfaceTypeInfo,
interfaceType,
configuration?.OuterXml);

inProcDataCollector.LoadDataCollector(_inProcDataCollectionSink);
Expand Down Expand Up @@ -215,7 +215,7 @@ private void InitializeInProcDataCollectors(string? runSettings)

_inProcDataCollectorSettingsCollection = inProcDataCollectionRunSettings!.DataCollectorSettingsList;

var interfaceTypeInfo = typeof(InProcDataCollection).GetTypeInfo();
var interfaceTypeInfo = typeof(InProcDataCollection);
foreach (var inProcDc in _inProcDataCollectorSettingsCollection)
{
var codeBase = GetCodebase(inProcDc.CodeBase!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ internal class InProcDataCollector : IInProcDataCollector
public InProcDataCollector(
string codeBase,
string assemblyQualifiedName,
TypeInfo interfaceTypeInfo,
Type interfaceType,
string? configXml)
: this(codeBase, assemblyQualifiedName, interfaceTypeInfo, configXml, new PlatformAssemblyLoadContext(), TestPluginCache.Instance)
: this(codeBase, assemblyQualifiedName, interfaceType, configXml, new PlatformAssemblyLoadContext(), TestPluginCache.Instance)
{
}

Expand All @@ -63,7 +63,7 @@ public InProcDataCollector(
/// </param>
/// <param name="assemblyLoadContext">
/// </param>
internal InProcDataCollector(string codeBase, string assemblyQualifiedName, TypeInfo interfaceTypeInfo, string? configXml, IAssemblyLoadContext assemblyLoadContext, TestPluginCache testPluginCache)
internal InProcDataCollector(string codeBase, string assemblyQualifiedName, Type interfaceType, string? configXml, IAssemblyLoadContext assemblyLoadContext, TestPluginCache testPluginCache)
{
_configXml = configXml;
_assemblyLoadContext = assemblyLoadContext;
Expand All @@ -75,15 +75,15 @@ internal InProcDataCollector(string codeBase, string assemblyQualifiedName, Type
{
// If we're loading coverlet collector we skip to check the version of assembly
// to allow upgrade through nuget package
filterPredicate = x => Constants.CoverletDataCollectorTypeName.Equals(x.FullName) && interfaceTypeInfo.IsAssignableFrom(x.GetTypeInfo());
filterPredicate = x => Constants.CoverletDataCollectorTypeName.Equals(x.FullName) && interfaceType.IsAssignableFrom(x);

// Coverlet collector is consumed as nuget package we need to add assemblies directory to resolver to correctly load references.
TPDebug.Assert(Path.IsPathRooted(codeBase), "Absolute path expected");
testPluginCache.AddResolverSearchDirectories(new string[] { Path.GetDirectoryName(codeBase)! });
}
else
{
filterPredicate = x => string.Equals(x.AssemblyQualifiedName, assemblyQualifiedName) && interfaceTypeInfo.IsAssignableFrom(x.GetTypeInfo());
filterPredicate = x => string.Equals(x.AssemblyQualifiedName, assemblyQualifiedName) && interfaceType.IsAssignableFrom(x);
}

_dataCollectorType = assembly?.GetTypes().FirstOrDefault(filterPredicate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private static string GetTimestampedLogFile(string logFile)
return settingsXml;
}

var extensionsFolder = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).GetTypeInfo().Assembly.GetAssemblyLocation())!, "Extensions");
var extensionsFolder = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).Assembly.GetAssemblyLocation())!, "Extensions");

using var stream = new StringReader(settingsXml);
using var reader = XmlReader.Create(stream, XmlRunSettingsUtilities.ReaderSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private static bool IsDiscovererFromDeprecatedLocations(
return false;
}

var discovererLocation = discoverer.Value.GetType().GetTypeInfo().Assembly.GetAssemblyLocation();
var discovererLocation = discoverer.Value.GetType().Assembly.GetAssemblyLocation();

return Path.GetDirectoryName(discovererLocation)!
.Equals(Constants.DefaultAdapterLocation, StringComparison.OrdinalIgnoreCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,12 @@ private bool RunTestInternalWithExecutors(IEnumerable<Tuple<Uri, string>> execut
if (!CrossPlatEngine.Constants.DefaultAdapters.Contains(executor.Metadata.ExtensionUri, StringComparer.OrdinalIgnoreCase))
{
// If real executor is wrapped by a decorator we get the real decorated type
TypeInfo executorTypeInfo =
Type executorType =
(executor.Value is SerialTestRunDecorator serialTestRunDecorator)
? serialTestRunDecorator.OriginalTestExecutor.GetType().GetTypeInfo()
: executor.Value.GetType().GetTypeInfo();
? serialTestRunDecorator.OriginalTestExecutor.GetType()
: executor.Value.GetType();

var executorLocation = executorTypeInfo.Assembly.GetAssemblyLocation();
var executorLocation = executorType.Assembly.GetAssemblyLocation();
executorsFromDeprecatedLocations |= Path.GetDirectoryName(executorLocation)!.Equals(CrossPlatEngine.Constants.DefaultAdapterLocation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private static IEnumerable<FieldPersistenceInfo> ReflectFields(Type type)

foreach (
FieldInfo reflectedFieldInfo in
type.GetTypeInfo().GetFields(
type.GetFields(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
{
FieldPersistenceInfo info = new(reflectedFieldInfo);
Expand Down Expand Up @@ -599,7 +599,7 @@ private static string GetDefaultFieldLocation(FieldInfo fieldInfo)

private static bool ImplementsIXmlTestStore(Type type)
{
return type.GetTypeInfo().GetInterface(typeof(IXmlTestStore).Name) != null;
return type.GetInterface(typeof(IXmlTestStore).Name) != null;
}

private static T? GetAttribute<T>(FieldInfo fieldInfo) where T : Attribute
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.TestPlatform.ObjectModel/TestObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public virtual IEnumerable<TestProperty> Properties
object? defaultValue = null;
var valueType = property.GetValueType();

if (valueType != null && valueType.GetTypeInfo().IsValueType)
if (valueType != null && valueType.IsValueType)
{
defaultValue = Activator.CreateInstance(valueType);
}
Expand Down Expand Up @@ -249,7 +249,7 @@ protected virtual void ProtectedSetPropertyValue(TestProperty property, object?
// Do not try conversion if the object is already of the type we're trying to convert.
// Note that typeof(T) may be object in case the value is getting deserialized via the StoreKvpList, however
// the de-serializer could have converted it already, hence the runtime type check.
if (valueType != null && (valueType.GetTypeInfo().IsAssignableFrom(typeof(T).GetTypeInfo()) || valueType.GetTypeInfo().IsAssignableFrom(value?.GetType().GetTypeInfo())))
if (valueType != null && (valueType.IsAssignableFrom(typeof(T)) || valueType.IsAssignableFrom(value?.GetType())))
{
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private TestProperty(string id, string label, string category, string descriptio
// Note that this doesn't handle generic types. Such types will fail during serialization.
ValueType = valueType.FullName!;
}
else if (valueType.GetTypeInfo().IsValueType)
else if (valueType.IsValueType)
{
// In case of custom types, let the assembly qualified name be available to help
// deserialization on the client.
Expand Down
Loading