Skip to content

Migrate AzureRepos.Git.GetSourceLinkUrl to multithreaded task model - #1732

Merged
ViktorHofer merged 3 commits into
dotnet:mainfrom
jankratochvilcz:mt/azurerepos-getsourcelinkurl
Jul 3, 2026
Merged

ViktorHofer merged 3 commits into
dotnet:mainfrom
jankratochvilcz:mt/azurerepos-getsourcelinkurl

Conversation

@jankratochvilcz

Copy link
Copy Markdown
Contributor

Summary

  • Adds [MSBuildMultiThreadableTask] to Microsoft.SourceLink.AzureRepos.Git.GetSourceLinkUrl.
  • Implements IMultiThreadableTask with TaskEnvironment.Fallback so direct unit-test construction preserves current behavior.
  • Replaces the BUILD_REPOSITORY_URL_MAP* lookup in TryGetEnvironmentUriMap() with TaskEnvironment.GetEnvironmentVariable(...) for MT-safe environment access.

Audit

  • grep -rn "TryGetEnvironmentUriMap" src/ only finds the private method declaration in src/SourceLink.AzureRepos.Git/GetSourceLinkUrl.cs; it is currently uncalled dead code with an existing TODO. Because there is no active behavior to exercise, no new behavioral unit test was added.
  • Verified no direct Environment.*, Directory.GetCurrentDirectory, or Path.GetFullPath usage remains in this file.
  • The environment-variable swap is behavior-preserving for existing single-process/direct construction because TaskEnvironment.Fallback reads the process environment.
  • No output property or log message consumes an absolutized path in this change, so the path compatibility concerns from the MT migration checklist do not apply.

References dotnet/msbuild#14093.

Validation

  • ./build.sh --restore --build
  • PATH="$PWD/.dotnet:$PATH" dotnet test src/SourceLink.AzureRepos.Git.UnitTests/Microsoft.SourceLink.AzureRepos.Git.UnitTests.csproj -f net11.0 --no-restore

Add the MSBuild multithreadable task marker and IMultiThreadableTask support so GetSourceLinkUrl can receive a TaskEnvironment. Route the BUILD_REPOSITORY_URL_MAP lookup through TaskEnvironment.GetEnvironmentVariable, preserving fallback process-environment behavior for direct unit-test construction.

Call-chain audit: grep found TryGetEnvironmentUriMap only at its private declaration in GetSourceLinkUrl.cs, so it is currently uncalled dead code and no new behavioral unit test was added. The file has no direct Environment.*, Directory.GetCurrentDirectory, or Path.GetFullPath usage remaining.

Co-authored-by: Copilot <[email protected]>
@jankratochvilcz
jankratochvilcz requested a review from tmat as a code owner June 30, 2026 13:31
@jankratochvilcz

Copy link
Copy Markdown
Contributor Author

Automated MT review (MT-migration reviewer + expert code review): both approved, no blocking issues. The only nit raised — dropping the value! null-forgiving operator as redundant — was investigated and is in fact required: TaskEnvironment.GetEnvironmentVariable is annotated string?, and net472's string.IsNullOrEmpty lacks [NotNullWhen(false)], so the value isn't narrowed there (CS8604 without it). Kept it and added a clarifying comment.

@tmat tmat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TryGetEnvironmentUriMap is unused. You can delete it.

Per @tmat, the private TryGetEnvironmentUriMap method was dead code (no
callers; pre-existing, gated behind a "confirm design" TODO for dotnet#2). Deleting
it removes the task's only TaskEnvironment consumer, so this migration is now
attribute-only: keep [MSBuildMultiThreadableTask] and drop the unused
IMultiThreadableTask interface, the TaskEnvironment property, the now-unused
UrlMapEnvironmentVariableName const, and the usings only that method needed
(System.Collections.Generic, System.IO, System.Linq). The base
GetSourceLinkUrlGitTask performs no environment/file/process operations, so no
TaskEnvironment plumbing is required.

Co-authored-by: Copilot <[email protected]>
@jankratochvilcz

jankratochvilcz commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, done @tmat !

@ViktorHofer
ViktorHofer merged commit 2f9f851 into dotnet:main Jul 3, 2026
9 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 8, 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.

4 participants