// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.1.0

#include "py.Windows.Networking.ServiceDiscovery.Dnssd.h"

namespace py::cpp::Windows::Networking::ServiceDiscovery::Dnssd
{
    // ----- DnssdRegistrationResult class --------------------

    static PyObject* _new_DnssdRegistrationResult(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_GET_SIZE(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_DnssdRegistrationResult(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DnssdRegistrationResult_ToString(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdRegistrationResult", L"ToString", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.ToString();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdRegistrationResult_get_HasInstanceNameChanged(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdRegistrationResult", L"HasInstanceNameChanged");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.HasInstanceNameChanged();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdRegistrationResult_get_IPAddress(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdRegistrationResult", L"IPAddress");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.IPAddress();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdRegistrationResult_get_Status(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdRegistrationResult", L"Status");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Status();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_DnssdRegistrationResult(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_DnssdRegistrationResult(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _str_DnssdRegistrationResult(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult* self) noexcept
    {
        try
        {
            return py::convert([&]()
            {
                auto _gil = py::release_gil();
                return self->obj.ToString();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DnssdRegistrationResult[] = {
        { "to_string", reinterpret_cast<PyCFunction>(DnssdRegistrationResult_ToString), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_DnssdRegistrationResult, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DnssdRegistrationResult), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DnssdRegistrationResult[] = {
        { "has_instance_name_changed", reinterpret_cast<getter>(DnssdRegistrationResult_get_HasInstanceNameChanged), nullptr, nullptr, nullptr },
        { "ip_address", reinterpret_cast<getter>(DnssdRegistrationResult_get_IPAddress), nullptr, nullptr, nullptr },
        { "status", reinterpret_cast<getter>(DnssdRegistrationResult_get_Status), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_DnssdRegistrationResult[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DnssdRegistrationResult) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DnssdRegistrationResult) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DnssdRegistrationResult) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DnssdRegistrationResult) },
        { Py_tp_str, reinterpret_cast<void*>(_str_DnssdRegistrationResult) },
        { }};

    static PyType_Spec type_spec_DnssdRegistrationResult = {
        "winrt._winrt_windows_networking_servicediscovery_dnssd.DnssdRegistrationResult",
        sizeof(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdRegistrationResult),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DnssdRegistrationResult};

    // ----- DnssdServiceInstance class --------------------

    static PyObject* _new_DnssdServiceInstance(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_GET_SIZE(args);
        if (arg_count == 3)
        {
            try
            {
                auto param0 = py::convert_to<winrt::hstring>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Networking::HostName>(args, 1);
                auto param2 = py::convert_to<uint16_t>(args, 2);

                winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance instance{param0, param1, param2};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_DnssdServiceInstance(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DnssdServiceInstance_RegisterDatagramSocketAsync1(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"RegisterDatagramSocketAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::Sockets::DatagramSocket>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.RegisterDatagramSocketAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstance_RegisterDatagramSocketAsync2(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"RegisterDatagramSocketAsync", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::Sockets::DatagramSocket>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Networking::Connectivity::NetworkAdapter>(args, 1);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.RegisterDatagramSocketAsync(param0, param1);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstance_RegisterStreamSocketListenerAsync1(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"RegisterStreamSocketListenerAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::Sockets::StreamSocketListener>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.RegisterStreamSocketListenerAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstance_RegisterStreamSocketListenerAsync2(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"RegisterStreamSocketListenerAsync", 2);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(2);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::Sockets::StreamSocketListener>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Networking::Connectivity::NetworkAdapter>(args, 1);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.RegisterStreamSocketListenerAsync(param0, param1);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstance_ToString(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"ToString", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.ToString();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstance_get_Weight(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"Weight");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Weight();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int DnssdServiceInstance_put_Weight(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"Weight");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<uint16_t>(arg);

            {
                auto _gil = release_gil();
                self->obj.Weight(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* DnssdServiceInstance_get_Priority(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"Priority");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Priority();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int DnssdServiceInstance_put_Priority(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"Priority");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<uint16_t>(arg);

            {
                auto _gil = release_gil();
                self->obj.Priority(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* DnssdServiceInstance_get_Port(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"Port");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Port();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int DnssdServiceInstance_put_Port(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"Port");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<uint16_t>(arg);

            {
                auto _gil = release_gil();
                self->obj.Port(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* DnssdServiceInstance_get_HostName(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"HostName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.HostName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int DnssdServiceInstance_put_HostName(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"HostName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Networking::HostName>(arg);

            {
                auto _gil = release_gil();
                self->obj.HostName(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* DnssdServiceInstance_get_DnssdServiceInstanceName(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"DnssdServiceInstanceName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.DnssdServiceInstanceName();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int DnssdServiceInstance_put_DnssdServiceInstanceName(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"DnssdServiceInstanceName");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            {
                auto _gil = release_gil();
                self->obj.DnssdServiceInstanceName(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* DnssdServiceInstance_get_TextAttributes(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstance", L"TextAttributes");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.TextAttributes();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_DnssdServiceInstance(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_DnssdServiceInstance(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _str_DnssdServiceInstance(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance* self) noexcept
    {
        try
        {
            return py::convert([&]()
            {
                auto _gil = py::release_gil();
                return self->obj.ToString();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DnssdServiceInstance[] = {
        { "register_datagram_socket_async1", reinterpret_cast<PyCFunction>(DnssdServiceInstance_RegisterDatagramSocketAsync1), METH_VARARGS, nullptr },
        { "register_datagram_socket_async2", reinterpret_cast<PyCFunction>(DnssdServiceInstance_RegisterDatagramSocketAsync2), METH_VARARGS, nullptr },
        { "register_stream_socket_listener_async1", reinterpret_cast<PyCFunction>(DnssdServiceInstance_RegisterStreamSocketListenerAsync1), METH_VARARGS, nullptr },
        { "register_stream_socket_listener_async2", reinterpret_cast<PyCFunction>(DnssdServiceInstance_RegisterStreamSocketListenerAsync2), METH_VARARGS, nullptr },
        { "to_string", reinterpret_cast<PyCFunction>(DnssdServiceInstance_ToString), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_DnssdServiceInstance, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DnssdServiceInstance), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DnssdServiceInstance[] = {
        { "weight", reinterpret_cast<getter>(DnssdServiceInstance_get_Weight), reinterpret_cast<setter>(DnssdServiceInstance_put_Weight), nullptr, nullptr },
        { "priority", reinterpret_cast<getter>(DnssdServiceInstance_get_Priority), reinterpret_cast<setter>(DnssdServiceInstance_put_Priority), nullptr, nullptr },
        { "port", reinterpret_cast<getter>(DnssdServiceInstance_get_Port), reinterpret_cast<setter>(DnssdServiceInstance_put_Port), nullptr, nullptr },
        { "host_name", reinterpret_cast<getter>(DnssdServiceInstance_get_HostName), reinterpret_cast<setter>(DnssdServiceInstance_put_HostName), nullptr, nullptr },
        { "dnssd_service_instance_name", reinterpret_cast<getter>(DnssdServiceInstance_get_DnssdServiceInstanceName), reinterpret_cast<setter>(DnssdServiceInstance_put_DnssdServiceInstanceName), nullptr, nullptr },
        { "text_attributes", reinterpret_cast<getter>(DnssdServiceInstance_get_TextAttributes), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_DnssdServiceInstance[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DnssdServiceInstance) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DnssdServiceInstance) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DnssdServiceInstance) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DnssdServiceInstance) },
        { Py_tp_str, reinterpret_cast<void*>(_str_DnssdServiceInstance) },
        { }};

    static PyType_Spec type_spec_DnssdServiceInstance = {
        "winrt._winrt_windows_networking_servicediscovery_dnssd.DnssdServiceInstance",
        sizeof(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DnssdServiceInstance};

    // ----- DnssdServiceInstanceCollection class --------------------

    static PyObject* _new_DnssdServiceInstanceCollection(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection>::type_name);
        return nullptr;
    }

    static void _dealloc_DnssdServiceInstanceCollection(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DnssdServiceInstanceCollection_First(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstanceCollection", L"First", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.First();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstanceCollection_GetAt(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstanceCollection", L"GetAt", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<uint32_t>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetAt(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstanceCollection_GetMany(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 2)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstanceCollection", L"GetMany", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<uint32_t>(args, 0);
                auto param1 = py::convert_to<py::pybuf_view<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance, true>>(args, 1);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetMany(param0, param1);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstanceCollection_IndexOf(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstanceCollection", L"IndexOf", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance>(args, 0);
                uint32_t param1{};

                auto return_value = [&]()
                {
                    auto _gil = release_gil();
                    return self->obj.IndexOf(param0, param1);
                }();

                py::pyobj_handle out_return_value{ py::convert(return_value) };
                if (!out_return_value)
                {
                    return nullptr;
                }
                py::pyobj_handle out1{ py::convert(param1) };
                if (!out1)
                {
                    return nullptr;
                }

                return PyTuple_Pack(2, out_return_value.get(), out1.get());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceInstanceCollection_get_Size(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceInstanceCollection", L"Size");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Size();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_DnssdServiceInstanceCollection(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_DnssdServiceInstanceCollection(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _iterator_DnssdServiceInstanceCollection(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self) noexcept
    {
        try
        {
            return py::convert([&]()
            {
                auto _gil = py::release_gil();
                return self->obj.First();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static Py_ssize_t _seq_length_DnssdServiceInstanceCollection(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self) noexcept
    {
        try
        {
            auto _gil = py::release_gil();
            return static_cast<Py_ssize_t>(self->obj.Size());
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* _seq_item_DnssdServiceInstanceCollection(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, Py_ssize_t i) noexcept
    {
        try
        {
            return py::convert([&]()
            {
                auto _gil = py::release_gil();
                return self->obj.GetAt(static_cast<uint32_t>(i));
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _seq_subscript_DnssdServiceInstanceCollection(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection* self, PyObject* slice) noexcept
    {
        try
        {
            if (PyIndex_Check(slice))
            {
                pyobj_handle index{PyNumber_Index(slice)};

                if (!index)
                {
                    return nullptr;
                }

                auto i = PyNumber_AsSsize_t(index.get(), PyExc_IndexError);

                if (i == -1 && PyErr_Occurred())
                {
                    return nullptr;
                }

                return _seq_item_DnssdServiceInstanceCollection(self, i);
            }

            if (!PySlice_Check(slice))
            {
                PyErr_Format(PyExc_TypeError, "indices must be integers, not '%s'", Py_TYPE(slice)->tp_name);
            }

            Py_ssize_t start, stop, step, length;

            auto size = [&]()
            {
                auto _gil = py::release_gil();
                return self->obj.Size();
            }();
            if (PySlice_GetIndicesEx(slice, size, &start, &stop, &step, &length) < 0)
            {
                return nullptr;
            }

            if (step != 1)
            {
                PyErr_SetString(PyExc_NotImplementedError, "slices with step other than 1 are not implemented");
                return nullptr;
            }

            winrt::com_array<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance> items(static_cast<uint32_t>(length), empty_instance<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance>::get());

            auto count = [&]()
            {
                auto _gil = py::release_gil();
                return self->obj.GetMany(static_cast<uint32_t>(start), items);
            }();

            if (count != static_cast<uint32_t>(length))
            {
                PyErr_Format(PyExc_RuntimeError, "returned count %d did not match requested length %zd", count, length);
                return nullptr;
            }

            return convert(items);
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DnssdServiceInstanceCollection[] = {
        { "first", reinterpret_cast<PyCFunction>(DnssdServiceInstanceCollection_First), METH_VARARGS, nullptr },
        { "get_at", reinterpret_cast<PyCFunction>(DnssdServiceInstanceCollection_GetAt), METH_VARARGS, nullptr },
        { "get_many", reinterpret_cast<PyCFunction>(DnssdServiceInstanceCollection_GetMany), METH_VARARGS, nullptr },
        { "index_of", reinterpret_cast<PyCFunction>(DnssdServiceInstanceCollection_IndexOf), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_DnssdServiceInstanceCollection, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DnssdServiceInstanceCollection), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DnssdServiceInstanceCollection[] = {
        { "size", reinterpret_cast<getter>(DnssdServiceInstanceCollection_get_Size), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_DnssdServiceInstanceCollection[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DnssdServiceInstanceCollection) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DnssdServiceInstanceCollection) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DnssdServiceInstanceCollection) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DnssdServiceInstanceCollection) },
        { Py_tp_iter, reinterpret_cast<void*>(_iterator_DnssdServiceInstanceCollection) },
        { Py_sq_length, reinterpret_cast<void*>(_seq_length_DnssdServiceInstanceCollection) },
        { Py_sq_item, reinterpret_cast<void*>(_seq_item_DnssdServiceInstanceCollection) },
        { Py_mp_subscript, reinterpret_cast<void*>(_seq_subscript_DnssdServiceInstanceCollection) },
        { }};

    static PyType_Spec type_spec_DnssdServiceInstanceCollection = {
        "winrt._winrt_windows_networking_servicediscovery_dnssd.DnssdServiceInstanceCollection",
        sizeof(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstanceCollection),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DnssdServiceInstanceCollection};

    // ----- DnssdServiceWatcher class --------------------

    static PyObject* _new_DnssdServiceWatcher(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher>::type_name);
        return nullptr;
    }

    static void _dealloc_DnssdServiceWatcher(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DnssdServiceWatcher_Start(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Start", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Start();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_Stop(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Stop", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Stop();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_get_Status(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Status");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Status();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_add_Added(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Added");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher, winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceInstance>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Added(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_remove_Added(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Added");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.Added(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_add_EnumerationCompleted(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"EnumerationCompleted");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher, winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.EnumerationCompleted(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_remove_EnumerationCompleted(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"EnumerationCompleted");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.EnumerationCompleted(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_add_Stopped(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Stopped");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher, winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Stopped(param0);
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* DnssdServiceWatcher_remove_Stopped(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Networking.ServiceDiscovery.Dnssd.DnssdServiceWatcher", L"Stopped");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            {
                auto _gil = release_gil();
                self->obj.Stopped(param0);
            }

            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_DnssdServiceWatcher(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_DnssdServiceWatcher(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DnssdServiceWatcher[] = {
        { "start", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_Start), METH_VARARGS, nullptr },
        { "stop", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_Stop), METH_VARARGS, nullptr },
        { "add_added", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_add_Added), METH_O, nullptr },
        { "remove_added", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_remove_Added), METH_O, nullptr },
        { "add_enumeration_completed", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_add_EnumerationCompleted), METH_O, nullptr },
        { "remove_enumeration_completed", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_remove_EnumerationCompleted), METH_O, nullptr },
        { "add_stopped", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_add_Stopped), METH_O, nullptr },
        { "remove_stopped", reinterpret_cast<PyCFunction>(DnssdServiceWatcher_remove_Stopped), METH_O, nullptr },
        { "_assign_array_", _assign_array_DnssdServiceWatcher, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DnssdServiceWatcher), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DnssdServiceWatcher[] = {
        { "status", reinterpret_cast<getter>(DnssdServiceWatcher_get_Status), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_DnssdServiceWatcher[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DnssdServiceWatcher) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DnssdServiceWatcher) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DnssdServiceWatcher) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DnssdServiceWatcher) },
        { }};

    static PyType_Spec type_spec_DnssdServiceWatcher = {
        "winrt._winrt_windows_networking_servicediscovery_dnssd.DnssdServiceWatcher",
        sizeof(py::wrapper::Windows::Networking::ServiceDiscovery::Dnssd::DnssdServiceWatcher),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DnssdServiceWatcher};

    // ----- Windows.Networking.ServiceDiscovery.Dnssd Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Networking.ServiceDiscovery.Dnssd");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_networking_servicediscovery_dnssd",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Networking::ServiceDiscovery::Dnssd

PyMODINIT_FUNC PyInit__winrt_windows_networking_servicediscovery_dnssd(void) noexcept
{
    using namespace py::cpp::Windows::Networking::ServiceDiscovery::Dnssd;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pytype_handle DnssdRegistrationResult_type{py::register_python_type(module.get(), &type_spec_DnssdRegistrationResult, object_bases.get(), inspectable_meta_type)};
    if (!DnssdRegistrationResult_type)
    {
        return nullptr;
    }

    py::pytype_handle DnssdServiceInstance_type{py::register_python_type(module.get(), &type_spec_DnssdServiceInstance, object_bases.get(), inspectable_meta_type)};
    if (!DnssdServiceInstance_type)
    {
        return nullptr;
    }

    py::pytype_handle DnssdServiceInstanceCollection_type{py::register_python_type(module.get(), &type_spec_DnssdServiceInstanceCollection, object_bases.get(), inspectable_meta_type)};
    if (!DnssdServiceInstanceCollection_type)
    {
        return nullptr;
    }

    py::pytype_handle DnssdServiceWatcher_type{py::register_python_type(module.get(), &type_spec_DnssdServiceWatcher, object_bases.get(), inspectable_meta_type)};
    if (!DnssdServiceWatcher_type)
    {
        return nullptr;
    }


    return module.detach();
}
