diff options
author | Aaron Robinson <arobins@microsoft.com> | 2019-03-07 12:19:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-07 12:19:53 -0800 |
commit | 8b3c55c36531689c337df37f15eb5a40530fa42f (patch) | |
tree | c7e4c4954b6b461b3ecdb1e5f8e87a2f330ca33c /src/vm/comcallablewrapper.cpp | |
parent | f6cc0134fa4bb0d2f329ebc18c4eb662a5a5d973 (diff) | |
download | coreclr-8b3c55c36531689c337df37f15eb5a40530fa42f.tar.gz coreclr-8b3c55c36531689c337df37f15eb5a40530fa42f.tar.bz2 coreclr-8b3c55c36531689c337df37f15eb5a40530fa42f.zip |
Update error message for when a parent is marked as COMVisible(false) (#23092)
* Update message to include type and parent type marked as COMVisible(false)
Diffstat (limited to 'src/vm/comcallablewrapper.cpp')
-rw-r--r-- | src/vm/comcallablewrapper.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/vm/comcallablewrapper.cpp b/src/vm/comcallablewrapper.cpp index 415cfa8232..ec05f00cd3 100644 --- a/src/vm/comcallablewrapper.cpp +++ b/src/vm/comcallablewrapper.cpp @@ -5305,7 +5305,16 @@ void ComCallWrapperTemplate::CheckParentComVisibility(BOOL fForIDispatch) // Throw an exception to report the error. if (!CheckParentComVisibilityNoThrow(fForIDispatch)) - COMPlusThrow(kInvalidOperationException, IDS_EE_COM_INVISIBLE_PARENT); + { + ComCallWrapperTemplate *invisParent = FindInvisibleParent(); + _ASSERTE(invisParent != NULL); + + SString thisType; + SString invisParentType; + TypeString::AppendType(thisType, m_thClass); + TypeString::AppendType(invisParentType, invisParent->m_thClass); + COMPlusThrow(kInvalidOperationException, IDS_EE_COM_INVISIBLE_PARENT, thisType.GetUnicode(), invisParentType.GetUnicode()); + } } BOOL ComCallWrapperTemplate::CheckParentComVisibilityNoThrow(BOOL fForIDispatch) @@ -6173,20 +6182,36 @@ void ComCallWrapperTemplate::DetermineComVisibility() m_flags &= (~enum_InvisibleParent); - // If there are no parents...leave it as false. if (m_pParent == NULL) return; - // If our parent has an invisible parent - if (m_pParent->HasInvisibleParent()) + // Check if the parent has an invisible parent + // or if the parent itself is invisible. + if (m_pParent->HasInvisibleParent() + || !IsTypeVisibleFromCom(m_pParent->m_thClass)) { + _ASSERTE(NULL != FindInvisibleParent()); m_flags |= enum_InvisibleParent; } - // If our parent is invisible - else if (!IsTypeVisibleFromCom(m_pParent->m_thClass)) +} + +ComCallWrapperTemplate* ComCallWrapperTemplate::FindInvisibleParent() +{ + ComCallWrapperTemplate* invisParentMaybe = m_pParent; + + // Walk up the CCW parent classes and try to find + // if one is invisible to COM. + while (invisParentMaybe != NULL) { - m_flags |= enum_InvisibleParent; + // If our parent is invisible, return it. + if (!IsTypeVisibleFromCom(invisParentMaybe->m_thClass)) + return invisParentMaybe; + + invisParentMaybe = invisParentMaybe->m_pParent; } + + // All classes in hierarchy are COM visible + return NULL; } //-------------------------------------------------------------------------- |