VB.NET 2K8: How to make all imports visible inside a class?

In general, the general VB.NET class should look like this:

Public Class MyClassName End Class 

Also, I have already seen, if I remember correctly, all import statements are displayed in the same way as in C #:

 Imports System Imports System.Data Imports System.Linq Public Class MyClassName End Class 

How to make default imports visible by default in VB.NET using Visual Studio 2008?

Is there any parameter or similar in the settings that I have to set?

Thanks! =)

+4
source share
3 answers
Good question. The VB.NET Language specification only mentions โ€œimplicit importโ€ without providing an authoritative list. I can reverse engineer it from the command line, as shown in the output window, VS2008 and VS2010 use this option / Import command line:
  • Microsoft.VisualBasic,
  • System,
  • System.Collections,
  • System.Collections.Generic,
  • System.Data,
  • System.Diagnostics,
  • System.Linq,
  • System.Xml.Linq

MSBuild sets them to Microsoft.VisualBasic.targets from the Import variable. Which is installed in the .vbproj file:

  <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> <Import Include="System.Collections" /> <Import Include="System.Collections.Generic" /> <Import Include="System.Data" /> <Import Include="System.Diagnostics" /> <Import Include="System.Linq" /> <Import Include="System.Xml.Linq" /> </ItemGroup> 

Changing the Project + Reference parameter changes this list, but there is no obvious one-to-one correspondence, since this screen changes assembly references, the <Import> variable contains a list of namespaces. I will have to kick, this is ultimately determined by the project template.

+4
source

Right-click on the project in Visual Studio, then go to Properties. The Links tab has a list of imported namespaces below. Everything added there does not need to be imported for any file in the project.

So, to see those that are defaulted, you can just look there. :)

+4
source

I think you are thinking: "Imports xxlibnamexx"

And as far as I know, if they are not in the text source file, they can be just system-related elements that are essentially imported.

+2
source

Source: https://habr.com/ru/post/1341012/


All Articles