Skip to content

Commit

Permalink
Merge pull request dotnet#38689 from jasonmalinowski/delete-nullable-…
Browse files Browse the repository at this point in the history
…analysis-checkbox

Delete the checkbox to control nullable analysis in the IDE
  • Loading branch information
jasonmalinowski authored Oct 29, 2019
2 parents 916e492 + b84a4d5 commit 855509a
Show file tree
Hide file tree
Showing 23 changed files with 2 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.QuickInfo;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
Expand Down Expand Up @@ -6569,31 +6568,9 @@ void N()
}

[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task NullableNotShownWithoutFeatureFlag()
public async Task NullableNotShownInNullableDisable()
{
var options = TestOptions.Regular8.WithFeature(CompilerFeatureFlags.RunNullableAnalysis, "false");
await TestWithOptionsAsync(options,
@"#nullable enable
using System.Collections.Generic;
class X
{
void N()
{
string s = """";
string s2 = $$s;
}
}",
MainDescription($"({FeaturesResources.local_variable}) string s"),
NullabilityAnalysis(""));
}

[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task NullableNotShownInNullableDisableContextEvenIfAnalysisIsRunning()
{
var options = TestOptions.Regular8.WithFeature(CompilerFeatureFlags.RunNullableAnalysis, "true");
await TestWithOptionsAsync(options,
await TestWithOptionsAsync(TestOptions.Regular8,
@"#nullable disable
using System.Collections.Generic;
Expand Down
10 changes: 0 additions & 10 deletions src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ internal static class FeatureOnOffOptions
nameof(FeatureOnOffOptions), nameof(UseEnhancedColors), defaultValue: 1,
storageLocations: new RoamingProfileStorageLocation("WindowManagement.Options.UseEnhancedColorsForManagedLanguages"));

/// <summary>
/// Feature to enable <see cref="CompilerFeatureFlags.RunNullableAnalysis"/> in the compiler flags for all csharp projects.
/// 0 = default, which leaves the flag unset.
/// 1 = set to true
/// -1 = set to false
/// </summary>
public static readonly Option<int> UseNullableReferenceTypeAnalysis = new Option<int>(
nameof(FeatureOnOffOptions), nameof(UseNullableReferenceTypeAnalysis), defaultValue: 0,
storageLocations: new RoamingProfileStorageLocation($"TextEditor.CSharp.{nameof(UseNullableReferenceTypeAnalysis)}"));

// Note: no storage location since this is intentionally a session variable
public static readonly Option<bool> AcceptedDecompilerDisclaimer = new Option<bool>(
nameof(FeatureOnOffOptions), nameof(AcceptedDecompilerDisclaimer), defaultValue: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_Enable_full_solution_analysis}" />
<CheckBox x:Name="Enable_navigation_to_decompiled_sources"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Enable_navigation_to_decompiled_sources}" />
<CheckBox x:Name="Enable_use_nullable_reference_types"
IsThreeState="True"
Content="{x:Static local:AdvancedOptionPageStrings.Option_use_nullable_reference_analysis_IDE_features}" />
<CheckBox x:Name="Use_editorconfig_compatibility_mode"
Content="{x:Static local:AdvancedOptionPageStrings.Option_use_editorconfig_compatibility_mode}" />
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public AdvancedOptionPageControl(OptionStore optionStore) : base(optionStore)

BindToFullSolutionAnalysisOption(Enable_full_solution_analysis, LanguageNames.CSharp);
BindToOption(Enable_navigation_to_decompiled_sources, FeatureOnOffOptions.NavigateToDecompiledSources);
BindTristateToOption(Enable_use_nullable_reference_types, FeatureOnOffOptions.UseNullableReferenceTypeAnalysis);
BindToOption(Use_editorconfig_compatibility_mode, EditorConfigDocumentOptionsProviderFactory.UseLegacyEditorConfigSupport);

BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public static string Option_Enable_full_solution_analysis
public static string Option_Enable_navigation_to_decompiled_sources
=> ServicesVSResources.Enable_navigation_to_decompiled_sources;

public static string Option_use_nullable_reference_analysis_IDE_features
=> ServicesVSResources.Enable_nullable_reference_analysis_IDE_features;

public static string Option_use_editorconfig_compatibility_mode
=> ServicesVSResources.Use_editorconfig_compatibility_mode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
using System.Collections.Immutable;
using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Shared.Options;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Expand All @@ -27,7 +24,6 @@ internal class VisualStudioProjectOptionsProcessor : IDisposable
private CommandLineArguments _commandLineArgumentsForCommandLine;
private string _explicitRuleSetFilePath;
private IReferenceCountedDisposable<ICacheEntry<string, IRuleSetFile>> _ruleSetFile = null;
private readonly IOptionService _optionService;

public VisualStudioProjectOptionsProcessor(VisualStudioProject project, HostWorkspaceServices workspaceServices)
{
Expand All @@ -37,15 +33,6 @@ public VisualStudioProjectOptionsProcessor(VisualStudioProject project, HostWork

// Set up _commandLineArgumentsForCommandLine to a default. No lock taken since we're in the constructor so nothing can race.
ReparseCommandLine_NoLock();

_optionService = workspaceServices.GetRequiredService<IOptionService>();

// For C#, we need to listen to the options for NRT analysis
// that can change in VS through tools > options
if (_project.Language == LanguageNames.CSharp)
{
_optionService.OptionChanged += OptionService_OptionChanged;
}
}

public string CommandLine
Expand Down Expand Up @@ -113,15 +100,6 @@ public string EffectiveRuleSetFilePath
}
}

private void OptionService_OptionChanged(object sender, OptionChangedEventArgs e)
{
if (e.Option.Name == FeatureOnOffOptions.UseNullableReferenceTypeAnalysis.Name
&& e.Option.Feature == FeatureOnOffOptions.UseNullableReferenceTypeAnalysis.Feature)
{
UpdateProjectForNewHostValues();
}
}

private void DisposeOfRuleSetFile_NoLock()
{
if (_ruleSetFile != null)
Expand Down Expand Up @@ -178,8 +156,6 @@ private void UpdateProjectOptions_NoLock()
var parseOptions = _commandLineArgumentsForCommandLine.ParseOptions
.WithDocumentationMode(documentationMode);

parseOptions = ComputeOptionsServiceParseOptions(parseOptions);

// We've computed what the base values should be; we now give an opportunity for any host-specific settings to be computed
// before we apply them
compilationOptions = ComputeCompilationOptionsWithHostValues(compilationOptions, this._ruleSetFile?.Target.Value);
Expand All @@ -198,25 +174,6 @@ private void UpdateProjectOptions_NoLock()
_project.ParseOptions = parseOptions;
}

private ParseOptions ComputeOptionsServiceParseOptions(ParseOptions parseOptions)
{
if (_project.Language == LanguageNames.CSharp)
{
var useNullableReferenceAnalysisOption = _optionService.GetOption(FeatureOnOffOptions.UseNullableReferenceTypeAnalysis);

if (useNullableReferenceAnalysisOption == -1)
{
parseOptions = parseOptions.WithFeatures(new[] { KeyValuePairUtil.Create(CompilerFeatureFlags.RunNullableAnalysis, "false") });
}
else if (useNullableReferenceAnalysisOption == 1)
{
parseOptions = parseOptions.WithFeatures(new[] { KeyValuePairUtil.Create(CompilerFeatureFlags.RunNullableAnalysis, "true") });
}
}

return parseOptions;
}

private void RuleSetFile_UpdatedOnDisk(object sender, EventArgs e)
{
lock (_gate)
Expand Down Expand Up @@ -275,7 +232,6 @@ public void Dispose()
lock (_gate)
{
DisposeOfRuleSetFile_NoLock();
_optionService.OptionChanged -= OptionService_OptionChanged;
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/VisualStudio/Core/Def/ServicesVSResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1166,9 +1166,6 @@ I agree to all of the foregoing:</value>
<data name="Use_enhanced_colors_for_C_and_Basic" xml:space="preserve">
<value>Use enhanced colors for C# and Basic</value>
</data>
<data name="Enable_nullable_reference_analysis_IDE_features" xml:space="preserve">
<value>Enable nullable reference analysis IDE features</value>
</data>
<data name="Move_to_namespace" xml:space="preserve">
<value>Move to Namespace</value>
</data>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">Element není platný.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Povolit funkce rozhraní IDE pro analýzu odkazů, které můžou mít hodnotu null</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Vyhodnocování (počet úloh ve frontě: {0})</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">Das Element ist ungültig.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">IDE-Features zur Analyse von Nullable-Verweisen aktivieren</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Auswertung ({0} Tasks in der Warteschlange)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">El elemento no es válido.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Habilitar características de IDE de análisis de referencias que aceptan valores NULL</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Evaluando ({0} tareas en cola)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">L'élément n'est pas valide.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Activer les fonctionnalités de l'IDE pour l'analyse des références Nullable</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Évaluation ({0} tâches en file d'attente)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">L'elemento non è valido.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Abilita le funzionalità IDE per l'analisi dei riferimenti nullable</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">In fase di valutazione ({0} attività in coda)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">要素が有効ではありません。</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">NULL 許容参照分析の IDE 機能を有効にします</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">評価中 ({0} 個のタスクがキューにあります)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">요소가 잘못되었습니다.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">nullable 참조 분석 IDE 기능 사용</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">평가 중(큐의 {0}개 작업)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">Element jest nieprawidłowy.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Włącz funkcje środowiska IDE do analizy odwołań dopuszczających wartość null</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Szacowanie (zadania w kolejce: {0})</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">O elemento é inválido.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Habilitar recursos do IDE de análise de referência que permite valor nulo</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Avaliando ({0} tarefas na fila)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">Элемент недопустим.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Включить функции IDE для анализа ссылок, допускающих значение NULL</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Оценка (задач в очереди: {0})</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">Öğe geçerli değil.</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">Boş değer atanabilir başvuru analizi IDE özelliklerini etkinleştir</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">Değerlendiriliyor (kuyrukta {0} görev var)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">元素无效。</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">启用可为 null 的引用分析 IDE 功能</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">正在评估(队列中有 {0} 个任务)</target>
Expand Down
5 changes: 0 additions & 5 deletions src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<target state="translated">元素無效。</target>
<note />
</trans-unit>
<trans-unit id="Enable_nullable_reference_analysis_IDE_features">
<source>Enable nullable reference analysis IDE features</source>
<target state="translated">啟用可為 null 的參考分析 IDE 功能</target>
<note />
</trans-unit>
<trans-unit id="Evaluating_0_tasks_in_queue">
<source>Evaluating ({0} tasks in queue)</source>
<target state="translated">正在評估 (佇列中的 {0} 工作)</target>
Expand Down
Loading

0 comments on commit 855509a

Please sign in to comment.