Migrate Common.GenerateSourceLinkFile to multithreaded task model#1733
Migrate Common.GenerateSourceLinkFile to multithreaded task model#1733jankratochvilcz wants to merge 3 commits into
Conversation
Add the MSBuild multithreaded task marker and IMultiThreadableTask implementation with a TaskEnvironment fallback for direct unit-test construction. Resolve OutputFile through TaskEnvironment once for file operations while preserving the original OutputFile value for the SourceLink output and log messages. Sanitize exception messages that may contain the absolutized path back to the original path, and preserve the empty-output/null-or-empty OutputFile no-file behavior before absolutization. Add a decoy-CWD test that proves a relative OutputFile is resolved against the project directory while SourceLink remains the original relative value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Automated MT review (MT-migration reviewer + expert code review): both approved, no blocking/actionable findings. Verified: Sin 1 ( |
The empty-OutputFile/null-content guard only calls string.IsNullOrEmpty and Log.LogMessage and returns before outputPath is assigned, so none of it can throw. Move it above the try so the try scopes exactly the code that can throw (GetAbsolutePath + file I/O). No behavior change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| Log.LogWarning(Resources.SourceControlInformationIsNotAvailableGeneratedSourceLinkEmpty); | ||
| } | ||
|
|
||
| if (content == null && string.IsNullOrEmpty(OutputFile)) |
There was a problem hiding this comment.
I'd make it a requirement on OutputFile to be an absolute path. The value of this parameter is controlled by our target and set from _SourceLinkFilePath defined here:
Summary
Migrates
Microsoft.SourceLink.Common.GenerateSourceLinkFileto the MSBuild multithreaded task model for dotnet/msbuild#14093.Details
[MSBuildMultiThreadableTask]and implementsIMultiThreadableTaskwithTaskEnvironment.Fallbackso direct unit-test construction keeps existing semantics.OutputFileviaTaskEnvironment.GetAbsolutePathbefore allFile.Exists,File.Delete,File.ReadAllText, andFile.WriteAllTextcalls, so relative paths are based on the project directory instead of process CWD.[Output] SourceLinkvalue as the originalOutputFilestring, not the absolute path.OutputFilevalue and sanitizing exception messages that include the absolutized path back to the original path.OutputFileno-existing-file behavior before absolutization; non-empty content still fails through the existing catch path.Tests
./build.sh --restore --build --verbosity minimal./.dotnet/dotnet test src/SourceLink.Common.UnitTests/Microsoft.SourceLink.Common.UnitTests.csproj -f net11.0 --no-restoreWriteSourceLinkFileResolvesRelativeOutputFileAgainstProjectDirectory, a decoy-CWD test that verifies a relative output file is written under theTaskEnvironmentproject directory, not process CWD, whileSourceLinkremains the original relative value.