简体   繁体   English

VB.NET在实现接口时调整自动生成的代码

[英]VB.NET adjust auto generated code when implementing interface

When pressing enter after Implements IInterface Visual Studio generates the code for implementing all methods, properties etc. So far, so good... My 'problem' is that it inserts too much code: Implements IInterface后按Enter Implements IInterface Visual Studio会生成实现所有方法,属性等的代码。到目前为止,很好......我的“问题”是它插入了太多代码:

Public Class A
    Implements IList(Of String)

    Public Sub Add(item As String) Implements System.Collections.Generic.ICollection(Of String).Add

    End Sub

    ...

End Class

I would like VS to realise that I have an Import System.Collections.Generic at the top of the file and that it can thus ommit the namespaces. 我想VS知道我在文件顶部有一个Import System.Collections.Generic ,因此可以省略命名空间。

In the above example, System.Collections.Generic.ICollection(Of String).Add should only be ICollection(Of String).Add . 在上面的例子中, System.Collections.Generic.ICollection(Of String).Add应该只是ICollection(Of String).Add

How can this behavior be achieved? 如何实现这种行为?

Update: What have you tried? 更新:你有什么尝试?
Nothing. 没有。 I have no idea where to start looking and all my google searches come up empty. 我不知道从哪里开始查看,所有我的谷歌搜索都是空的。

尝试安装Roslyn预览版(可从http://roslyn.codeplex.com获取 )我相信它应该足够聪明,不要包含额外的命名空间信息,或者立即调出QuickFix选项来删除无关代码的所有实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM