0
VB 헤더 파일에 저작권 헤더를 추가했지만 불행히도 예상대로 작동하지 않습니다.Visual Studio 매크로에 도움이 필요합니다.
다음은 매크로
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module CopyrightCode
Sub AddCopyrightHeader()
Dim doc As Document
Dim docName As String
Dim companyName As String = "My Company"
Dim authorName As String = "rockinthesixstring"
Dim authorEmail As String = "[email protected]"
Dim copyrightText As String = "All code is Copyright © " & vbCrLf & _
"' - My Exceptional Company (http://example.com)" & vbCrLf & _
"' All Rights Reserved"
' Get the name of this object from the file name
doc = DTE.ActiveDocument
' Get the name of the current document
docName = doc.Name
' Set selection to top of document
DTE.ActiveDocument.Selection.StartOfDocument()
DTE.ActiveDocument.Selection.NewLine()
Dim sb As New StringBuilder
sb.Append("' --------------------------------")
sb.Append(vbCrLf)
sb.Append("' <copyright file=""" & docName & """ company=""" & companyName & """>")
sb.Append(vbCrLf)
sb.Append(copyrightText)
sb.Append(vbCrLf)
sb.Append("' </copyright>")
sb.Append(vbCrLf)
sb.Append("' <author>" & authorName & "</author>")
sb.Append(vbCrLf)
sb.Append("' <email>" & authorEmail & "</email>")
sb.Append(vbCrLf)
sb.Append("' <date>" & FormatDateTime(Date.Now, vbLongDate) & "</date>")
sb.Append(vbCrLf)
sb.Append("' ---------------------------------")
' Write first line
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text = sb.ToString
End Sub
End Module
이다하지만 내가 수동으로 제거 가야 삽입의 끝에서 FOUR 인용 부호를 추가하는 것하는 문제입니다. 이 따옴표는 어디에서 오는가?
' --------------------------------
' <copyright file="MyFile.vb" company="My Company">
' All code is Copyright ©
' - My Exceptional Company (http://example.com)
' All Rights Reserved
' </copyright>
' <author>rockinthesixstring</author>
' <email>[email protected]</email>
' <date>Monday, July 05, 2010</date>
' ---------------------------------
""""
그러나 작은 따옴표를 사용하면 모두 좋습니다.
sb.Append("' <copyright file='" & docName & "' company='" & companyName & "'>")
파일에서 "실행 취소"를 통해 뒤로 이동하면 따옴표가'' –
에 작성되므로 "빌드"됩니다. 인용문이 파일에 쓰여질 때, 초가 쓰여집니다. –
어떤 종류의 Resharper 스타일의 도구가 자동으로 두 번째 "처음 입력 할 때? –