I have a huge library of classes I copied and I want to set all methods in all classes to:
throw new NotImplementedException();
Does ReSharper have a way to do this globally over the whole solution?
You can do this using ReSharper's Search with Pattern feature in semi-automatic way, i would say. I'll better attach screenshot.
This way you replace all private instance methods in Solution. Then you need to replace all public, protected, internal, same with static and virtual keywords and you'll be there.
Related
What I'm trying to achieve:
I have a public method in a class that I would like to be removed from autocompletion in IDEs by making it private via YARD.
I've tried adding #api private, #!visibility private, #private and it doesn't seem to make any difference - IDE in documentation popups clearly shows this method is still public, and it is still available to be auto-completed.
Why not just make this method a true private one?
I'm trying to achieve full backward compatibility for existing users. It's a public gem.
The goal is better UX for end users by removing unnecessary methods from being listed in auto-completion.
IDEs affected: RubyMine(2021.1), Emacs/LSP(Solagraph backend).. probably Visual Studio Code as well.
So, the question is "Does RubyMine/LSP ignore YARD #private #!visibility private settings?" or is it something with my local setup?
I would like to use Confirm Prompt but currently Confirm Prompt supports only few languages such as en-us, fr-fr etc. I would like to use Confirm Prompt for 2 different languages which are not supported by default. I know I can use fields as confirmChoices and choiceOptions to manually specify confirm choices but that would mean that I have to create 1 ConfirmPrompt for every language which is not included in Confirm Prompt by default.
The easiest way to add support for more languages, which are not included by default, would be to add them to defaultChoiceOptions map. But this map is declared as private static, hence it can not be modified.
So I am thinking about extending ConfirmPrompt class and overriding onPrompt and onRecognize method which will be exactly same as in ConfirmPrompt class but it will use myCustomDefaultChoiceOptions which will be non static and public field in my custom class => problem solved.
But this is hackish solution and I can not understand why this map is not public and non static in Bot Framework SDK.
Hence I am asking, is there any other solution (natively supported by framework) which allows me to add support for different languages in ConfirmPrompt?
This was actually a change pushed out a couple of months ago (by me). You'll need to update your packages.
choiceDefaults is private (and non-static, now), however, it can be updated by passing it into the constructor.
The easiest/best way to do this would be to build your PromptCultureModel for each language/locale/culture (so you can also use it easily with ChoicePrompt), then create the object with those PromptCultureModels that matches ChoiceDefaultsConfirmPrompt, and then pass that into the constructor.
You can see how I did this in it's test here.
Note: When you overwrite choiceDefaults, you lose all of the currently-supported languages. You can easily add them to your PromptCultureModel object via PromptCultureModels.getSupportedCultures().
Note: I've got a to-do to add some additional languages, but it's on the backlog since you can now add your own.
I'm building a Web Test using Microsoft VS2010.
I used the explanation on MSDN: How to: Create a Custom Validation Rule for a Web Performance Test.
In the example there using string and int as private members with public "get" and "set" those parameters valid for edit in the UI when I add this validation rule to my test.
I want to have an Enum with 3 option that when I add the validation rule to the UI I can choose from.
Is there a way to add an Enum variable which will also be valid in the UI ?
Are there any other types which can be used which will be valid in the UI ?
Unfortunately the UI only shows String and primitive-type properties in user-created rules/plugins. Yet some built-in rules/plugins use enums... how can this be? Thanks to the magic of the disassember and some detective work, we discover that it only accepts enums whose assembly name contains the string "Microsoft.VisualStudio.QualityTools.WebTestFramework".
So if you go to the trouble of compiling your enums (or indeed, your entire project) into an assembly called, for example, "MyEnums.Microsoft.VisualStudio.QualityTools.WebTestFramework", BOOM your enum-typed properties will happily appear in the editor UI.
I have to write a lot of helper classes for some reasons like below:
//original class
public class Class1{
public Class1(int p1,int p2){}
}
public class Class2{
public Class2(int p3,int p4,int p5){}
}
//helper class
public static Helper{
public static Class1(int p1,int p2){}
public static Class2(int p3,int p4,int p5){}
}
I need auto generate these helpers at design time, so I think I need a tools require these feature:
Template write at design time.
Template varible can base on the exists classes in source codes at design time(means they are not compilered to Assembly).
Can be auto generate when the source codes(classed) changed or then file saved.
Is there any tools like that?
BTW: Is there any tools can query classes at design time? like I want find classes that is not sealed when they dont have subclasses.
You may want to consider Roslyn. I rewrote classes before using Roslyn, but only as an experiment, to inject attributes in the class. To make it work, I had to write a console application because Visual Studio 2010 didn't allow easy integration at the time. Since the code didn't change much, it wasn't a problem to run manually.
You may be able to adapt it for your scenario.
Maybe this helps (the T4 templates) ?
http://msdn.microsoft.com/en-us/library/bb126445.aspx
Or there is a purely manual way to use the reflection
http://www.codeproject.com/Articles/19513/Dynamic-But-Fast-The-Tale-of-Three-Monkeys-A-Wolf
But I bet this is not the way you really want it.
Is there a way to handle the application_start "event" without using the global.asax?
The best I can come up with is an HttpModule that checks some static variable on every begin_request, which is INCREDIBLY wasteful :(
Do I have any other options?
Thanks
AFAIK, the reflection-based "pseudo-events" in Global.asax are not accessible in any other way than by reflection. However, for the application_start event, you might be able to achieve similar functionality by overriding the Init() method on a subclass of HttpApplication. Some functionality might not be accessible, as it probably fires on a slightly different point in the lifecycle.
Alternatively, if you're going with an HttpModule, couldn't you just use the Init() method instead of begin_request?
If your code is existing in the website, you can use the largely undocumented 'AppInitialize' method. Add this static method to any class in your web project.
(Note: it will not work if contained in a compiled assembly within the site.)
For more info, search for "AppInitialize". (Ex: http://www.bing.com/search?q=appinitialize+msdn&src=IE-SearchBox&FORM=IE9bSRC)