IDebugCustomAttributeQuery::GetCustomAttributeByName
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. 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
Retrieves a custom attribute given its name.
Syntax
HRESULT GetCustomAttributeByName(
LPCOLESTR pszCustomAttributeName,
BYTE* ppBlob,
DWORD* pdwLen
);
int GetCustomAttributeByName(
string pszCustomAttributeName,
ref int[] ppBlob,
out uint pdwLen
);
Parameters
pszCustomAttributeName
[in] Name of the custom attribute.
ppBlob
[in,out] Array of bytes that contain the custom attribute data.
pdwLen
[out] Length in bytes of the ppBlob
parameter.
Return Value
If successful, returns S_OK
. If custom attribute does not exist, returns S_FALSE
. Otherwise, returns an error code.
Example
The following example shows how to implement this method for a CDebugClassFieldSymbol object that exposes the IDebugCustomAttributeQuery interface.
HRESULT CDebugClassFieldSymbol::GetCustomAttributeByName(
LPCOLESTR pszCustomAttributeName,
BYTE *pBlob,
DWORD *pdwLen
)
{
HRESULT hr = S_FALSE;
CComPtr<IMetaDataImport> pMetadata;
mdToken token = mdTokenNil;
CComPtr<IDebugField> pField;
CComPtr<IDebugCustomAttributeQuery> pCA;
ASSERT(IsValidWideStringPtr(pszCustomAttributeName));
ASSERT(IsValidWritePtr(pdwLen, ULONG*));
METHOD_ENTRY( CDebugClassFieldSymbol::GetCustomAttributeByName );
IfFalseGo( pszCustomAttributeName && pdwLen, E_INVALIDARG );
IfFailGo( m_spSH->GetMetadata( m_spAddress->GetModule(), &pMetadata ) );
IfFailGo( CDebugCustomAttribute::GetTokenFromAddress( m_spAddress, &token) );
IfFailGo( CDebugCustomAttribute::GetCustomAttributeByName( pMetadata,
token,
pszCustomAttributeName,
pBlob,
pdwLen ) );
Error:
METHOD_EXIT( CDebugClassFieldSymbol::GetCustomAttributeByName, hr );
return hr;
}