Opening .inl file breaks IntelliSense globally - visual-studio

I'm working with Visual Studio 2017, latest version (just updated yesterday).
I'm using DirectXMath which uses .inl files for some things. I understand why IntelliSense has problems with .inl files, however in my case, Visual Studio breaks IntelliSense for my files.
A simple snipped of code on which I can reproduce the problem:
#include <DirectXMath.h>
#include <DirectXCollision.h>
void f() {
DirectX::XMMATRIX projLH;
DirectX::XMMATRIX viewLH;
DirectX::BoundingFrustum fr{ projLH };
fr.Transform(fr, DirectX::XMMatrixInverse(nullptr, viewLH));
}
All works fine, VS knows about all types and functions. When I now right-click on a type or function and click Show Definition, Visual Studio shows me the source code in a overlay, which might be in a header file or in a .inl file. Sometimes (after three or four times), after I close this overlay, Visual Studio forgets about all the types. XMMATRIX, projLH, viewLH, fr and XMMatrixInverse all have red squiggly lines underneath and hovering the words says namespace DirectX has no member 'XMMATRIX' , ; expected and so on. It still compiles though.
This is quite annoying as I have to restart Visual Studio each time to fix this. Closing and reopening the file doesn't help. The next time I want to look at a declaration and the declaration happens to be in a .inl file, it breaks again. Why does IntelliSense break for my code once I opened a .inl file? Can I somehow globally disable IntelliSense for .inl files or how would I prevent this problem?

Related

Remove automatic addition of using statements on Visual Studio on using methods not in the current namespace [duplicate]

I am using Visual Studio with Unity. When I copy and paste a code in Visual Studio. It automatically adds an unnecessary namespace on the top. It is pretty annoying to see if there have many unused namespaces over time. May I ask if is this a bug or how can I turn off the auto import namespace when copy paste?
From the suggested name, I think Visual Studio confuses the "length" and "Length"
Here are the steps to reproduce the problem
On the top of the page in Visual Studio, go to Tools > Options > Text Editor > C# > Advanced > Uncheck the option for "Add missing using directives on paste" then click OK on the bottom of the page. And then restart Visual Studio.
Might be useful to some to note that tab completion will still auto-add missing using directives.
Here is an example with the option checked (the example specifics are not relevant but in this case an attribute is being pasted to an ASP.Net Core Razor Page):
Here is an example with the option unchecked:

how to get color code on my code FOR EXAMPLE (Debug.Log) to be in a color?

s
I want someone to tell me how to put colors on the code so its easier for me to code.
I think you forgot to select unity c# components when installing visual studio,
try again with visual code
If you are talking about Intellisense / syntax highlighting, you need to make sure that you installed Visual Studio Tools for Unity (Note this is needed for Visual Studio only and you may already have it installed).
Then follow these steps:
Close Visual Studio
In Unity, go to Edit > Preferences > External Tools
Click on the External Script Editor dropdown (this should be on which ever Visual Studio editor you are using or any other supported editor).
Make sure Embedded packages and Local Packages is checked under Generate csproj files for:
Click on Regenerate project files
Open any C# script and check if syntax highlighting is working.
In the worst case, if that does not work, you can close Unity and delete everything except the Assets/ and Project Settings/ folders (as well as anything you explicitly added) in your project's root directory. Unity will regenerate the project folders and files again when you open the project in the editor. It may just be that some of your project files were corrupt.
Also, in case I misinterpreted your question and you are talking about coloring the output in the console window within the editor, you can try using rich text which I believe is supported by Unity's console window in the latest versions.
Example:
Debug.Log("<color=red>this is red text</color>");
For more info on that:
https://docs.unity3d.com/Packages/com.unity.ugui#1.0/manual/StyledText.html

Strange case of intellisense not working in Visual Studio 2015/2017

When a code block is auto-generated in Visual Studio as result of a suggestion...
...we are automatically prompted to type inside a little red box, like this:
But inside that red little box intellisense doesn't work! Is there a way to fix this? It's rather annoying.

Code-Snippet not refreshed in Visual-Studio

I am creating Code Snippet in Visual-Studio 2010 using "Snippet Editor". All is working fine when i first save the snippet in the folder ... Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets.
The snippet is executed when i do CTRL-K CTRL-X and choose it in the list, and also by intellissence using the snippet Shortcut.
My problem comes when i only change the code of the snippet and save it again :
the new code is executed when i hit CTRL-K CTRL-X
the old code is executed when using intellisense ??
the problem is still here when i reopen VS
I don't think this is a "Snippet Editor" issue. Is there any "Intelissence Cache" i would have to reset ?
I have the same issue in visual studio 2019.
I have a custom ( My Code ) snippet file with multiple CodeSnippet elements added with the Code Snippets Manager and recognized and working in visual studio.
I make two changes.
The first I add a comment to an existing CodeSnippet just to demo that the change has been recognized.
I then change the Shortcut element of another CodeSnippet and completely change the Code.
Import again with Code Snippets Manager and Overwrite.
Use both snippets.
The first now has the additional comment.
The second does not have the code that is in the CDATA of the Code element but has what was there before !
Put the two CodeSnippet elements in separate snippet files and all ok.
Seems to be a bug in Visual Studio 2010, no more problem on the next version of VS

Visual Studio not displaying compile time errors in editor

For example, when I write:
string x = "turtle";
x.Go();
There is no red squiggly line detecting the absence of the Go() method on String.
Only when I compile does the error get detected.
I've just upgraded to Windows 7, I have Visual Studio 2008.
In my old environment the errors were detected before the actual compile.
Is there a setting that I am missing?
EDIT: "Tools -> Options -> Text Editor -> C# -> Underline errors in the editor" is checked.
I dont have the "Live Semantic" option. Maybe I need to go to SP1?
You need to turn on the underline errors in the editor and show live semantic errors options in Visual Studio.
These options can be found here:
Tools > Options > Text Editor > C# > Advanced > Editor Help
Edit: You will need to install SP1 for this functionality to work.
Select Tool -> Options, then Text Editor. Under the language you are using (ie C#), go to the Advanced and make sure the Underline errors in the editor and Show live semantic errors are checked
Stop the project.
Open Folder Project.
Delete .vs folder (he is a hidden folder)
Then restart Visual Studio
EDIT:
This approach has been around since the 2012 version of Visual Studio. This folder consists of keeping all breakpoint information and other settings saved. It is not known why, the configurations arrive at a time when the errors of compilations no longer appear. Deleting the .vs folder will "reset" your breakpoints forcing you to do them again if you need to.
For visual studio 2015 and higher:
Go to: Tools > Options > Text Editor > C# > Advanced > Editor Help
Then select: Enable Full solution analysis
I had the same issue and had SP1 installed and had Underline errors in the editor and Show live semantic errors checked in VS2008's options.
My solution was to download Microsoft Visual Studio 2008 Service Pack 1 (Installer) and re-install the package. It wasn't classified as a 'repair' or a 're-install' despite the fact it was already installed, but it worked.
Restarting VS solved my problem once.
my solution; I know it won't help like 80% of the viewers, but for the sake of who it will:
i have had a lot of noise in the IOS part of the solution, a VS bug that showed a lot of errors that weren't supposed to appear, so I just deleted the IOS part because I didn't really needed it as I didn't even had a Mac server to test it on... Something happened after that and the squiggly line returned! Seriously, VS team, fix your bugs...
JavaScript Type Checking
Sometimes type checking your JavaScript code can help you spot mistakes you might have not caught otherwise. You can run the TypeScript type checker against your existing JavaScript code by simply adding a // #ts-check comment to the top of your file.
// #ts-nocheck
let easy = true;
easy = 42;
Tip: You can also enable the checks workspace or application wide by adding "javascript.implicitProjectConfig.checkJs": true to your workspace or user settings and explicitly ignoring files or lines using // #ts-nocheck and // #ts-ignore. Check out the docs on JavaScript in VS Code to learn more.
In my case the problem was that I created a file with .s extension instead of .cs an then changed the extension to .cs once it was created.
I deleted it and created again correctly and now VS is underlining the errors in this file.

Resources