Results 1 to 16 of 16

Thread: [RESOLVED] VS 2010 Property annoyance

  1. #1

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Resolved [RESOLVED] VS 2010 Property annoyance

    I don't know if it's a bug or something but in VS 2010 Beta 2 if you're working on a class and you type in:
    Code:
    Friend Property SomeThing As SomeType
    and press enter, it doesn't add the rest of the code snippet. It's extremely annoying and I hope they fix it before it's released.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VS 2010 Property annoyance

    carp.... that's not good... but I think that's by design... part of the "magic properties" that was added to VB in the last go around. It will create a Get/Set and a private member behind the scenes for you.

    I don't have VB2010 in front of me, but try this: type in "Friend Property" then press the tab key... I'm hoping that at least will still give you the Property code snippet that it used to.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: VS 2010 Property annoyance

    That's an auto implemented property. C# has had it for a while, VB.NET finally gets it. Not a bug, new feature.

    public string Blah { get; set; }

    This is actually good practice. When you declare a property, you should be using the property rather than its inner field member in the class code. Another reason it's around is because it's common to create a public property with an inner member that doesn't do anything but return/set.

  4. #4

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: VS 2010 Property annoyance

    So, say I have a Class that has a Name property (type String, obviously) in VS 2008 I would do:
    Code:
    Friend Class myClass
    
      Private mName As String
    
      Friend Sub New(ByVal Name As String)
        mName = Name
      End Sub
    
      Friend Property Name() As String
        Get
          Return mName
        End Get
        Set (Value As String)
          mName = Value
        End Set
      End Property
    
      Public Overrides Function ToString() As String
        Return mName
      End Function
    
    End Class
    If VS 2010 has this new feature, could I just do this:
    Code:
    Friend Class myClass
    
      Friend Sub New(ByVal Name As String)
        me.Name = Name
      End Sub
    
      Friend Property Name() As String
    
      Public Overrides Function ToString() As String
        Return Me.Name
      End Function
    
    End Class
    ?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: VS 2010 Property annoyance

    Quote Originally Posted by mendhak View Post
    That's an auto implemented property. C# has had it for a while, VB.NET finally gets it. Not a bug, new feature...
    The feature is not new - it was available in 2005 and 2008 at least (don't have 2003 to verify).
    When you type what OP suggested and hit the enter key the "auto complete" will finish the job and this is what you'll get:
    Code:
        Friend Property abc() As String
            Get
    
            End Get
            Set(ByVal value As String)
    
            End Set
        End Property
    If 2010 doesn't do that I would report it as a bug.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VS 2010 Property annoyance

    no, it is a new feature.... as mendhak pointed out, C# has had this, but VB didn't... with VS2010, it now does. The auto complete feature you mentioned RB, has been around for sometime, and it presumably what JB was expecting. You should still be able to get that with typing property and hitting the tab key, which should insert the property code snippet. But the previous auto code stubbing when pressing enter.... I don't think exists any more.... which is going to drive people nuts.

    I'll have to double check this when I get home.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VS 2010 Property annoyance

    Just tried this out... it's not a bug... it's a feature. It allows you to easily create properties for your object with minimal coding. If you want a full property stub, then type property hit tab a couple times, and the snippet is added.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: VS 2010 Property annoyance

    Ok, so this new feature is something I'll have to get used to then. I can see the benefit of it being set up that way, but it still counters what VS 2005 and VS 2008 do, both of which I'll be heavily using for the next 5 years. It's almost a shame that I rarely write a property for a class that has no validation in the setter or code in the get so this VS 2010 "feature" does me very little good
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VS 2010 Property annoyance

    I'm the other way around... I tend to use simple properties, with only the occasional completx property that requires validation or other stuff, so for me, it is a feature. I tried to look around the options, to see if there was a way to switch it off.... no luck.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: VS 2010 Property annoyance

    Quote Originally Posted by RhinoBull View Post
    The feature is not new - it was available in 2005 and 2008 at least (don't have 2003 to verify).
    When you type what OP suggested and hit the enter key the "auto complete" will finish the job and this is what you'll get:
    Code:
        Friend Property abc() As String
            Get
    
            End Get
            Set(ByVal value As String)
    
            End Set
        End Property
    If 2010 doesn't do that I would report it as a bug.
    That's an auto-complete feature of the IDE.

    Auto-implemented properties are a feature of the language.

  11. #11

  12. #12
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: VS 2010 Property annoyance

    Quote Originally Posted by techgnome View Post
    I'm the other way around... I tend to use simple properties, with only the occasional completx property that requires validation or other stuff, so for me, it is a feature. I tried to look around the options, to see if there was a way to switch it off.... no luck.

    -tg
    If JuggaloBrotha really wants it, he could create his own property snippet and just use that instead of the built in one.

  13. #13
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: VS 2010 Property annoyance

    I think there is one already. Type prop, then tab tab.

  14. #14
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: VS 2010 Property annoyance

    Is it not propa for a full property?

    I know there is a snippit for both in c#

  15. #15

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: VS 2010 Property annoyance

    Granted the property snippet helps, the thing with the default one is that it creates an internal variable and gives it a scope of Public whereas I already have the variable (all class level vars are at the top of the file) and since I'm used to typing the scope level before accessing the property, it ends up being more typing than it's worth. When I get around to making my own snippet that works like VS 2005/2008 I'll post it here for anyone else who'd like to use it too.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  16. #16
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: VS 2010 Property annoyance

    I saw a video a while back about this, and I'm pretty sure they showed how you could 'convert' an auto-implemented property to the normal ('old style') properties without having to retype it. I don't remember how they did it though... I must be completely wrong, but something tells me it was simply pressing Enter (possibly tab?) after the auto-implemented property and it would add the getter and setter after all, but apparently not...?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width