Skip to content

Commit

Permalink
Merge pull request #9393 from rainersigwald/fix-sdk-resolver-events
Browse files Browse the repository at this point in the history
Log ETW for SDK resolution by avoiding passing `null`.
  • Loading branch information
rainersigwald authored Nov 30, 2023
2 parents fdb94c3 + e77aa19 commit d8283be
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Build/BackEnd/Client/MSBuildClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public MSBuildClientExitResult Execute(CancellationToken cancellationToken)

ReadPacketsLoop(cancellationToken);

MSBuildEventSource.Log.MSBuildServerBuildStop(descriptiveCommandLine, _numConsoleWritePackets, _sizeOfConsoleWritePackets, _exitResult.MSBuildClientExitType.ToString(), _exitResult.MSBuildAppExitTypeString);
MSBuildEventSource.Log.MSBuildServerBuildStop(descriptiveCommandLine, _numConsoleWritePackets, _sizeOfConsoleWritePackets, _exitResult.MSBuildClientExitType.ToString(), _exitResult.MSBuildAppExitTypeString ?? string.Empty);
CommunicationsUtilities.Trace("Build finished.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private async Task<CacheResult> GetCacheResultAsync(BuildRequestData buildReques

ErrorUtilities.VerifyThrow(plugin.Instance != null, "Plugin '{0}' instance is null", plugin.Name);

MSBuildEventSource.Log.ProjectCacheGetCacheResultStart(plugin.Name, buildRequest.ProjectFullPath, targetNames);
MSBuildEventSource.Log.ProjectCacheGetCacheResultStart(plugin.Name, buildRequest.ProjectFullPath, targetNames ?? MSBuildConstants.DefaultTargetsMarker);
cacheResult = await plugin.Instance!.GetCacheResultAsync(buildRequest, pluginLogger, cancellationToken);

if (pluginLogger.HasLoggedErrors || cacheResult.ResultType == CacheResultType.None)
Expand All @@ -548,7 +548,7 @@ private async Task<CacheResult> GetCacheResultAsync(BuildRequestData buildReques
if (MSBuildEventSource.Log.IsEnabled())
{
string cacheResultType = cacheResult?.ResultType.ToString() ?? nameof(CacheResultType.None);
MSBuildEventSource.Log.ProjectCacheGetCacheResultStop(plugin.Name, buildRequest.ProjectFullPath, targetNames, cacheResultType);
MSBuildEventSource.Log.ProjectCacheGetCacheResultStop(plugin.Name, buildRequest.ProjectFullPath, targetNames ?? "<default>", cacheResultType);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override SdkResult ResolveSdk(int submissionId, SdkReference sdk, Logging

bool wasResultCached = true;

MSBuildEventSource.Log.CachedSdkResolverServiceResolveSdkStart(sdk.Name, solutionPath, projectPath);
MSBuildEventSource.Log.CachedSdkResolverServiceResolveSdkStart(sdk.Name, solutionPath ?? string.Empty, projectPath ?? string.Empty);

if (Traits.Instance.EscapeHatches.DisableSdkResolutionCache)
{
Expand Down Expand Up @@ -79,7 +79,7 @@ public override SdkResult ResolveSdk(int submissionId, SdkReference sdk, Logging
loggingContext.LogWarning(null, new BuildEventFileInfo(sdkReferenceLocation), "ReferencingMultipleVersionsOfTheSameSdk", sdk.Name, result.Version, result.ElementLocation, sdk.Version);
}

MSBuildEventSource.Log.CachedSdkResolverServiceResolveSdkStop(sdk.Name, solutionPath, projectPath, result.Success, wasResultCached);
MSBuildEventSource.Log.CachedSdkResolverServiceResolveSdkStop(sdk.Name, solutionPath ?? string.Empty, projectPath ?? string.Empty, result.Success, wasResultCached);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private List<SdkResolver> GetResolvers(IList<SdkResolverManifest> resolversManif
MSBuildEventSource.Log.SdkResolverServiceLoadResolversStart();
newResolvers = _sdkResolverLoader.LoadResolversFromManifest(resolverManifest, sdkReferenceLocation);
_manifestToResolvers[resolverManifest] = newResolvers;
MSBuildEventSource.Log.SdkResolverServiceLoadResolversStop(resolverManifest.DisplayName, newResolvers.Count);
MSBuildEventSource.Log.SdkResolverServiceLoadResolversStop(resolverManifest.DisplayName ?? string.Empty, newResolvers.Count);
}
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ private bool TryResolveSdkUsingSpecifiedResolvers(
}
finally
{
MSBuildEventSource.Log.SdkResolverResolveSdkStop(sdkResolver.Name, sdk.Name, solutionPath, projectPath, result?.Path, result?.Success ?? false);
MSBuildEventSource.Log.SdkResolverResolveSdkStop(sdkResolver.Name, sdk.Name, solutionPath ?? string.Empty, projectPath ?? string.Empty, result?.Path ?? string.Empty, result?.Success ?? false);
}

SetResolverState(submissionId, sdkResolver, context.State);
Expand Down Expand Up @@ -487,7 +487,7 @@ private void RegisterResolversManifests(ElementLocation location)
MSBuildEventSource.Log.SdkResolverServiceLoadResolversStart();
sdkDefaultResolversManifest = new SdkResolverManifest(DisplayName: "DefaultResolversManifest", Path: null, ResolvableSdkRegex: null);
_manifestToResolvers[sdkDefaultResolversManifest] = defaultResolvers;
MSBuildEventSource.Log.SdkResolverServiceLoadResolversStop(sdkDefaultResolversManifest.DisplayName, defaultResolvers.Count);
MSBuildEventSource.Log.SdkResolverServiceLoadResolversStop(sdkDefaultResolversManifest.DisplayName ?? string.Empty, defaultResolvers.Count);
}

MSBuildEventSource.Log.SdkResolverServiceFindResolversManifestsStop(allResolversManifests.Count);
Expand Down
4 changes: 2 additions & 2 deletions src/Build/Evaluation/LazyItemEvaluator.IncludeOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected override ImmutableArray<I> SelectItems(OrderedItemDataCollection.Build
string[] includeSplitFilesEscaped;
if (MSBuildEventSource.Log.IsEnabled())
{
MSBuildEventSource.Log.ExpandGlobStart(_rootDirectory, glob, string.Join(", ", excludePatternsForGlobs));
MSBuildEventSource.Log.ExpandGlobStart(_rootDirectory ?? string.Empty, glob, string.Join(", ", excludePatternsForGlobs));
}

using (_lazyEvaluator._evaluationProfiler.TrackGlob(_rootDirectory, glob, excludePatternsForGlobs))
Expand All @@ -121,7 +121,7 @@ protected override ImmutableArray<I> SelectItems(OrderedItemDataCollection.Build

if (MSBuildEventSource.Log.IsEnabled())
{
MSBuildEventSource.Log.ExpandGlobStop(_rootDirectory, glob, string.Join(", ", excludePatternsForGlobs));
MSBuildEventSource.Log.ExpandGlobStop(_rootDirectory ?? string.Empty, glob, string.Join(", ", excludePatternsForGlobs));
}

foreach (string includeSplitFileEscaped in includeSplitFilesEscaped)
Expand Down
4 changes: 1 addition & 3 deletions src/Framework/MSBuildEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

using System.Diagnostics.Tracing;

#nullable disable

namespace Microsoft.Build.Eventing
{
/// <summary>
Expand Down Expand Up @@ -242,7 +240,7 @@ public void RarOverallStart()
WriteEvent(27);
}

[Event(28, Keywords = Keywords.All | Keywords.PerformanceLog)]
[Event(28, Keywords = Keywords.All | Keywords.PerformanceLog, Version = 1)]
public void RarOverallStop(int assembliesCount, int assemblyFilesCount, int resolvedFilesCount, int resolvedDependencyFilesCount, int copyLocalFilesCount, bool findDependencies)
{
WriteEvent(28, assembliesCount, assemblyFilesCount, resolvedFilesCount, resolvedDependencyFilesCount, copyLocalFilesCount, findDependencies);
Expand Down

0 comments on commit d8283be

Please sign in to comment.