-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow visualization of properties on generic types #1472
base: master
Are you sure you want to change the base?
Conversation
{"Object", ElementType::Object} | ||
}; | ||
std::string_view partName = *it; | ||
auto basic_type_pos = std::find_if(std::begin(elementNames), std::end(elementNames), [&partName](auto&& elem) { return elem.first == partName; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be case insensitive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question, and I had to really think about this answer. From everything I've learned about WinRT over the years, the exact casing of the string returned by GetRuntimeClassName
is not prescribed by the type system, just that "In particular, IInspectable.GetRuntimeClassName enables an object's client to retrieve a WinRT typename that can be resolved in metadata to enable language projection." (source https://learn.microsoft.com/en-us/uwp/winrt-cref/winrt-type-system)
That same WinRT type system doc linked above also calls out the names of these fundamental types, so these exact strings are standard, with the exception of Object
. What isn't strictly specified in the standard is that an implementation's internal type for a generic must return a particular string from GetRuntimeClassName
.
With a concrete type that implements generic interfaces, like Windows.Foundation.Collections.ValueSet
, it only needs to return that string. After looking up that string in the winmd, the relationship of the runtime class to the various generic interfaces it implements is all captured in the ECMA metadata.
But with these implementation-supplied objects, the class name is more of a convention, rather than a dictate of the type system, as far as I can tell. But what I do know is that I checked 3 of the big implementations that actually generate matching pinterface GUIDs and runtime class names, and they all use these same names. So, I think we're good here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did just notice that I need to validate Char16
and Guid
. I'm also going to ping the CsWinRT owners to verify they also return consistent strings for these cases.
We can now visualize properties on generic types. For example:
IReference<T>.Value
IVector<T>.Size
IKeyValuePair<T>.Key
andIKeyValuePair<T>.Value
This does the heavy lifting of parsing the generic type strings received from the debugger, synthesizing type signatures for generics, calculating the pinterface UUID, and retrieving the property.
Note that this change only attacks true properties. For collections, (e.g. Vector, Map), only
Size
is a property. Obtaining the contents requires non-property method calls. Fortunately, I have an idea for that which I'll add in a separate PR.Fixes: #784