提交 72b78427 编写于 作者: C CyrusNajmabadi

Add user option to control new feature.

上级 3ef12de6
......@@ -249,6 +249,27 @@ public C(string s)
//]
}
}
";
private static readonly string s_preferCoalesceExpression = @"
using System;
class C
{
private string s;
public C(string s)
{
//[
// Prefer:
var v = x ?? y;
// Over:
var v = x != null ? x : y; // and
var v = x == null ? y : x;
//]
}
}
";
private static readonly string s_preferConditionalDelegateCall = @"
......@@ -598,6 +619,7 @@ internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) :
// Null preferences.
CodeStyleItems.Add(new SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferThrowExpression, CSharpVSResources.Prefer_throw_expression, s_preferThrowExpression, s_preferThrowExpression, this, optionSet, nullCheckingGroupTitle));
CodeStyleItems.Add(new SimpleCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferConditionalDelegateCall, CSharpVSResources.Prefer_conditional_delegate_call, s_preferConditionalDelegateCall, s_preferConditionalDelegateCall, this, optionSet, nullCheckingGroupTitle));
CodeStyleItems.Add(new SimpleCodeStyleOptionViewModel(CodeStyleOptions.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, this, optionSet, nullCheckingGroupTitle));
}
}
}
\ No newline at end of file
......@@ -1365,6 +1365,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Prefer coalesce expression.
/// </summary>
internal static string Prefer_coalesce_expression {
get {
return ResourceManager.GetString("Prefer_coalesce_expression", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Prefer framework type.
/// </summary>
......
......@@ -804,4 +804,7 @@ Additional information: {1}</value>
<data name="This_item_cannot_be_deleted_because_it_is_used_by_an_existing_Naming_Rule" xml:space="preserve">
<value>This item cannot be deleted because it is used by an existing Naming Rule.</value>
</data>
<data name="Prefer_coalesce_expression" xml:space="preserve">
<value>Prefer coalesce expression</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册