Skip to content

[release/9.0] Disable ResolveLinkTarget_Succeeds returnFinalTarget=true for UNC paths#124867

Open
Copilot wants to merge 2 commits intorelease/9.0from
copilot/fix-symbolic-link-tests
Open

[release/9.0] Disable ResolveLinkTarget_Succeeds returnFinalTarget=true for UNC paths#124867
Copilot wants to merge 2 commits intorelease/9.0from
copilot/fix-symbolic-link-tests

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

ResolveLinkTarget_Succeeds fails with IOException: The specified network name is no longer available on Windows versions that have UNC access disabled, because SymbolicLink_ResolveLinkTarget_PathToTarget_Data was yielding UNC paths with returnFinalTarget=true, causing Windows to actually attempt to resolve \\LOCALHOST\share\path.

main PR

Description

  • In BaseSymbolicLinks.cs, split SymbolicLink_ResolveLinkTarget_PathToTarget_Data to iterate PathToTargetData with both returnFinalTarget=false/true, but restrict PathToTargetUncData to returnFinalTarget=false only
  • Non-UNC path behavior is unchanged; UNC paths still get basic symlink target verification without the network resolution step that fails on restricted machines
foreach (string path in PathToTargetData)
{
    yield return new object[] { path, false };
    yield return new object[] { path, true };
}
// UNC paths are excluded from the returnFinalTarget=true case since
// they throw "The specified network name is no longer available" in
// various Windows versions. https://github.com/dotnet/runtime/issues/120380
foreach (string path in PathToTargetUncData)
{
    yield return new object[] { path, false };
}

Customer Impact

Tests in FileInfo_SymbolicLinks, File_SymbolicLinks, DirectoryInfo_SymbolicLinks, and Directory_SymbolicLinks are failing on affected Windows machines, blocking CI.

Regression

Not a product regression — test infrastructure issue. Triggered by Windows policy changes disabling UNC paths on certain machines.

Testing

Minimal test-only change. The fix narrows the test matrix for UNC paths to avoid exercising the network resolution path that is unavailable on restricted machines.

Risk

Very low. Single-line logic change scoped entirely to test data generation. No production code touched. Reduces test coverage only for a scenario (returnFinalTarget=true on UNC paths) that cannot reliably run in affected environments.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Original prompt

Problem

As reported in #120380, the test ResolveLinkTarget_Succeeds (used by FileInfo_SymbolicLinks, File_SymbolicLinks, DirectoryInfo_SymbolicLinks, Directory_SymbolicLinks) is failing on various Windows versions that have recently disabled UNC paths with:

System.IO.IOException : The specified network name is no longer available

The failure occurs because SymbolicLink_ResolveLinkTarget_PathToTarget_Data in BaseSymbolicLinks.cs yields UNC paths (from PathToTargetUncData) with returnFinalTarget=true. When resolving a symlink target with returnFinalTarget=true, Windows tries to actually resolve the UNC path \\LOCALHOST\share\path, which fails on machines where UNC is disabled.

Fix

In the file src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Base/SymbolicLinks/BaseSymbolicLinks.cs, modify the SymbolicLink_ResolveLinkTarget_PathToTarget_Data property (lines 56-66) so that UNC paths only yield test cases with returnFinalTarget=false, not true.

Current code (lines 56-66):

public static IEnumerable<object[]> SymbolicLink_ResolveLinkTarget_PathToTarget_Data
{
    get
    {
        foreach (string path in PathToTargetData.Union(PathToTargetUncData))
        {
            yield return new object[] { path, false };
            yield return new object[] { path, true };
        }
    }
}

The fix should change this to iterate PathToTargetData with both false and true, but iterate PathToTargetUncData with only false:

public static IEnumerable<object[]> SymbolicLink_ResolveLinkTarget_PathToTarget_Data
{
    get
    {
        foreach (string path in PathToTargetData)
        {
            yield return new object[] { path, false };
            yield return new object[] { path, true };
        }
        // UNC paths are excluded from the returnFinalTarget=true case since
        // they throw "The specified network name is no longer available" in
        // various Windows versions. https://github.com/dotnet/runtime/issues/120380
        foreach (string path in PathToTargetUncData)
        {
            yield return new object[] { path, false };
        }
    }
}

Only this one property needs to change. The other data properties (SymbolicLink_LinkTarget_PathToTarget_Data, Junction_*) should remain unchanged.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing ResolveLinkTarget_Succeeds test for UNC paths Fix ResolveLinkTarget_Succeeds test failure on Windows with UNC paths disabled Feb 25, 2026
@jozkee jozkee marked this pull request as ready for review February 25, 2026 17:56
Copilot AI review requested due to automatic review settings February 25, 2026 17:56
@jozkee jozkee added Servicing-approved Approved for servicing release disabled-test The test is disabled in source code against the issue area-System.IO and removed disabled-test The test is disabled in source code against the issue labels Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates symbolic link test data generation to avoid UNC network resolution failures on Windows configurations where UNC access is disabled, stabilizing CI for ResolveLinkTarget_Succeeds.

Changes:

  • Split SymbolicLink_ResolveLinkTarget_PathToTarget_Data generation to cover returnFinalTarget=false/true only for non-UNC paths.
  • Restrict UNC path cases to returnFinalTarget=false to prevent Windows from attempting UNC resolution.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

@jozkee jozkee changed the title Fix ResolveLinkTarget_Succeeds test failure on Windows with UNC paths disabled [release/9.0] Disable ResolveLinkTarget_Succeeds returnFinalTarget=true for UNC paths Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.IO Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants