Repository navigation
Document safe temporary file creation for tasks - #15091
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The test must explicitly verify that the documented helper compiles without errors.
Review effort: Lite
Findings: None
What changed in this PR
Updates TaskAnalyzer guidance for safe, task-local temporary-file creation.
Changes:
- Documents atomic, collision-resistant temporary-file creation.
- Updates
MSBuildTask0002guidance and removes stale references. - Adds diagnostic assertions and analyzer coverage.
| File | Description |
|---|---|
src/TaskAnalyzer/README.md |
Documents the temporary-file helper and cleanup ownership. |
src/TaskAnalyzer/BannedApiDefinitions.cs |
Updates diagnostic guidance. |
src/TaskAnalyzer.Tests/MultiThreadableTaskAnalyzerTests.cs |
Verifies diagnostic text and the documented pattern. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
VolPlita
left a comment
There was a problem hiding this comment.
| # | Dimension | Verdict |
|---|---|---|
| 4 | Test Coverage & Completeness | 🟠 1 MAJOR |
✅ 23/24 dimensions clean.
- Test Coverage & Completeness — the documented-pattern test checks only analyzer diagnostics and therefore passes even though its source does not compile against the test stubs.
No production correctness, compatibility, concurrency, security, or ChangeWave issue was confirmed.
There was a problem hiding this comment.
| # | Dimension | Verdict |
|---|---|---|
| 22 | Correctness | 🟡 1 MODERATE |
✅ 23/24 dimensions clean.
- Correctness — retry only confirmed filename collisions. In
src/TaskAnalyzer/README.mdaround line 176, the documented helper catches and retries everyIOException. Failures unrelated to a generated-name collision (for example, the task-local temporary directory becoming unavailable) are retried ten times rather than propagated immediately. Restrict retries to failures that can be identified asFileMode.CreateNewcollisions and preserve immediate failure for other I/O errors.
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
api.github.life-white.ukgithub.life-white.uk
[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:
tools:
github:
mode: gh-proxySee GitHub Tools for more information on gh-proxy mode.
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "api.github.com"
- "github.com"See Network Configuration for more information.
Generated by Expert Code Review (on open) for #15091 · copilot · gpt56 · 359.5 AIC · ⌖ 5.61 AIC · ⊞ 17.8K
eb75223 to
e9eafd3
Compare
Replace the stale Path.GetTempFileName guidance with an atomic file-creation pattern based on TaskEnvironment.GetTempPath. Add exact diagnostic and documented-pattern coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b7562379-021b-44cf-8a49-4df05a7c3b13
Compile the documented pattern against complete framework stubs and retry only confirmed filename collisions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b7562379-021b-44cf-8a49-4df05a7c3b13
e9eafd3 to
a6ea2d3
Compare
Fixes #15088
Context
TaskAnalyzer reports
MSBuildTask0002forPath.GetTempFileName()because it resolves the temporary directory from process-wide environment variables.#14729 added
TaskEnvironment.GetTempPath(). A task can now create a temporary file in its task-local temporary directory without a newTaskEnvironment.GetTempFileName()API.The current diagnostic says that suppression is the only option. The README also says that no workaround exists and links to the completed #14583.
Changes
Path.GetTempFileName()diagnostic guidance.TaskEnvironment.GetTempPath();Path.GetRandomFileName();FileMode.CreateNew;AbsolutePath.TaskEnvironment.GetTempFileName()convenience API.Directory.CreateTempSubdirectory()still has no supported task-local equivalent.Compatibility
This PR changes guidance text for an existing diagnostic. It does not add a diagnostic, change its severity, or expand its scope. No ChangeWave is required.
Validation
dotnet test src\TaskAnalyzer.Tests\TaskAnalyzer.Tests.csproj -c Release