IDebugCustomAttributeQuery::IsCustomAttributeDefined
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Determines if the specified custom attribute is defined.
Syntax
HRESULT IsCustomAttributeDefined(
LPCOLESTR pszCustomAttributeName
);
int IsCustomAttributeDefined(
string pszCustomAttributeName
);
Parameters
pszCustomAttributeName
[in] Name of the custom attribute.
Return Value
If the custom attribute is defined, returns S_OK
; otherwise, returns S_FALSE
.
Example
The following example shows how to implement this method for a CDebugClassFieldSymbol object that exposes the IDebugCustomAttributeQuery interface.
HRESULT CDebugClassFieldSymbol::IsCustomAttributeDefined(
LPCOLESTR pszCustomAttribute
)
{
HRESULT hr = S_FALSE;
CComPtr<IMetaDataImport> pMetadata;
mdToken token = mdTokenNil;
CComPtr<IDebugField> pField;
CComPtr<IDebugCustomAttributeQuery> pCA;
ASSERT(IsValidWideStringPtr(pszCustomAttribute));
METHOD_ENTRY( CDebugClassFieldSymbol::IsCustomAttributeDefined );
IfFalseGo( pszCustomAttribute, E_INVALIDARG );
IfFailGo( m_spSH->GetMetadata( m_spAddress->GetModule(), &pMetadata ) );
IfFailGo( CDebugCustomAttribute::GetTokenFromAddress( m_spAddress, &token) );
IfFailGo( pMetadata->GetCustomAttributeByName( token,
pszCustomAttribute,
NULL,
NULL ) );
Error:
METHOD_EXIT( CDebugClassFieldSymbol::IsCustomAttributeDefined, hr );
if (hr != S_OK)
{
hr = S_FALSE;
}
return hr;
}