30

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.

Suggestion to "simplify" <code>Nullable<Int32></code> to <code>Int32?</code>

How do I disable the IDE0001 Name can be simplified. for Nullable<T>?

mbx
  • 6,292
  • 6
  • 58
  • 91
  • @HansPassant thanks for caring, I ended up disabling bulb and squiggles in R# under `Code Inspection`-`Settings`. R# and CodeRush users may be interested in this [UserVoice suggestion](https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/9139204-option-to-disable-quick-action-squiggles). – mbx Jan 25 '16 at 14:44

3 Answers3

12

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.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 2
    I still have the hope that there is another option. Disabling `IDE0001` would also mean loosing helpful suggestions. As we have ReSharper setting that is already aligned with our style that shouldn't hurt too much. – mbx Aug 14 '15 at 09:11
  • @mbx: That's all I've got, I'm afraid. I don't know of any way of configuring it at a more fine-grained level. – Jon Skeet Aug 14 '15 at 09:21
  • @bitbonk: The OP already refers to that question *in the question*, so I don't think it helps... – Jon Skeet Aug 17 '15 at 20:16
  • 1
    Its worth noting that you will need to unload+reload the project for this to come into effect. Simply building did not get rid of the suggestion...even though its under the 'Build' tab :O – Andacious Jul 20 '17 at 13:25
5

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.

Jif
  • 843
  • 9
  • 17
2

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.

mbx
  • 6,292
  • 6
  • 58
  • 91
  • 1
    That last hint worked better for me thanks! Using VS in Unity projects we dont have much control over the csproj so setting properties in it gets reverted. – vexe Dec 21 '18 at 15:37
  • 2
    Thanks, I was about to scrap using VS 2017 all together as a result of all of this flashing lightbulb/screwdriver gimmickry. So glad I stumbled on your solution. – Festus Martingale Feb 10 '19 at 02:44