diff --git a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
index 3cf6989c6130d3556fee617781627e5f531db922..d46e2128872530b1372d0385c59fa1c9a55454b4 100644
--- a/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
+++ b/src/VisualStudio/CSharp/Impl/Options/Formatting/StyleViewModel.cs
@@ -560,6 +560,32 @@ class Customer2
void DoWork(CancellationToken cancellationToken = default(CancellationToken)) {{ }}
//]
}}
+";
+
+ private static readonly string s_preferSimplifiedConditionalExpressions = $@"
+using System.Threading;
+
+class Customer1
+{{
+ bool A() => true;
+ bool B() => true;
+
+ void M1()
+ {{
+//[
+ // {ServicesVSResources.Prefer_colon}
+ var x = A() && B();
+//]
+ }}
+
+ void M2()
+ {{
+//[
+ // {ServicesVSResources.Over_colon}
+ var x = A() && B() ? true : false
+//]
+ }}
+}}
";
private static readonly string s_preferInferredTupleName = $@"
@@ -1658,6 +1684,7 @@ internal StyleViewModel(OptionStore optionStore, IServiceProvider serviceProvide
// Expression preferences
CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, this, optionStore, expressionPreferencesGroupTitle));
CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, this, optionStore, expressionPreferencesGroupTitle));
+ CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferSimplifiedConditionalExpression, ServicesVSResources.Prefer_simplified_conditional_expressions, s_preferSimplifiedConditionalExpressions, s_preferSimplifiedConditionalExpressions, this, optionStore, expressionPreferencesGroupTitle));
CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferSwitchExpression, CSharpVSResources.Prefer_switch_expression, s_preferSwitchExpression, s_preferSwitchExpression, this, optionStore, expressionPreferencesGroupTitle));
CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferPatternMatchingOverIsWithCastCheck, CSharpVSResources.Prefer_pattern_matching_over_is_with_cast_check, s_preferPatternMatchingOverIsWithCastCheck, s_preferPatternMatchingOverIsWithCastCheck, this, optionStore, expressionPreferencesGroupTitle));
CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferPatternMatchingOverAsWithNullCheck, CSharpVSResources.Prefer_pattern_matching_over_as_with_null_check, s_preferPatternMatchingOverAsWithNullCheck, s_preferPatternMatchingOverAsWithNullCheck, this, optionStore, expressionPreferencesGroupTitle));
diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx
index 71c5bd63a649a7e7da860f279b0a7a28970edef7..e853eb084589b93a9e7ed477594004ac1157dd32 100644
--- a/src/VisualStudio/Core/Def/ServicesVSResources.resx
+++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx
@@ -1372,4 +1372,7 @@ I agree to all of the foregoing:
Some color scheme colors are being overridden by changes made in the Environment > Fonts and Colors options page. Choose `Use Defaults` in the Fonts and Colors page to revert all customizations.
+
+ Prefer simplified conditional expressions
+
\ No newline at end of file
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf
index 87bdadf433a7d71ba3ba3b07c33521dc32aed1f4..3283a1348dec4a9dbf0e2987594f0f38b2c20855 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf
@@ -427,6 +427,11 @@
Preferovat jednoduchý příkaz using
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Preferovat statické místní funkce
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf
index 1b0936feabeeefb90112f356b219e3709ff62e7e..6701b555c3ee2a45bceadf6b070ef756f6aefb79 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf
@@ -427,6 +427,11 @@
Einfache using-Anweisung bevorzugen
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Statische lokale Funktionen bevorzugen
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf
index 88ddbd1c2b494bf817b38ccdc96b0760511b8eca..74e36e512a5fea340241e2a4bf903c8eaae9e051 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf
@@ -427,6 +427,11 @@
Preferir la instrucción "using" sencilla
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Preferir funciones locales estáticas
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf
index 37d6cd46c5a979cb315db1a66c1d8e06c157c3a5..341605d664bd91cc73792110a00868889187070d 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf
@@ -427,6 +427,11 @@
Préférer une instruction 'using' simple
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Préférer les fonctions locales statiques
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf
index ceba47ff834ae5023fa40b6853914dec67c87785..2400556d1d21598a7770ebb39cf0bacbf3052d52 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf
@@ -427,6 +427,11 @@
Preferisci l'istruzione 'using' semplice
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Preferisci funzioni locali statiche
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf
index f04a2bf3893674a892c236feddaf25dc7585c6b3..408bb327a181f3735850386e22e4c2d36b16519d 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf
@@ -427,6 +427,11 @@
単純な 'using' ステートメントを優先する
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
静的ローカル関数を優先する
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf
index d11f9bd4e7863a87da03b1a7e9d90ff467cc3ac5..b8ead839a3ba9da88e5206328847ef0fc125712a 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf
@@ -427,6 +427,11 @@
간단한 'using' 문 선호
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
정적 로컬 함수 선호
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf
index f45986bdcdf942b513e3e97d5fc80c6aa41b02fa..4c1b95386fb04d9444c7d0730d624c911b506196 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf
@@ -427,6 +427,11 @@
Preferuj prostą instrukcję „using”
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Preferuj statyczne funkcje lokalne
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf
index ee0dbcd1f2554c9df3a1f8a953551be35c04dbb3..a9ea92ebbc823160af149cd286a3387e3f2ff6b2 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf
@@ -427,6 +427,11 @@
Preferir a instrução 'using' simples
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Preferir as funções locais estáticas
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf
index a2192fc38ef53562c747c958eb0735348d8ae693..e11d6466c2f76cffca9f1c827624ee5b85f40eb4 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf
@@ -427,6 +427,11 @@
Предпочитать простой оператор using
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Предпочитать статические локальные функции
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf
index bf044302168315b99d00f7fd98a5cf76e053321f..a5a6d51fe56c752823f0e2b3d2a8f01079c3df2c 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf
@@ -427,6 +427,11 @@
Basit 'using' deyimini tercih et
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
Statik yerel işlevleri tercih et
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf
index 9367756b62d51aa04d3c0c54519d04dcb510c8ba..7d674fceca5504c13a96decce1dbf04c4ba08c91 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf
@@ -427,6 +427,11 @@
首选简单的 "using" 语句
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
首选静态本地函数
diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf
index 53cbfe94d3c0847b1ac715ac5e62067e3b691a5f..06f5c04fba5c955ab940cf09f5e408d5a6b42ae5 100644
--- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf
+++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf
@@ -427,6 +427,11 @@
優先使用簡單的 'using' 陳述式
+
+ Prefer simplified conditional expressions
+ Prefer simplified conditional expressions
+
+
Prefer static local functions
優先使用靜態區域函式
diff --git a/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb b/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb
index 3ad3dea02a962e5ac75fa032641c16bd565463fc..052be54f0b0e33f62ac289abb31b3d5b8394c4db 100644
--- a/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb
+++ b/src/VisualStudio/VisualBasic/Impl/Options/StyleViewModel.vb
@@ -196,6 +196,32 @@ Class Customer
End Sub
End Class"
+ Private Shared ReadOnly s_preferSimplifiedConditionalExpressions As String = $"
+
+Class Customer
+ Sub M1()
+//[
+ ' {ServicesVSResources.Prefer_colon}
+ Dim x = A() AndAlso B()
+//]
+ End Sub
+
+ Sub M2()
+//[
+ ' {ServicesVSResources.Over_colon}
+ Dim x = If(A() AndAlso B(), True, False)
+//]
+ End Sub
+
+ Function A() As Boolean
+ Return True
+ End Function
+
+ Function B() As Boolean
+ Return True
+ End Function
+End Class"
+
Private Shared ReadOnly s_preferExplicitTupleName As String = $"
Class Customer
Sub M1()
@@ -692,6 +718,7 @@ End Class
' expression preferences
Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, Me, optionStore, expressionPreferencesGroupTitle))
Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, Me, optionStore, expressionPreferencesGroupTitle))
+ Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferSimplifiedConditionalExpression, ServicesVSResources.Prefer_simplified_conditional_expressions, s_preferSimplifiedConditionalExpressions, s_preferSimplifiedConditionalExpressions, Me, optionStore, expressionPreferencesGroupTitle))
Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, Me, optionStore, expressionPreferencesGroupTitle))
Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredTupleNames, ServicesVSResources.Prefer_inferred_tuple_names, s_preferInferredTupleName, s_preferInferredTupleName, Me, optionStore, expressionPreferencesGroupTitle))
Me.CodeStyleItems.Add(New BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, ServicesVSResources.Prefer_inferred_anonymous_type_member_names, s_preferInferredAnonymousTypeMemberName, s_preferInferredAnonymousTypeMemberName, Me, optionStore, expressionPreferencesGroupTitle))