microsoft / microsoft/cppwinrt

Bug: Spurious IntelliSense errors with C++20 Modules

Offen
#1,610 3 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
C++
Sterne
1.9k
Forks
281
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Version

3.0.260715.1

Summary

A simple project that uses C++/WinRT with the new C++20 Modules feature can build successfully with MSVC 14.52 Preview in Visual Studio Insiders, but has IntelliSense errors in the IDE that get in the way of return type deduction and similar. For instance, the example code causes this IntelliSense error:

function "winrt::Windows::Foundation::IUnknown::operator new(size_t)" (declared at line 2117 of module "winrt_base" ("D:\...\winrtmodcom\x64\Debug\Generated Files\winrt\base.h")) cannot be referenced -- it is a deleted function

More likely than not, this is simply an IDE and IntelliSense bug and I've reported it as such in DevCom-11123562. Anyone who cares about this scenario is welcome to upvote it. Having said that, if there's any workaround that can be implemented on the cppwinrt side to mitigate these IntelliSense failures, it would be a welcome improvement to the user experience.

Reproducible example
import std;
import winrt_base;
import winrt.Windows.Foundation;

winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> GetStringAsync()
{
    co_return L"Hello, World!";
}

winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> foo()
{
    auto str = co_await GetStringAsync(); // IntelliSense labels this <error type> instead of figuring out it is a winrt::hstring.
    co_return str;
}
Expected behavior

IntelliSense should be fully functional with cppwinrt C++20 Modules in scenarios that work correctly with header files.

Actual behavior

IntelliSense reports spurious E1776 errors and fails to deduce return types

Additional comments

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem reproduzierbaren C++20 Modules-Beispiel unter Verwendung von import std, import winrt_base und import winrt.Windows.Foundation in Visual Studio Insiders mit MSVC 14.52 Preview. Vergleiche das IntelliSense-Verhalten mit dem des entsprechenden headerbasierten Projekts und prüfe die generierte winrt\base.h, die im Fehler erwähnt wird. Als abgeschlossen gilt die Aufgabe, wenn entweder ein Workaround auf cppwinrt-Seite für die falschen E1776-Meldungen identifiziert wurde oder bestätigt wird, dass das Problem in DevCom-11123562 behoben werden muss.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
developer-experience, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.