Freigeben über


Source.CommentSpan Method

Comments out the specified span of source.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaration
Public Overridable Function CommentSpan ( _
    span As TextSpan _
) As TextSpan
public virtual TextSpan CommentSpan(
    TextSpan span
)
public:
virtual TextSpan CommentSpan(
    TextSpan span
)
abstract CommentSpan : 
        span:TextSpan -> TextSpan  
override CommentSpan : 
        span:TextSpan -> TextSpan
public function CommentSpan(
    span : TextSpan
) : TextSpan

Parameters

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.

Remarks

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.

.NET Framework Security

See Also

Reference

Source Class

Microsoft.VisualStudio.Package Namespace

Other Resources

Commenting Code (Managed Package Framework)