Skip to content

xml doc cref can't disambiguate types based on visibility like method body can #61478

@AArnott

Description

@AArnott

Version Used: Microsoft (R) Visual C# Compiler version 4.3.0-2.22270.4 (a51b65c)

Steps to Reproduce:

  1. Create a solution with 3 C# projects. One project references the other two.
  2. In the two referenced projects, define the same type, but make one public and one internal.
  3. In the one referencing project, define a method which references this ambiguous type both from an xml doc cref, and from the method body.

Minimal repro: CSharpCrefResolutionBug.zip

Expected Behavior:

Both type references resolve to the public type.

Actual Behavior:

The cref resolves to the internal type.

This can be observed by using the Go To Definition command on each type reference.
It also impacts the completion list offered within the cref. Note how members on the public type are not enumerated like they would be without the internal type being declared.
Most impactful, this producing compiler warnings in one solution due to type resolution failure. I wasn't able to reproduce this in the minimal repro, but you can observe it with these repro steps:

git clone https://github.com/aarnott/MessagePack-CSharp.git
cd MessagePack-CSharp
git checkout roslynbug61478
dotnet build  -bl tests\MessagePack.Tests -t:rebuild -f net472

In that case, the internal type comes via a nuget package reference. But the public type is in scope and in fact is used in the method body without trouble. It's just the cref that fails to resolve because of the ambiguity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions