Add edge-case tests for SharedFileSystemPathInTestAnalyzer (MSTEST0077) - #10280
Conversation
There was a problem hiding this comment.
Pull request overview
Adds missing MSTEST0077 analyzer coverage for two documented edge cases.
Changes:
- Tests diagnostics for
File.OpenWritewith a constant path. - Tests diagnostics inside
[TestInitialize]methods.
Show a summary per file
| File | Description |
|---|---|
test/UnitTests/MSTest.Analyzers.UnitTests/SharedFileSystemPathInTestAnalyzerTests.cs |
Adds both analyzer regression tests. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Medium
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
Review Summary
Verdict: All clear ✅
This PR adds two focused edge-case tests for SharedFileSystemPathInTestAnalyzer (MSTEST0077). Both new test methods follow the established patterns in the file exactly — same structure, same assertion style, same use of VerifyCS.VerifyAnalyzerAsync with explicit .WithLocation(0).WithArguments(...).
| Dimension | Status |
|---|---|
| Correctness | ✅ Tests exercise documented but uncovered code paths (File.OpenWrite and [TestInitialize] fixtures) |
| Naming | ✅ Follows When<Condition>_<Expected> convention |
| Style | ✅ Consistent with existing tests in the file |
| Comments | ✅ Useful context explaining why these cases matter |
| Public API | ✅ N/A — test-only change |
| Performance | ✅ N/A |
| Thread Safety | ✅ N/A |
| Backward Compat | ✅ No production changes |
No actionable findings.
This comment has been minimized.
This comment has been minimized.
- WhenTestMethodOpensFileForWriting_Diagnostic: verifies File.OpenWrite with a constant path fires the diagnostic. The analyzer comments mention OpenWrite as the only unambiguously-writing File.Open* variant but no test covered it. - WhenTestInitializeWritesConstantPath_Diagnostic: verifies the analyzer fires inside a [TestInitialize] fixture method, which runs before each test and can race under method-level parallelization. Fixture-method coverage was absent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
be71a4b to
afa855e
Compare
The diagnosis was right about the symptom but the fix belongs on Running Rebased onto |
This comment has been minimized.
This comment has been minimized.
🔴 Build failure analysisAll 6 build legs fail with the same error: Root causeThis PR did not cause the failure. The sole changed file is The build was triggered on the merge commit of this PR against the PR base Timeline
Because RFC 020 landed after the PR was queued, the build ran on a state where the BOM-less xlf was still present. Impact
Recommended actionRe-trigger the PR build (or rebase onto current
|
|
Correcting my earlier reply — the BOM was a red herring, and I have the real root cause now. Do not run Why my local verification was wrong
<Target Name="_UpdateXlf" ... Inputs="@(XlfSource);$(_XlfSourceList)" Outputs="$(_UpdateXlfLastRun)">With a warm Actual root causeExactly one trans-unit is affected: The OneLocBuild check-in #10268 ( – le type de retour doit être « void », « Task » ou « ValueTask ».
-
+{0}
Le type déclarant ces méthodes doit également respecter les règles suivantes :The English source has no format placeholders at all — that position is a blank paragraph separator. The French target now claims a So running This is not caused by this PR
This PR is Suggested fix (for
|
|
Closing the loop on my previous comment: the fix already exists as #10281 ("Restore localization filters after #10268"), which reverts exactly the So there is nothing to do on this PR. Once #10281 lands on |
🧪 Test quality grade — PR #10280
This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Re-run with
|
|
On the grade-tests suggestions — I checked both against the code and am not acting on either here.
This test already exists. using FileStream stream = File.Open("fixture.txt", FileMode.Open, FileAccess.Read);
...
await VerifyCS.VerifyAnalyzerAsync(code); // no diagnosticIt even carries a comment spelling out the
Fair in principle, but low value here. The opt-out is not implemented per-analyzer — it lives in the shared Same for Also worth noting the grades have moved A/A → A/A → B/B across three runs on unchanged code, so I'm treating the deltas as heuristic noise rather than a signal to keep appending tests. This PR closes a specifically-scoped issue (#10272: two documented-but-untested edge cases) and is already approved; broadening it would be scope creep. Happy for the |
Fixes #10272
Two edge cases of
SharedFileSystemPathInTestAnalyzer(MSTEST0077) were documented in code comments but not exercised by any test. This adds coverage for both.Changes
WhenTestMethodOpensFileForWriting_Diagnostic— verifiesFile.OpenWrite("shared.log")inside a[TestMethod]under[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]fires the diagnostic.OpenWriteis listed inIsMutatingFileSystemMethodas the only unambiguously-mutatingFile.Open*variant (unlike the generalFile.Open, which can request a read-only handle), but nothing covered it.WhenTestInitializeWritesConstantPath_Diagnostic— verifies a constant-path write inside a[TestInitialize]fixture method fires the diagnostic.ParallelSafetyHelper.GetEnclosingTestMethodaccepts fixture attribute types, but no fixture-method test existed for this analyzer.No production code changed.
Validation
The original work was produced by the Test Improver agentic workflow on branch
test-assist/mstest0077-edge-cases-08394bb30b927b0a; the commit is cherry-picked here onto currentmainsince GitHub Actions cannot open PRs in this repo.