Can't invoke snippets through their shortcuts - c#

Being New to Visual Studio 2013 Premium, I don't find any code snippets appearing in the IntelliSense help. I do notice a Code Snippets Manager.
Without using any Resharper tools, or Add Ins, can I get back the same shortcuts in Visual Basic and C# files?
Basically I'm saying that
ctor, Tab, Tab isn't available, nor is prop, Tab, Tab.
New Update:
Works On CS files but not for VB files. Is there a setting I might have to tweak from the code snippet manager?

Maybe the shortcut naming differences throwing you off?
In VB the built in snippet for a property is property (tab) (tab). I don't believe there is a snippet for a constructor in VB since "Sub New" (enter) gets the job done.
You should be able to right click and select insert snippet to navigate the built in VB snippet options and see the shortcuts associated.

Related

Code snippet shortcuts not working with Visual Studio 2019 and Intellisense

When using Intellisennse with Visual Studio 2019 (C#) it doesn't show shortcuts anymore for my code snippets. I tried enabling Intellisense include all snippets option, but still code snippet shortcuts are not working. Any solutions for enabling shortcuts again in Visual studio?
You mentioned "my code snippets", so I suppose you used the customized code snippets.
Please check these aspects:
1). In Visual Studio 2019 > Tools > Options > Text Editor > C# > IntelliSense > Snippets behavior, and make sure that you didn't select Never include snippets option by accident.
2). Make sure you have added related codes to your customized code snippet file(.snippet).
<Shortcut>XXXX</Shortcut>
And make sure that you have imported the customized code snippet file into the related folder/VS(remember to re-import(override) it if you changed some codes of .snippet file, and remember to choose the Language for CSharp).
If you indeed imported the file, the snippet file will be located in for example C:\Users\Administrator\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets, you can check if it exists.
3). For using code snippet shortcuts, remember to press "Tab" key twice(once for Visual Basic, twice for C#) after you type the shortcut. For example, type XXXX in one new code line, and press "Tab" twice, and then the code snippet will be inserted.
Besides, there are some other troubleshooting suggestions, such as repairing VS, reset VS settings, you can also have a try. And I'm not sure if Resharper Extension or other extensions which you installed cause this issue, perhaps you can try to disable it and test again.
BTW, if you mean the default keyboard shortcut key for inserting/surrounding code snippets doesn't work, please check this > Tools > Options > Environment > Keyboard > Press shortcut keys > and make sure, the shortcut keys have been assigned(Ctrl + K/X => Edit.InsertSnippet, Ctrl + K/S => Edit.SurroundWith).

InitializeComponent() - Ambiguous invocation warning?

I admit that I'm new to the world of xaml but seeing warnings using the built-in Visual Studio templates indicate that there might be another issue besides my brain.
If I create an empty VSIX Project (it has to be a VSIX Project) in Visual Studio using Add -> New Project, and then proceed to create a new user control using Add -> New Item -> User Control (WPF), after I have compiled the code, the editor shows me the warning Ambiguous invocation on the line InitializeComponent(), as shown below:
EDIT
There are warnings in the Designer view as well, shown below:
The warning is only present in the editor. Building the project is no problem, as shown below:
Please note that there are NO warnings if you add a User Control (WPF) to a Class Library (.NET Framework) project, as shown below:
If I look in the obj/Debug/ folder of SomeProject I see two files for SomeControl. The first is SomeControl.g.cs, and the second is SomeControl.g.i.cs. The files are identical.
The same goes for the obj/Debug/ folder of SomeOtherProject, without the warning.
I have cloned various official Microsoft repos (e.g. UnitTestBoilerplateGenerator) and the warning is present here as well, for example in: src/View/CreateUnitTestBoilerplateDialog.xaml.cs at InitializeComponent(), as shown below:
What's going on?? =(
EDIT
This is using Visual Studio 15.4 and ReSharper 2017.2.2; I don't seem to be getting this warning with older versions of Visual Studio/ReSharper.
EDIT
This seem to be a ReSharper specific problem, since after suspending ReSharper the warnings are no longer present. I have submitted a bug through ReSharper -> Help -> Report a Bug or Submit Feedback....
It is a known issue for ReSharper 2017.2.x
Update: It was fixed in ReSharper 2017.3 version.

vs 2017 intellisense not working C# and XAML

I have a Strange issue that I can't seem to fix, my Intellisense for XAML is no longer showing up and the code behind is only showing the premade Members. The Classes and Methods I have made are not showing up. Also Visual Studios is not recognizing other pages and wont recognize Navigation either.
I have tried going to Tools>Text Editor>C#>Intellisense -Statement completion and checking the boxes Auto list members and Parameter information. I also tried to clear out the cache.
From what I have researched it seems nobody else is having the same problems.
Close all open tabs in the project and quit VS, reopen the solution in VS and right click the XAML file in the Solution Explorer and then select Open With….> Source Code (Text) Editor.
Delete obj folder and clean project
Right click the XAML page>Properties>Build Action>change it to something else and back
Add a new content page under this specific project and check it works or not.
I would like to add that this worked for my .cs files only.
To get the XAML files Intellisense to work try to repeat the above steps on your .cs files or wait for the XAML files to gain Intellisense.
For ReSharper users: I found that having ReSharper's IntelliSense enabled for all languages can break Intellisense unexpectedly (especially for XAML files). Here's how I was able to fix the same problem that the asker had in Visual Studio 2017 with ReSharper installed:
In Visual Studio, go to the ReSharper menu and click on Options.
On the left side go to Environment > IntelliSense > General.
Select the Custom IntelliSense radio button.
Change any languages that have broken IntelliSense to Visual Studio (like XAML).
Click the Save button.
Just Exclude and Include Xaml Pages and It works again.
I solve that by changing the default editor in visual studio :
In Visual : File > Open
In the open file box : Select a .xaml file (don't open it)
Select "Open with" in the button arrow
Select "Source Code (Text) Editor and Set as Default
Click OK
I tried most of the above without much luck, but noticed if I created a new page, then intellisense worked as expected. For the properties section of the xaml file I noticed that the new page had a Custom Tool assigned (MSBuild:UpdateDesignTimeXaml) do I tried to cut-and-paste this into the existing forms without luck.
Looking at the .cs page for the new page that worked I notice that there is some extra info above the partial class [XamlCompilation(XamlCompilationOptions.Compile)] so I added this along with a using Xamarin.Forms.Xaml statement.
Finally I went back to the xaml properties page and selected Reset to Default for the Custom tool. Voila, for me everything started behaving itself.
Please add the following Nuget Package from Nuget Console.
Install-Package MobileEssentials.FormsIntellisense -Version 0.1.1-pre
You can download the latest update from the following link.
https://www.nuget.org/packages/MobileEssentials.FormsIntellisense/0.1.1-pre
After installing the package please restart the project and wait for sometime and check it.
Just delete .vs directory. this directory is hidden. so
Just Exclude and Include Xaml Pages worked for me too. The difference in .csproj file was:
MSBuild:Compile
now:
XamlIntelliSenseFileGenerator
I could fix the issue in VS2019 by launching the VS installer to modify it, un-check and check the workload ‘.NET desktop development’ to re-install it.

Accessing properties of a project using EnvDTE

I'm writing a visual studio add-in to automate some of our BizTalk related tasks.
I'd like to be able to access the property values of a project (not what shows in the default 'Properties' pane. The properties shown in a window if you right click on the project and select 'properties' from the context menu.)
Specifically I'd like to get/set the application it deploys to, assembly signing, etc. The rest of the add-in is already working.
Thanks!
I'm not sure it includes deploys/assembly signing and it's hard to give a complete sample as there is lots of supporting code, but you can start from IVsSolutionBuildManager.FindActiveProjectCfg, cast the result to IVsProjectCfg2 and enumerate OutputGroups.

Unable to access 'Build Action' property for .cs files

i got a problem with my site with my app_code files and a lot of question ive read people say you need to change the proprties of the .cs files to Build Action.
by right clicking the .cs files and press proprties.
but...
when i right clicking the files i cant see any option called proprties so i press F4 and it open a proprties window and i just click on the .cs file and still cant see any option i can change somthing to Build Action.
any idea why i cant see this options?
EDIT:
my problem is that when i get in the file proprties i have only 2 options...
thay are called:
1.Full Name
2.Full Path
EDIT2:
here what i see in visual studio 2010 when i try access the protrtie menu/window
http://img338.imageshack.us/img338/2359/blac.png
As Microsoft points out in the article "Web Application Projects versus Web Site Projects":
Web application projects use Visual Studio project files (.csproj or
.vbproj) to keep track of information about the project. Among other
tasks, this makes it possible to specify which files are included in
or excluded from the project, and therefore which files are compiled
during a build.
An answer to a similiar question at CodeProject's forums reveals a hint. Abstract:
[...] Looks like you are working on a web application that is actually a
Website as per Visual Studio. You would need to create a new Web Application
and probably copy over the source files there. [...]
http://www.codeproject.com/Questions/173637/Setting-Build-Action-for-Files-in-App_Data
Have you tried this:
You say you haven't got the option being suggested by other posters.
If this is the case, than it is quite possible that your Visual Studio settings are corrupt; this can give rise to all sorts of odd behaviour.
I would suggest you reset your settings, but please be aware you will lose any custom IDE settings that you've previously applied.
Try this:
In Visual Studio, go to Tools->Import and Export Settings
Choose "Reset All Settings" and click Next
Choose to save your current settings if you wish, or select "no" and then click next.
Choose the collection of settings( he IDE preset) you want, probably "Visual C# Development Settings"
Visual Studio will now revert all settings. Hopefully this will make the Build Action reappear.
[EDIT]
It might be worth trying safe mode too.
To do this, start up a "Visual Studio Command Prompt" from your start menu/programs list in Windows, and start Visual Studio with
devenv.exe /SafeMode
Does this make the options appear?
You can copy the file from Windows Explorer and paste it in the Solution Explorer. It will replace (or do nothing but incorporating it in the proj file) the file and recognize it as C#.
Normally you should see a Property named "Build Action" in the first line of the Property Window. This property should be set to "Compile".
Please select file and right click on it so that you will get following screen
Than click on the Properties you will get following screen
You can find build option in as a first option.

Categories

Resources