Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio Visual Studio宏需要帮助_Visual Studio_Macros - Fatal编程技术网

Visual studio Visual Studio宏需要帮助

Visual studio Visual Studio宏需要帮助,visual-studio,macros,Visual Studio,Macros,我有一个宏,它将版权头添加到我的VB文件中,但不幸的是,它的行为并不像预期的那样 这是宏 Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports EnvDTE90a Imports EnvDTE100 Imports System.Diagnostics Public Module CopyrightCode Sub AddCopyrightHeader() Dim doc As

我有一个宏,它将版权头添加到我的VB文件中,但不幸的是,它的行为并不像预期的那样

这是宏

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 = "rockinthesixstring@example.com"
        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
导入系统
进口环境
进口环境80
进口EnvDTE90
进口EnvDTE90a
进口环境数据100
导入系统。诊断
公共模块版权代码
子地址头()
将文档变为文档
将docName设置为字符串
Dim companyName As String=“我的公司”
Dim authorName As String=“RocktheSixstring”
将authorEmail设置为字符串=”rockinthesixstring@example.com"
将版权文本标注为String=“所有代码均受版权保护”&vbCrLf&_
“——我卓越的公司(http://example.com)“&vbCrLf&_
“保留所有权利”
'从文件名中获取此对象的名称
doc=DTE.ActiveDocument
'获取当前文档的名称
docName=doc.Name
'将所选内容设置为文档顶部
DTE.ActiveDocument.Selection.StartOfDocument()
DTE.ActiveDocument.Selection.NewLine()
使某人成为新的架线工
某人加上(“-------------------------------------”)
某人附加(vbCrLf)
某人加上(“”)
某人附加(vbCrLf)
某人附加(正文)
某人附加(vbCrLf)
某人加上(“”)
某人附加(vbCrLf)
sb.追加(“'”和authorName&”)
某人附加(vbCrLf)
sb.追加(“'”和authorEmail&“”
某人附加(vbCrLf)
sb.追加(“'”和FormatDateTime(Date.Now,vbLongDate)和“”)
某人附加(vbCrLf)
某人加上(“-------------------------------------”)
“写第一行
DTE.ActiveDocument.Selection.LineUp()
DTE.ActiveDocument.Selection.Text=sb.ToString
端接头
端模块
但问题是,它在插入的末尾添加了四个引号,我必须手动删除。这些引号来自哪里

' --------------------------------  
' <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>rockinthesixstring@example.com</email>  
' <date>Monday, July 05, 2010</date>  
' ---------------------------------   
""""  
”-------------------------------------
'   
“所有代码都是版权所有的©
“-我的特殊公司(http://example.com) 
“保留所有权利
'   
“摇摆的弦
' rockinthesixstring@example.com  
“2010年7月5日,星期一
' ---------------------------------   
""""  
然而,如果我使用单引号,这一切都很好

    sb.Append("' <copyright file='" & docName & "' company='" & companyName & "'>")
sb.Append(“”)

无需复制,它们不是来自宏。考虑某种VisualStudioAddion作为问题的来源。

如果我在文件中向后“撤消”,它们开始“构建”,因为引用是在<代码> <代码>上写入的,所以每次向文件写入引用时,第二个也是这样写的。某种类型的重竖琴风格的工具,当你键入第一个时会自动添加第二个?啊,就是这样…重竖琴。当。好的,我会在这一个上使用单引号。