diff --git a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs index 0f5848d568..ccff458549 100644 --- a/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs +++ b/src/Microsoft.TestPlatform.AdapterUtilities/ManagedNameUtilities/ManagedNameHelper.Reflection.cs @@ -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; } /// diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs index 3ffc03e5e3..4408c94f4e 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Client.Discovery; using Microsoft.VisualStudio.TestPlatform.Client.Execution; @@ -276,7 +275,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)) { diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs index c0a46e7423..7c6019e525 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectorConfig.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; @@ -155,6 +154,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(); } } diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs index a62f6c3af4..3350a61f17 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginCache.cs @@ -349,7 +349,7 @@ internal static IList 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); @@ -374,7 +374,7 @@ internal IList 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); diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs index 3bbef8f8cf..ca80aa7a2c 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/TestPluginDiscoverer.cs @@ -156,7 +156,7 @@ private static void GetTestExtensionsFromAssembly(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) @@ -166,7 +166,7 @@ private static void GetTestExtensionsFromAssembly(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) @@ -209,7 +209,7 @@ private static void GetTestExtensionFromType( string filePath) where TPluginInfo : TestPluginInformation { - if (!extensionType.GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + if (!extensionType.IsAssignableFrom(type)) { return; } diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs index 54eed86b92..8b947cd8e2 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestDiscovererPluginInformation.cs @@ -90,7 +90,7 @@ private static List GetFileExtensions(Type testDiscovererType) { var fileExtensions = new List(); - 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) @@ -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]; @@ -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. @@ -153,7 +153,7 @@ private static AssemblyType GetAssemblyType(Type testDiscovererType) /// Data type of the test discoverer 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; } } diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs index 6aaa8bd8c0..14e9eea63e 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensionPluginInformation.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -68,7 +67,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]; @@ -81,7 +80,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; diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs index afc3a705df..e1f6c01ebc 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.DataCollector; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; @@ -430,7 +429,7 @@ internal static Dictionary 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); } diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs index 4e57bcd94c..14b7e06105 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestLoggerPluginInformation.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -54,7 +53,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]; diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs index 4a7060713a..52554b9197 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestRunTimePluginInformation.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -54,7 +53,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]; diff --git a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs index 6322353be3..3066bb52c8 100644 --- a/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs +++ b/src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestSettingsProviderPluginInformation.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.ObjectModel; @@ -68,7 +67,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]; diff --git a/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs b/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs index 267faa0d58..6c0c0bebaa 100644 --- a/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs +++ b/src/Microsoft.TestPlatform.Common/Utilities/InstallationContext.cs @@ -3,7 +3,6 @@ using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; @@ -25,7 +24,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); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs index 866cdc612e..721d618432 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DefaultDataCollectionLauncher.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; @@ -53,7 +52,7 @@ internal DefaultDataCollectionLauncher(IProcessHelper processHelper, IMessageLog /// ProcessId of launched Process. 0 means not launched. public override int LaunchDataCollector(IDictionary? environmentVariables, IList 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(); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs index 6bfab43138..b1d2c674eb 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/DotnetDataCollectionLauncher.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.Logging; using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; @@ -62,7 +61,7 @@ internal DotnetDataCollectionLauncher(IProcessHelper processHelper, IFileHelper /// ProcessId of launched Process. 0 means not launched. public override int LaunchDataCollector(IDictionary? environmentVariables, IList 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); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs index 9f7c321dfd..89917eaa08 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollectionExtensionManager.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Xml; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; @@ -100,12 +99,12 @@ protected InProcDataCollectionExtensionManager(string? runSettings, ITestEventsP /// /// The . /// - 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); @@ -215,7 +214,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!); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs index c3d1684291..f8cdcf9837 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/InProcDataCollector.cs @@ -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) { } @@ -63,7 +63,7 @@ public InProcDataCollector( /// /// /// - 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; @@ -75,7 +75,7 @@ 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"); @@ -83,7 +83,7 @@ internal InProcDataCollector(string codeBase, string assemblyQualifiedName, Type } 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); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs index 1cb86f1268..216c29c155 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs @@ -6,7 +6,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Xml; using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; @@ -348,7 +347,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); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs index aafa907ef8..418d5a32d4 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Discovery/DiscovererEnumerator.cs @@ -7,7 +7,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; @@ -296,7 +295,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); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs index 0d5e6dacae..4600200c39 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Execution/BaseRunTests.cs @@ -9,7 +9,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionDecorators; @@ -494,12 +493,12 @@ private bool RunTestInternalWithExecutors(IEnumerable> 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); } diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs index aa73268c32..8808c57314 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/XML/XmlPersistence.cs @@ -528,7 +528,7 @@ private static IEnumerable ReflectFields(Type type) foreach ( FieldInfo reflectedFieldInfo in - type.GetTypeInfo().GetFields( + type.GetFields( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) { FieldPersistenceInfo info = new(reflectedFieldInfo); @@ -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(FieldInfo fieldInfo) where T : Attribute diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs b/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs index e99175c525..634fe33e5f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestObject.cs @@ -8,7 +8,6 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -using System.Reflection; using System.Runtime.Serialization; using Microsoft.VisualStudio.TestPlatform.CoreUtilities; @@ -108,7 +107,7 @@ public virtual IEnumerable Properties object? defaultValue = null; var valueType = property.GetValueType(); - if (valueType != null && valueType.GetTypeInfo().IsValueType) + if (valueType != null && valueType.IsValueType) { defaultValue = Activator.CreateInstance(valueType); } @@ -249,7 +248,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; } diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs index 7555f82793..ed0e02b8be 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestProperty/TestProperty.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Reflection; using System.Runtime.Serialization; using Microsoft.VisualStudio.TestPlatform.Utilities; @@ -62,7 +61,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. diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs index 5db8da531c..89ba1aca36 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs @@ -8,7 +8,6 @@ using System.Diagnostics; using System.Globalization; using System.IO; -using System.Reflection; using System.Threading; #if !NET5_0_OR_GREATER using System.Threading.Tasks; @@ -235,7 +234,7 @@ void InitializeAndStart() /// public string? GetTestEngineDirectory() { - return Path.GetDirectoryName(typeof(ProcessHelper).GetTypeInfo().Assembly.Location); + return Path.GetDirectoryName(typeof(ProcessHelper).Assembly.Location); } /// diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs index 5a92e65263..6b42aa4caa 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DefaultTestHostManager.cs @@ -9,7 +9,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -180,7 +179,7 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo( string testHostProcessName = GetTestHostName(_architecture, _targetFramework, _processHelper.GetCurrentProcessArchitecture()); - var currentWorkingDirectory = Path.GetDirectoryName(typeof(DefaultTestHostManager).GetTypeInfo().Assembly.Location); + var currentWorkingDirectory = Path.GetDirectoryName(typeof(DefaultTestHostManager).Assembly.Location); var argumentsString = " " + connectionInfo.ToCommandLineOptions(); TPDebug.Assert(currentWorkingDirectory is not null, "Current working directory must not be null."); diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs index 3e675e6f6a..be2a1030f3 100644 --- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs +++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs @@ -166,7 +166,7 @@ private static void LoadCodeCoverageAssembly() return; } - var dataAttachmentAssemblyLocation = typeof(CodeCoverageDataAttachmentsHandler).GetTypeInfo().Assembly.GetAssemblyLocation()!; + var dataAttachmentAssemblyLocation = typeof(CodeCoverageDataAttachmentsHandler).Assembly.GetAssemblyLocation()!; var assemblyPath = Path.Combine(Path.GetDirectoryName(dataAttachmentAssemblyLocation)!, CodeCoverageIoAssemblyName + ".dll"); s_codeCoverageAssembly = new PlatformAssemblyLoadContext().LoadAssemblyFromPath(assemblyPath); diff --git a/src/datacollector/DataCollectorMain.cs b/src/datacollector/DataCollectorMain.cs index a867bde716..5946455b36 100644 --- a/src/datacollector/DataCollectorMain.cs +++ b/src/datacollector/DataCollectorMain.cs @@ -105,7 +105,6 @@ public void Run(string[]? args) if (EqtTrace.IsVerboseEnabled) { var version = typeof(DataCollectorMain) - .GetTypeInfo() .Assembly .GetCustomAttribute()?.InformationalVersion; EqtTrace.Verbose($"Version: {version}"); diff --git a/src/testhost.x86/DefaultEngineInvoker.cs b/src/testhost.x86/DefaultEngineInvoker.cs index 14746cee92..b28332e8ad 100644 --- a/src/testhost.x86/DefaultEngineInvoker.cs +++ b/src/testhost.x86/DefaultEngineInvoker.cs @@ -100,7 +100,6 @@ public void Invoke(IDictionary argsDictionary) if (EqtTrace.IsVerboseEnabled) { var version = typeof(DefaultEngineInvoker) - .GetTypeInfo() .Assembly .GetCustomAttribute()?.InformationalVersion; EqtTrace.Verbose($"Version: {version} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}"); diff --git a/src/vstest.console/Internal/Product.cs b/src/vstest.console/Internal/Product.cs index 277da3d2a3..de39a99c4f 100644 --- a/src/vstest.console/Internal/Product.cs +++ b/src/vstest.console/Internal/Product.cs @@ -12,7 +12,6 @@ public class Product private static string? GetProductVersion() { var attr = typeof(Product) - .GetTypeInfo() .Assembly .GetCustomAttribute(); return attr?.InformationalVersion; diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 860306190d..094e0351ca 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -9,7 +9,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Xml; @@ -1110,7 +1109,7 @@ private static void AddConsoleLogger(XmlDocument document, LoggerRunSettings log FriendlyName = ConsoleLogger.FriendlyName, Uri = new Uri(ConsoleLogger.ExtensionUri), AssemblyQualifiedName = typeof(ConsoleLogger).AssemblyQualifiedName, - CodeBase = typeof(ConsoleLogger).GetTypeInfo().Assembly.Location, + CodeBase = typeof(ConsoleLogger).Assembly.Location, IsEnabled = true }; @@ -1144,7 +1143,7 @@ private static bool UpdateConsoleLoggerIfExists( { var consoleLogger = loggerRunSettings.LoggerSettingsList[existingLoggerIndex]; consoleLogger.AssemblyQualifiedName = typeof(ConsoleLogger).AssemblyQualifiedName; - consoleLogger.CodeBase = typeof(ConsoleLogger).GetTypeInfo().Assembly.Location; + consoleLogger.CodeBase = typeof(ConsoleLogger).Assembly.Location; RunSettingsProviderExtensions.UpdateRunSettingsXmlDocumentInnerXml( document, ObjectModel.Constants.LoggerRunSettingsName, diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs index 796ee6b2b8..89631f1b85 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestDiscoveryExtensionManagerTests.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; @@ -49,7 +48,7 @@ public void GetDiscoveryExtensionManagerShouldReturnADiscoveryManagerWithExtensi { var extensionManager = TestDiscoveryExtensionManager.GetDiscoveryExtensionManager( - typeof(TestDiscoveryExtensionManagerTests).GetTypeInfo().Assembly.Location); + typeof(TestDiscoveryExtensionManagerTests).Assembly.Location); Assert.IsNotNull(extensionManager.Discoverers); Assert.IsTrue(extensionManager.Discoverers.Any()); diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs index ca0aefbf1f..6f0b810351 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestExecutorExtensionManagerTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; @@ -47,7 +46,7 @@ public void GetExecutorExtensionManagerShouldReturnAnExecutionManagerWithExtensi { var extensionManager = TestExecutorExtensionManager.GetExecutionExtensionManager( - typeof(TestExecutorExtensionManagerTests).GetTypeInfo().Assembly.Location); + typeof(TestExecutorExtensionManagerTests).Assembly.Location); Assert.IsNotNull(extensionManager.TestExtensions); Assert.IsTrue(extensionManager.TestExtensions.Any()); diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs index a33d8c122c..ff82d8f17b 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginCacheTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common; @@ -31,7 +30,7 @@ public TestPluginCacheTests() // Reset the singleton. TestPluginCache.Instance = null; _mockFileHelper = new Mock(); - _testablePluginCache = new TestableTestPluginCache(new List { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }); + _testablePluginCache = new TestableTestPluginCache(new List { typeof(TestPluginCacheTests).Assembly.Location }); _mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); } @@ -71,7 +70,7 @@ public void UpdateAdditionalExtensionsShouldNotThrowIfExtensionPathIsEmpty() [TestMethod] public void UpdateAdditionalExtensionsShouldUpdateAdditionalExtensions() { - var additionalExtensions = new List { typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location }; + var additionalExtensions = new List { typeof(TestPluginCacheTests).Assembly.Location }; TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); @@ -84,8 +83,8 @@ public void UpdateAdditionalExtensionsShouldOnlyAddUniqueExtensionPaths() { var additionalExtensions = new List { - typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location, - typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location + typeof(TestPluginCacheTests).Assembly.Location, + typeof(TestPluginCacheTests).Assembly.Location }; TestPluginCache.Instance.UpdateExtensions(additionalExtensions, false); var updatedExtensions = TestPluginCache.Instance.GetExtensionPaths(string.Empty); @@ -206,7 +205,7 @@ public void GetExtensionPathsShouldNotSkipDefaultExtensionsIfSetFalse() [TestMethod] public void GetDefaultResolutionPathsShouldReturnCurrentDirectoryByDefault() { - var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location); + var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).Assembly.Location); var expectedDirectories = new List { currentDirectory! }; var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); @@ -218,7 +217,7 @@ public void GetDefaultResolutionPathsShouldReturnCurrentDirectoryByDefault() [TestMethod] public void GetDefaultResolutionPathsShouldReturnAdditionalExtensionPathsDirectories() { - var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location)!; + var currentDirectory = Path.GetDirectoryName(typeof(TestPluginCache).Assembly.Location)!; var candidateDirectory = Directory.GetParent(currentDirectory)!.FullName; var extensionPaths = new List { Path.Combine(candidateDirectory, "foo.dll") }; @@ -244,7 +243,7 @@ public void GetDefaultResolutionPathsShouldReturnDirectoryFromDefaultExtensionsP // Setup the testable instance. TestPluginCache.Instance = _testablePluginCache; - var defaultExtensionsFile = typeof(TestPluginCache).GetTypeInfo().Assembly.Location; + var defaultExtensionsFile = typeof(TestPluginCache).Assembly.Location; _testablePluginCache.DefaultExtensionPaths = new List() { defaultExtensionsFile }; var resolutionPaths = TestPluginCache.Instance.GetDefaultResolutionPaths(); @@ -269,7 +268,7 @@ public void GetResolutionPathsShouldReturnExtensionAssemblyDirectoryAndTpCommonD var temp = Path.GetTempPath(); var resolutionPaths = TestPluginCache.GetResolutionPaths($@"{temp}{Path.DirectorySeparatorChar}Idonotexist.dll").Select(p => p.Replace("/", "\\")).ToList(); - var tpCommonDirectory = Path.GetDirectoryName(typeof(TestPluginCache).GetTypeInfo().Assembly.Location)!; + var tpCommonDirectory = Path.GetDirectoryName(typeof(TestPluginCache).Assembly.Location)!; var expectedPaths = new List { temp, tpCommonDirectory }.ConvertAll(p => p.Replace("/", "\\").TrimEnd('\\')); CollectionAssert.AreEqual(expectedPaths, resolutionPaths, $"Collection {string.Join(", ", resolutionPaths)}, is not equal to the expected collection {string.Join(", ", expectedPaths)}."); @@ -278,7 +277,7 @@ public void GetResolutionPathsShouldReturnExtensionAssemblyDirectoryAndTpCommonD [TestMethod] public void GetResolutionPathsShouldNotHaveDuplicatePathsIfExtensionIsInSameDirectory() { - var tpCommonlocation = typeof(TestPluginCache).GetTypeInfo().Assembly.Location; + var tpCommonlocation = typeof(TestPluginCache).Assembly.Location; var resolutionPaths = TestPluginCache.GetResolutionPaths(tpCommonlocation); @@ -296,7 +295,7 @@ public void GetTestExtensionsShouldReturnExtensionsInAssembly() { TestPluginCacheHelper.SetupMockAdditionalPathExtensions(typeof(TestPluginCacheTests)); - TestPluginCache.Instance.GetTestExtensions(typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location); + TestPluginCache.Instance.GetTestExtensions(typeof(TestPluginCacheTests).Assembly.Location); Assert.IsNotNull(TestPluginCache.Instance.TestExtensions); Assert.IsTrue(TestPluginCache.Instance.TestExtensions.TestDiscoverers!.Count > 0); @@ -305,7 +304,7 @@ public void GetTestExtensionsShouldReturnExtensionsInAssembly() [TestMethod] public void GetTestExtensionsShouldAddTestExtensionsDiscoveredToCache() { - var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; + var extensionAssembly = typeof(TestPluginCacheTests).Assembly.Location; var testDiscovererPluginInfos = _testablePluginCache.GetTestExtensions(extensionAssembly); @@ -318,7 +317,7 @@ public void GetTestExtensionsShouldAddTestExtensionsDiscoveredToCache() [TestMethod] public void GetTestExtensionsShouldGetTestExtensionsFromCache() { - var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; + var extensionAssembly = typeof(TestPluginCacheTests).Assembly.Location; var testDiscovererPluginInfos = _testablePluginCache.GetTestExtensions(extensionAssembly); Assert.IsFalse(testDiscovererPluginInfos.ContainsKey("td")); @@ -335,7 +334,7 @@ public void GetTestExtensionsShouldShouldThrowIfDiscovererThrows() { //TODO : make ITestDiscoverer interface and then mock it in order to make this test case pass. - var extensionAssembly = typeof(TestPluginCacheTests).GetTypeInfo().Assembly.Location; + var extensionAssembly = typeof(TestPluginCacheTests).Assembly.Location; Assert.ThrowsException(() => _testablePluginCache.GetTestExtensions(extensionAssembly)); } diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs index 43e300c336..15fdc0702a 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginDiscovererTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Xml; @@ -38,7 +37,7 @@ public void GetTestExtensionsInformationShouldNotThrowOnALoadException() [TestMethod] public void GetTestExtensionsInformationShouldNotConsiderAbstractClasses() { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).Assembly.Location }; // The below should not throw an exception. var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); @@ -49,7 +48,7 @@ public void GetTestExtensionsInformationShouldNotConsiderAbstractClasses() [TestMethod] public void GetTestExtensionsInformationShouldReturnDiscovererExtensions() { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).Assembly.Location }; // The below should not throw an exception. var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); @@ -64,7 +63,7 @@ public void GetTestExtensionsInformationShouldReturnDiscovererExtensions() [TestMethod] public void GetTestExtensionsInformationShouldReturnExecutorExtensions() { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).Assembly.Location }; // The below should not throw an exception. var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); @@ -80,7 +79,7 @@ public void GetTestExtensionsInformationShouldReturnExecutorExtensions() [TestMethod] public void GetTestExtensionsInformationShouldReturnLoggerExtensions() { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).Assembly.Location }; // The below should not throw an exception. var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); @@ -95,7 +94,7 @@ public void GetTestExtensionsInformationShouldReturnLoggerExtensions() [TestMethod] public void GetTestExtensionsInformationShouldReturnDataCollectorExtensionsAndIgnoresInvalidDataCollectors() { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).Assembly.Location }; // The below should not throw an exception. var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); @@ -110,7 +109,7 @@ public void GetTestExtensionsInformationShouldReturnDataCollectorExtensionsAndIg [TestMethod] public void GetTestExtensionsInformationShouldReturnSettingsProviderExtensions() { - var pathToExtensions = new List { typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location }; + var pathToExtensions = new List { typeof(TestPluginDiscovererTests).Assembly.Location }; // The below should not throw an exception. var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); @@ -128,7 +127,7 @@ public void GetTestExtensionsInformationShouldNotAbortOnFaultyExtensions() { var pathToExtensions = new List { - typeof(TestPluginDiscovererTests).GetTypeInfo().Assembly.Location, + typeof(TestPluginDiscovererTests).Assembly.Location, }; var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation(pathToExtensions); diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs index dc97e8fc40..62682571f6 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/TestPluginManagerTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common; @@ -109,7 +108,7 @@ public void GetTestExtensionsShouldDiscoverExtensionsOnlyOnce() public void GetTestExtensionsForAnExtensionAssemblyShouldReturnExtensionsInThatAssembly() { TestPluginManager.GetTestExtensions( - typeof(TestPluginManagerTests).GetTypeInfo().Assembly.Location, + typeof(TestPluginManagerTests).Assembly.Location, out _, out var testExtensions); diff --git a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs index c7c8fcd484..a26d10ac56 100644 --- a/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs +++ b/test/Microsoft.TestPlatform.Common.UnitTests/ExtensionFramework/Utilities/TestExtensionsTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; @@ -114,7 +113,7 @@ public void AddExtensionsShouldNotAddAnAlreadyExistingExtensionToTheCollection() [TestMethod] public void GetExtensionsDiscoveredFromAssemblyShouldReturnNullIfNoExtensionsPresent() { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(TestExtensionsTests).Assembly.Location; Assert.IsNull(_testExtensions.GetExtensionsDiscoveredFromAssembly(assemblyLocation)); } @@ -133,7 +132,7 @@ public void GetExtensionsDiscoveredFromAssemblyShouldNotThrowIfExtensionAssembly [TestMethod] public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoverers() { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(TestExtensionsTests).Assembly.Location; _testExtensions.TestDiscoverers = new Dictionary { @@ -153,7 +152,7 @@ public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoverers() [TestMethod] public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestExecutors() { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(TestExtensionsTests).Assembly.Location; _testExtensions.TestExecutors = new Dictionary { @@ -173,7 +172,7 @@ public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestExecutors() [TestMethod] public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestSettingsProviders() { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(TestExtensionsTests).Assembly.Location; _testExtensions.TestSettingsProviders = new Dictionary { @@ -193,7 +192,7 @@ public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestSettingsProviders [TestMethod] public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestLoggers() { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(TestExtensionsTests).Assembly.Location; _testExtensions.TestLoggers = new Dictionary { @@ -213,7 +212,7 @@ public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestLoggers() [TestMethod] public void GetExtensionsDiscoveredFromAssemblyShouldReturnTestDiscoveresAndLoggers() { - var assemblyLocation = typeof(TestExtensionsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(TestExtensionsTests).Assembly.Location; _testExtensions.TestDiscoverers = new Dictionary { diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs index 6a1df7d787..205553eec3 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/DotnetDataCollectionLauncherTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; @@ -48,7 +47,7 @@ public void LaunchDataCollectorShouldLaunchDataCollectorProcess() [TestMethod] public void LaunchDataCollectorShouldAppendDoubleQuoteForDataCollectorDllPath() { - var currentWorkingDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).GetTypeInfo().Assembly.GetAssemblyLocation())!; + var currentWorkingDirectory = Path.GetDirectoryName(typeof(DefaultDataCollectionLauncher).Assembly.GetAssemblyLocation())!; var dataCollectorAssemblyPath = Path.Combine(currentWorkingDirectory, "datacollector.dll"); List arguments = new(); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs index 730d1a0a07..1edc315269 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectionExtensionManagerTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Xml; using Microsoft.TestPlatform.TestUtilities; @@ -301,7 +300,7 @@ public TestableInProcDataCollectionExtensionManager(string runSettings, ITestEve { } - protected override IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, TypeInfo interfaceTypeInfo) + protected override IInProcDataCollector CreateDataCollector(string assemblyQualifiedName, string codebase, XmlElement configuration, Type interfaceType) { return new MockDataCollector(assemblyQualifiedName, codebase, configuration); } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs index e3ae6c7b20..0baec50dbd 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/InProcDataCollectorTests.cs @@ -69,49 +69,49 @@ public void InProcDataCollectorShouldNotThrowExceptionIfAssemblyDoesNotContainAn [TestMethod] public void InProcDataCollectorShouldInitializeIfAssemblyContainsAnyInProcDataCollector() { - var typeInfo = typeof(TestableInProcDataCollector).GetTypeInfo(); + var type = typeof(TestableInProcDataCollector); _assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) - .Returns(typeInfo.Assembly); + .Returns(type.Assembly); _inProcDataCollector = new InProcDataCollector( string.Empty, - typeInfo.AssemblyQualifiedName!, - typeInfo, + type.AssemblyQualifiedName!, + type, string.Empty, _assemblyLoadContext.Object, TestPluginCache.Instance); Assert.IsNotNull(_inProcDataCollector.AssemblyQualifiedName); - Assert.AreEqual(_inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName); + Assert.AreEqual(_inProcDataCollector.AssemblyQualifiedName, type.AssemblyQualifiedName); } [TestMethod] public void InProcDataCollectorLoadCoverlet() { - var typeInfo = typeof(CoverletInProcDataCollector).GetTypeInfo(); + var type = typeof(CoverletInProcDataCollector); - Assert.AreEqual("9.9.9.9", typeInfo.Assembly.GetName().Version!.ToString()); + Assert.AreEqual("9.9.9.9", type.Assembly.GetName().Version!.ToString()); _assemblyLoadContext.Setup(alc => alc.LoadAssemblyFromPath(It.IsAny())) - .Returns(typeInfo.Assembly); + .Returns(type.Assembly); // We need to mock TestPluginCache because we have to create assembly resolver instance // using SetupAssemblyResolver method, we don't use any other method of class(like DiscoverTestExtensions etc...) // that fire creation TestableTestPluginCache testablePlugin = new(); - testablePlugin.SetupAssemblyResolver(typeInfo.Assembly.Location); + testablePlugin.SetupAssemblyResolver(type.Assembly.Location); _inProcDataCollector = new InProcDataCollector( - typeInfo.Assembly.Location, + type.Assembly.Location, "Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - typeof(InProcDataCollection).GetTypeInfo(), + typeof(InProcDataCollection), string.Empty, _assemblyLoadContext.Object, testablePlugin); Assert.IsNotNull(_inProcDataCollector.AssemblyQualifiedName); - Assert.AreEqual(_inProcDataCollector.AssemblyQualifiedName, typeInfo.AssemblyQualifiedName); + Assert.AreEqual(_inProcDataCollector.AssemblyQualifiedName, type.AssemblyQualifiedName); } private class TestableInProcDataCollector : InProcDataCollection diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs index d0f1629b56..6ed0c20b60 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs @@ -7,7 +7,6 @@ using System.Diagnostics; using System.Globalization; using System.IO; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.DataCollection; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; @@ -160,7 +159,7 @@ public void BeforeTestRunStartShouldPassRunSettingsWithExtensionsFolderUpdatedAs var result = _proxyDataCollectionManager.BeforeTestRunStart(true, true, null); - var extensionsFolderPath = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).GetTypeInfo().Assembly.Location)!, "Extensions"); + var extensionsFolderPath = Path.Combine(Path.GetDirectoryName(typeof(ITestPlatform).Assembly.Location)!, "Extensions"); var expectedSettingsXml = $"{extensionsFolderPath}"; _mockDataCollectionRequestSender.Verify( x => x.SendBeforeTestRunStartAndGetResult(expectedSettingsXml, sourceList, true, It.IsAny()), Times.Once); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs index 20c276ee28..ec44ce64b4 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscovererEnumeratorTests.cs @@ -6,7 +6,6 @@ using System.ComponentModel; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using Microsoft.TestPlatform.TestUtilities; @@ -50,7 +49,7 @@ public DiscovererEnumeratorTests() _discovererEnumerator = new DiscovererEnumerator(_mockRequestData.Object, _discoveryResultCache, _mockTestPlatformEventSource.Object, _mockAssemblyProperties.Object, _cancellationTokenSource.Token); _runSettingsMock = new Mock(); _messageLoggerMock = new Mock(); - TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); TestDiscoveryExtensionManager.Destroy(); } @@ -71,9 +70,9 @@ public void Cleanup() public void LoadTestsShouldReportWarningOnNoDiscoverers() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(TestPluginCache).GetTypeInfo().Assembly.Location }, + new string[] { typeof(TestPluginCache).Assembly.Location }, () => { }); - var sources = new List { typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location }; + var sources = new List { typeof(DiscoveryResultCacheTests).Assembly.Location }; var extensionSourceMap = new Dictionary> { @@ -91,7 +90,7 @@ public void LoadTestsShouldReportWarningOnNoDiscoverers() public void LoadTestsShouldNotCallIntoDiscoverersIfNoneMatchesSources() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { "temp.jpeg" }; @@ -116,7 +115,7 @@ public void LoadTestsShouldNotCallIntoDiscoverersIfNoneMatchesSources() public void LoadTestsShouldCallOnlyNativeDiscovererIfNativeAssembliesPassed() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); @@ -151,7 +150,7 @@ public void LoadTestsShouldCallOnlyNativeDiscovererIfNativeAssembliesPassed() public void LoadTestsShouldCallOnlyManagedDiscovererIfManagedAssembliesPassed() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("managed.dll")).Returns(AssemblyType.Managed); @@ -186,7 +185,7 @@ public void LoadTestsShouldCallOnlyManagedDiscovererIfManagedAssembliesPassed() public void LoadTestsShouldCallBothNativeAndManagedDiscoverersWithCorrectSources() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); _mockAssemblyProperties.Setup(pe => pe.GetAssemblyType("native.dll")).Returns(AssemblyType.Native); @@ -229,13 +228,13 @@ public void LoadTestsShouldCallBothNativeAndManagedDiscoverersWithCorrectSources public void LoadTestsShouldCallIntoADiscovererThatMatchesTheSources() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location, + typeof(DiscoveryResultCacheTests).Assembly.Location }; var extensionSourceMap = new Dictionary> @@ -270,13 +269,13 @@ public void LoadTestsShouldCallIntoADiscovererThatMatchesTheSources() public void LoadTestsShouldCallIntoMultipleDiscoverersThatMatchesTheSources() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var dllsources = new List { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location, + typeof(DiscoveryResultCacheTests).Assembly.Location }; var jsonsources = new List @@ -351,13 +350,13 @@ public void LoadTestsShouldCallIntoMultipleDiscoverersThatMatchesTheSources() public void LoadTestsShouldCallIntoOtherDiscoverersWhenCreatingOneFails() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { "test1.csv", - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location }; var extensionSourceMap = new Dictionary> @@ -395,13 +394,13 @@ public void LoadTestsShouldCallIntoOtherDiscoverersWhenCreatingOneFails() public void LoadTestsShouldCallIntoOtherDiscoverersEvenIfDiscoveryInOneFails() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { "test1.cs", - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location }; var extensionSourceMap = new Dictionary> @@ -450,13 +449,13 @@ public void LoadTestsShouldCollectMetrics() }; TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location, + typeof(DiscoveryResultCacheTests).Assembly.Location }; var extensionSourceMap = new Dictionary> @@ -485,13 +484,13 @@ public void LoadTestsShouldCollectMetrics() public void LoadTestsShouldNotCallIntoDiscoverersWhenCancelled() { // Setup - string[] extensions = new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }; + string[] extensions = new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }; TestPluginCacheHelper.SetupMockExtensions(extensions, () => { }); var dllsources = new List { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location, + typeof(DiscoveryResultCacheTests).Assembly.Location }; var jsonsources = new List { @@ -573,13 +572,13 @@ public void LoadTestShouldInstrumentAdapterDiscoveryStop() public void LoadTestsShouldIterateOverAllExtensionsInTheMapAndDiscoverTests() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var dllsources = new List { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location, + typeof(DiscoveryResultCacheTests).Assembly.Location }; var jsonsources = new List { @@ -589,7 +588,7 @@ public void LoadTestsShouldIterateOverAllExtensionsInTheMapAndDiscoverTests() var extensionSourceMap = new Dictionary> { - { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location, jsonsources }, + { typeof(DiscovererEnumeratorTests).Assembly.Location, jsonsources }, { "_none_", dllsources } }; @@ -683,8 +682,8 @@ private static void SetupForNoTestsAvailableInGivenAssemblies( out Dictionary> extensionSourceMap, out string sourcesString) { - var crossPlatEngineAssemblyLocation = typeof(DiscovererEnumerator).GetTypeInfo().Assembly.Location; - var objectModelAseeAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + var crossPlatEngineAssemblyLocation = typeof(DiscovererEnumerator).Assembly.Location; + var objectModelAseeAssemblyLocation = typeof(TestCase).Assembly.Location; var sources = new string[] { crossPlatEngineAssemblyLocation, objectModelAseeAssemblyLocation }; extensionSourceMap = new Dictionary> @@ -697,12 +696,12 @@ private static void SetupForNoTestsAvailableInGivenAssemblies( private void InvokeLoadTestWithMockSetup() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryResultCacheTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryResultCacheTests).Assembly.Location }; var extensionSourceMap = new Dictionary> diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs index 92d9b539fe..dca3280bf7 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Discovery/DiscoveryManagerTests.cs @@ -5,7 +5,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; @@ -60,7 +59,7 @@ public void InitializeShouldUpdateAdditionalExtenions() TestPluginCache.Instance = new TestableTestPluginCache(); _discoveryManager.Initialize( - new string[] { typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location }, mockLogger.Object); + new string[] { typeof(DiscoveryManagerTests).Assembly.Location }, mockLogger.Object); var allDiscoverers = TestDiscoveryExtensionManager.Create().Discoverers; @@ -122,7 +121,7 @@ public void DiscoverTestsShouldLogIfTheSourceDoesNotExistIfItHasAPackage() var packageName = "recipe.AppxRecipe"; - var fakeDirectory = Directory.GetDirectoryRoot(typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location); + var fakeDirectory = Directory.GetDirectoryRoot(typeof(DiscoveryManagerTests).Assembly.Location); criteria.Package = Path.Combine(fakeDirectory, Path.Combine(packageName)); var mockLogger = new Mock(); @@ -161,13 +160,13 @@ public void DiscoverTestsShouldLogIfThereAreNoValidSources() public void DiscoverTestsShouldLogIfTheSameSourceIsSpecifiedTwice() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location, - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryManagerTests).Assembly.Location, + typeof(DiscoveryManagerTests).Assembly.Location }; var criteria = new DiscoveryCriteria(sources, 100, null); @@ -188,12 +187,12 @@ public void DiscoverTestsShouldLogIfTheSameSourceIsSpecifiedTwice() public void DiscoverTestsShouldDiscoverTestsInTheSpecifiedSource() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryManagerTests).Assembly.Location }; var criteria = new DiscoveryCriteria(sources, 1, null); @@ -216,12 +215,12 @@ public void DiscoverTestsShouldSendMetricsOnDiscoveryComplete() DiscoveryCompleteEventArgs? receivedDiscoveryCompleteEventArgs = null; TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryManagerTests).Assembly.Location }; var mockLogger = new Mock(); @@ -254,12 +253,12 @@ public void DiscoverTestsShouldCollectMetrics() _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollector.Object); TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(DiscovererEnumeratorTests).Assembly.Location }, () => { }); var sources = new List { - typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location + typeof(DiscoveryManagerTests).Assembly.Location }; var mockLogger = new Mock(); @@ -276,7 +275,7 @@ public void DiscoverTestsShouldCollectMetrics() [TestMethod] public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() { - var assemblyLocation = typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(DiscoveryManagerTests).Assembly.Location; var mockLogger = new Mock(); TestPluginCacheHelper.SetupMockExtensions( new string[] { assemblyLocation }, @@ -296,7 +295,7 @@ public void DiscoveryInitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() public void DiscoveryTestsShouldSendAbortValuesCorrectlyIfAbortionHappened() { // Arrange - var sources = new List { typeof(DiscoveryManagerTests).GetTypeInfo().Assembly.Location }; + var sources = new List { typeof(DiscoveryManagerTests).Assembly.Location }; var criteria = new DiscoveryCriteria(sources, 100, null); var mockHandler = new Mock(); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs index f1da1e0c02..6d0f6746d1 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/BaseRunTestsTests.cs @@ -7,7 +7,6 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; @@ -92,7 +91,7 @@ public BaseRunTestsTests() new PlatformThread(), _mockDataSerializer.Object); - TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location }, () => { }); + TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).Assembly.Location }, () => { }); } [TestCleanup] @@ -247,7 +246,7 @@ public void RunTestsShouldAbortIfExecutorUriExtensionMapIsNull() [TestMethod] public void RunTestsShouldInvokeTheTestExecutorIfAdapterAssemblyIsKnown() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -326,7 +325,7 @@ public void RunTestsShouldInstrumentAdapterExecutionStop() [TestMethod] public void RunTestsShouldReportAWarningIfExecutorUriIsNotDefinedInExtensionAssembly() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri("executor://nonexistent/"), assemblyLocation) @@ -362,7 +361,7 @@ public void RunTestsShouldReportAWarningIfExecutorUriIsNotDefinedInExtensionAsse [TestMethod] public void RunTestsShouldNotAddExecutorUriToExecutorUriListIfNoTestsAreRun() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -379,7 +378,7 @@ public void RunTestsShouldNotAddExecutorUriToExecutorUriListIfNoTestsAreRun() [TestMethod] public void RunTestsShouldAddExecutorUriToExecutorUriListIfExecutorHasRunTests() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -404,7 +403,7 @@ public void RunTestsShouldAddExecutorUriToExecutorUriListIfExecutorHasRunTests() [TestMethod] public void RunTestsShouldReportWarningIfExecutorThrowsAnException() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -435,7 +434,7 @@ public void RunTestsShouldReportWarningIfExecutorThrowsAnException() [TestMethod] public void RunTestsShouldNotFailOtherExecutorsRunIfOneExecutorThrowsAnException() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), @@ -468,7 +467,7 @@ public void RunTestsShouldNotFailOtherExecutorsRunIfOneExecutorThrowsAnException [TestMethod] public void RunTestsShouldIterateThroughAllExecutors() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), @@ -607,7 +606,7 @@ public void RunTestsShouldCloneTheTestResultsObjectsIfTestSourceIsPackage() public void RunTestsShouldNotifyItsImplementersOfAnyExceptionThrownByTheExecutors() { bool? isExceptionThrown = null; - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -627,7 +626,7 @@ public void RunTestsShouldNotifyItsImplementersOfAnyExceptionThrownByTheExecutor [TestMethod] public void RunTestsShouldReportLogMessagesFromExecutors() { - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -695,7 +694,7 @@ public void RunTestsShouldCollectMetrics() { { "DummyMessage", "DummyValue" } }; - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), @@ -810,8 +809,8 @@ private void SetupForExecutionThreadApartmentStateTests(PlatformApartmentState a _mockThread.Object, _mockDataSerializer.Object); - TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location }, () => { }); - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + TestPluginCacheHelper.SetupMockExtensions(new string[] { typeof(BaseRunTestsTests).Assembly.Location }, () => { }); + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BaseRunTestsExecutorUri), assemblyLocation) @@ -845,7 +844,7 @@ private void SetUpTestRunEvents(string? package = null, bool setupHandleTestRunC new PlatformThread(), _mockDataSerializer.Object); - var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(BaseRunTestsTests).Assembly.Location; var executorUriExtensionMap = new List> { new Tuple(new Uri(BadBaseRunTestsExecutorUri), assemblyLocation), diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs index 7dfec2e75a..c630d9c529 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/ExecutionManagerTests.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Reflection; using System.Xml; using Microsoft.TestPlatform.TestUtilities; @@ -76,7 +75,7 @@ public void TestCleanup() [TestMethod] public void InitializeShouldLoadAndInitializeAllExtensions() { - var commonAssemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + var commonAssemblyLocation = typeof(ExecutionManagerTests).Assembly.Location; var mockTestMessageEventHandler = new Mock(); TestPluginCacheHelper.SetupMockExtensions( new string[] { commonAssemblyLocation }, @@ -141,7 +140,7 @@ public void InitializeShouldNotFailIfMetricsFieldIsNull() [TestMethod] public void StartTestRunShouldRunTestsInTheProvidedSources() { - var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(ExecutionManagerTests).Assembly.Location; TestPluginCacheHelper.SetupMockExtensions( new string[] { assemblyLocation }, () => { }); @@ -185,7 +184,7 @@ public void StartTestRunShouldRunTestsInTheProvidedSources() [TestMethod] public void StartTestRunShouldRunTestsForTheProvidedTests() { - var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(ExecutionManagerTests).Assembly.Location; var tests = new List { @@ -251,7 +250,7 @@ public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedSource //[TestMethod] //public void InitializeShouldVerifyWarningMessageIfAdapterFailedToLoad() //{ - // var assemblyLocation = typeof(ExecutionManagerTests).GetTypeInfo().Assembly.Location; + // var assemblyLocation = typeof(ExecutionManagerTests).Assembly.Location; // var mockLogger = new Mock(); // TestPluginCacheHelper.SetupMockExtensions( // new string[] { assemblyLocation }, diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs index 4c1c64250f..d0b676eb03 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Execution/RunTestsWithSourcesTests.cs @@ -6,7 +6,6 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common; @@ -57,7 +56,7 @@ public RunTestsWithSourcesTests() _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(RunTestsWithSourcesTests).Assembly.Location }, () => { }); TestPluginCache.Instance.DiscoverTestExtensions(TestPlatformConstants.TestAdapterEndsWithPattern); @@ -128,7 +127,7 @@ public void GetExecutorUriExtensionMapShouldReturnEmptyOnInvalidSources() [TestMethod] public void GetExecutorUriExtensionMapShouldReturnDefaultExecutorUrisForTheDiscoverersDefined() { - var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(RunTestsWithSourcesTests).Assembly.Location; var adapterSourceMap = new Dictionary> { @@ -188,7 +187,7 @@ public void InvokeExecutorShouldInvokeTestExecutorWithTheSources() [TestMethod] public void RunTestsShouldRunTestsForTheSourcesSpecified() { - var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; + var assemblyLocation = typeof(RunTestsWithSourcesTests).Assembly.Location; var adapterSourceMap = new Dictionary> { @@ -312,9 +311,9 @@ public void SendSessionEndShouldCallSessionEnd() [MemberNotNull(nameof(_runTestsInstance))] private void SetupForNoTestsAvailable(string? testCaseFilter, out string sourcesString) { - var testAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; + var testAssemblyLocation = typeof(TestCase).Assembly.Location; - var adapterAssemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; + var adapterAssemblyLocation = typeof(RunTestsWithSourcesTests).Assembly.Location; var adapterSourceMap = new Dictionary>(); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs index 9ed67b2da8..c20ae3f1c6 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestEngineTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.TestPlatform.TestUtilities; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; @@ -32,7 +31,7 @@ public class TestEngineTests public TestEngineTests() { - TestPluginCacheHelper.SetupMockExtensions(new[] { typeof(TestEngineTests).GetTypeInfo().Assembly.Location }, () => { }); + TestPluginCacheHelper.SetupMockExtensions(new[] { typeof(TestEngineTests).Assembly.Location }, () => { }); _mockProcessHelper = new Mock(); _mockRequestData = new Mock(); _mockMetricsCollection = new Mock(); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs index 78503bb7f4..c4c8293cd2 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestExtensionManagerTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; @@ -33,7 +32,7 @@ public void TestCleanup() [TestMethod] public void UseAdditionalExtensionsShouldUpdateAdditionalExtensionsInCache() { - var extensions = new List { typeof(TestExtensionManagerTests).GetTypeInfo().Assembly.Location }; + var extensions = new List { typeof(TestExtensionManagerTests).Assembly.Location }; _testExtensionManager.UseAdditionalExtensions(extensions, true); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs index 0432df7c67..c263627a84 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/TestLoggerManagerTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Reflection; using System.Threading; using Microsoft.TestPlatform.TestUtilities; @@ -37,7 +36,7 @@ public class TestLoggerManagerTests public void Initialize() { TestPluginCacheHelper.SetupMockExtensions( - new string[] { typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location }, + new string[] { typeof(TestLoggerManagerTests).Assembly.Location }, () => { }); } @@ -277,8 +276,6 @@ public void AddLoggerShouldAddDefaultLoggerParameterForTestLoggerWithParameters( var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = @" @@ -667,7 +664,7 @@ public void InitializeShouldInitializeLoggerFromAssemblyNameWhenAssemblyNameAndC mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -722,7 +719,7 @@ public void InitializeShouldNotInitializeLoggersFromAssemblyNameWhenInterfaceDoe mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(InvalidLogger).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -774,7 +771,7 @@ public void InitializeShouldNotInitializeLoggersWhenCodeBaseInvalid() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(InvalidLogger).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -802,7 +799,7 @@ public void InitializeShouldInitializeLoggerOnceWhenMultipleLoggersWithSameAssem mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -833,7 +830,7 @@ public void InitializeShouldInitializeLoggerOnce() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -865,7 +862,7 @@ public void InitializeShouldNotConsiderLoggerAsInitializedWhenInitializationErro mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(LoggerWithInitializationError).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -891,7 +888,7 @@ public void InitializeShouldThrowWhenLoggerManagerAlreadyDisposed() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -917,7 +914,7 @@ public void InitializeShouldInitilaizeMultipleLoggersIfPresent() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -948,7 +945,7 @@ public void AreLoggersInitializedShouldReturnTrueWhenLoggersInitialized() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -976,21 +973,6 @@ public void AreLoggersInitializedShouldReturnFalseWhenLoggersNotInitialized() var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - - string settingsXml = - @" - - - - - - - - - "; - var testLoggerManager = new DummyTestLoggerManager(mockRequestData.Object); Assert.IsFalse(testLoggerManager.LoggersInitialized); @@ -1004,9 +986,6 @@ public void AreLoggersInitializedShouldReturnFalseWhenNoLoggersPresent() var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; - string settingsXml = @" @@ -1031,7 +1010,7 @@ public void InitializeShouldPassConfigurationElementAsParameters() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1071,7 +1050,7 @@ public void InitializeShouldSkipEmptyConfigurationValueInParameters() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1111,7 +1090,7 @@ public void InitializeShouldUseLastValueInParametersForDuplicateConfigurationVal mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1152,7 +1131,7 @@ public void InitializeShouldNotInitializeDisabledLoggers() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1183,7 +1162,7 @@ public void InitializeShouldInitializeFromAssemblyNameIfAllAttributesPresent() mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); var assemblyQualifiedName = typeof(ValidLoggerWithParameters).AssemblyQualifiedName; - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1221,7 +1200,7 @@ public void InitializeShouldInitializeFromUriIfUriAndNamePresent() var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1259,7 +1238,7 @@ public void InitializeShouldInitializeFromUriIfUnableToFromAssemblyName() var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1297,7 +1276,7 @@ public void InitializeShouldInitializeFromNameIfUnableToFromUri() var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1335,7 +1314,7 @@ public void InitializeShouldInitializeLoggersWithTestRunDirectoryIfPresentInRunS var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1380,7 +1359,7 @@ public void InitializeShouldInitializeLoggersWithDefaultTestRunDirectoryIfNotPre var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" @@ -1424,7 +1403,7 @@ public void InitializeShouldNotInitializeIfUnableToFromName() var mockMetricsCollection = new Mock(); mockRequestData.Setup(rd => rd.MetricsCollection).Returns(mockMetricsCollection.Object); - var codeBase = typeof(TestLoggerManagerTests).GetTypeInfo().Assembly.Location; + var codeBase = typeof(TestLoggerManagerTests).Assembly.Location; string settingsXml = @" diff --git a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs index cfe1ca37f5..c38169246a 100644 --- a/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs +++ b/test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DefaultTestHostManagerTests.cs @@ -7,7 +7,6 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using System.Threading.Tasks; @@ -435,7 +434,7 @@ public void LaunchTestHostShouldSetExitCallbackInCaseCustomHost() [TestCategory("Windows")] public void GetTestSourcesShouldReturnAppropriateSourceIfAppxRecipeIsProvided() { - var sourcePath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).GetTypeInfo().Assembly.GetAssemblyLocation())!, @"..\..\..\..\..\test\TestAssets\UWPTestAssets\UnitTestApp8.build.appxrecipe"); + var sourcePath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).Assembly.GetAssemblyLocation())!, @"..\..\..\..\..\test\TestAssets\UWPTestAssets\UnitTestApp8.build.appxrecipe"); IEnumerable sources = _testHostManager.GetTestSources(new List { sourcePath }); Assert.IsTrue(sources.Any()); Assert.IsTrue(sources.First().EndsWith(".exe", StringComparison.OrdinalIgnoreCase)); @@ -445,7 +444,7 @@ public void GetTestSourcesShouldReturnAppropriateSourceIfAppxRecipeIsProvided() [TestCategory("Windows")] public void AppxManifestFileShouldReturnAppropriateSourceIfAppxManifestIsProvided() { - var appxManifestPath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).GetTypeInfo().Assembly.GetAssemblyLocation())!, @"..\..\..\..\..\test\TestAssets\UWPTestAssets\AppxManifest.xml"); + var appxManifestPath = Path.Combine(Path.GetDirectoryName(typeof(TestableTestHostManager).Assembly.GetAssemblyLocation())!, @"..\..\..\..\..\test\TestAssets\UWPTestAssets\AppxManifest.xml"); string? source = AppxManifestFile.GetApplicationExecutableName(appxManifestPath); Assert.AreEqual("UnitTestApp8.exe", source); } diff --git a/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs b/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs index 8ab04fccf5..a36eee6046 100644 --- a/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs +++ b/test/Microsoft.TestPlatform.TestUtilities/TestPluginCacheHelper.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.SettingsProvider; @@ -18,7 +17,7 @@ public static class TestPluginCacheHelper public static TestableTestPluginCache SetupMockAdditionalPathExtensions(Type callingTest) { return SetupMockAdditionalPathExtensions( - new string[] { callingTest.GetTypeInfo().Assembly.Location }); + new string[] { callingTest.Assembly.Location }); } public static TestableTestPluginCache SetupMockAdditionalPathExtensions(string[] extensions) @@ -43,7 +42,7 @@ public static void SetupMockExtensions(Type callingTest, Mock? mock public static void SetupMockExtensions(Type callingTest, Action callback, Mock? mockFileHelper = null) { - SetupMockExtensions(new[] { callingTest.GetTypeInfo().Assembly.Location }, callback, mockFileHelper); + SetupMockExtensions(new[] { callingTest.Assembly.Location }, callback, mockFileHelper); } public static void SetupMockExtensions(string[] extensions, Action callback, Mock? mockFileHelper = null) diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs index ecb2407bcf..50849cada2 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/ClientUtilitiesTests.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using System.Reflection; using System.Xml; using Microsoft.VisualStudio.TestPlatform.Utilities; @@ -36,7 +35,7 @@ public void FixRelativePathsInRunSettingsShouldNotModifyAnEmptyRunSettings() var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -57,7 +56,7 @@ public void FixRelativePathsInRunSettingsShouldModifyRelativeTestSettingsFilePat var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -84,7 +83,7 @@ public void FixRelativePathsInRunSettingsShouldNotModifyAbsoluteTestSettingsFile var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -105,7 +104,7 @@ public void FixRelativePathsInRunSettingsShouldNotModifyEmptyTestSettingsFilePat var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -126,7 +125,7 @@ public void FixRelativePathsInRunSettingsShouldModifyRelativeResultsDirectory() var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -153,7 +152,7 @@ public void FixRelativePathsInRunSettingsShouldNotModifyAbsoluteResultsDirectory var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -174,7 +173,7 @@ public void FixRelativePathsInRunSettingsShouldNotModifyEmptyResultsDirectory() var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); @@ -200,7 +199,7 @@ public void FixRelativePathsInRunSettingsShouldExpandEnvironmentVariable() var doc = new XmlDocument(); doc.LoadXml(runSettingsXml); - var currentAssemblyLocation = typeof(ClientUtilitiesTests).GetTypeInfo().Assembly.Location; + var currentAssemblyLocation = typeof(ClientUtilitiesTests).Assembly.Location; ClientUtilities.FixRelativePathsInRunSettings(doc, currentAssemblyLocation); diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs index 639ac46d43..e6023e99b7 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageRunSettingsProcessorTests.cs @@ -227,7 +227,7 @@ public void MixedTestShouldCorrectlyAddMissingTags() private static XmlElement GetDefaultConfiguration() { var document = new XmlDocument(); - Assembly assembly = typeof(CodeCoverageRunSettingsProcessorTests).GetTypeInfo().Assembly; + Assembly assembly = typeof(CodeCoverageRunSettingsProcessorTests).Assembly; using (Stream stream = assembly.GetManifestResourceStream("Microsoft.TestPlatform.Utilities.UnitTests.DefaultCodeCoverageConfig.xml")!) { document.Load(stream); diff --git a/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs b/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs index f2018a4089..27b26d83c5 100644 --- a/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs +++ b/test/datacollector.PlatformTests/CommunicationLayerIntegrationTests.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection; @@ -38,7 +37,7 @@ public CommunicationLayerIntegrationTests() _mockRequestData = new Mock(); _mockMetricsCollection = new Mock(); _mockRequestData.Setup(rd => rd.MetricsCollection).Returns(_mockMetricsCollection.Object); - _dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, "", typeof(CustomDataCollector).AssemblyQualifiedName, typeof(CustomDataCollector).GetTypeInfo().Assembly.Location); + _dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, "", typeof(CustomDataCollector).AssemblyQualifiedName, typeof(CustomDataCollector).Assembly.Location); _runSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, _dataCollectorSettings); _testSources = new List() { "testsource1.dll" }; _processHelper = new ProcessHelper(); diff --git a/test/datacollector.UnitTests/DataCollectionManagerTests.cs b/test/datacollector.UnitTests/DataCollectionManagerTests.cs index 8b18acb215..9db1412dce 100644 --- a/test/datacollector.UnitTests/DataCollectionManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionManagerTests.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Xml; @@ -47,7 +46,7 @@ public DataCollectionManagerTests() _mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(_envVarList); _mockCodeCoverageDataCollector = new Mock(); _mockCodeCoverageDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Returns(_codeCoverageEnvVarList); - _dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + _dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); _mockMessageSink = new Mock(); _mockDataCollectionAttachmentManager = new Mock(); _mockDataCollectionAttachmentManager.SetReturnsDefault(new List()); @@ -74,7 +73,7 @@ public void InitializeDataCollectorsShouldReturnEmptyDictionaryIfDataCollectorsA [TestMethod] public void InitializeDataCollectorsShouldLoadDataCollector() { - var dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + var dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettings); Assert.IsTrue(_dataCollectionManager.RunDataCollectors.ContainsKey(_mockDataCollector.Object.GetType())); @@ -86,7 +85,7 @@ public void InitializeDataCollectorsShouldLoadDataCollector() [TestMethod] public void InitializeShouldNotAddDataCollectorIfItIsDisabled() { - var dataCollectorSettingsDisabled = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled=\"false\"")); + var dataCollectorSettingsDisabled = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, "enabled=\"false\"")); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsDisabled); Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); @@ -96,7 +95,7 @@ public void InitializeShouldNotAddDataCollectorIfItIsDisabled() [TestMethod] public void InitializeShouldAddDataCollectorIfItIsEnabled() { - var dataCollectorSettingsEnabled = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled=\"true\"")); + var dataCollectorSettingsEnabled = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, "enabled=\"true\"")); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsEnabled); Assert.IsTrue(_dataCollectionManager.RunDataCollectors.ContainsKey(_mockDataCollector.Object.GetType())); @@ -106,7 +105,7 @@ public void InitializeShouldAddDataCollectorIfItIsEnabled() [TestMethod] public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNotCorrectAndUriIsCorrect() { - var dataCollectorSettingsWithWrongFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "anyFriendlyName", _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + var dataCollectorSettingsWithWrongFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "anyFriendlyName", _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongFriendlyName); Assert.AreEqual(1, _dataCollectionManager.RunDataCollectors.Count); @@ -116,7 +115,7 @@ public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNotCo [TestMethod] public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsNotCorrect() { - var dataCollectorSettingsWithWrongUri = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, "my://custom/WrongDatacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + var dataCollectorSettingsWithWrongUri = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, "my://custom/WrongDatacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongUri); Assert.AreEqual(1, _dataCollectionManager.RunDataCollectors.Count); @@ -126,7 +125,7 @@ public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorre [TestMethod] public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNullAndUriIsCorrect() { - var dataCollectorSettingsWithNullFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, string.Empty, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); + var dataCollectorSettingsWithNullFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, string.Empty, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullFriendlyName); Assert.AreEqual(1, _dataCollectionManager.RunDataCollectors.Count); @@ -136,21 +135,21 @@ public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsNullA [TestMethod] public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsCorrectAndUriIsEmpty() { - var dataCollectorSettingsWithEmptyUri = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + var dataCollectorSettingsWithEmptyUri = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); Assert.ThrowsException(() => _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithEmptyUri)); } [TestMethod] public void InitializeDataCollectorsShouldLoadDataCollectorIfFriendlyNameIsEmptyAndUriIsCorrect() { - var dataCollectorSettingsWithEmptyFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + var dataCollectorSettingsWithEmptyFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, string.Empty, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); Assert.ThrowsException(() => _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithEmptyFriendlyName)); } [TestMethod] public void InitializeDataCollectorsShouldNotLoadDataCollectorIfFriendlyNameIsNotCorrectAndUriIsNotCorrect() { - var dataCollectorSettingsWithWrongFriendlyNameAndWrongUri = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "anyFriendlyName", "datacollector://data", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + var dataCollectorSettingsWithWrongFriendlyNameAndWrongUri = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "anyFriendlyName", "datacollector://data", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithWrongFriendlyNameAndWrongUri); Assert.AreEqual(0, _dataCollectionManager.RunDataCollectors.Count); @@ -160,7 +159,7 @@ public void InitializeDataCollectorsShouldNotLoadDataCollectorIfFriendlyNameIsNo [TestMethod] public void InitializeDataCollectorsShouldNotAddSameDataCollectorMoreThanOnce() { - var datacollecterSettings = string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "CustomDataCollector", "my://custom/datacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, "enabled =\"true\""); + var datacollecterSettings = string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "CustomDataCollector", "my://custom/datacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, "enabled =\"true\""); var runSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, datacollecterSettings + datacollecterSettings); _dataCollectionManager.InitializeDataCollectors(runSettings); @@ -234,8 +233,8 @@ public void InitializeDataCollectorsShouldReturnOtherThanCodeCoverageEnvironment _codeCoverageEnvVarList.Add(new KeyValuePair("same_key", "same_value")); _dataCollectorSettings = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, - string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "Code Coverage", "my://custom/ccdatacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty) + - string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty)); + string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, "Code Coverage", "my://custom/ccdatacollector", _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty) + + string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, _friendlyName, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty)); var result = _dataCollectionManager.InitializeDataCollectors(_dataCollectorSettings); @@ -341,7 +340,7 @@ public void SessionEndedShouldReturnEmptyCollectionIfDataCollectionIsNotEnabled( [TestMethod] public void GetInvokedDataCollectorsShouldReturnDataCollector() { - var dataCollectorSettingsWithNullFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, string.Empty, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).GetTypeInfo().Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); + var dataCollectorSettingsWithNullFriendlyName = string.Format(CultureInfo.InvariantCulture, _defaultRunSettings, string.Format(CultureInfo.InvariantCulture, _defaultDataCollectionSettings, string.Empty, _uri, _mockDataCollector.Object.GetType().AssemblyQualifiedName, typeof(DataCollectionManagerTests).Assembly.Location, string.Empty).Replace("friendlyName=\"\"", string.Empty)); _dataCollectionManager.InitializeDataCollectors(dataCollectorSettingsWithNullFriendlyName); var invokedDataCollector = _dataCollectionManager.GetInvokedDataCollectors(); Assert.AreEqual(1, invokedDataCollector.Count); diff --git a/test/vstest.console.UnitTests/ExecutorUnitTests.cs b/test/vstest.console.UnitTests/ExecutorUnitTests.cs index 3005e86e2f..d26c3934c2 100644 --- a/test/vstest.console.UnitTests/ExecutorUnitTests.cs +++ b/test/vstest.console.UnitTests/ExecutorUnitTests.cs @@ -41,7 +41,7 @@ public void ExecutorPrintsSplashScreenTest() { var mockOutput = new MockOutput(); var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object, new ProcessHelper(), new PlatformEnvironment()).Execute("/badArgument"); - var assemblyVersion = typeof(Executor).GetTypeInfo().Assembly.GetCustomAttribute()!.InformationalVersion; + var assemblyVersion = typeof(Executor).Assembly.GetCustomAttribute()!.InformationalVersion; Assert.AreEqual(1, exitCode, "Exit code must be One for bad arguments"); @@ -331,7 +331,7 @@ public void ExecutorShouldPrintWarningIfRunningEmulatedOnARM64() environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.ARM64); var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(); - var assemblyVersion = typeof(Executor).GetTypeInfo().Assembly.GetCustomAttribute()!.InformationalVersion; + var assemblyVersion = typeof(Executor).Assembly.GetCustomAttribute()!.InformationalVersion; Assert.AreEqual(5, mockOutput.Messages.Count); Assert.AreEqual("vstest.console.exe is running in emulated mode as x64. For better performance, please consider using the native runner vstest.console.arm64.exe.", @@ -351,7 +351,7 @@ public void ExecutorShouldPrintRunnerArchitecture() environment.Setup(x => x.Architecture).Returns(PlatformArchitecture.X64); var exitCode = new Executor(mockOutput, _mockTestPlatformEventSource.Object, processHelper.Object, environment.Object).Execute(); - var assemblyVersion = typeof(Executor).GetTypeInfo().Assembly.GetCustomAttribute()!.InformationalVersion; + var assemblyVersion = typeof(Executor).Assembly.GetCustomAttribute()!.InformationalVersion; Assert.AreEqual(4, mockOutput.Messages.Count); Assert.IsTrue(Regex.IsMatch(mockOutput.Messages[0].Message!, @"Microsoft \(R\) Test Execution Command Line Tool Version .* \(x64\)")); diff --git a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs index 5168369a40..2ed759112b 100644 --- a/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/RunTestsArgumentProcessorTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Runtime.Versioning; using System.Threading.Tasks; @@ -288,7 +287,7 @@ public static void SetupMockExtensions() mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny())).Returns(true); mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny(), SearchOption.TopDirectoryOnly, new[] { ".dll" })) .Callback(() => { }) - .Returns(new string[] { typeof(RunTestsArgumentProcessorTests).GetTypeInfo().Assembly.Location, typeof(ConsoleLogger).GetTypeInfo().Assembly.Location }); + .Returns(new string[] { typeof(RunTestsArgumentProcessorTests).Assembly.Location, typeof(ConsoleLogger).Assembly.Location }); var testableTestPluginCache = new TestableTestPluginCache(); diff --git a/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs index c6fff696bd..8dd96a60ad 100644 --- a/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/TestAdapterPathArgumentProcessorTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; using Microsoft.VisualStudio.TestPlatform.Common; @@ -134,7 +133,7 @@ public void InitializeShouldUpdateTestAdapterPathInRunSettings() var mockOutput = new Mock(); var executor = new TestAdapterPathArgumentExecutor(CommandLineOptions.Instance, RunSettingsManager.Instance, mockOutput.Object, new FileHelper()); - var currentAssemblyPath = typeof(TestAdapterPathArgumentExecutor).GetTypeInfo().Assembly.Location; + var currentAssemblyPath = typeof(TestAdapterPathArgumentExecutor).Assembly.Location; var currentFolder = Path.GetDirectoryName(currentAssemblyPath); executor.Initialize(currentFolder); diff --git a/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs b/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs index 2aca16f37f..4859fe631a 100644 --- a/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs +++ b/test/vstest.console.UnitTests/Processors/Utilities/ArgumentProcessorFactoryTests.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors; using Microsoft.VisualStudio.TestPlatform.Utilities; @@ -162,9 +161,9 @@ public void BuildCommandMapsForMultipleProcessorAddsProcessorToAppropriateMaps() private static IEnumerable GetArgumentProcessors(bool specialCommandFilter) { - var allProcessors = typeof(ArgumentProcessorFactory).GetTypeInfo() + var allProcessors = typeof(ArgumentProcessorFactory) .Assembly.GetTypes() - .Where(t => !t.GetTypeInfo().IsAbstract && !t.Name.Equals("IArgumentProcessor") && typeof(IArgumentProcessor).IsAssignableFrom(t)); + .Where(t => !t.IsAbstract && !t.Name.Equals("IArgumentProcessor") && typeof(IArgumentProcessor).IsAssignableFrom(t)); foreach (var processor in allProcessors) {