Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. VS 2008 and "using" in a new class

VS 2008 and "using" in a new class

Scheduled Pinned Locked Moved Visual Studio
csharpvisual-studiolinqquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vodstok
    wrote on last edited by
    #1

    This should hopefully be pretty straight forward: Is there a way to configure VS 2008 so that whenever I add a new class file, i can customise the "using" declarations at the top automatically? For instance, I have a project where literally every class has this: "using System.Data.Linq;". Can i configure VS to add that by default when i create a file, just like it already adds "using System;"? I know its not hard at all to add them manually every time, but it is annoying sometimes to do a lengthy build only to find i forgot to add a declaration and have to wait for it to build over again. Thank you :)

    ______________________ Oh Hamburgers!

    K 1 Reply Last reply
    0
    • V Vodstok

      This should hopefully be pretty straight forward: Is there a way to configure VS 2008 so that whenever I add a new class file, i can customise the "using" declarations at the top automatically? For instance, I have a project where literally every class has this: "using System.Data.Linq;". Can i configure VS to add that by default when i create a file, just like it already adds "using System;"? I know its not hard at all to add them manually every time, but it is annoying sometimes to do a lengthy build only to find i forgot to add a declaration and have to wait for it to build over again. Thank you :)

      ______________________ Oh Hamburgers!

      K Offline
      K Offline
      Kevin McFarlane
      wrote on last edited by
      #2

      Vodstok wrote:

      but it is annoying sometimes to do a lengthy build only to find i forgot to add a declaration and have to wait for it to build over again.

      Are you using VS 2008 SP1? Does C#'s auto-syntax errors feature pick up missing usings? BTW, you can insert usings as you type using the smart tag (Alt+Shift+F10). That helps to keep the missing usings to a minimum.

      Kevin

      M 1 Reply Last reply
      0
      • K Kevin McFarlane

        Vodstok wrote:

        but it is annoying sometimes to do a lengthy build only to find i forgot to add a declaration and have to wait for it to build over again.

        Are you using VS 2008 SP1? Does C#'s auto-syntax errors feature pick up missing usings? BTW, you can insert usings as you type using the smart tag (Alt+Shift+F10). That helps to keep the missing usings to a minimum.

        Kevin

        M Offline
        M Offline
        MrSymo
        wrote on last edited by
        #3

        This has not answered the question. The OP is asking if we can customise what default usings get set for a new class when it is created. I would also like to know this as we also don't use linq!

        K 1 Reply Last reply
        0
        • M MrSymo

          This has not answered the question. The OP is asking if we can customise what default usings get set for a new class when it is created. I would also like to know this as we also don't use linq!

          K Offline
          K Offline
          Kevin McFarlane
          wrote on last edited by
          #4

          It can't be customised as far as I know. But I was suggesting a workaround. If C# 2008 SP1 does add the red squigglies then at least you can spot the missing usings as you're going along and invoke them using that keyboard shortcut. I don't know if third party tools such as Resharper can add in missing usings.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups