When using Resharper to encapsulate a class's properties, is there a way to get it to do more than one property at a time?
You might or might not already know this (R# does suffer from a lack of discoverability, unless you get the one-page key-shortcut page printed out), but ALT-INS opens a box which can at least mass-generate properties for fields.
Not sure if that's any use - it's not the same as a retrospective encapsulation.
I don't think there such a feature out of the box.
However, you could write a RS plugin that does this. But this would be another question...
Related
this is kind of a specific question but I am wondering if someone of you came across the same problem before.
What I am trying to do:
I am working on a jtl plugin.
To start off, the plugin should just run over the payments (the specific hook is active an works) and rename the description. Since I need to add more functionality later, all the stuff has to happen in the plugin (even though jquery would be easier for the former case).
In the shop system, the payments are set like this:
$smarty->assign('Zahlarten', $zahlarten);
In the plugin, I get all the payments like this:
$tmpPayments = $smarty->get_template_vars('Zahlarten');
I then loop over the array, doing specific changes. In the end, I want to add the payments back like:
$smarty->assign('Zahlarten', $tmpPayments');
And this is, what does not work. When I change the description and watch the variables in the phpstorm debugger, they are updated accordingly.
But after the page is loaded completely, the changes are not visible.
I know professional plugins that do it the exact way, and it works.
Changing the original array also does not help.
Also, deactivation caching does not work. Like this:
$smarty->assign('Zahlarten', $tmpPayments', true);
What works is:
$smarty->assign('Zahlarten_tmp', $tmpPayments');
But thats obviously not what I want, since I would have to change the template for that.
To wrap it up, it seams to me that there is some kind of caching going on which I can not figure out.
Does anyone has an idea or can point me to sources that might help?
Thanks in advance!
I finally came across the answer (hours later :P).
Root of the problem:
Some system source code far away from my actual context made its own calculations, leading to another
$smarty->assign('Zahlarten', $farAwayCalcs);
,thus overriding my changes.
Never underestimate stepping through the code with your favorite debugger. ;)
Cheers!
As an enthusiasting refactorer, there's an IntelliJ feature that I love: "Refactor --> Change signature".
Basically, you have a function and you can decide to remove a parameter or add a new one, setting a default value. This is so convenient, so beautiful, and I dearly love it.
So when I got involved in an oldschool UFT project with maintenance tasks, I felt jaded.
It there a way to achieve this without changing each and every instance of the function? Please tell me yes. Please!
Well, no. I don´t know of any tool capable of this.
There seem to be people who created a C# adapter for the UFT test object API, enabling them to write their tests in C#, and to use VisualStudio for development of test scripts. In VS, you have the refactoring support you look for. But you don´t create UFT scripts anymore, you´d create C# apps. (Note I am not talking about the API testing aspect of UFT, which uses C# anyways -- I am talking about the VBScript test scripts for GUI tests and BPT components.)
UFT itself is not capable of doing real static code analysis. (Let this statement drown a minute, and you´ll agree: it´s true.)
Adding this to the fact that the UFT´s IDE is, let´s say: sub-optimal, this led to the development of Test Design Studio (TDS), a VisualStudio "feel-alike" subset of VS for UFT (VBScript) scripts. You can check it out here: http://www.patterson-consulting.net/products/test_design_studio/Default.aspx
Among other things, TDS does static code analysis for UFT scripts in a pretty complete way (as far as an interpreted variant-typed language like VBScript allows that at all), and the author of the tool seems to be thinking about adding refactoring features like the one you asked for, but -- this has not happened yet. It will probably come only if demand is high.
Until then, TDS could help you:
You could simply change the signature
If TDS knows all calls (which is usually does), it will list you all locations where you need to edit -- and this happens at design-time, not at runtime
TDS allows you to specify the type of identifiers, for example: formal parameters, variables, and so on. This means you might even get warnings if you change nothing about the pure VBScript signature (which does not include type information), but do change the TDS directive of that signature parameter of which you changed the type.
This is no advertisement. I am not part of the company that developed TDS.
This is just an honest answer to the (slightly offtopic) question that I wish would have gotten years ago, asking questions like yours, and it proved to be a real lifesaver.
In summary, TDS quadrupled (or more) my productivity when creating and maintaining test scripts, especially if a large base framework is used. So I´d recommend checking out the option of using TDS to better handle changes like the ones you outlined.
I've just started work on an existing Joomla! site, and have a requirement to add an alternative language version of an article. Note that this isn't a full-internationalization effort - we don't need every part of the interface translated - just the need to have another 'version' of an article. Ideally, though, this would include more than just the core content - for example, title. I don't really want to create a second article because, in essence, this really is just a single article, and I don't want things like comments to be split between two separate articles.
Does anyone know if this can be done using joomla core?
If not, can anyone recommend an existing component that will do this?
A good component for manage translations in Joomla 1.5 is Joom!fish. It allows you to do a whole internationalization that, as you said, isn't exactly what you want to do. However I like to think in the long run so, if there's more change, I have not to restructure again and again just because of I haven't thought it before. Hence, if I were you, I would like to use Joom!fish anyway.
Well, as a short fix - Google Translator works and can be installed into your template you're using.
Then you can set it to be hidden unless the users browser is set to use a different language as default - then a small pop-up box drops down and it asks to translate it using google translate.
If that's not the option you're looking for - joom!fish is a good component others rave about but I don't have much experience with personally. Outside of that I'm not really sure.
Hanny had a good idea that would be really easy to implement in an article with the right extension. You can use this extension -
http://www.nonumber.nl/extensions/tabber
This would allow you to easily create tabs with the translations available anywhere you have them. The page above uses the extension to display the tabs, it would be trivial to implement.
I've just done a major, major overhaul on a colleagues project and throughout the process almost everything got rewritten. There was far too much code beforehand.
Now, I am left with the prospect that in amongst my project somewhere are old pre-refactoring methods that are no longer needed.
Is there a way to search the whole project for such methods in one go?
I understand the risk of potentially removing code used via reflection.
It's very similar to this question, except I would like two extra things:
An answer specific to ReSharper
Instructions on how to achieve this using ReSharper as I cannot seem to figure it out
Use solution-wide analysis.
If you change "Unused declaration" in
"R# Options/Inspection Severity/Code Redundancies/Unused declaration" to "Show as Errors", you'll be able to identify all unused declarations.
As far as I know, there is not way to do this with R# for the entire solution/project. The only way I know of is to go through your code manually, pressing Alt+F7 on each method name.
Is it possible to identify classes that implement IDisposable. I was hoping to do so in the Visual Studio Color settings or with an addon.
I don't use Resharper and I have heard that FXcop has this feature. I was looking for something different than these options.
You can right click on the type and select go to definition. It should show you the public members of the class and the interfaces it implements. The object browser can also be used to see this.
However Brody's answer is usually the simplest way and works so long as someone hasn't implemented a method called Dispose but not implemented the IDisposable interface.
You can use the Class View and Object Browser to determine it. But going to the definition is the best idea as the MetaData generated will show you all the methods and the inheritance of the class
Look for the method Dispose() on the class.
Not at a risk of coming across the wrong way (so please don't take it that way), but the best way is to know your code and know the Framework. You should only need to look something up a couple of times to learn which are which. There is not really a dependable way apart from either checking if .Dispose() is a method (which always does not work, as Dispose can be private on some of the Framework classes, such as ManualResetEvent where it is protected), or by going to the definition to find it.
That is not to say that someone could not write an add-in that would do it. I don't see any issues with the technical feasibility of that. A cursory search of Google didn't turn up any existing add-ins that do it, but there might be something out there already.