microsoft / microsoft/MIEngine

templated type alias not recognized

Open
#1,449 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
859
Forks
233
Avg merge
1d 6h
Merged PRs (30d)
3

Description

Consider the following code

template<typename T>
struct Foo
{
};

template<typename T> using Bar = Foo<T>;

int main()
{
    Foo<int> foo = {};
    Bar<int> bar = {};
    // break here and hover over foo and bar.
    return 0;
}

with this natvis file

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="Foo&lt;*&gt;">
        <DisplayString>this is a Foo</DisplayString>
    </Type>
</AutoVisualizer>

then cppdbg with gcc on Linux will be able to display the content of foo as this is a Foo, but it displays the default visualizer for bar.

Expected result: display this is a Foo for bar as well.

Adding <AlternativeType Name="Bar&lt;*&gt;"> to the Foo type does not work.

Adding a separate <Type Name="Bar&lt;*&gt;"> does not work.

Adding a separate <Type Name="Bar"> does work. However, I loose the information about the template parameters. I can't access $T1 anymore.

Side note / trivia: with cppvsdbg, this is a Foo is displayed for bar - also if the entry for Bar is missing in the natvis file.

More trivia: this contrived example stems from an attempt to display Qt's type QVector which is defined as template <typename T> using QVector = QList<T>.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the templated Foo and Bar example, cppdbg on Linux, and the shown natvis file, then compare visualization of foo and bar. Trace how the natvis Type matching handles the alias and template parameters; done means Bar displays “this is a Foo” while preserving access to the template parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.