Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
308 changes: 255 additions & 53 deletions 308 src/msbuild/documentation/specs/event-source.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ private void AssertProjectFileAfterReload(

if (initialProjectFromMemory && reloadProjectFromMemory)
{
Assert.Equal(NativeMethodsShared.GetCurrentDirectory(), rootElement.DirectoryPath);
Assert.Equal(Environment.CurrentDirectory, rootElement.DirectoryPath);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,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
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,9 @@ 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
if (explicitlyLaunchTaskHost)
{
factoryParameters = factoryParameters.WithTaskHostFactoryExplicitlyRequested(true);
Expand Down
83 changes: 83 additions & 0 deletions 83 src/msbuild/src/Build.UnitTests/BackEnd/BuildManager_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3858,6 +3858,89 @@ public void OutOfProcFileBasedP2PBuildSucceeds()
}
}

/// <summary>
/// Pins the interaction between a target's <c>Returns</c> attribute and <c>AfterTargets</c>:
/// a target's returned item set is captured when that target itself completes, before its
/// after-targets run. Items that an after-target adds to the same ItemGroup are therefore not
/// observed in the predecessor target's returned outputs (the same set the MSBuild task's
/// TargetOutputs would observe for that target).
/// </summary>
[Fact]
public void ReturnsCapturedBeforeAfterTargetsRun()
{
string contents = CleanupFileContents("""
<Project>
<Target Name="A" Returns="@(MyItem)">
<ItemGroup>
<MyItem Include="FromA" />
</ItemGroup>
</Target>
<Target Name="B" AfterTargets="A">
<ItemGroup>
<MyItem Include="FromB" />
</ItemGroup>
<Message Text="[B-ran]" Importance="High" />
</Target>
</Project>
""");
BuildRequestData data = GetBuildRequestData(contents, ["A"]);
ProjectInstance projectInstance = data.ProjectInstance;
BuildResult result = _buildManager.Build(_parameters, data);

result.OverallResult.ShouldBe(BuildResultCode.Success);

// Sanity: the after-target B must actually have run, otherwise this test would pass trivially.
_logger.AssertLogContains("[B-ran]");

// A's Returns snapshot is taken when A completes, before B runs, so only FromA is captured;
// the FromB that B adds is not present.
result.ResultsByTarget["A"].Items.ShouldHaveSingleItem().ItemSpec.ShouldBe("FromA");

// The live project item state, by contrast, does see B's mutation: the FromB that is
// absent from A's returned snapshot was genuinely added to the item group, just too late
// for A's Returns.
projectInstance.GetItems("MyItem").Select(i => i.EvaluatedInclude).ShouldBe(["FromA", "FromB"]);
}

/// <summary>
/// Pins the same <c>Returns</c>/<c>AfterTargets</c> timing as <see cref="ReturnsCapturedBeforeAfterTargetsRun"/>,
/// but for a <c>Returns</c> that expands a property value: the value is captured when the target
/// completes, before its after-targets run, so a later property change in an after-target is not
/// reflected in the predecessor target's returned outputs.
/// </summary>
[Fact]
public void ReturnsCapturedPropertyValueBeforeAfterTargetsRun()
{
string contents = CleanupFileContents("""
<Project>
<PropertyGroup>
<MyProp>FromA</MyProp>
</PropertyGroup>
<Target Name="A" Returns="$(MyProp)" />
<Target Name="B" AfterTargets="A">
<PropertyGroup>
<MyProp>FromB</MyProp>
</PropertyGroup>
<Message Text="[B-ran]" Importance="High" />
</Target>
</Project>
""");
BuildRequestData data = GetBuildRequestData(contents, ["A"]);
ProjectInstance projectInstance = data.ProjectInstance;
BuildResult result = _buildManager.Build(_parameters, data);

result.OverallResult.ShouldBe(BuildResultCode.Success);

// Sanity: the after-target B must actually have run, otherwise this test would pass trivially.
_logger.AssertLogContains("[B-ran]");

// A's Returns expands $(MyProp) when A completes, before B runs, so it captures FromA.
result.ResultsByTarget["A"].Items.ShouldHaveSingleItem().ItemSpec.ShouldBe("FromA");

// The live project property state, by contrast, does see B's change to FromB.
projectInstance.GetPropertyValue("MyProp").ShouldBe("FromB");
}

/// <summary>
/// When a <see cref="ProjectInstance"/> based <see cref="BuildRequestData"/> is built out of proc, the node should
/// not reload it from disk but instead fully utilize the entire translate project instance state
Expand Down
63 changes: 12 additions & 51 deletions 63 src/msbuild/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 @@ -1229,11 +1194,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
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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 @@ -157,7 +157,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
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,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 @@ -1249,7 +1249,7 @@ private void InitializeHost()
#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
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.