How to disable "Light Bulb" Quick Action "simplification" for Nullable<T>? - visual-studio

For several reasons we prefer Nullable<Int32> over int?. Wherever possible we prefer Types over keywords - as we do so since C#2 we have a large codebase already using that style.
I recently switched to VS2015 and got the annoying light bulbs all over my code. For Int32 and other related non-generic types I fixed that by using this answer. For Nullable<T> however I cannot find the option to disable nagging.
How do I disable the IDE0001 Name can be simplified. for Nullable<T>?

In your project properties, under the Build tab, in "Errors and warnings", add IDE0001 to the set of suppressed warnings. I know this isn't really a warning (just a suggestion) but it's the same infrastructure. That removes the suggestion.

There is a feature-request here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/9139204-option-to-disable-quick-action-squiggles
concerning disabling the light-bulb. Please add your votes to this if you agree that it is important.

The answer was finally given for another related question:
You can disable analyzers on a per-project basis.
To do it, right click on Project>References>Analyzers in the Solution Explorer and hit Open Active Rule Set
Here you'd need to disable IDE0001 Simplify Names under Microsoft.CodeAnalysis.CSharp.Features.
Additionally you can set Tools > Options > Text Editor > C# > Code Style > predefined type preferences for For locals, parameters and members and For member access expressions to Prefer framework type and Refactoring Only (default). This however is a machine specific config setting.

Related

Set Intellisense delay (VS 2019)

Writing C# code in Visual Studio 2019. The constant popups as you type or position the mouse are very distracting. In Tools > Options > Text Editor > All Languages (or your language), you can disable all popups as you type by untciking Auto list members, but this is not what I need. Firstly I don't want to disable them completely and secondly this doesn't affect popups when you hover over a variable.
Ideally, I'd like popups more sparingly and only after a long-ish delay (say 1000ms). Currently they appear nearly instantly whenever I type any character or move the mouse over the code.
Can the delay be configured?
Update
According to a comment to this question, Visual Studio does not currently support a delay. But the experience for C# coding can be improved at Tools > Options > Text Editor > C# > Intellisense. Find the option Show completion list after a character is typed and untick it.
Actually, VS does not such feature to make a delay for code Intellisense.
Suggestion
So my suggestion is that you can disable the option Show completion list after a character is typed just as you said.
And then if you want to invoke Intellisense, you should type Ctrl + Space manually to invoke the Intellisense.
In this way, you can invoke the Intellisense anytime based on your needs.
Besides, if you still want this requirement, I suggest you could suggest your feature on our DC Forum.
Also, you can share the link here and anyone including us will vote it so that it will get more Microsoft's attention.
Update 1
I already suggested the feature for you and you can check the link.
You can vote on it and add any comments if I did not describe the issue in detail. Hope the Team will consider the idea carefully and give us a satisfactory reply.
Since the process would take a long time, so you have to use my workaround manually so far.

Automatic Tab / Insert spaces as tab setting switch

It happens sometimes to switch between codebases using different strategy for indentantion, in term of using pure tabs or spaces instead of tab. Since each codebase reasonably want to preserve the coding style, the developer has to remember to switch to the proper setting each time he change the project he's working on. Is there some way to do this automatically, or having the setting saved as a property on the project/solution ?
VS, out-of-the-box, only supports per-user-per-machine settings, including code formatting.
There are third-party add-ins that enable per-project settings. This example add-in provides support for VS2008.
Another option is to perform the formatting externally, one option is "Uncrustify", which is blogged about here.

Resharper (or Visual Studio) auto completion

I'm using VS 2010 with resharper. If I have a class called ConfigParserTests and then write
new ConfigParser(
the code will auto complete to
new ConfigParserTests()
which is not what I want. Any idea how to disable this nasty feature.
[Edit]
What is want is to write out
new ConfigParser()
without pressing "Esc". In this case I am using TDD so ConfigParser does not exist.
[/Edit]
I have been looking around in both the resharper and VS intellisense menus without finding anything helpful.
Open Options window, navigate to Intellisense > Autopopup. You will see auto-complete options correspond to several cases and categorized according to language:
As you see, you can select for each single case:
Do not display.
Display but do not preselect. (seems proper for your case)
Display and preselect. (default)
Different options may be selected in different cases or languages. For example, you can specify different behaviours in C#:
After dot
After 'new'
In doc comments
Letter and digits
Where value is expected
HTH
It's not clear whether you're complaining about which class name it's filling in, or the parentheses. I'll address both.
If the class you're trying to use is in another namespace, and you haven't added the appropriate using yet, then the code completion is doing just what you would expect -- you told it which namespaces to use, and you didn't tell it to use the one with ConfigParser in it; so it uses the nearest match, as expected.
But ReSharper has shortcuts that can save you work by finding the class and adding the using for you. For this case, I would suggest that you look into the different Ctrl+Space options in ReSharper. You could write new cp <Ctrl+Alt+Space> and ReSharper will give you a pop-up menu asking whether you mean ConfigParser or ConfigParserTests. When you hit Enter to select the one you want, it will add the necessary using to the top of your file, and complete new ConfigParser() with the cursor between the parentheses.
(If the ConfigParser class doesn't exist yet, then that's one of the cases where you don't want code completion. Just type new ConfigParser and then hit Esc before typing your open paren.)
If your problem is that it adds a close paren, be aware that if you type ) ReSharper will not add a second close parenthesis -- it will recognize that you're typing a paren that it already added, so it will just move the cursor to the right. If for some reason you still don't want it to complete the open paren for you, #jdv-Jan de Vaan's answer explains where to change this preference.
When doing TDD you should put the VS intellisense into suggestion mode instead of the normal completion mode.
The difference is described here
Unfortunately Resharper takes over the intellisense so you can not change mode without deactivating resharper.
Select Resharper \ Options. From the list on the left, select Enirionment \ Intellisence \ Completion behavior.
Then disable the checkboxes under "Automatically complete single item with:"
If you are using resharper 6.0 I would upgrade to 6.1 as there were a lot of these sort of preselecting bugs introduced in 6.0 and fixed in 6.1.
CTRL+ALT+Space Bar
Gotta give props to Zain for showing us how to get around these issues when utilizing TDD
http://blogs.msdn.com/b/zainnab/archive/2010/01/22/intellisense-suggestion-mode-vstipedit0012.aspx
Select Resharper \ Options \ Environment\ Intellisence \ Completion Behavior
Then Change the options under “Automatically insert parentheses after completion: can disable all together Really Old Man Voice I want to type my own (), Opening Only, or Young Hip Coder Dude I like resharper to do it all for me man

Visual Studio - easy way to bring up type definition as source code

Oftentimes I want to bring up a system class in a source view, so that I can browse the properties and methods exposed by the class. Below is the screenshot of what I mean:
Srting from metadata http://img443.imageshack.us/img443/940/stringfrommetadata.png
Usually I do this by selecting the class name and pressing F12 (or right click>Go To Definition). However, if I haven't got it anywhere ready, i have type it up and then do Go To Definition. Most of the time I have to delete what I typed later on.
Is there a way to bring up this view without having to type the class name? The VS2010 Navigate To dialog doesn't support this.
EDIT: When I posted the question I didn't use any Visual Studio plugins. Now that I realised that I have full CodeRush license (thanks to StackOverflow promotion for users with 10K rep) I will accept answers that use CodeRush or Refactor!.
EDIT: At this stage I haven't really got anywhere with trying to answer this question. I am going to leave it open and let the bounty auto-award itself to Rory as he explained what's happening the best. In the meantime(schedule allowing) I will investigate doing this with DXCore as I think it should be possible.
The view you're looking at appears to have been built by some sort of analysis of the IL of the framework. Without knowing the type you intend to look at, no deconstruction can be done. Therefore I feel that, you are unlikely to find exactly what you have said you are looking for.
Allow me to suggest a few alternatives though.
Disclaimer: I work for DevExpress as a CodeRush Community Evangelist.
The Object Browser (Ctrl+Alt+J) This screen will load without attempting to show you any particular type, it will therefore be down to you to find the type in question. However all types are available and full search functionality is provided. once the type you're looking or is found, all members are listed and available.
Update: If you use the (Ctrl+K, Ctrl+R) shortcut to launch the object browser, then it will launch focused on the Search box. This is invaluable.
There are a number of CodeRush features which can prove useful when trying to locate code.
TabToNextReference (Tab) Whilst the caret is positioned within a type, strike the tab key and the next reference to that type will be located. More Details
References ToolWindow (Shift+F12) When activated the References ToolWindow will show you any references to the current type or member. This toolwindow can also be used to navigate said references. The References Toolwindow can be used in both on demand and Live mode. this allows you to have the window update as you navigate your code (via mouse or keyboard) and locate all references of any symbol the caret lands upon.
QuickNav (Ctrl+Shift+Q): This feature is closest in style to VS2010's NavigateTo feature. QuickNav will locate symbols matching whatever you type into it's filter box. This facility also supports Camel Case search. More details
QuickNav is also much more configurable than it's VS counterpart
Finally
Please also keep in mind that CodeRush is build upon the DXCore, a framework which allows users to create their own plugins for use alongside each other and CodeRush.
This framework has been repeatedly been leveraged by the community to add additional functionality. So even if you don't see any thing quite to your needs, consider suggesting something to the community by way of the forums or even contact me directly RoryB at DevExpress dot Com
I'm sure there's something we can do to help you out :)
I was not aware of that new "Navigate To" feature, but I used to use Reflector for this sort of things. The pro version offers some integration with Visual Studio (Right clicking the method and selecting "Open In .NET Reflector"). It will open the reflector window and won't show the code in the VS itself. You can watch the demo that shows this feature and some others.
This is not the best answer that I'd expect but is a good option to know.
There is no way that I know of to do this in Visual Studio 2010. However, you can do this in ReSharper via the 'navigate to' menu. I suggest you try the 30 day trial from them, then if you really do need this then purchase it.
A number of add-ins allow you to browse objects (though usually in an object-browser treeview manner rather than in a "header" file form - I believe Resharper, CodeRush and Visual Assist X all have variations on this theme).
However, one add-in to consider (as it's free) is the VS Productivity Power Tools. It adds a Solution Navigator window that gives a view onto your solution just like Solution Explorer, but (among other enhancements):
can search & filter the files listed, e.g. show only those files that are named Test.
can "expand" any file entry to show the types and members within it.

Type ahead autocompletion in Eclipse

Do Eclipse have a plugin for type ahead autocompletion like Visual Studio, so I don't have to destroy my spacebar by pressing Ctrl+Space all the time? (If you don't know how it works in Visual Studio, please don't bother answering.)
And also, can I limit the autocomplete to imported packages, rather than every single Java class on earth? It's fustrating seeing suggestions from awt and swing etc., when I'm working with GWT. And I don't want to add every single Java class to the filter, that's just stupid. (Again, like how it's done in Visual Studio!)
Regarding your second part, yes you can
Open Eclipse
Select Window/Preferences from the menu
Expand Java/Appearance/Type Filters from the menu on the left
Click the "Add package" button, enter "java.awt" (without the quotes) and click OK
OK your way out
This will make Eclipse remove any matching classes from the java.awt package from your type ahead list. Very nice...
So "type-ahead" exists in Eclipse (mentioned in this status report in June 2006), but is synonym of auto-completion, most often triggered by CTRL+ Space... (which is not exactly what you are looking for)
To be more specific, the kind of automatic auto-completion (completion while you are typing, with a "Common" or "All" list of possible completions) you have in Visual Studio is not there in Eclipse (actually read below):
Original answer January 2010:
At least, not without a dedicating plugin.
And even with that plugin, it would have to follow a TemplateCompletionProcessor, meaning it would need a list of characters triggering said completion (again, not what you are looking for), by redefining method getCompletionProposalAutoActivationCharacters().
Update November 2011:
Cristi mentions in his answer (upvoted) a great workaround, which consists adding all the letters as Auto activation triggers for java.
See also "Automatically opening completion window in Eclipse".
From the thread "Eclipse auto-completion ":
Windows -> Preferences -> Java -> Editor -> Content Assist
Set delay to: 0 (actually >0 is better: 50, it avoids CPU picks because of constant listening)
Set triggers to:
.(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV WXYZ#
My answer may come too late, but maybe will help others searching this feature in eclipse.
This workaround works for me (eclipse helios):
Go to Windows -> Preferences -> Java -> Editor -> Content Assist.
Here, enable Auto activation and set Auto activation delay to a low value, let's say 50 ms.
Then comes the workaround: In Auto activation triggers for java, simply put all the characters: abcdefghijklmnopqrstuvwxyz.
And there you go, just type something.
Completion is triggered when pressing ".", if that is what you are referring to as "type-ahead autocompletion". This is what Visual Studio also does, unless you are referring to another Visual Studio feature I'm unaware of.
Limiting completion to only imported packages I think is a somewhat unorthodox thing to do; you are forced to rely on wildcard imports to define the set of types to complete on. I think most users would consider that less than useful. You're welcome to elaborate on your use case for this, though. For example, why would you want to exclude all Java classes from completion?
BTW, using "type filters" (as VonC suggests) doesn't require you to add every single class. I typically (globally) exclude java.awt.*, sun.com.*, org.omd.*, and a few others. Eclipse also sorts completion according to a (type-sensitive) heuristic which usually results in the most relevant types being displayed at the top. For example, auto-completion inside a method call will put the variables which matches the method type signature at the top.
I know that Claus spoke of Java in the second part of his question, but the general question is about any language in Eclipse (no Java tag here), so the following might be of use to python eclipse coders:
Go to Windows -> Preferences -> PyDev -> Editor -> Code Completion. Here, check the box next to "Request completion on all letter chars and '_'?".
(Purposefully similar to Cristi's answer.)

Resources