Skip to content

Task analyzer reports false positives for AbsolutePath.Value #15072

Closed

Description

@AR-May

Issue Description

The task analyzer reports unsafe-path warnings when AbsolutePath.Value is passed to file APIs, even though the value is already fully qualified.

Steps to Reproduce

Compile these calls inside an MT-scoped task with the task analyzer enabled:

AbsolutePath path = TaskEnvironment.GetAbsolutePath("input.txt");
new FileInfo(path.Value);
using var stream = File.OpenRead(path.Value);

string directory = TaskEnvironment.GetAbsolutePath("out").Value;
Directory.CreateDirectory(directory);

The same problem occurs inside a separate source helper called by the task.

Expected Behavior

No unsafe-path diagnostic: AbsolutePath.Value is already absolute.

Actual Behavior

Direct calls produce MSBuildTask0003. Calls inside source helpers produce MSBuildTask0005.

Analysis

The analyzer recognizes AbsolutePath values and implicit conversions to string, but not the string exposed by .Value.

Unlike the canonicalization case fixed by #14970, these calls do not use Path.GetFullPath(path.Value). Adding that redundant call avoids the warning.

Activity

  1. AR-May commented on Oct 5, 2026

    @AR-May
    MemberAuthor

    Update: decided not to encourage use of .Value, see #15073 (comment)

  2. self-assigned this
    on Oct 7, 2026
  3. added a commit that references this issue on Oct 20, 2026
    91446ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions