You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ide/lnt-make-member-function-const.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ monikerRange: ">=msvc-170"
8
8
---
9
9
# `make-member-function-const`
10
10
11
-
When member functions don’t modify their object state, annotate them with the `const` keyword. This guidance comes from the [C++ Core Guideline Con.2](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#con2-by-default-make-member-functions-const).
11
+
When member functions don’t modify the object's state, annotate them with the `const` keyword. This guidance comes from the [C++ Core Guideline Con.2](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#con2-by-default-make-member-functions-const).
12
12
13
13
## Example
14
14
@@ -33,7 +33,7 @@ double getRadius()
33
33
34
34
## How to fix the issue
35
35
36
-
The solution proposed by the linter is to mark member functions `const` when they don't modify the object's state. This provides a clear indication to both developers and the compiler that the function is safe to call on `const`objects.
36
+
The solution proposed by the linter is to mark member functions `const` when they don't modify the object's state. This let's both developers and the compiler know that the function is safe to call on a `const`object.
37
37
38
38
In the following example, `const` has been added to `getValue()` and `getRadius()`:
The editor can make this change for you. Place the cursor on the flagged symbol and choose **Show potential fixes** and then **Make member const**:
61
61
62
-
:::image type="content" source="media/make-member-function-const.png" alt-text="Screenshot of the editor suggesting to make member const." :::
62
+
:::image type="complex" source="media/make-member-function-const.png" alt-text="Screenshot of the editor suggesting to make member const." :::
63
63
The cursor is on the line int getValue() and **Show potential fixes** appeared and was chosen. Now **Make member const** is visible and it shows the get value function with const added to it. You can now choose **Make member const** to make the change.
64
64
:::image-end:::
65
65
@@ -69,7 +69,7 @@ Make this change for all flagged member functions.
69
69
70
70
This check focuses on `const` usage for member functions in C++ code. The C++ Core Guidelines recommends marking member functions as `const` when they don't modify the object's state.
71
71
72
-
The current implementation of this check allows for the assignment of`const` to member functions after their declaration. It's a good practice to declare member functions as `const` from the beginning if they don't modify the object's state.
72
+
The current implementation of this check allows you to add`const` to member functions after their declaration. It's a good practice to declare member functions as `const` from the beginning if they don't modify the object's state.
Copy file name to clipboardExpand all lines: docs/ide/lnt-naming-convention.md
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
-
title: int-naming-convention
3
-
description: "Reference for Visual Studio C++ IntelliSense Linter check int-naming-convention."
2
+
title: lnt-naming-convention
3
+
description: "Reference for Visual Studio C++ IntelliSense Linter check lnt-naming-convention."
4
4
ms.date: 09/27/2023
5
-
f1_keywords: ["int-naming-convention"]
6
-
helpviewer_keywords: ["int-naming-convention"]
5
+
f1_keywords: ["lnt-naming-convention"]
6
+
helpviewer_keywords: ["lnt-naming-convention"]
7
7
monikerRange: ">=msvc-170"
8
8
---
9
-
# `int-naming-convention`
9
+
# `lnt-naming-convention`
10
10
11
11
Ensure that the naming convention for symbols aligns with the coding style specified in the project's `.editorconfig` file.
12
12
13
13
To enable this feature, add an `.editorconfig` file in the same directory as your project file. The `.editorconfig` specifies the naming conventions for symbols in your project. For an example `.editorconfig` that specifies the naming conventions for Unreal Engine projects, see this example on [GitHub](https://raw.githubusercontent.com/microsoft/vc-ue-extensions/main/Source/.editorconfig).
14
14
15
-
Once you have the `.editorconfig` file in your project, turn on the `int-naming-convention` check with the **Naming Convention** setting in the C/C++ Code Style options. For information about how to change this setting, see [Configure the linter](cpp-linter-overview.md#configure-the-linter).
15
+
Once you have the `.editorconfig` file in your project, turn on the `lnt-naming-convention` check with the **Naming Convention** setting in the C/C++ Code Style options. For information about how to change this setting, see [Configure the linter](cpp-linter-overview.md#configure-the-linter).
16
16
17
17
## Example
18
18
@@ -21,9 +21,9 @@ Given an `editorconfig` file that contains:
cpp_naming_style.boolean_style.required_prefix = b
24
-
``````
24
+
```
25
25
26
-
The linter will flag the following code:
26
+
The linter will flag the following code because it isn't prefixed with 'b' and it isn't Pascal case, as specified in the `.editorconfig` file:
27
27
28
28
```cpp
29
29
voidexample()
@@ -34,7 +34,7 @@ void example()
34
34
35
35
## How to fix the issue
36
36
37
-
Change the naming to match the style specified in the `.editorconfig`. For example:
37
+
Change the naming to match the style specified in the `.editorconfig`:
38
38
39
39
```cpp
40
40
voidexample()
@@ -45,13 +45,13 @@ void example()
45
45
46
46
The editor can make the change for you. Place the cursor on the flagged symbol. Choose **Show potential fixes** and then **Apply naming convention**:
47
47
48
-
:::image type="complex" source="media/int-naming-convention-apply-naming-convention.png" alt-text="Screenshot of the IDE suggesting applying naming convention.":::
48
+
:::image type="complex" source="media/lnt-naming-convention-apply-naming-convention.png" alt-text="Screenshot of the IDE suggesting applying naming convention.":::
49
49
The code editor shows bool myFlag = true. With the cursor on that line of code, **Show potential fixes** appeared and was chosen. Now **Apply naming convention** is visible and it shows bool my Flag = true in red and the suggested change, bool b My Flag, in green. You can now choose **Apply naming convention** to change the flagged code to bool b My Flag = true.
50
50
:::image-end:::
51
51
52
52
## Remarks
53
53
54
-
The `int-naming-convention` linter check ensures that naming conventions align with naming conventions specified in the `editorconfig` file. You can apply this check to any project that has an `editorconfig` file. You can also customize your `.editorconfig` file to suit your project's coding style.
54
+
The `lnt-naming-convention` linter check ensures that naming conventions align with naming conventions specified in the `editorconfig` file. You can apply this check to any project that has an `editorconfig` file. You can also customize your `.editorconfig` file to suit your project's coding style.
0 commit comments