Skip to content

Add [MSBuildMultiThreadableTask] to attribute-only SourceLink tasks - #1725

Merged
ViktorHofer merged 1 commit into
dotnet:mainfrom
jankratochvilcz:mt-migration-attribute-only
Jun 18, 2026
Merged

ViktorHofer merged 1 commit into
dotnet:mainfrom
jankratochvilcz:mt-migration-attribute-only

Conversation

@jankratochvilcz

Copy link
Copy Markdown
Contributor

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 their Execute() path, so no IMultiThreadableTask implementation is needed.

Migrated tasks (all attribute-only)

  • 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

Call-chain audit

Traced from Execute() through both base classes (GetSourceLinkUrlGitTask, TranslateRepositoryUrlsGitTask) to all leaves. The full transitive call graph reaches only:

  • Uri.TryCreate, string manipulation, UriUtilities.Combine/TryParseAuthority (pure string/Uri)
  • AzureDevOpsUrlParser.TryParse* (pure string/Uri parsing)
  • ITaskItem.GetMetadata/SetMetadata, Evaluation.ProjectCollection.Escape
  • Log.LogError/LogWarning/LogMessage

Zero 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 + TaskEnvironment migration:

  • Microsoft.SourceLink.AzureRepos.Git.GetSourceLinkUrl — Environment.GetEnvironmentVariable
  • Microsoft.SourceLink.Common.GenerateSourceLinkFile — File.* operations
  • Microsoft.Build.Tasks.Git.LocateRepository — File I/O via GitRepository
  • Microsoft.Build.Tasks.Git.GetUntrackedFiles — File I/O via GitRepository

Testing

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).

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
jankratochvilcz marked this pull request as ready for review June 18, 2026 09:49
@jankratochvilcz
jankratochvilcz requested a review from tmat as a code owner June 18, 2026 09:49

@jankratochvilcz jankratochvilcz left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 call Evaluation.ProjectCollection.Escape() is a thread-safe pure string utility.
  • SourceLinkHasSingleProvider — trivially safe (single string.Split on 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.

@ViktorHofer
ViktorHofer merged commit 3658fb0 into dotnet:main Jun 18, 2026
9 checks passed
@jankratochvilcz
jankratochvilcz deleted the mt-migration-attribute-only branch June 18, 2026 16:06
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants