Repository navigation
Add [MSBuildMultiThreadableTask] to attribute-only SourceLink tasks - #1725
Conversation
Mark 16 concrete task classes as multithreaded-safe by adding the [MSBuildMultiThreadableTask] attribute. These tasks perform only pure URL/string manipulation with no file system, environment variable, or process operations in their Execute() path, so no IMultiThreadableTask implementation is needed. Migrated tasks: - Microsoft.SourceLink.GitHub.GetSourceLinkUrl - Microsoft.SourceLink.GitHub.TranslateRepositoryUrls - Microsoft.SourceLink.GitLab.GetSourceLinkUrl - Microsoft.SourceLink.GitLab.TranslateRepositoryUrls - Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl - Microsoft.SourceLink.Bitbucket.Git.TranslateRepositoryUrls - Microsoft.SourceLink.AzureRepos.Git.TranslateRepositoryUrls - Microsoft.SourceLink.Common.SourceLinkHasSingleProvider - Microsoft.SourceLink.Gitea.GetSourceLinkUrl - Microsoft.SourceLink.Gitea.TranslateRepositoryUrls - Microsoft.SourceLink.Gitee.GetSourceLinkUrl - Microsoft.SourceLink.Gitee.TranslateRepositoryUrls - Microsoft.SourceLink.AzureDevOpsServer.Git.GetSourceLinkUrl - Microsoft.SourceLink.AzureDevOpsServer.Git.TranslateRepositoryUrls - Microsoft.SourceLink.GitWeb.GetSourceLinkUrl - Microsoft.SourceLink.GitWeb.TranslateRepositoryUrls Co-authored-by: Copilot <[email protected]>
jankratochvilcz
left a comment
There was a problem hiding this comment.
Expert Review Summary
Verdict: ✅ No issues found
Verified all 24 review dimensions. Key findings:
Call-chain audit confirmed ✅
Traced Execute() through both base classes locally:
GetSourceLinkUrlGitTask— pure URL/string ops:Uri.TryCreate,ITaskItem.GetMetadata,UriUtilities.Combine/TryParseAuthority, string manipulation,Log.*. Zero static mutable state, zero file/env/process access.TranslateRepositoryUrlsGitTask— same pattern. The one static callEvaluation.ProjectCollection.Escape()is a thread-safe pure string utility.SourceLinkHasSingleProvider— trivially safe (singlestring.Spliton instance property).
Exclusions correct ✅
AzureRepos.Git/GetSourceLinkUrl correctly excluded — calls Environment.GetEnvironmentVariable and uses Path.PathSeparator.
Attribute placement correct ✅
[MSBuildMultiThreadableTask] has Inherited = false, requiring placement on each concrete sealed class (not base). All 16 placements are correct.
Backwards compatibility ✅
Attribute is detected by namespace+name only (ignoring assembly). Older MSBuild versions that don't know about it simply ignore it — purely additive.
using directives ✅
Added using Microsoft.Build.Framework; only where it was missing (the TranslateRepositoryUrls files with empty bodies). Files that already had it (via [Output] etc.) needed no additions.
No inline comments needed — clean PR.
Summary
Marks 16 concrete task classes as multithreaded-safe by adding the
[MSBuildMultiThreadableTask]attribute. These tasks perform only pure URL/string manipulation with no file system, environment variable, or process operations in theirExecute()path, so noIMultiThreadableTaskimplementation is needed.Migrated tasks (all attribute-only)
Microsoft.SourceLink.GitHub.GetSourceLinkUrlMicrosoft.SourceLink.GitHub.TranslateRepositoryUrlsMicrosoft.SourceLink.GitLab.GetSourceLinkUrlMicrosoft.SourceLink.GitLab.TranslateRepositoryUrlsMicrosoft.SourceLink.Bitbucket.Git.GetSourceLinkUrlMicrosoft.SourceLink.Bitbucket.Git.TranslateRepositoryUrlsMicrosoft.SourceLink.AzureRepos.Git.TranslateRepositoryUrlsMicrosoft.SourceLink.Common.SourceLinkHasSingleProviderMicrosoft.SourceLink.Gitea.GetSourceLinkUrlMicrosoft.SourceLink.Gitea.TranslateRepositoryUrlsMicrosoft.SourceLink.Gitee.GetSourceLinkUrlMicrosoft.SourceLink.Gitee.TranslateRepositoryUrlsMicrosoft.SourceLink.AzureDevOpsServer.Git.GetSourceLinkUrlMicrosoft.SourceLink.AzureDevOpsServer.Git.TranslateRepositoryUrlsMicrosoft.SourceLink.GitWeb.GetSourceLinkUrlMicrosoft.SourceLink.GitWeb.TranslateRepositoryUrlsCall-chain audit
Traced from
Execute()through both base classes (GetSourceLinkUrlGitTask,TranslateRepositoryUrlsGitTask) to all leaves. The full transitive call graph reaches only:Uri.TryCreate,stringmanipulation,UriUtilities.Combine/TryParseAuthority(pure string/Uri)AzureDevOpsUrlParser.TryParse*(pure string/Uri parsing)ITaskItem.GetMetadata/SetMetadata,Evaluation.ProjectCollection.EscapeLog.LogError/LogWarning/LogMessageZero file system, environment variable, process, Console, or static mutable state in any reachable leaf.
Not migrated (tracked in dotnet/msbuild#14093)
These tasks need full
IMultiThreadableTask+TaskEnvironmentmigration:Microsoft.SourceLink.AzureRepos.Git.GetSourceLinkUrl—Environment.GetEnvironmentVariableMicrosoft.SourceLink.Common.GenerateSourceLinkFile—File.*operationsMicrosoft.Build.Tasks.Git.LocateRepository— File I/O via GitRepositoryMicrosoft.Build.Tasks.Git.GetUntrackedFiles— File I/O via GitRepositoryTesting
No new tests needed — attribute-only migrations on tasks with zero file/env/process interactions have no testable MT-specific behavior (a decoy-CWD test would pass identically with or without the attribute).