Condividi tramite


IVsTextLines.GetMarkerData(Int32, Int32, MARKERDATA[]) Method

Definition

Returns text marker data for the specified line range within the text buffer.

public:
 int GetMarkerData(int iTopLine, int iBottomLine, cli::array <Microsoft::VisualStudio::TextManager::Interop::MARKERDATA> ^ pMarkerData);
int GetMarkerData(int iTopLine, int iBottomLine, std::Array <Microsoft::VisualStudio::TextManager::Interop::MARKERDATA> const & pMarkerData);
public int GetMarkerData (int iTopLine, int iBottomLine, Microsoft.VisualStudio.TextManager.Interop.MARKERDATA[] pMarkerData);
abstract member GetMarkerData : int * int * Microsoft.VisualStudio.TextManager.Interop.MARKERDATA[] -> int
Public Function GetMarkerData (iTopLine As Integer, iBottomLine As Integer, pMarkerData As MARKERDATA()) As Integer

Parameters

iTopLine
Int32

[in] Top line of the marker data.

iBottomLine
Int32

[in] Bottom line of the marker data.

pMarkerData
MARKERDATA[]

[out] Pointer to filled MARKERDATA structure for the range indicated.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsTextLines::GetMarkerData(  
   [in] long iTopLine,  
   [in] long iBottomLine,  
   [out] MARKERDATA *pMarkerData  
);  

Use this method with GetLineData to determine the marker data for a given range in the text buffer. After you call IVsTextLines.GetMarkerData, you then need to call ReleaseMarkerData to allow the text buffer to clean up the MARKERDATA structure.

GetMarkerData in Managed Code

GetMarkerData can cause problems in managed code. The GetMarkerData implementation that you do not Release the pLayer member. Thus, it does not perform an AddRef on the interface. There is no problem in native C++ so long as you do not call Release In managed code you cannot control when a Release is done. To be safe, you should do an AddRef on the pLayer member after GetMarkerData fills in the data structure. The simplest way to do this is with GetIUnknownForObject:

[C#]

MARKERDATA[] markerData = new MARKERDATA[1];  
markerData[0] = new Microsoft.VisualStudio.TextManager.Interop.MARKERDATA();  
buffer.GetMarkerData(line, line, markerData);  
IntPtr dummyAddRef = Marshal.GetIUnknownForObject(markerData[0].pLayer);  

Applies to