提交 59827874 编写于 作者: S Sam Harwell

Remove OptionGroup

上级 f5eb7df5
......@@ -10,6 +10,7 @@
namespace Microsoft.CodeAnalysis.CSharp {
using System;
using System.Reflection;
/// <summary>
......@@ -19,7 +20,7 @@ namespace Microsoft.CodeAnalysis.CSharp {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class CSharpCodeStyleResources {
......@@ -39,7 +40,7 @@ internal class CSharpCodeStyleResources {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources", typeof(CSharpCodeStyleResources).Assembly);
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.CSharp.CSharpCodeStyleResources", typeof(CSharpCodeStyleResources).GetTypeInfo().Assembly);
resourceMan = temp;
}
return resourceMan;
......@@ -61,47 +62,11 @@ internal class CSharpCodeStyleResources {
}
/// <summary>
/// Looks up a localized string similar to .
/// Looks up a localized string similar to Remove this value when another is added..
/// </summary>
internal static string Expected_string_or_char_literal {
internal static string EmptyResource {
get {
return ResourceManager.GetString("Expected_string_or_char_literal", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string Indentation_preferences {
get {
return ResourceManager.GetString("Indentation_preferences", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string New_line_preferences {
get {
return ResourceManager.GetString("New_line_preferences", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string Space_preferences {
get {
return ResourceManager.GetString("Space_preferences", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string Wrapping_preferences {
get {
return ResourceManager.GetString("Wrapping_preferences", resourceCulture);
return ResourceManager.GetString("EmptyResource", resourceCulture);
}
}
}
......
......@@ -117,19 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Expected_string_or_char_literal" xml:space="preserve">
<value />
</data>
<data name="Indentation_preferences" xml:space="preserve">
<value />
</data>
<data name="New_line_preferences" xml:space="preserve">
<value />
</data>
<data name="Space_preferences" xml:space="preserve">
<value />
</data>
<data name="Wrapping_preferences" xml:space="preserve">
<value />
<data name="EmptyResource" xml:space="preserve">
<value>Remove this value when another is added.</value>
<comment>https://github.com/Microsoft/msbuild/issues/1661</comment>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Odebrat tuto hodnotu, když se přidá jiná</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Dieser Wert wird entfernt, wenn ein anderer hinzugefügt wird.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Quite este valor cuando se agregue otro.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Supprimer cette valeur quand une autre est ajoutée.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Rimuovere questo valore quando ne viene aggiunto un altro.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">別の値が追加されたら、この値を削除します。</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ko" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">다른 값을 추가할 때 이 값을 제거하세요.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pl" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Usuń tę wartość, gdy dodawana jest kolejna.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pt-BR" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Remover este valor quando outro for adicionado.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ru" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Удалите это значение при добавлении другого значения.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="tr" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">Başka bir değer eklendiğinde bu değeri kaldırın.</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hans" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">在添加其他值时删除此值。</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hant" original="../CSharpCodeStyleResources.resx">
<body />
<body>
<trans-unit id="EmptyResource">
<source>Remove this value when another is added.</source>
<target state="translated">當新增另一個值時移除此值。</target>
<note>https://github.com/Microsoft/msbuild/issues/1661</note>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
......@@ -97,24 +97,6 @@ internal class CodeStyleResources {
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string Indentation_and_spacing {
get {
return ResourceManager.GetString("Indentation_and_spacing", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
internal static string New_line_preferences {
get {
return ResourceManager.GetString("New_line_preferences", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
......
......@@ -129,12 +129,6 @@
<data name="Fix_formatting" xml:space="preserve">
<value>Fix formatting</value>
</data>
<data name="Indentation_and_spacing" xml:space="preserve">
<value />
</data>
<data name="New_line_preferences" xml:space="preserve">
<value />
</data>
<data name="None" xml:space="preserve">
<value />
</data>
......
......@@ -13,22 +13,22 @@ internal static class FormattingOptions
internal static ImmutableArray<IOption> AllOptions { get; }
private static PerLanguageOption<T> CreatePerLanguageOption<T>(OptionGroup group, string name, T defaultValue, params OptionStorageLocation[] storageLocations)
private static PerLanguageOption<T> CreatePerLanguageOption<T>(string name, T defaultValue, params OptionStorageLocation[] storageLocations)
{
var option = new PerLanguageOption<T>(nameof(FormattingOptions), group, name, defaultValue, storageLocations);
var option = new PerLanguageOption<T>(nameof(FormattingOptions), name, defaultValue, storageLocations);
s_allOptionsBuilder.Add(option);
return option;
}
private static Option<T> CreateOption<T>(OptionGroup group, string name, T defaultValue, params OptionStorageLocation[] storageLocations)
private static Option<T> CreateOption<T>(string name, T defaultValue, params OptionStorageLocation[] storageLocations)
{
var option = new Option<T>(nameof(FormattingOptions), group, name, defaultValue, storageLocations);
var option = new Option<T>(nameof(FormattingOptions), name, defaultValue, storageLocations);
s_allOptionsBuilder.Add(option);
return option;
}
public static PerLanguageOption<bool> UseTabs { get; } = CreatePerLanguageOption(
FormattingOptionGroups.IndentationAndSpacing, nameof(UseTabs),
nameof(UseTabs),
defaultValue: false,
storageLocations: new EditorConfigStorageLocation<bool>(
"indent_style",
......@@ -37,23 +37,23 @@ private static Option<T> CreateOption<T>(OptionGroup group, string name, T defau
// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<int> TabSize { get; } = CreatePerLanguageOption(
FormattingOptionGroups.IndentationAndSpacing, nameof(TabSize),
nameof(TabSize),
defaultValue: 4,
storageLocations: EditorConfigStorageLocation.ForInt32Option("tab_width"));
// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<int> IndentationSize { get; } = CreatePerLanguageOption(
FormattingOptionGroups.IndentationAndSpacing, nameof(IndentationSize),
nameof(IndentationSize),
defaultValue: 4,
storageLocations: EditorConfigStorageLocation.ForInt32Option("indent_size"));
// This is also serialized by the Visual Studio-specific LanguageSettingsPersister
public static PerLanguageOption<IndentStyle> SmartIndent { get; } = CreatePerLanguageOption(
FormattingOptionGroups.IndentationAndSpacing, nameof(SmartIndent),
nameof(SmartIndent),
defaultValue: IndentStyle.Smart);
public static PerLanguageOption<string> NewLine { get; } = CreatePerLanguageOption(
FormattingOptionGroups.NewLine, nameof(NewLine),
nameof(NewLine),
defaultValue: Environment.NewLine,
storageLocations: new EditorConfigStorageLocation<string>(
"end_of_line",
......@@ -61,7 +61,7 @@ private static Option<T> CreateOption<T>(OptionGroup group, string name, T defau
GetEndOfLineEditorConfigString));
internal static Option<bool> InsertFinalNewLine { get; } = CreateOption(
FormattingOptionGroups.NewLine, nameof(InsertFinalNewLine),
nameof(InsertFinalNewLine),
defaultValue: false,
storageLocations: EditorConfigStorageLocation.ForBoolOption("insert_final_newline"));
......@@ -79,11 +79,11 @@ private static Optional<string> ParseEditorConfigEndOfLine(string endOfLineValue
private static string GetEndOfLineEditorConfigString(string option)
=> s_parenthesesPreferenceMap.TryGetKey(option, out var editorConfigString) ? editorConfigString : null;
internal static PerLanguageOption<bool> DebugMode { get; } = CreatePerLanguageOption(OptionGroup.Default, nameof(DebugMode), defaultValue: false);
internal static PerLanguageOption<bool> DebugMode { get; } = CreatePerLanguageOption(nameof(DebugMode), defaultValue: false);
internal static Option<bool> AllowConcurrent { get; } = new Option<bool>(nameof(FormattingOptions), nameof(AllowConcurrent), defaultValue: true);
internal static Option<bool> AllowDisjointSpanMerging { get; } = CreateOption(OptionGroup.Default, nameof(AllowDisjointSpanMerging), defaultValue: false);
internal static Option<bool> AllowDisjointSpanMerging { get; } = CreateOption(nameof(AllowDisjointSpanMerging), defaultValue: false);
static FormattingOptions()
{
......@@ -99,10 +99,4 @@ public enum IndentStyle
Smart = 2
}
}
internal static class FormattingOptionGroups
{
public static readonly OptionGroup IndentationAndSpacing = new OptionGroup(CodeStyleResources.Indentation_and_spacing, priority: 1);
public static readonly OptionGroup NewLine = new OptionGroup(CodeStyleResources.New_line_preferences, priority: 2);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Options
{
/// <summary>
/// Group/sub-feature associated with an <see cref="IOption"/>.
/// </summary>
internal interface IOptionWithGroup : IOption
{
/// <summary>
/// Group/sub-feature for this option.
/// </summary>
OptionGroup Group { get; }
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.CodeAnalysis.Options
{
/// <summary>
/// Group/sub-feature associated with an <see cref="IOption"/>.
/// </summary>
internal sealed class OptionGroup
{
public static readonly OptionGroup Default = new OptionGroup(string.Empty, int.MaxValue);
public OptionGroup(string description, int priority)
{
Description = description ?? throw new ArgumentNullException(nameof(description));
Priority = priority;
}
/// <summary>
/// A localizable resource description string for the option group.
/// </summary>
public string Description { get; }
/// <summary>
/// Relative priority of the option group with respect to other option groups within the same feature.
/// </summary>
public int Priority { get; }
}
}
......@@ -2,25 +2,19 @@
using System;
using System.Collections.Immutable;
using System.Diagnostics;
namespace Microsoft.CodeAnalysis.Options
{
/// <summary>
/// An global option. An instance of this class can be used to access an option value from an OptionSet.
/// </summary>
internal class Option<T> : IOptionWithGroup
internal class Option<T> : IOption
{
/// <summary>
/// Feature this option is associated with.
/// </summary>
public string Feature { get; }
/// <summary>
/// Optional group/sub-feature for this option.
/// </summary>
internal OptionGroup Group { get; }
/// <summary>
/// The name of the option.
/// </summary>
......@@ -50,29 +44,18 @@ public Option(string feature, string name, T defaultValue)
}
public Option(string feature, string name, T defaultValue, params OptionStorageLocation[] storageLocations)
: this(feature, group: OptionGroup.Default, name, defaultValue, storageLocations)
{
}
internal Option(string feature, OptionGroup group, string name, T defaultValue, params OptionStorageLocation[] storageLocations)
{
if (string.IsNullOrWhiteSpace(feature))
{
throw new ArgumentNullException(nameof(feature));
}
if (group == null)
{
throw new ArgumentNullException(nameof(group));
}
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException(nameof(name));
}
this.Feature = feature;
this.Group = group;
this.Name = name;
this.DefaultValue = defaultValue;
this.StorageLocations = storageLocations.ToImmutableArray();
......@@ -82,8 +65,6 @@ internal Option(string feature, OptionGroup group, string name, T defaultValue,
bool IOption.IsPerLanguage => false;
OptionGroup IOptionWithGroup.Group => this.Group;
public override string ToString()
{
return string.Format("{0} - {1}", this.Feature, this.Name);
......
......@@ -2,7 +2,6 @@
using System;
using System.Collections.Immutable;
using System.Diagnostics;
namespace Microsoft.CodeAnalysis.Options
{
......@@ -10,18 +9,13 @@ namespace Microsoft.CodeAnalysis.Options
/// An option that can be specified once per language.
/// </summary>
/// <typeparam name="T"></typeparam>
internal class PerLanguageOption<T> : IOptionWithGroup
internal class PerLanguageOption<T> : IOption
{
/// <summary>
/// Feature this option is associated with.
/// </summary>
public string Feature { get; }
/// <summary>
/// Optional group/sub-feature for this option.
/// </summary>
internal OptionGroup Group { get; }
/// <summary>
/// The name of the option.
/// </summary>
......@@ -45,29 +39,18 @@ public PerLanguageOption(string feature, string name, T defaultValue)
}
public PerLanguageOption(string feature, string name, T defaultValue, params OptionStorageLocation[] storageLocations)
: this(feature, group: OptionGroup.Default, name, defaultValue, storageLocations)
{
}
internal PerLanguageOption(string feature, OptionGroup group, string name, T defaultValue, params OptionStorageLocation[] storageLocations)
{
if (string.IsNullOrWhiteSpace(feature))
{
throw new ArgumentNullException(nameof(feature));
}
if (group == null)
{
throw new ArgumentNullException(nameof(group));
}
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException(nameof(name));
}
this.Feature = feature;
this.Group = group;
this.Name = name;
this.DefaultValue = defaultValue;
this.StorageLocations = storageLocations.ToImmutableArray();
......@@ -77,8 +60,6 @@ internal PerLanguageOption(string feature, OptionGroup group, string name, T def
bool IOption.IsPerLanguage => true;
OptionGroup IOptionWithGroup.Group => this.Group;
public override string ToString()
{
return string.Format("{0} - {1}", this.Feature, this.Name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册