microsoft/winmd

need ability for filter to match exact type names

Closed this issue · 4 comments

for the swift/winrt language projection, we need the ability to filter out exact type names, and not just lazy matching by the beginning of the string. this means changing the implementation of filter::match from this:

        static bool match(std::string_view const& type_namespace, std::string_view const& type_name, std::string_view const& match) noexcept
        {
            if (match.size() <= type_namespace.size())
            {
                return impl::starts_with(type_namespace, match);
            }

            if (!impl::starts_with(match, type_namespace))
            {
                return false;
            }
            if (match[type_namespace.size()] != '.')
            {
                return false;
            }
            return impl::starts_with(type_name, match.substr(type_namespace.size() + 1));
        }

to

        static bool match(std::string_view const& type_namespace, std::string_view const& type_name, std::string_view const& match, bool exact) noexcept
        {
            if (match.size() <= type_namespace.size())
            {
                if (exact)
                {
                    return type_namespace == match;
                }
                return impl::starts_with(type_namespace, match);
            }

            if (!impl::starts_with(match, type_namespace))
            {
                return false;
            }
            if (match[type_namespace.size()] != '.')
            {
                return false;
            }

            if (exact)
            {
                return type_name == match.substr(type_namespace.size() + 1);
            }
            return impl::starts_with(type_name, match.substr(type_namespace.size() + 1));
        }

Hi Steve! Note that this winmd parser is no longer under active development and mostly serves as an implementation detail of https://github.com/microsoft/cppwinrt so I'm reluctant to make any significant changes at this point. Such a change would also have to be tested with cppwinrt to ensure it doesn't impact code gen at all.

totally makes sense. we can validate cpp/winrt.

i think this a pretty minor change. should be pretty easy to verify from the code change that existing behavior won't be affected (since this won't be the default behavior)

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.

we figured out a different solution so we no longer need this