Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ public void ProjectChangedEvent()
[Fact]
public void ProjectCollectionVersionIsCorrect()
{
Version expectedVersion = new Version(this.GetType().GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version);
Version expectedVersion = new Version(this.GetType().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version);

ProjectCollection.Version.Major.ShouldBe(expectedVersion.Major);
ProjectCollection.Version.Minor.ShouldBe(expectedVersion.Minor);
Expand Down
10 changes: 2 additions & 8 deletions src/Build.UnitTests/BackEnd/AssemblyTaskFactory_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void CreatableByTaskFactoryMismatchedIdentity()
public void VerifyGetTaskParameters()
{
TaskPropertyInfo[] propertyInfos = _taskFactory.GetTaskParameters();
LoadedType comparisonType = new LoadedType(typeof(TaskToTestFactories), _loadInfo, typeof(TaskToTestFactories).GetTypeInfo().Assembly, typeof(ITaskItem));
LoadedType comparisonType = new LoadedType(typeof(TaskToTestFactories), _loadInfo, typeof(TaskToTestFactories).Assembly, typeof(ITaskItem));
PropertyInfo[] comparisonInfo = comparisonType.Type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
Assert.Equal(comparisonInfo.Length, propertyInfos.Length);

Expand Down Expand Up @@ -784,13 +784,7 @@ public void VerifySameFactoryCanGenerateDifferentTaskInstances()
private void SetupTaskFactory(TaskHostParameters factoryParameters, bool explicitlyLaunchTaskHost = false, bool isTaskHostFactory = false)
{
_taskFactory = new AssemblyTaskFactory();
#if FEATURE_ASSEMBLY_LOCATION
_loadInfo = AssemblyLoadInfo.Create(null, Assembly.GetAssembly(typeof(TaskToTestFactories)).Location);
#else
_loadInfo = explicitlyLaunchTaskHost || isTaskHostFactory
? AssemblyLoadInfo.Create(assemblyName: null, typeof(TaskToTestFactories).GetTypeInfo().Assembly.Location)
: AssemblyLoadInfo.Create(typeof(TaskToTestFactories).GetTypeInfo().Assembly.FullName, assemblyFile: null);
#endif
_loadInfo = AssemblyLoadInfo.Create(null, typeof(TaskToTestFactories).Assembly.Location);
if (explicitlyLaunchTaskHost)
{
factoryParameters = factoryParameters.WithTaskHostFactoryExplicitlyRequested(true);
Expand Down
63 changes: 12 additions & 51 deletions src/Build.UnitTests/BackEnd/LoggingService_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,7 @@ public void RegisterDistributedLoggerServiceShutdown()
{
_initializedService.ShutdownComponent();
string className = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription description = CreateLoggerDescription(className, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).Assembly.FullName, true);
_initializedService.RegisterDistributedLogger(null, description);
});
}
Expand All @@ -347,13 +343,8 @@ public void RegisterGoodDistributedAndCentralLogger()
{
string configurableClassName = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
string distributedClassName = "Microsoft.Build.Logging.DistributedFileLogger";
#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription configurableDescription = CreateLoggerDescription(configurableClassName, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
LoggerDescription distributedDescription = CreateLoggerDescription(distributedClassName, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription configurableDescription = CreateLoggerDescription(configurableClassName, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
LoggerDescription distributedDescription = CreateLoggerDescription(distributedClassName, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription configurableDescription = CreateLoggerDescription(configurableClassName, typeof(ProjectCollection).Assembly.FullName, true);
LoggerDescription distributedDescription = CreateLoggerDescription(distributedClassName, typeof(ProjectCollection).Assembly.FullName, true);

DistributedFileLogger fileLogger = new DistributedFileLogger();
RegularILogger regularILogger = new RegularILogger();
Expand Down Expand Up @@ -384,13 +375,8 @@ public void RegisterGoodDistributedAndCentralLoggerTestBuildStartedFinished()
string configurableClassNameA = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
string configurableClassNameB = "Microsoft.Build.Logging.ConfigurableForwardingLogger";

#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription configurableDescriptionA = CreateLoggerDescription(configurableClassNameA, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
LoggerDescription configurableDescriptionB = CreateLoggerDescription(configurableClassNameB, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription configurableDescriptionA = CreateLoggerDescription(configurableClassNameA, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
LoggerDescription configurableDescriptionB = CreateLoggerDescription(configurableClassNameB, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription configurableDescriptionA = CreateLoggerDescription(configurableClassNameA, typeof(ProjectCollection).Assembly.FullName, true);
LoggerDescription configurableDescriptionB = CreateLoggerDescription(configurableClassNameB, typeof(ProjectCollection).Assembly.FullName, true);

RegularILogger regularILoggerA = new RegularILogger();
RegularILogger regularILoggerB = new RegularILogger();
Expand Down Expand Up @@ -430,11 +416,7 @@ public void RegisterGoodDistributedAndCentralLoggerTestBuildStartedFinished()
public void RegisterDuplicateCentralLogger()
{
string className = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription description = CreateLoggerDescription(className, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).Assembly.FullName, true);

RegularILogger regularILogger = new RegularILogger();
Assert.True(_initializedService.RegisterDistributedLogger(regularILogger, description));
Expand All @@ -458,11 +440,7 @@ public void RegisterDuplicateCentralLogger()
public void RegisterDuplicateForwardingLoggerLogger()
{
string className = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription description = CreateLoggerDescription(className, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).Assembly.FullName, true);

RegularILogger regularILogger = new RegularILogger();
Assert.True(_initializedService.RegisterDistributedLogger(regularILogger, description));
Expand Down Expand Up @@ -523,11 +501,7 @@ public void NullForwardingLoggerSink()
Assert.Throws<InternalErrorException>(() =>
{
string className = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription description = CreateLoggerDescription(className, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).Assembly.FullName, true);
_initializedService.ShutdownComponent();
List<LoggerDescription> tempList = new List<LoggerDescription>();
tempList.Add(description);
Expand All @@ -545,13 +519,8 @@ public void RegisterGoodDiscriptions()
EventSourceSink sink = new EventSourceSink();
EventSourceSink sink2 = new EventSourceSink();
List<LoggerDescription> loggerDescriptions = new List<LoggerDescription>();
#if FEATURE_ASSEMBLY_LOCATION
loggerDescriptions.Add(CreateLoggerDescription(configurableClassName, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true));
loggerDescriptions.Add(CreateLoggerDescription(distributedClassName, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true));
#else
loggerDescriptions.Add(CreateLoggerDescription(configurableClassName, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true));
loggerDescriptions.Add(CreateLoggerDescription(distributedClassName, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true));
#endif
loggerDescriptions.Add(CreateLoggerDescription(configurableClassName, typeof(ProjectCollection).Assembly.FullName, true));
loggerDescriptions.Add(CreateLoggerDescription(distributedClassName, typeof(ProjectCollection).Assembly.FullName, true));

// Register some descriptions with a sink
_initializedService.InitializeNodeLoggers(loggerDescriptions, sink, 1);
Expand Down Expand Up @@ -608,11 +577,7 @@ public void RegisterGoodDiscriptions()
public void RegisterDuplicateDistributedCentralLogger()
{
string className = "Microsoft.Build.Logging.ConfigurableForwardingLogger";
#if FEATURE_ASSEMBLY_LOCATION
LoggerDescription description = CreateLoggerDescription(className, Assembly.GetAssembly(typeof(ProjectCollection)).FullName, true);
#else
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).GetTypeInfo().Assembly.FullName, true);
#endif
LoggerDescription description = CreateLoggerDescription(className, typeof(ProjectCollection).Assembly.FullName, true);

RegularILogger regularILogger = new RegularILogger();
Assert.True(_initializedService.RegisterDistributedLogger(regularILogger, description));
Expand Down Expand Up @@ -1105,11 +1070,7 @@ private void VerifyShutdownExceptions(ILogger logger, string className, Type exp
InitializeLoggingService();
if (className != null)
{
#if FEATURE_ASSEMBLY_LOCATION
Assembly thisAssembly = Assembly.GetAssembly(typeof(LoggingService_Tests));
#else
Assembly thisAssembly = typeof(LoggingService_Tests).GetTypeInfo().Assembly;
#endif
Assembly thisAssembly = typeof(LoggingService_Tests).Assembly;
string loggerAssemblyName = thisAssembly.FullName;
LoggerDescription centralLoggerDescrption = CreateLoggerDescription(className, loggerAssemblyName, true);
_initializedService.RegisterDistributedLogger(null, centralLoggerDescrption);
Expand Down
4 changes: 2 additions & 2 deletions src/Build.UnitTests/BackEnd/SdkResolverLoader_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void VerifyThrowsWhenResolverFailsToLoad()
{
SdkResolverLoader sdkResolverLoader = new MockSdkResolverLoader
{
LoadResolverAssemblyFunc = (resolverPath) => typeof(SdkResolverLoader_Tests).GetTypeInfo().Assembly,
LoadResolverAssemblyFunc = (resolverPath) => typeof(SdkResolverLoader_Tests).Assembly,
FindPotentialSdkResolversFunc = (rootFolder, loc) => new List<string>
{
"myresolver.dll"
Expand Down Expand Up @@ -158,7 +158,7 @@ public void VerifyThrowsWhenResolverHasNoPublicConstructor()
{
SdkResolverLoader sdkResolverLoader = new MockSdkResolverLoader
{
LoadResolverAssemblyFunc = (resolverPath) => typeof(SdkResolverLoader_Tests).GetTypeInfo().Assembly,
LoadResolverAssemblyFunc = (resolverPath) => typeof(SdkResolverLoader_Tests).Assembly,
FindPotentialSdkResolversFunc = (rootFolder, loc) => new List<string>
{
"myresolver.dll"
Expand Down
6 changes: 3 additions & 3 deletions src/Build.UnitTests/BackEnd/TaskExecutionHost_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ public bool BuildProjectFile(string projectFileName, string[] targetNames, IDict
/// </summary>
private static bool IsTaskFactoryClass(Type type, object unused)
{
return type.GetTypeInfo().IsClass &&
!type.GetTypeInfo().IsAbstract &&
return type.IsClass &&
!type.IsAbstract &&
(type.GetInterface("Microsoft.Build.Framework.ITaskFactory") != null);
}

Expand All @@ -1253,7 +1253,7 @@ private void InitializeHost(bool throwOnExecute)
#if !FEATURE_ASSEMBLYLOADCONTEXT
AssemblyLoadInfo loadInfo = AssemblyLoadInfo.Create(Assembly.GetAssembly(typeof(TaskBuilderTestTask.TaskBuilderTestTaskFactory)).FullName, null);
#else
AssemblyLoadInfo loadInfo = AssemblyLoadInfo.Create(typeof(TaskBuilderTestTask.TaskBuilderTestTaskFactory).GetTypeInfo().FullName, null);
AssemblyLoadInfo loadInfo = AssemblyLoadInfo.Create(typeof(TaskBuilderTestTask.TaskBuilderTestTaskFactory).FullName, null);
#endif
LoadedType loadedType = new LoadedType(typeof(TaskBuilderTestTask.TaskBuilderTestTaskFactory), loadInfo, typeof(TaskBuilderTestTask.TaskBuilderTestTaskFactory).Assembly, typeof(ITaskItem));

Expand Down
24 changes: 2 additions & 22 deletions src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class TaskRegistry_Tests
/// </summary>
public TaskRegistry_Tests(ITestOutputHelper output)
{
_testTaskLocation = typeof(TaskRegistry_Tests).GetTypeInfo().Assembly.ManifestModule.FullyQualifiedName;
_testTaskLocation = typeof(TaskRegistry_Tests).Assembly.ManifestModule.FullyQualifiedName;

_loggingService = LoggingService.CreateLoggingService(LoggerMode.Synchronous, 1);
_targetLoggingContext = new TargetLoggingContext(_loggingService, _loggerContext);
Expand Down Expand Up @@ -1128,7 +1128,7 @@ public void TaskFactoryWithNullTaskTypeLogsError()
List<ProjectUsingTaskElement> elementList = new List<ProjectUsingTaskElement>();
ProjectRootElement project = ProjectRootElement.Create();

ProjectUsingTaskElement element = project.AddUsingTask("Task1", AssemblyUtilities.GetAssemblyLocation(typeof(TaskRegistry_Tests.NullTaskTypeTaskFactory).GetTypeInfo().Assembly), null);
ProjectUsingTaskElement element = project.AddUsingTask("Task1", typeof(TaskRegistry_Tests.NullTaskTypeTaskFactory).Assembly.Location, null);

element.TaskFactory = typeof(NullTaskTypeTaskFactory).FullName;
elementList.Add(element);
Expand Down Expand Up @@ -1352,11 +1352,7 @@ public void BadScalarInputOnInputParameterDerivedFromITask()
// Note output is false so these are only input parameters
string output = bool.FalseString;
string required = bool.TrueString;
#if FEATURE_ASSEMBLY_LOCATION
string type = type = typeof(DerivedFromITaskItem).FullName + "," + typeof(DerivedFromITaskItem).Assembly.FullName;
#else
string type = type = typeof(DerivedFromITaskItem).FullName + "," + typeof(DerivedFromITaskItem).GetTypeInfo().Assembly.FullName;
#endif

List<ProjectUsingTaskElement> elementList = CreateParameterElementWithAttributes(output, required, type);
TaskRegistry registry = CreateTaskRegistryAndRegisterTasks(elementList);
Expand Down Expand Up @@ -1407,11 +1403,7 @@ public void GoodOutPutParameters()
type = typeof(ITaskItem).FullName;
VerifyTypeParameter(output, required, type);

#if FEATURE_ASSEMBLY_LOCATION
type = typeof(DerivedFromITaskItem).FullName + "," + typeof(DerivedFromITaskItem).Assembly.FullName;
#else
type = typeof(DerivedFromITaskItem).FullName + "," + typeof(DerivedFromITaskItem).GetTypeInfo().Assembly.FullName;
#endif
VerifyTypeParameter(output, required, type);

type = typeof(ITaskItem[]).FullName;
Expand All @@ -1426,11 +1418,7 @@ public void GoodOutPutParameters()
type = typeof(DateTime[]).FullName;
VerifyTypeParameter(output, required, type);

#if FEATURE_ASSEMBLY_LOCATION
type = typeof(DerivedFromITaskItem[]).FullName + "," + typeof(DerivedFromITaskItem).Assembly.FullName;
#else
type = typeof(DerivedFromITaskItem[]).FullName + "," + typeof(DerivedFromITaskItem).GetTypeInfo().Assembly.FullName;
#endif
VerifyTypeParameter(output, required, type);
}

Expand Down Expand Up @@ -1597,11 +1585,7 @@ public void ExpandedGoodParameters()
Assert.Equal(
parameterInfo.PropertyType,
Type.GetType(
#if FEATURE_ASSEMBLY_LOCATION
expandedType + "," + typeof(ITaskItem).Assembly.FullName,
#else
expandedType + "," + typeof(ITaskItem).GetTypeInfo().Assembly.FullName,
#endif
false /* don't throw on error */,
true /* case-insensitive */));
}
Expand Down Expand Up @@ -1981,11 +1965,7 @@ private void VerifyTypeParameter(string output, string required, string type)
if (paramType == null)
{
paramType = Type.GetType(
#if FEATURE_ASSEMBLY_LOCATION
type + "," + typeof(ITaskItem).Assembly.FullName,
#else
type + "," + typeof(ITaskItem).GetTypeInfo().Assembly.FullName,
#endif
false /* don't throw on error */,
true /* case-insensitive */);
}
Expand Down
Loading