Skip to content

Complete MSTEST0077 test coverage: remaining File.* allowlist entries #10316

Closed

Description

Follow-up to #10305, which completed the Directory.* arm of SharedFileSystemPathInTestAnalyzer's mutating allowlist (CreateDirectory, CreateSymbolicLink, Delete, Move, and all six Set*Time* members) plus the [DoNotParallelize] opt-out branch. That issue deliberately scoped item 2 to Directory.*, so the File.* arm is still only partially pinned.

What is covered today

SharedFileSystemPathInTestAnalyzerTests covers these File.* members: WriteAllText, Copy (both path roles), Move, Replace (backup role), Delete, OpenWrite — plus the negative pins for File.ReadAllText/File.Exists/File.Open.

What is not covered

IsMutatingFileSystemMethod's file arm lists many more entries that have no test:

  • The exact mirrors of what Complete MSTEST0077 test coverage: [DoNotParallelize] opt-out and remaining Directory.* allowlist entries #10305 just added on the Directory.* side, and therefore the cheapest to add:

    • File.CreateSymbolicLink — same (path, pathToTarget) shape as Directory.CreateSymbolicLink; the "pathToTarget is only read, so a constant target must not be flagged" behavior is unpinned on the File side.
    • File.SetCreationTime(Utc), File.SetLastAccessTime(Utc), File.SetLastWriteTime(Utc) — the identical six-member family. The Directory equivalent is a [DataRow]-driven test that can be mirrored almost verbatim.
  • The write/append/create family, which has a few distinct signature shapes so it does not templatize as cleanly: WriteAllTextAsync, WriteAllBytes(Async), WriteAllLines(Async), AppendAllText(Async), AppendAllLines(Async), AppendText, Create, CreateText.

  • The attribute/encryption members: Encrypt, Decrypt, SetAttributes, SetUnixFileMode.

Notes for whoever picks this up

  • [ResourceLock] is not an opt-out for MSTEST0077 — the analyzer never calls HasResourceLockFor/HasAnyResourceLock, unlike CurrentDirectoryMutation…/CultureMutation…. Do not copy a WhenResourceLockDeclared_NoDiagnostic test over from those files.
  • The [DoNotParallelize] opt-out is already covered by Complete MSTEST0077 test coverage: [DoNotParallelize] opt-out and remaining Directory.* allowlist entries #10305 (class-level, method-level, and the fixture-method negative that pins the IsTestMethod restriction); there is no need to repeat it per API.
  • File.Open is intentionally excluded from the allowlist and already has a negative test — do not "fix" that.
  • The analyzer test harness resolves against ReferenceAssemblies.Net.Net80 on both the net472 and net8.0 legs, so .NET 6+ APIs such as File.CreateSymbolicLink and File.SetUnixFileMode compile fine in the snippets without any #if guard.

Re-verified against current main (2026-08-23): all File.* allowlist entries listed in this issue are present in SharedFileSystemPathInTestAnalyzerTests.cs (WhenTestMethodCallsMutatingFileMethodWithConstantPath_Diagnostic DataRow list covers CreateSymbolicLink, SetCreationTime(Utc), SetLastAccessTime(Utc), SetLastWriteTime(Utc), Encrypt, Decrypt, SetAttributes, SetUnixFileMode, AppendText, CreateText, Create; the write/append/create async family is covered by WhenTestMethodCallsAsyncMutatingFileMethodWithConstantPath_Diagnostic; the CreateSymbolicLink pathToTarget-not-flagged negative case is covered by WhenTestMethodCreatesFileSymbolicLinkToConstantTarget_NoDiagnostic). This is the 4th independent confirmation this coverage is complete — closing for good.> 🤖 Automated content by GitHub Copilot. Generated by the Test Improver workflow. · auto · 91.8 AIC · ⌖ 5.43 AIC · ⊞ 19.4K · [◷]( · ◷)

Comment /test-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/test-improver.md@main

Activity

  1. github-actions commented on Aug 10, 2026

    @github-actions
  2. github-actions commented on Aug 16, 2026

    @github-actions
    Contributor

    Re-verified against current main (2026-08-16): all File.* allowlist entries listed in this issue are already covered in SharedFileSystemPathInTestAnalyzerTests.cs:

    • WhenTestMethodCallsMutatingFileMethodWithConstantPath_Diagnostic (DataRow-driven) covers AppendAllText, AppendAllLines, WriteAllBytes, WriteAllLines, Create, SetAttributes, SetUnixFileMode, all six Set*Time* members, Encrypt, Decrypt, AppendText, CreateText, and CreateSymbolicLink.
    • WhenTestMethodCallsAsyncMutatingFileMethodWithConstantPath_Diagnostic covers AppendAllTextAsync, AppendAllLinesAsync, WriteAllBytesAsync, WriteAllLinesAsync, WriteAllTextAsync.
    • WhenTestMethodCreatesFileSymbolicLinkToConstantTarget_NoDiagnostic covers the pathToTarget-is-not-flagged negative for File.CreateSymbolicLink.

    Full MSTest.Analyzers.UnitTests suite: 1782/1782 passed locally. No remaining gap — recommend closing this issue as complete.

    Warning

    Firewall blocked 1 domain

    The following domain was blocked by the firewall during workflow execution:

    • southcentralus0.in.applicationinsights.azure.com

    To allow these domains, add them to the network.allowed list in your workflow frontmatter:

    network:
      allowed:
        - defaults
        - "southcentralus0.in.applicationinsights.azure.com"

    See Network Configuration for more information.

    🤖 Automated content by GitHub Copilot. Generated by the Test Improver workflow. · auto · 104.8 AIC · ⌖ 4.38 AIC · ⊞ 19.4K · [◷]( · ◷)
    Comment /test-assist to run again

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/test-improver.md@main
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/test-gapMissing or insufficient tests.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions