|
-
Nov 30th, 2009, 12:41 PM
#1
[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.
-
Nov 30th, 2009, 12:57 PM
#2
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
-
Nov 30th, 2009, 02:43 PM
#3
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.
-
Nov 30th, 2009, 02:56 PM
#4
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
?
-
Nov 30th, 2009, 03:03 PM
#5
Re: VS 2010 Property annoyance
 Originally Posted by mendhak
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.
-
Nov 30th, 2009, 04:17 PM
#6
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
-
Nov 30th, 2009, 08:45 PM
#7
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
-
Nov 30th, 2009, 09:34 PM
#8
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
-
Nov 30th, 2009, 10:16 PM
#9
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
-
Dec 1st, 2009, 03:24 AM
#10
Re: VS 2010 Property annoyance
 Originally Posted by RhinoBull
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.
-
Dec 1st, 2009, 11:13 AM
#11
Re: VS 2010 Property annoyance
Ah, I stand corrected - you are absolutely right and I should've paid a bit more attention.
Thanks.
-
Dec 8th, 2009, 11:45 PM
#12
Re: VS 2010 Property annoyance
 Originally Posted by techgnome
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.
-
Dec 10th, 2009, 04:24 PM
#13
Re: VS 2010 Property annoyance
I think there is one already. Type prop, then tab tab.
-
Dec 13th, 2009, 04:05 PM
#14
Frenzied Member
Re: VS 2010 Property annoyance
Is it not propa for a full property?
I know there is a snippit for both in c#
-
Dec 13th, 2009, 06:38 PM
#15
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.
-
Dec 15th, 2009, 05:18 AM
#16
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|