Visual Studio 2017 require "this" code analysis rule like SA1101 - visual-studio-2017

When using Visual Studio 2017, with roslyn, is there a way to enable requiring the "this" keyword for all calls to methods inside the class, and class variables?
I'm trying to accomplish it through the creation of a new ruleset but I'm not sure if that is the best way, I can't find that rule to enable.

As Dai mentioned, you can use code style (you can find it in Options under the editor settings for the language). You can set it as None, Information, Warning and Error.
Your settings will be on an editorconfig file. The current version of Visual Studio (15.6) uses this as an editor feature and will not be enforced at build time. That will be a feature in 15.7.
In the meantime, you can use the StyleCop.Analyzers on your projects.

Related

How to change the DEFAULT C++ Language with Visual Studio 2022?

I've read about how to change these settings in .props files for VS 2019, but those solutions didn't work for me with VS 2022.
I simply want the DEFAULT C++ Language Standard to be CPP20, not CPP14.
I don't like having to change it for every project as sometimes I forget and thus my code won't run.
https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-choosing-a-language-standard/
Setting a language standard in Visual Studio
As of the time of writing, Visual Studio 2022 defaults to C++14 capabilities, which does not allow for the use of newer features introduced in C++17 and C++20.
To use these newer features, you’ll need to enable a newer language standard. Unfortunately, there is currently no way to do this globally -- you must do so on a project-by-project basis.
Warning
With Visual Studio, you will need to reselect your language standard every time you create a new project.
To select a language standard, open your project, then go to Project menu > (Your application’s Name) Properties, then open Configuration Properties > C/C++ > Language.

How to change default code in Visual studio

I am going to programming c++ with Visual Studio, but there is something annoying and that's the default code, which is shown automatically in launching the editor. Is there a way to change that or it is rigid ?
Thanks.
Yes there is: you can create a Visual Studio project template and use that as the basis for future projects. The way you do this is to get your project looking how you like it and then save it as a template. Full details here:
https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates?view=vs-2019

How to set Visual Studio C++ "default default" project settings

How do I change the default settings (property pages) that new "Solutions" and projects start with? When I create a new project using the Application Wizard, it always has the same settings, but they are not the ones I want.
Surely the question must have been asked and answered, but I cannot find it. Maybe I do not know the right jargon.
Visual Studio allows you to generate a custom project template, allowing you to set the defaults to what makes the most sense for any given environment.
The procedure involves 2 steps:
Create a new project, and adjust the settings.
Export a template using the Export Template Wizard. Up until Visual Studio 2015, the Export Template... command was under the File menu. Starting with Visual Studio 2017, it was moved to the Project menu.
On the first page, select Project template, and continue on to the next (final) page, filling in the information as appropriate. Choose Automatically import the template into Visual Studio to have it instantly available.
Official documentation is available at How to: Create project templates.

Attaching Documentation in Visual Studio (à la Eclipse)

I'm new to Visual Studio (2012) and having come from using Eclipse, I'm finding myself missing the ability to hover my mouse over a method and receive a dialogue detailing the parameters and any accompanying comments.
In this particular example, I'm using the OpenGL SDK with C++ in Visual Studio, and I would like to be able to quickly get at the documentation without having to jump between VS and http://www.opengl.org/sdk/docs/man/.
Is there a way that I can attach the documentation somehow so that I can view it from within Visual Studio itself without needing to manually search?
visual studio does provide the functionality you are looking for as a tooltip (instead of a dialogue) when you hover long enough (2-3 seconds). For this to work correctly and more usefully though, you'd need the functions to be documented properly in the code itself.
Check the following questions for more information on how intellisense tooltip works :
How to get full intellisense tooltip comments working?
Documenting C++/CLI library code for use from c# - best tools and practices?
By default though, intellisense will simply display the comment above the function declaration or deninition (which ever comment is larger, it seems). It takes a while longer when you hover first time over a function, so be patient and retry :)
you can type in the code 3 slash /// and visual studio automaticalli write a xml template for the documentation of the method/class/property.
next you can go in the project properties. Build tab, Output section, XML documentation file, and enter the filename. It will be built on every build of the project.
You could try NDOC or SandCastle if you dont mind using 3rd party tools.

How visual studio intellisense recognize functions and properties in classes even though there is no reflection in C++?

I want to list properties and functions present in c++ classes. Is that functionality already implemented in any library ? Does visual studio intellisense use any library ? Is that library available publicly from Microsoft?
Visual Studio parses your code, so that's how it knows. You would need to do the same.
The Visual C++ team maintains a blog that has had several very nice articles about how IntelliSense has worked in the past and how it will work in the future:
IntelliSense History, Part 1
IntelliSense, Part 2 (The Future)
Visual C++ Code Model
Rebuilding Intellisense
Visual C++ Code Model in Visual Studio 2010
Essentially they build their own 'reflection' database (the .ncb file in current and past version sof VS, using a compact SQL database starting with VS2010) by parsing the headers and other source files - using both custom parsers and parsing that's done with the cooperation of the compiler.
Apparently at least some of that information is available in the VCCodeModel and related interfaces that the Visual Studio extensibility model provides. I have no idea how well the extensibility model works or how easy it is to use.
They use a propriety format to store intellisense information (they are saved as NCB files). You can delete these files to force VS to recreate its intellisense database if things go wrong.
They then scan header files for class information as well as dependencies, then build the NCB file for future reference.
No, this library is not available for personal use.
Intellisense in C# is lots better than the one in C++
VS2010 will see C++ have the same intellisense features as C# currently enjoys.
I would imagine that Visual Studio uses the header files to provide Intellisense.