Category Archives

50 Articles

Visual Studio Tips

Intellisense just got smarter..using Intellicode

Posted by matteskolin on

Intellicode is a new feature Microsoft is adding to Visual Studio, integrated into the existing intellisense, Intellicdoe adds machine learning powered suggestions to the auto-completion list. Microsoft says the default machine learning model is based on thousands of open source git hub projects. 

Eventually, Intellicode will also use it’s knowledge to catch common bugs in code review, and make suggestions based on your code.

Intellicode is now available as a Visual Studio extension, but it appears that it may be added as a default feature in the future.

According to the FAQ in the Microsoft documentation, Intellicode is in preview mode, and will likely involve some cost once in full release. Weather this means requiring a higher level VS sku, or even as additional add on fee/ service, remains to be seen.

I tried out the extension, and like what I see so far. See example below. My most used symbols now appear with a ⭐star next to them. I love this sort of thing.. I think it would be cool if you had the option of turning off all the items that aren’t identified as having star.

Intellisense is great, but when working with large classes with lots of properties, methods, or extension methods, the provided list is WAY too long. I almost never scroll through the list.


Get the Extension: Download the Intellicode Visual Studio 2017/2019 Extension HERE

Train a Model Based on Your Code: Open a solution (this is more fun with a big solution with a lot of code), and train a custom model. The Intellicode functionality lives it’s own separate window.  You can find the window in the Visual Studio View->Other Windows->Intellicode


Before Applying Intellicode

After Intellicode


For more and updated information, see microsoft link below…






Visual Studio Tips

Visual Studio – Collapse and Expand Shortcuts – What they actually do

Posted by matteskolin on

Visual Studio has several shortcuts available for expanding and collapsing sections of code. These Shortcuts have been tested with Visual Studio 2017 15.87 with default settings. Below I explain what each of these does in more detail.

Collapse All Outlining (Edit.CollapseAllOutlining)
Ctrl+ (M, A)

Toggle All Outlining (Edit.ToggleAllOutlining)
Ctrl+ (M, L)

Toggle Outline Expansion (Edit.ToggleOutlinineExpansion)
Ctrl+ (M,M)

Expand All Outlining (Edit.ExpandAllOutlining)
Ctrl+ (M,X)

Expand Current Region (Edit.ExpandCurrentRegion)
Ctrl+(M,E)

Collapse Current Region (Edit.CollapseCurrentRegion)
Ctrl+(M,S)

Toggle Outline Expansion
Ctrl+ (M,M) – This is probably the shortcut that makes the most sense of this bunch. Pressing this command repeatedly will open and close the region or auto-outlined section under the cursor. 

In the example below this can be used to open and close the constructors region, as well as the Foo and Bar2 types separately.

Collapse All Outlining
Ctrl+ (M, A) In the code below, this command does what you would expect. All outlining is collapsed as much as possible. 

Expand All Outlining
Ctrl+ (M,X) – this command works great for expanding everything so all code is visible

Toggle All Outlining
Ctrl+ (M,L)  this command behaves someone strangely. The word toggle suggests that repeating this command will switch outlining back and forth. This isn’t quite what happens. The first time you press Ctrl+ (M,L) if there is a mixture of open and closed sections in the file, the closed sections will be opened as the first step in the toggle. 

In the example below, if the Constructors region starts closed, typing this command will first open the region, and the command must be executed a second time to actually toggle all outlining. This is relatively unintuitive. 


Expand Current Region and Collapse Current Region
Ctrl + (M,E) – Expand
Ctrl + (M,S) – Collapse

These commands will collapse or expand the region under the cursor. While editing code I have a hard time thinking of time where one of these commands would be preferable to “Toggle Outline Expansion” above. 

The associated commands may be useful outside of an editing context, such as in auto generated code, code assistance extensions, etc.


Below is simple file to demonstrate the outlining system…

namespace ExpandCollapse
{


    public class Foo
    {
        public int Integer1 { get; set; }

        #region Constructors 
        public Foo()
        {

        }
        #endregion

    }

    public class Bar2
    {

        public Bar2()
        {
            Console.WriteLine("Hello from Bar2");
        }

        public int Int1 { get; set; }
    }

    public class Food
    {

    }
}