From 4b609a0e540ab4163c7eb13c76f7a1253918a898 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Mon, 15 Mar 2021 13:55:01 +0200 Subject: [PATCH 1/2] Update SA1305 doc to mention allowedHungarianPrefixes in stylecop.json --- documentation/SA1305.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/documentation/SA1305.md b/documentation/SA1305.md index 69350b55fe..2e079ae5a4 100644 --- a/documentation/SA1305.md +++ b/documentation/SA1305.md @@ -29,9 +29,17 @@ In addition, modern code editors such as Visual Studio make it easy to identify StyleCop assumes that any variable name that begins with one or two lower-case letters followed by an upper-case letter is making use of Hungarian notation, and will flag a violation of this rule in each case. It is possible to declare certain prefixes as legal, in which case they will be ignored. For example, a variable named *onExecute* will appear to StyleCop to be using Hungarian notation, when in reality it is not. Thus, the *on* prefix should be flagged as an allowed prefix. -To configure the list of allowed prefixes, bring up the StyleCop settings for a project, and navigate to the Hungarian tab, as shown below: - -![](Images/HungarianSettings.JPG) +To configure the list of allowed prefixes, use *stylecop.json* like the following: + +```json +{ + "settings": { + "namingRules": { + "allowedHungarianPrefixes": [ "aa", "bb" ], + }, + } +} +``` Adding a one or two letter prefix to this list will cause StyleCop to ignore variables or fields which begin with this prefix. From d5c6fd228fbbf3d5ed1ebc4993f713cfd3372d80 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Mon, 15 Mar 2021 14:10:30 +0200 Subject: [PATCH 2/2] Update documentation/SA1305.md Co-authored-by: Sam Harwell --- documentation/SA1305.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/SA1305.md b/documentation/SA1305.md index 2e079ae5a4..def384f0ad 100644 --- a/documentation/SA1305.md +++ b/documentation/SA1305.md @@ -29,7 +29,7 @@ In addition, modern code editors such as Visual Studio make it easy to identify StyleCop assumes that any variable name that begins with one or two lower-case letters followed by an upper-case letter is making use of Hungarian notation, and will flag a violation of this rule in each case. It is possible to declare certain prefixes as legal, in which case they will be ignored. For example, a variable named *onExecute* will appear to StyleCop to be using Hungarian notation, when in reality it is not. Thus, the *on* prefix should be flagged as an allowed prefix. -To configure the list of allowed prefixes, use *stylecop.json* like the following: +To configure the list of allowed prefixes, use **stylecop.json** like the following: ```json {