Skip to content

Incorrect output of ToMinimalDisplayString() with namespace hiding #36654

@ltcmelo

Description

@ltcmelo

Version Used: 2.10

Steps to Reproduce: Consider the 2 files below.

test1.cs

using System;
namespace Abc.System {}
namespace Abc
{
    public class Test
    {
        public void fff()
        {
            Video vvv = null;
            foreach (var ooo in vvv.getlist()) {}
        }
    }
}

test2.cs

using System.Collections.Generic;
class Video
{
    public IEnumerable<int> getlist() { return null; }
}

Actual Behavior:

If I get the ITypeSymbol of vvv.getlist() and its minimal display string through ToMinimalDisplayString() (in the span of the in the foreach statement), I get System.Collections.Generic.IEnumerable<int>, which is not correct.

Expected Behavior:

Given that the minimal display string is expected to be semantically correct within the scope in question, the correct value of it should, in my opinion, be global::System.Collections.Generic.IEnumerable<int>.

NOTE: This behaviour would lead to a compilation error if the computed string is being use for any sort of code rewriting.

NOTE 2: I'm using the default display format, which, I believe, should account for such case.

UPDATE

See #36655 as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions