Visual Studio에서 자동 주석 달기 텍스트를 어떻게 사용자 지정하나요?
-
06-07-2019 - |
문제
Visual Studio에서 "'''" 또는 "///"를 입력하여 자동 주석 기능을 트리거하면 내가 좋아하는 대부분의 XML 주석 세부 정보가 표시됩니다.그러나 나는 일반적으로 문서에 기록 태그를 추가하여 시간이 지남에 따라 메서드에 적용된 변경 사항을 추적하고 변경할 수 있습니다.
기록 태그와 잠재적으로 일부 일반 이름 - 날짜 - 자리 표시자 텍스트 변경을 추가하도록 자동 주석 달기 기능을 사용자 정의할 수 있는 방법이 있습니까?
해결책
사용하는 것이 좋습니다 고스트 돔. 메소드 이름과 매개 변수를 기반으로 ///를 사용하여 매우 현명한 주석을 생성합니다. 또한 완전히 사용자 정의 할 수 있습니다.
다른 팁
dgarcia가 말한 대로 도구를 사용할 수 있다고 생각하지만 버전 제어를 삽입하는 도구를 선택해 보십시오. 개인적으로 저는 코드의 주석을 사용하여 프로젝트의 "역사"를 추적하거나 추적하는 것을 별로 좋아하지 않습니다.
이 방식이 마음에 든다면 스니펫의 사용자 정의 버전을 만들 수 있습니다. 다음과 같은 도구를 사용하면 더 쉽습니다. 날카로운
이 파일을 복사하세요 너의 ~에게
내 문서\Visual Studio 2005\코드 조각[언어]\내 코드 조각\
VB.NET에서 사용하려면 파일을 변경하는 데 주의하세요.
이 도움을 바랍니다
Olivier에 대한 의견에 대한 후속 조치. 다음은 매크로의 사본입니다.``Do History Section을 찾으려면 코드를 삽입 한 위치를 찾으십시오.
''// InsertDocComments goes through the current document using the VS Code Model
''// to add documentation style comments to each function.
''
Sub InsertDocComments()
Dim projectItem As ProjectItem
Dim fileCodeModel As FileCodeModel
Dim codeElement As CodeElement
Dim codeElementType As CodeType
Dim editPoint As EditPoint
Dim commentStart As String
projectItem = DTE.ActiveDocument.ProjectItem
fileCodeModel = projectItem.FileCodeModel
codeElement = fileCodeModel.CodeElements.Item(1)
''// For the sample, don't bother recursively descending all code like
''// the OutlineCode sample does. Just get a first CodeType in the
''// file.
If (TypeOf codeElement Is CodeNamespace) Then
codeElement = codeElement.members.item(1)
End If
If (TypeOf codeElement Is CodeType) Then
codeElementType = CType(codeElement, CodeType)
Else
Throw New Exception("Didn't find a type definition as first thing in file or find a namespace as the first thing with a type inside the namespace.")
End If
editPoint = codeElementType.GetStartPoint(vsCMPart.vsCMPartHeader).CreateEditPoint()
''// Make doc comment start.
commentStart = LineOrientedCommentStart()
If (commentStart.Length = 2) Then
commentStart = commentStart & commentStart.Chars(1) & " "
ElseIf (commentStart.Length = 1) Then
commentStart = commentStart & commentStart.Chars(0) & commentStart.Chars(0) & " "
End If
''// Make this atomically undo'able. Use Try...Finally to ensure Undo
''// Context is close.
Try
DTE.UndoContext.Open("Insert Doc Comments")
''// Iterate over code elements emitting doc comments for functions.
For Each codeElement In codeElementType.Members
If (codeElement.Kind = vsCMElement.vsCMElementFunction) Then
''// Get Params.
Dim parameters As CodeElements
Dim codeFunction As CodeFunction
Dim codeElement2 As CodeElement
Dim codeParameter As CodeParameter
codeFunction = codeElement
editPoint.MoveToPoint(codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader))
''//editPoint.LineUp()
parameters = codeFunction.Parameters
''// Do comment.
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.LineUp()
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "<summary>")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "Summary of " & codeElement.Name & ".")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "</summary>")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart)
For Each codeElement2 In parameters
codeParameter = codeElement2
editPoint.Insert("<param name=" & codeParameter.Name & "></param>")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart)
Next ''//param
''// Do history tag.
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.LineUp()
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "<history>")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "Name MM/DD/YYYY [Created]")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart & "</history>")
editPoint.Insert(Microsoft.VisualBasic.Constants.vbCrLf)
editPoint.Insert(Microsoft.VisualBasic.Constants.vbTab & commentStart)
End If ''//we have a function
Next ''//code elt member
Finally
DTE.UndoContext.Close()
End Try
End Sub
어떤 이유로 든, 저장, 재건 및 비주얼 스튜디오를 다시 시작한 후에는 히스토리 태그를 얻지 못합니다. 아무도 내가 여기서 뭔가를 볼 수 있습니까?
VB는 XML 파일을 사용하여 DeFults를로드합니다. VBXMLDOC.XML이며 파일 위치에 대해 실행중인 버전에 따라 다릅니다.