35

I'm using Visual Studio 2010 and ReSharper 5.

I define this at the top of a .cs file.

#if X86
using size_t = System.Int32;
#else
using size_t = System.Int64;
#endif

Then I can use size_t and know that it is a native integer, 32 bits if compiled as a 32 bit assembly, and 64 bits if compiled as a 64 bit assembly. (for those that are curious, the alternatives are always use Int64, or branch at runtime on IntPtr.Size == 4 and have two versions of the code. I prefer this solution.)

However, if I type size_t and hit space, it will be automatically converted to Int64 (or Int32 if X86 is defined). Obviously that's undesirable.

I went into ReSharper options and went to Environment \ Intellisence \ Completion behavior and disabled all the checkboxes under "Automatically complete single item with:".

It still happens, is there anything else I can try?

Eloff
  • 20,828
  • 17
  • 83
  • 112
  • 2
    Might sound cliché, but...have you tried turning it off and on again? Seriously - try making the change, close VS and reboot your machine. – Only Bolivian Here Apr 09 '11 at 18:40
  • 1
    Not an answer, but you should use IntPtr for sizes... – Thomas Levesque Apr 09 '11 at 18:53
  • IntPtr is suitable for pointers, it is not suitable for bitwise and arithmetic operations on pointers (you cannot find the difference between two pointers for example.) Since I use the bottom 3 bits in pointers for storing information, I need an integer type the same size as a pointer to do the bitwise operations. – Eloff Apr 10 '11 at 20:16

5 Answers5

31

I ran into a similar issue (using VS2013 and Resharper 8.2).

To stop the undesirable auto-completion on every "space" hit, I had to disable IntelliSense completion on "space" both within VS and R# options:

  1. VS > Tools > Options > Text Editor > C# > IntelliSense > "Committed by pressing the space bar" checkbox
  2. VS > Resharper > Options > Environment > IntelliSense > Completing Characters > C# "Complete on space" checkbox

Cheers!

bobocoder
  • 311
  • 3
  • 2
  • 2
    Thanks for this. Works for me in VS 2015. Only had to do the resharper option. Was driving me insane. – Architekt Jan 29 '17 at 18:02
  • 5
    I use VS 2017, and it seems the checkbox has been moved or removed. I kind of want to punch someone for that...but, Malagur's answer works for me, and I CAN still autocomplete with Tab – donutguy640 Oct 12 '18 at 00:10
28

One solution would be to toggle to suggestion completion mode for intellisense. The default key binding for the toggle is Ctrl+Alt+Space. When in suggestion mode, it will only change what you type if you explicitly choose a value to change to. You can read more about it here:

http://blogs.msdn.com/b/zainnab/archive/2012/05/01/9943045.aspx

In the VS2017 menu hierarchy the suggestion mode can be found under:

Edit -> Intellisense -> Toggle Completion Mode

Additionally when the suggestion mode is enabled, it is visually indicated by the following button (and can also be enabled/disabled by clicking the button):

visual studio 2017 suggestion mode button

Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
Malgaur
  • 1,842
  • 15
  • 17
6

To turn IntelliSense options OFF by default

On the Tools menu, click Options.

Select the Text Editor folder.

Select the folder for the language you want to customize IntelliSense.

In the General property page, clear check boxes for IntelliSense features that you do not want:

Auto list members applies to List Members

Parameter information applies to Parameter Info

Raghav
  • 766
  • 16
  • 24
3

You can use the escape key to cancel the current intellisense suggestion.

Tod
  • 8,192
  • 5
  • 52
  • 93
3

In VS 2019 and ReSharper 2020 toggling completion mode doesn't solve the issue - suggestions are applied when spacebar is hit. To have it working one has to go to:

Extensions -> ReSharper -> Options... -> IntelliSense -> Completing Characters

and uncheck Complete on space for a respective programming language

ReSharper IntelliSense settings

Łukasz Sypniewski
  • 602
  • 1
  • 10
  • 19