public void OptionPerLanguageOption() { var optionService = TestOptionService.GetService(); var optionSet = optionService.GetOptions(); Assert.Throws<System.ArgumentException>(delegate { var option = new PerLanguageOption<bool>("Test Feature", "", false); }); Assert.Throws<System.ArgumentException>(delegate { var option2 = new PerLanguageOption<bool>("Test Feature", null, false); }); Assert.Throws<System.ArgumentNullException>(delegate { var option3 = new PerLanguageOption<bool>(" ", "Test Name", false); }); Assert.Throws<System.ArgumentNullException>(delegate { var option4 = new PerLanguageOption<bool>(null, "Test Name", false); }); var optionvalid = new PerLanguageOption<bool>("Test Feature", "Test Name", false); Assert.Equal(false, optionSet.GetOption(optionvalid, "CS")); }
public FullSolutionAnalysisOptionBinding(IOptionService optionService, string languageName) { _optionService = optionService; _languageName = languageName; _fullSolutionAnalysis = RuntimeOptions.FullSolutionAnalysis; _closedFileDiagnostics = ServiceFeatureOnOffOptions.ClosedFileDiagnostic; }
protected void BindToOption(CheckBox checkbox, PerLanguageOption<bool> optionKey, string languageName) { Binding binding = new Binding(); binding.Source = new PerLanguageOptionBinding<bool>(OptionService, optionKey, languageName); binding.Path = new PropertyPath("Value"); binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit; var bindingExpression = checkbox.SetBinding(CheckBox.IsCheckedProperty, binding); _bindingExpressions.Add(bindingExpression); }
protected void BindToOption(TextBox textBox, PerLanguageOption<int> optionKey, string languageName) { Binding binding = new Binding(); binding.Source = new PerLanguageOptionBinding<int>(OptionService, optionKey, languageName); binding.Path = new PropertyPath("Value"); binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit; var bindingExpression = textBox.SetBinding(TextBox.TextProperty, binding); _bindingExpressions.Add(bindingExpression); }
internal static bool GetFeatureOnOffOption(this ITextBuffer buffer, PerLanguageOption<bool> option) { // Add a FailFast to help diagnose 984249. Hopefully this will let us know what the issue is. try { var document = buffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); if (document != null) { return document.Project.Solution.Options.GetOption(option, document.Project.Language); } return option.DefaultValue; } catch (Exception e) when (FatalError.Report(e)) { throw ExceptionUtilities.Unreachable; } }
private string GetXmlOption(PerLanguageOption<CodeStyleOption<bool>> option) { return _workspace.Options.GetOption(option, LanguageNames.CSharp).ToXElement().ToString(); }
private IDictionary <OptionKey, object> GetSingleRequireOption(PerLanguageOption <CodeStyleOption <ParenthesesPreference> > option) => OptionsSet(GetAllParenthesesOptions() .Where(o => o != option) .Select(o => SingleOption(o, RemoveIfUnnecessaryPreference)) .Concat(SingleOption(option, RequireForPrecedenceClarityPreference)).ToArray());
private void SetOption <T>(PerLanguageOption <T> key, T value) { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(key, LanguageNames.CSharp, value))); }
private T GetOption <T>(PerLanguageOption <T> key) { return(_workspace.Options.GetOption(key, LanguageNames.CSharp)); }
public T GetOption <T>(PerLanguageOption <T> option, string languageName) { throw new NotImplementedException(); }
public static T GetOption <T>(this AnalyzerConfigOptions analyzerConfigOptions, PerLanguageOption <T> option) { if (!TryGetEditorConfigOptionOrDefault(analyzerConfigOptions, option, out T value)) { Debug.Fail("Failed to find a .editorconfig key for the option."); value = option.DefaultValue; } return(value); }
[return : MaybeNull] public T GetOption <T>(PerLanguageOption <T> option, string?languageName) => _globalOptionService.GetOption(option, languageName);
private void SetBooleanOption(PerLanguageOption<bool?> key, int value) { bool? boolValue = (value < 0) ? (bool?)null : (value > 0); var optionSet = _optionService.GetOptions(); optionSet = optionSet.WithChangedOption(key, LanguageNames.CSharp, boolValue); _optionService.SetOptions(optionSet); }
public static T GetOption <T>(this AnalyzerConfigOptions analyzerConfigOptions, PerLanguageOption <T> option, string language) { // Language is not used for .editorconfig lookups _ = language; return(GetOption(analyzerConfigOptions, option)); }
private Task TestMissingAsyncWithOptionAndNotificationOption(string code, PerLanguageOption <CodeStyleOption <bool> > option, NotificationOption notification) { return(TestMissingAsync(code, options: Option(option, true, notification))); }
private Task TestMissingAsyncWithOption(string code, PerLanguageOption <CodeStyleOption <bool> > option) { return(TestMissingAsyncWithOptionAndNotificationOption(code, option, NotificationOption.Error)); }
public static PerLanguageOption <T> CreateRuleSpecificOption <T>(ReportingDescriptor rule, PerLanguageOption <T> option) { // This helper returns a copy of a rule option that is qualified by a new feature name constructed // from an arbitrary rule instance. This allows users to create a generic property descriptor // that is further qualified (by feature name) to be associated with a different check. return(new PerLanguageOption <T>( feature: rule.Id + "." + rule.Name.Text, name: option.Name, defaultValue: option.DefaultValue, description: option.Description)); }
protected T GetOption <T>(ITextBuffer buffer, PerLanguageOption <T> option) { return(buffer.GetOption(option)); }
private void SetBooleanOption(PerLanguageOption<bool?> key, int value) { bool? boolValue = (value < 0) ? (bool?)null : (value > 0); _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, boolValue); }
public static T GetOption <T>(this AnalyzerConfigOptions analyzerConfigOptions, PerLanguageOption <T> option) { if (!TryGetEditorConfigOptionOrDefault(analyzerConfigOptions, option, out T value)) { // There are couple of reasons this assert might fire: // 1. Attempting to access an option which does not have an IEditorConfigStorageLocation. // 2. Attempting to access an option which is not exposed from any option provider, i.e. IOptionProvider.Options. Debug.Fail("Failed to find a .editorconfig key for the option."); value = option.DefaultValue; } return(value); }
public T?GetOption <T>(PerLanguageOption <T> option, string?languageName) => _globalOptionService.GetOption(option, languageName);
private void SetBooleanOption(PerLanguageOption<bool> key, int value) { var optionSet = _optionService.GetOptions(); optionSet = optionSet.WithChangedOption(key, LanguageNames.CSharp, value != 0); _optionService.SetOptions(optionSet); }
protected IDictionary <OptionKey, object> Option(PerLanguageOption <CodeStyle.CodeStyleOption <bool> > option, bool value, CodeStyle.NotificationOption notification) { return(OptionsSet(Tuple.Create(option, value, notification))); }
private DiagnosticDescriptor GetApplicablePredefinedTypeDiagnosticDescriptor <T>(string id, PerLanguageOption <T> option, OptionSet optionSet) where T : CodeStyleOption <bool> { var optionValue = optionSet.GetOption(option, GetLanguageName()); DiagnosticDescriptor descriptor = null; if (optionValue.Notification.Value != DiagnosticSeverity.Hidden) { descriptor = new DiagnosticDescriptor(id, s_localizableTitleSimplifyNames, s_localizableMessage, DiagnosticCategory.Style, optionValue.Notification.Value, isEnabledByDefault: true, customTags: DiagnosticCustomTags.Unnecessary); } return(descriptor); }
public T GetOption <T>(PerLanguageOption <T> option, string language) => _optionSet.GetOption(option, language);
static void ResetPerLanguageOption <T>(IGlobalOptionService globalOptions, PerLanguageOption <T> option) { globalOptions.SetGlobalOption(new OptionKey(option, LanguageNames.CSharp), option.DefaultValue); globalOptions.SetGlobalOption(new OptionKey(option, LanguageNames.VisualBasic), option.DefaultValue); }
public void SetOption <T>(PerLanguageOption <T> option, string language, T value) { _optionSet = _optionSet.WithChangedOption(option, language, value); OnOptionChanged(new OptionKey(option, language)); }
private int GetBooleanOption(PerLanguageOption <bool> key) { return(_workspace.Options.GetOption(key, LanguageNames.CSharp) ? 1 : 0); }
private void SetBooleanOption(PerLanguageOption <bool> key, int value) { _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, value != 0); }
private void SetBooleanOption(PerLanguageOption <bool> key, int value) { _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(_workspace.Options .WithChangedOption(key, LanguageNames.CSharp, value != 0))); }
private void SetOption <T>(PerLanguageOption <T> key, T value) { _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, value); }
private string GetXmlOption(PerLanguageOption <CodeStyleOption <bool> > option) { return(_workspace.Options.GetOption(option, LanguageNames.CSharp).ToXElement().ToString()); }
private void SetBooleanOption(PerLanguageOption <bool?> key, int value) { var boolValue = (value < 0) ? (bool?)null : (value > 0); _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, boolValue); }
private void SetXmlOption(PerLanguageOption <CodeStyleOption <bool> > option, string value) { var convertedValue = CodeStyleOption <bool> .FromXElement(XElement.Parse(value)); _workspace.Options = _workspace.Options.WithChangedOption(option, LanguageNames.CSharp, convertedValue); }
public PerLanguageOptionBinding(IOptionService optionService, PerLanguageOption <T> key, string languageName) { _optionService = optionService; _key = key; _languageName = languageName; }
private int GetBooleanOption(PerLanguageOption<bool> key) { return _workspace.Options.GetOption(key, LanguageNames.CSharp) ? 1 : 0; }
private Task TestMissingAsyncWithOption(string code, PerLanguageOption<CodeStyleOption<bool>> option) { return TestMissingAsyncWithOptionAndNotificationOption(code, option, NotificationOption.Error); }
private void SetBooleanOption(PerLanguageOption<bool> key, int value) { _workspace.Options = _workspace.Options.WithChangedOption(key, LanguageNames.CSharp, value != 0); }
private Task TestMissingAsyncWithOptionAndNotificationOption(string code, PerLanguageOption<CodeStyleOption<bool>> option, NotificationOption notification) { return TestMissingAsync(code, options: Option(option, true, notification)); }
private void SetXmlOption(PerLanguageOption<CodeStyleOption<bool>> option, string value) { var convertedValue = CodeStyleOption<bool>.FromXElement(XElement.Parse(value)); _workspace.Options = _workspace.Options.WithChangedOption(option, LanguageNames.CSharp, convertedValue); }
private bool IsFrameworkTypePreferred(OptionSet optionSet, PerLanguageOption <CodeStyleOption <bool> > option, string language) { var optionValue = optionSet.GetOption(option, language); return(OptionSettingPrefersFrameworkType(optionValue, optionValue.Notification.Value)); }
private int GetBooleanOption(PerLanguageOption<bool?> key) { var option = _optionService.GetOption(key, LanguageNames.CSharp); if (!option.HasValue) { return -1; } return option.Value ? 1 : 0; }
/// <summary> /// Find the <see cref="CodeStyleOption{T}"/> for <paramref name="key"/>. /// </summary> /// <typeparam name="T">The type of the value.</typeparam> /// <param name="document">The <see cref="Document"/>.</param> /// <param name="key">The <see cref="CodeStyleOption{T}"/> for c#.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that cancels the operation.</param> /// <returns><see cref="CodeStyleOption{T}"/> or null if not found.</returns> public static async Task <CodeStyleOption <T>?> FindInEditorConfigAsync <T>(Document document, PerLanguageOption <CodeStyleOption <T> > key, CancellationToken cancellationToken) { if (document is null) { throw new ArgumentNullException(nameof(document)); } if (key is null) { throw new ArgumentNullException(nameof(key)); } var optionSet = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); if (optionSet.GetOption(key, document.Project.Language) is { } option&& !ReferenceEquals(option, key.DefaultValue)) { return(option); } return(null); }
private int GetBooleanOption(PerLanguageOption<bool> key) { return _optionService.GetOption(key, LanguageNames.CSharp) ? 1 : 0; }
private int GetBooleanOption(PerLanguageOption <bool> key) { return(_optionService.GetOption(key, LanguageNames.CSharp) ? 1 : 0); }
protected IDictionary<OptionKey, object> Option(PerLanguageOption<CodeStyle.CodeStyleOption<bool>> option, bool value, CodeStyle.NotificationOption notification) { return OptionsSet(Tuple.Create(option, value, notification)); }
internal static IDictionary<OptionKey, object> With(this IDictionary<OptionKey, object> options, PerLanguageOption<CodeStyleOption<bool>> option, object value, string language) { options.Add(new OptionKey(option, language), value); return options; }