Source::CommentSpan Method (TextSpan)

 

Comments out the specified span of source.

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public:
virtual TextSpan CommentSpan(
	TextSpan span
)

Parameters

span
Type: Microsoft.VisualStudio.TextManager.Interop::TextSpan

A TextSpan object describing the span of source to comment out.

Return Value

Type: Microsoft.VisualStudio.TextManager.Interop::TextSpan

A new TextSpan object encompassing the entire commented out span, including any comment start and end strings.

This method determines how best to comment out the span by deciding between line and block comments, and then calls the CommentBlock or CommentLines methods on the span. Call the GetCommentFormat method to obtain the strings that define a comment.

The base method calls the GetCommentFormat method, and then calls the CommentLines method if the line comment string is specified; otherwise, calls the CommentBlock method if the block comment strings are specified. Note that this approach always uses line comments if both line comment and block comment strings are specified -- even when commenting out a block of text.

This method is typically called in response to the user selecting the command Comment Selection from the Advanced menu on the Edit menu.

See Commenting Code (Managed Package Framework) for more information on this method is used.

Return to top
Show: