| CreateProperty Add-In |
| Wednesday, November 17 2004 |
|
A few days ago I posted about writing properties. I got a couple interesting and thought provoking comments from Dennis Webb about how it would be nice if:
- We didn't have to declare private member variables for properties, essentially saying let the compiler determine that one is needed and inject it into the IL where appropriate, or
- If that's not possible, have the IDE auto-generate the private member variables for us
Of course, this got me thinking and since I can't do much about #1, I can do something to address #2. I've been wanting to play around with creating an add-in for Visual Studio anyway, and this gave me the right opportunity to do that. So I spent a few hours and built an add-in named “CreateProperty Add-In” for Visual Studio .NET 2003.
The add-in will auto-generate properties for you and if you'd like, it's private member variable as well. It works for VB.NET and C#, so give it a try and let me know what you think. The download is free and comes with all source code.
Even if this isn't a huge benefit to people, it was *fun* to go through the exercise of building the add-in. I learned some things along the way that I'll post soon because building an add-in is a different beast.

9 comment(s) so far
Great little utility. I definitely will be using it. However, my VS seems to autocomplete the Property text and I end up with two copies of gets and sets. Have you seen this? - kdjones74@hotmail.com
Good work!
Thanks Dave! You Rock! I will be using this utility as well. I will also let the other developers where I work know about it.
Yet another example of the power of blogging...
Dave -- my bad. My previous comment covered an issue that you documented in the readme. Cool utility.
Nice utility. I was thinking how great it would be if I could define my member variables, highlight those then run the CreateProperty utility which would generate the Properties from the member variable definitions selected.
However the tool as it stands is pretty good, just one small annoyance:
If I choose to auto-generate the member variable for a property I have to explicitly give the member variable a name, or it will defaut to m_Property1 for example. It would be much better if it defaulted to something like m_<property name>.
Regards,
Joe.
Joe - thanks for the comment. The annoyance you mention is something I've been meaning to fix, but just haven't gotten around to yet. Now that I know more than a couple people are using it, I'll try to get it taken care of.
It's cool.
I have already read
the url is broken, can you please fix the link?
thanks!