Skip to content

Complete MSTEST0077 test coverage: [DoNotParallelize] opt-out and remaining Directory.* allowlist entries #10305

Description

Follow-up to #10299 / the delete-move coverage PR, which deliberately kept its scope to the delete/move path-role logic.

Two adjacent gaps in SharedFileSystemPathInTestAnalyzerTests remain:

1. No [DoNotParallelize] negative test

SharedFileSystemPathInTestAnalyzer bails out via ParallelSafetyHelper.IsOptedOutOfParallelization before reporting:

// Opting out of parallelization (sequential phase) removes the collision risk entirely, so stay silent
if (ParallelSafetyHelper.IsOptedOutOfParallelization(testMethod, doNotParallelizeAttributeSymbol, testMethodAttributeSymbol))
{
    return;
}

That branch is entirely untested for MSTEST0077, even though the sibling analyzers (CurrentDirectoryMutation…, CultureMutation…) both carry a WhenDoNotParallelizeDeclared_NoDiagnostic test as an established convention. A constant-path File.WriteAllText/File.Delete inside a [DoNotParallelize] test is exactly the shape that must stay quiet.

2. Untested entries in the Directory.* allowlist

IsMutatingFileSystemMethod's directory arm lists CreateDirectory, CreateSymbolicLink, Delete, Move, SetCreationTime(Utc), SetLastAccessTime(Utc), SetLastWriteTime(Utc). Only CreateDirectory, Delete, and Move are covered. Directory.CreateSymbolicLink and the Directory.Set*Time* family have no tests.

Note 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; it would assert behavior this rule does not have.

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