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-int-naming-convention.md
+9-21Lines changed: 9 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -10,32 +10,20 @@ monikerRange: ">=msvc-170"
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
-
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 [`.editorconfig`on ](https://raw.githubusercontent.com/microsoft/vc-ue-extensions/main/Source/.editorconfig).
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
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).
16
16
17
17
## Example
18
18
19
-
The For example, an `editorconfig` file that contains:
19
+
Given an `editorconfig` file that contains:
20
20
21
-
```cpp
22
-
classMyClass
23
-
{
24
-
25
-
public:
26
-
27
-
int getValue() { return value; } // Flagged: ‘getValue’ doesn't modify the object's state.
28
-
29
-
void setValue(int newValue) { value = newValue; } // OK: ‘setValue’ modifies the object's state.
cpp_naming_style.boolean_style.required_prefix = b
36
24
``````
37
25
38
-
flags the following code:
26
+
The linter will flag the following code:
39
27
40
28
```cpp
41
29
void example()
@@ -46,7 +34,7 @@ void example()
46
34
47
35
## How to fix the issue
48
36
49
-
Change the naming based on the code style specified in the `.editorconfig`. For example:
37
+
Change the naming to match the style specified in the `.editorconfig`. For example:
50
38
51
39
```cpp
52
40
voidexample()
@@ -55,9 +43,9 @@ void example()
55
43
}
56
44
```
57
45
58
-
The editor can make the change for you. Place the cursor on the flagged symbol, and choose**Show potential fixes** and then **Apply naming convention**:
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**:
59
47
60
-
:::image type="content" source="media/int-naming-convention-apply-naming-convention.png" alt-text="Screenshot of the IDE suggesting to apply naming convention.":::
48
+
:::image type="complex" source="media/int-naming-convention-apply-naming-convention.png" alt-text="Screenshot of the IDE suggesting applying naming convention.":::
61
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.
Copy file name to clipboardExpand all lines: docs/ide/lnt-make-member-function-const.md
+7-5Lines changed: 7 additions & 5 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, mark them as const. 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 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).
12
12
13
13
## Example
14
14
@@ -18,13 +18,11 @@ class MyClass
18
18
public:
19
19
20
20
int getValue() { return value; } // Flagged: ‘getValue’ doesn't modify the object's state.
21
-
22
21
void setValue(int newValue) { value = newValue; } // OK: ‘setValue’ modifies the object's state.
23
22
24
23
private:
25
24
26
25
int value = 42;
27
-
28
26
};
29
27
30
28
doublegetRadius()
@@ -35,7 +33,9 @@ double getRadius()
35
33
36
34
## How to fix the issue
37
35
38
-
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. In the following example, `const` has been added to `getValue()` and `getRadius()`:
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.
37
+
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**:
60
+
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
62
:::image type="content" 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
66
+
Make this change for all flagged member functions.
67
+
66
68
## Remarks
67
69
68
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.
0 commit comments