Re: Is it possible to override a class?
The find/replace method is OK but Resharper can go one better. Consider these three instantiations ofButton _button1 = new System.Windows.Forms.Button(); _button2 = new Button(); _button3 = new DumbAlias.Button(); So its likely you'll find all instances declared like_button1. If you remember you'll look for instances like_button2. It's likely you'll miss_button3. Use Resharper to find them all in one go.Resharper - Find - Search With Pattern Then enter the following pattern Click Find and you should see Now if that doesn't excite you what does ?!
RE: Is it possible to override a class?
That excites me J thanks Wallace! From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Wallace Turner Sent: Friday, 29 April 2011 4:12 PM To: ozDotNet Subject: Re: Is it possible to override a class? The find/replace method is OK but Resharper can go one better. Consider these three instantiations ofButton _button1 = new System.Windows.Forms.Button(); _button2 = new Button(); _button3 = new DumbAlias.Button(); So its likely you'll find all instances declared like _button1. If you remember you'll look for instances like _button2. It's likely you'll miss _button3. Use Resharper to find them all in one go. Resharper - Find - Search With Pattern Then enter the following pattern Click Find and you should see Now if that doesn't excite you what does ?! image001.pngimage002.pngimage003.png
Re: Is it possible to override a class?
Just a word of warning, that search does not find class members so it will miss: private Button _button = new Button(); however when using the designer they are initialized inside a method so R# will find them. You can do a different search to find any _expression_ that is 'new Button()' but it returns duplicate results(msg me if you want to know how) If I was going to do what you're doing I *would* use Find/Replace that comes with Visual Studio and then use r# to check whether I missed any. On 29/04/2011 3:01 PM, Anthony wrote: That excites me J thanks Wallace! From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Wallace Turner Sent: Friday, 29 April 2011 4:12 PM To: ozDotNet Subject: Re: Is it possible to override a class? The find/replace method is OK but Resharper can go one better. Consider these three instantiations ofButton _button1 = new System.Windows.Forms.Button(); _button2 = new Button(); _button3 = new DumbAlias.Button(); So its likely you'll find all instances declared like_button1. If you remember you'll look for instances like_button2. It's likely you'll miss_button3. Use Resharper to find them all in one go.Resharper - Find - Search With Pattern Then enter the following pattern Click Find and you should see Now if that doesn't excite you what does ?!
Re: Is it possible to override a class?
I've got the free CodeRush Xpress (from DevExpress) installed so I don't know for sure it isn't helping, but from the Object Browser (and from Class View for your own objects) I can right click on any class and choose Find All References. This lists every reference in a Find Symbol Results view (which does have some idiosyncrasies -- like not including the references in any well defined order I can see). If you double click on the reference in this view the actual class name reference is selected in the code. Then you could just paste the new name. And/or you can use searchreplace if you feal safe to do so and do the Find All References after to check they've all been changed, as you suggest. -- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.) On 29 April 2011 16:42, Wallace Turner wallacetur...@gmail.com wrote: Just a word of warning, that search does not find class members so it will miss: private Button _button = new Button(); however when using the designer they are initialized inside a method so R# will find them. You can do a different search to find any expression that is 'new Button()' but it returns duplicate results(msg me if you want to know how) If I was going to do what you're doing I *would* use Find/Replace that comes with Visual Studio and then use r# to check whether I missed any. On 29/04/2011 3:01 PM, Anthony wrote: That excites me J thanks Wallace! *From:* ozdotnet-boun...@ozdotnet.com [ mailto:ozdotnet-boun...@ozdotnet.com ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Wallace Turner *Sent:* Friday, 29 April 2011 4:12 PM *To:* ozDotNet *Subject:* Re: Is it possible to override a class? The find/replace method is OK but Resharper can go one better. Consider these three instantiations ofButton _button1 = new System.Windows.Forms.Button(); _button2 = new Button(); _button3 = new DumbAlias.Button(); So its likely you'll find all instances declared like _button1. If you remember you'll look for instances like _button2. It's likely you'll miss _button3. Use Resharper to find them all in one go. Resharper - Find - Search With Pattern Then enter the following pattern Click Find and you should see Now if that doesn't excite you what does ?!
RE: Is it possible to override a class?
Anthony, it sounds like you do actually want to derive a new class. A control is just a class. In large WinForm apps I usually create FooLabel, FooButton, FooPanel, etc classes and use them in place of the usual base classes. My FooLabel could detect a settings change for example and they would all change colour or font. Your derived FooButton would optionally beep when clicked. The only nuisance is keeping all the Foo controls in the toolbox and remembering to use them consistently. Greg
RE: Is it possible to override a class?
Greg...that's what i was afraid of...yeh..good idea..will create my own toolbox with derived controlsmmm...now i have to do a search and replace on my current project J From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Greg Keogh Sent: Friday, 29 April 2011 5:40 AM To: 'ozDotNet' Subject: RE: Is it possible to override a class? Anthony, it sounds like you do actually want to derive a new class. A control is just a class. In large WinForm apps I usually create FooLabel, FooButton, FooPanel, etc classes and use them in place of the usual base classes. My FooLabel could detect a settings change for example and they would all change colour or font. Your derived FooButton would optionally beep when clicked. The only nuisance is keeping all the Foo controls in the toolbox and remembering to use them consistently. Greg
RE: Is it possible to override a class?
Refactoring like this is where R# really pays its way... From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Anthony Sent: Friday, 29 April 2011 8:02 AM To: 'ozDotNet' Subject: RE: Is it possible to override a class? Greg...that's what i was afraid of...yeh..good idea..will create my own toolbox with derived controlsmmm...now i have to do a search and replace on my current project :) From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Greg Keogh Sent: Friday, 29 April 2011 5:40 AM To: 'ozDotNet' Subject: RE: Is it possible to override a class? Anthony, it sounds like you do actually want to derive a new class. A control is just a class. In large WinForm apps I usually create FooLabel, FooButton, FooPanel, etc classes and use them in place of the usual base classes. My FooLabel could detect a settings change for example and they would all change colour or font. Your derived FooButton would optionally beep when clicked. The only nuisance is keeping all the Foo controls in the toolbox and remembering to use them consistently. Greg This email is intended for the named recipient only. The information it contains may be confidential or commercially sensitive. If you are not the intended recipient you must not reproduce or distribute any part of this email, disclose its contents to any other party, or take any action in reliance on it. If you have received this email in error, please contact the sender immediately and delete the message from your computer.
Re: Is it possible to override a class?
R#? On Fri, Apr 29, 2011 at 10:39 AM, ben.robb...@jlta.com.au wrote: Refactoring like this is where R# really pays its way... -- *From:* ozdotnet-boun...@ozdotnet.com [mailto: ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Anthony *Sent:* Friday, 29 April 2011 8:02 AM *To:* 'ozDotNet' *Subject:* RE: Is it possible to override a class? Greg...that’s what i was afraid of...yeh..good idea..will create my own toolbox with derived controlsmmm...now i have to do a search and replace on my current project J *From:* ozdotnet-boun...@ozdotnet.com [mailto: ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Greg Keogh *Sent:* Friday, 29 April 2011 5:40 AM *To:* 'ozDotNet' *Subject:* RE: Is it possible to override a class? Anthony, it sounds like you do actually want to derive a new class. A control is just a class. In large WinForm apps I usually create FooLabel, FooButton, FooPanel, etc classes and use them in place of the usual base classes. My FooLabel could detect a settings change for example and they would all change colour or font. Your derived FooButton would optionally beep when clicked. The only nuisance is keeping all the Foo controls in the toolbox and remembering to use them consistently. Greg This email is intended for the named recipient only. The information it contains may be confidential or commercially sensitive. If you are not the intended recipient you must not reproduce or distribute any part of this email, disclose its contents to any other party, or take any action in reliance on it. If you have received this email in error, please contact the sender immediately and delete the message from your computer.
Re: Is it possible to override a class?
Oh, Resharper, hadn't heard of R# before to refer to that. On Fri, Apr 29, 2011 at 10:58 AM, David Burstin david.burs...@gmail.comwrote: Resharper - www.jetbrains.com/resharper *** * On 29 April 2011 10:56, Hoss Ravanparsa hitman.h...@gmail.com wrote: R#? On Fri, Apr 29, 2011 at 10:39 AM, ben.robb...@jlta.com.au wrote: Refactoring like this is where R# really pays its way... -- *From:* ozdotnet-boun...@ozdotnet.com [mailto: ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Anthony *Sent:* Friday, 29 April 2011 8:02 AM *To:* 'ozDotNet' *Subject:* RE: Is it possible to override a class? Greg...that’s what i was afraid of...yeh..good idea..will create my own toolbox with derived controlsmmm...now i have to do a search and replace on my current project J *From:* ozdotnet-boun...@ozdotnet.com [mailto: ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Greg Keogh *Sent:* Friday, 29 April 2011 5:40 AM *To:* 'ozDotNet' *Subject:* RE: Is it possible to override a class? Anthony, it sounds like you do actually want to derive a new class. A control is just a class. In large WinForm apps I usually create FooLabel, FooButton, FooPanel, etc classes and use them in place of the usual base classes. My FooLabel could detect a settings change for example and they would all change colour or font. Your derived FooButton would optionally beep when clicked. The only nuisance is keeping all the Foo controls in the toolbox and remembering to use them consistently. Greg This email is intended for the named recipient only. The information it contains may be confidential or commercially sensitive. If you are not the intended recipient you must not reproduce or distribute any part of this email, disclose its contents to any other party, or take any action in reliance on it. If you have received this email in error, please contact the sender immediately and delete the message from your computer.
RE: Is it possible to override a class?
By an easier approach I assume you mean a time machine to go back and a crystal ball to ensure that the people that developed the system you are now working on do everything perfectly and with perfect anticipation of future changes to requirements... -Original Message- From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Noon Silk Sent: Friday, 29 April 2011 9:00 AM To: ozDotNet Subject: Re: Is it possible to override a class? R#? He's talking about Resharper; some people use it to correct design mistakes. I think there is an easier approach :P -- Noon Silk http://dnoondt.wordpress.com/ (Noon Silk) | http://www.mirios.com.au:8081 Fancy a quantum lunch? http://www.mirios.com.au:8081/index.php?title=Quantum_Lunch Every morning when I wake up, I experience an exquisite joy - the joy of being this signature. This email is intended for the named recipient only. The information it contains may be confidential or commercially sensitive. If you are not the intended recipient you must not reproduce or distribute any part of this email, disclose its contents to any other party, or take any action in reliance on it. If you have received this email in error, please contact the sender immediately and delete the message from your computer.
Re: Is it possible to override a class?
By an easier approach I assume you mean a time machine to go back and a crystal ball to ensure that the people that developed the system you are now working on do everything perfectly and with perfect anticipation of future changes to requirements... Indeed; in Visual Studio just press F15, it activates this feature. -- Noon Silk http://dnoondt.wordpress.com/ (Noon Silk) | http://www.mirios.com.au:8081 Fancy a quantum lunch? http://www.mirios.com.au:8081/index.php?title=Quantum_Lunch Every morning when I wake up, I experience an exquisite joy - the joy of being this signature.
Re: Is it possible to override a class?
I use Ctrl-Alt-Butterfly to do that http://xkcd.com/378/ http://xkcd.com/378/Also, this is the price we pay for using designers. They create code that is useful for the tool, not the developer. Back in the old-school days of Java at uni we have a widget-factory that would create our controls for us. You could ask it for a button and who really knows what class it gives you as long as it inherits from ButtonBase. That way you could make a change to the widget factory and change the controls being used everywhere. Having said that, the designer lets you create a screen in 10 minutes that might have taken a few hours in the java days so the trade-off works both ways. On Fri, Apr 29, 2011 at 9:31 AM, Noon Silk noonsli...@gmail.com wrote: By an easier approach I assume you mean a time machine to go back and a crystal ball to ensure that the people that developed the system you are now working on do everything perfectly and with perfect anticipation of future changes to requirements... Indeed; in Visual Studio just press F15, it activates this feature. -- Noon Silk http://dnoondt.wordpress.com/ (Noon Silk) | http://www.mirios.com.au:8081 Fancy a quantum lunch? http://www.mirios.com.au:8081/index.php?title=Quantum_Lunch Every morning when I wake up, I experience an exquisite joy - the joy of being this signature.
Re: Is it possible to override a class?
Noon Silk, I've gathered you dislike Resharper from this post and previous posts. Are you using an alternative? (eg CodeRush) I think you have stuck yourself in a corner where you've said 'i don't like it' and wont go back on your position even if it can cure cancer. I would like to show you around it sometime. All the things that annoy you about it (code completion, brace insertion etc) can be disabled and then you can properly try it without it getting in the way I'm not trying to start a war so lets not go down that path; just a warm invitation if you choose. Regards Wal On 29/04/2011 9:20 AM, ben.robb...@jlta.com.au wrote: By an easier approach I assume you mean a time machine to go back and a crystal ball to ensure that the people that developed the system you are now working on do everything perfectly and with perfect anticipation of future changes to requirements... -Original Message- From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Noon Silk Sent: Friday, 29 April 2011 9:00 AM To: ozDotNet Subject: Re: Is it possible to override a class? R#? He's talking about Resharper; some people use it to correct design mistakes. I think there is an easier approach :P
Re: Is it possible to override a class?
Noon Silk, I've gathered you dislike Resharper from this post and previous posts. Are you using an alternative? (eg CodeRush) I think you have stuck yourself in a corner where you've said 'i don't like it' and wont go back on your position even if it can cure cancer. I would like to show you around it sometime. All the things that annoy you about it (code completion, brace insertion etc) can be disabled and then you can properly try it without it getting in the way I'm not trying to start a war so lets not go down that path; just a warm invitation if you choose. :) You make a very kind offer. I know it doesn't come across in email very well but I was joking really. I might evaluate resharper one day, but at the moment I don't do enough programming to warrant it. Thank you though :) I promise, I won't make stupid jokes about R# here again without having trialed it (recently, I used it years ago now) for myself. -- Noon Silk http://dnoondt.wordpress.com/ (Noon Silk) | http://www.mirios.com.au:8081 Fancy a quantum lunch? http://www.mirios.com.au:8081/index.php?title=Quantum_Lunch Every morning when I wake up, I experience an exquisite joy — the joy of being this signature.
Re: Is it possible to override a class?
Damn. And here I was looking forward to a good old fashioned Silky style stoush for a Friday afternoon :) On 29 April 2011 12:52, Noon Silk noonsli...@gmail.com wrote: Noon Silk, I've gathered you dislike Resharper from this post and previous posts. Are you using an alternative? (eg CodeRush) I think you have stuck yourself in a corner where you've said 'i don't like it' and wont go back on your position even if it can cure cancer. I would like to show you around it sometime. All the things that annoy you about it (code completion, brace insertion etc) can be disabled and then you can properly try it without it getting in the way I'm not trying to start a war so lets not go down that path; just a warm invitation if you choose. :) You make a very kind offer. I know it doesn't come across in email very well but I was joking really. I might evaluate resharper one day, but at the moment I don't do enough programming to warrant it. Thank you though :) I promise, I won't make stupid jokes about R# here again without having trialed it (recently, I used it years ago now) for myself. -- Noon Silk http://dnoondt.wordpress.com/ (Noon Silk) | http://www.mirios.com.au:8081 Fancy a quantum lunch? http://www.mirios.com.au:8081/index.php?title=Quantum_Lunch Every morning when I wake up, I experience an exquisite joy — the joy of being this signature.
RE: Is it possible to override a class?
How can I do a replace of all buttons with my inherited version using resharper? I have resharper but would have no idea how to do this? I assume just a search and replace or is it more clever? -Original Message- From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Noon Silk Sent: Friday, 29 April 2011 12:53 PM To: ozDotNet Subject: Re: Is it possible to override a class? Noon Silk, I've gathered you dislike Resharper from this post and previous posts. Are you using an alternative? (eg CodeRush) I think you have stuck yourself in a corner where you've said 'i don't like it' and wont go back on your position even if it can cure cancer. I would like to show you around it sometime. All the things that annoy you about it (code completion, brace insertion etc) can be disabled and then you can properly try it without it getting in the way I'm not trying to start a war so lets not go down that path; just a warm invitation if you choose. :) You make a very kind offer. I know it doesn't come across in email very well but I was joking really. I might evaluate resharper one day, but at the moment I don't do enough programming to warrant it. Thank you though :) I promise, I won't make stupid jokes about R# here again without having trialed it (recently, I used it years ago now) for myself. -- Noon Silk http://dnoondt.wordpress.com/ (Noon Silk) | http://www.mirios.com.au:8081 Fancy a quantum lunch? http://www.mirios.com.au:8081/index.php?title=Quantum_Lunch Every morning when I wake up, I experience an exquisite joy the joy of being this signature.
Re: Is it possible to override a class?
On 29 April 2011 13:43, ben.robb...@jlta.com.au wrote: Actually in this scenario I'd just do a search and replace too. However Resharper can help here and what I typically do in this situation is select a usage of the class I want to replace (e.g. Button) and use the find usages feature to find all instances and I can see how the class is used, then use search and replace to change to the new class (Button - MyButton), then refresh the find usages to ensure I got them all. Of course that much is available in the basic Visual Studio. -- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.)