提交 b37f5665 编写于 作者: M Manish Vasani

Revert "turn off csharp full solution analysis."

This reverts commit ffec6afc.
上级 bc827351
......@@ -10,7 +10,6 @@ Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.UnitTests.Diagnostics
......@@ -1918,9 +1917,6 @@ class MyClass
</Workspace>
Using workspace = TestWorkspace.CreateWorkspace(test)
' set csharp closed diagnostic option on
workspace.Options = workspace.Options.WithChangedOption(ServiceFeatureOnOffOptions.ClosedFileDiagnostic, LanguageNames.CSharp, True)
Dim project = workspace.CurrentSolution.Projects.Single()
' Add analyzer
......
// 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.Collections.Immutable;
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.Shared.Options
......@@ -14,7 +13,6 @@ internal static class ServiceFeatureOnOffOptions
/// this option doesn't mean we will show all diagnostics that belong to opened files when turned off,
/// rather it means we will only show diagnostics that are cheap to calculate for small scope such as opened files.
/// </summary>
public static readonly PerLanguageOption<bool> ClosedFileDiagnostic = new PerLanguageOption<bool>(
OptionName, "Closed File Diagnostic", defaultValue: true, perLanguageDefaults: ImmutableDictionary<string, bool>.Empty.Add(LanguageNames.CSharp, false));
public static readonly PerLanguageOption<bool> ClosedFileDiagnostic = new PerLanguageOption<bool>(OptionName, "Closed File Diagnostic", defaultValue: true);
}
}
......@@ -34,7 +34,7 @@ public virtual bool TryPersist(OptionKey optionKey, object value)
return TryPersist(optionKey, value, (r, k, o, v) => r.SetValue(k, (bool)v ? 1 : 0, RegistryValueKind.DWord));
}
protected bool TryFetch(OptionKey optionKey, Func<RegistryKey, string, OptionKey, object> valueGetter, out object value)
protected bool TryFetch(OptionKey optionKey, Func<RegistryKey, string, IOption, object> valueGetter, out object value)
{
if (this.RegistryKey == null)
{
......@@ -58,7 +58,7 @@ protected bool TryFetch(OptionKey optionKey, Func<RegistryKey, string, OptionKey
return false;
}
value = valueGetter(subKey, collectionPathAndPropertyName.Item2, optionKey);
value = valueGetter(subKey, collectionPathAndPropertyName.Item2, optionKey.Option);
return true;
}
}
......
......@@ -146,7 +146,7 @@ public virtual bool TryFetch(OptionKey optionKey, out object value)
}
var storageKey = GetStorageKeyForOption(optionKey.Option);
value = this.Manager.GetValueOrDefault(storageKey, optionKey.DefaultValue);
value = this.Manager.GetValueOrDefault(storageKey, optionKey.Option.DefaultValue);
return true;
}
......
// 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
{
internal interface IOption2 : IOption
{
object GetDefaultValue(string language);
}
}
......@@ -10,8 +10,6 @@ public struct OptionKey : IEquatable<OptionKey>
public IOption Option { get; }
public string Language { get; }
internal object DefaultValue => ((IOption2)Option).GetDefaultValue(Language);
public OptionKey(IOption option, string language = null)
{
if (option == null)
......
......@@ -81,7 +81,7 @@ private object LoadOptionFromSerializerOrGetDefault(OptionKey optionKey)
// Just use the default. We will still cache this so we aren't trying to deserialize
// over and over.
return optionKey.DefaultValue;
return optionKey.Option.DefaultValue;
}
}
......
......@@ -51,7 +51,7 @@ public object GetOption(OptionKey optionKey)
if (!_values.TryGetValue(optionKey, out value))
{
value = _service != null ? _service.GetOption(optionKey) : optionKey.DefaultValue;
value = _service != null ? _service.GetOption(optionKey) : optionKey.Option.DefaultValue;
_values = _values.Add(optionKey, value);
}
......
......@@ -7,7 +7,7 @@ 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>
public class Option<T> : IOption2, IOption
public class Option<T> : IOption
{
/// <summary>
/// Feature this option is associated with.
......@@ -22,7 +22,10 @@ public class Option<T> : IOption2, IOption
/// <summary>
/// The type of the option value.
/// </summary>
public Type Type => typeof(T);
public Type Type
{
get { return typeof(T); }
}
/// <summary>
/// The default value of the option.
......@@ -46,13 +49,19 @@ public Option(string feature, string name, T defaultValue = default(T))
this.DefaultValue = defaultValue;
}
Type IOption.Type => typeof(T);
object IOption.DefaultValue => this.DefaultValue;
bool IOption.IsPerLanguage => false;
Type IOption.Type
{
get { return typeof(T); }
}
object IOption.DefaultValue
{
get { return this.DefaultValue; }
}
object IOption2.GetDefaultValue(string language)
bool IOption.IsPerLanguage
{
return this.DefaultValue;
get { return false; }
}
public override string ToString()
......
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Options
{
......@@ -10,13 +8,8 @@ namespace Microsoft.CodeAnalysis.Options
/// An option that can be specified once per language.
/// </summary>
/// <typeparam name="T"></typeparam>
public class PerLanguageOption<T> : IOption2, IOption
public class PerLanguageOption<T> : IOption
{
/// <summary>
/// Save per language defaults
/// </summary>
private readonly IImmutableDictionary<string, T> _perLanguageDefaults;
/// <summary>
/// Feature this option is associated with.
/// </summary>
......@@ -40,32 +33,7 @@ public Type Type
/// </summary>
public T DefaultValue { get; }
/// <summary>
/// The default option value of specific language
/// </summary>
internal T GetDefaultValue(string language)
{
if (_perLanguageDefaults.Count == 0)
{
return DefaultValue;
}
T languageSpecificDefault;
if (!_perLanguageDefaults.TryGetValue(language, out languageSpecificDefault))
{
return DefaultValue;
}
return languageSpecificDefault;
}
public PerLanguageOption(string feature, string name, T defaultValue) :
this(feature, name, defaultValue, ImmutableDictionary<string, T>.Empty)
{
}
internal PerLanguageOption(
string feature, string name, T defaultValue, IDictionary<string, T> perLanguageDefaults)
public PerLanguageOption(string feature, string name, T defaultValue)
{
if (string.IsNullOrWhiteSpace(feature))
{
......@@ -77,18 +45,9 @@ internal T GetDefaultValue(string language)
throw new ArgumentException(nameof(name));
}
if (perLanguageDefaults == null)
{
throw new ArgumentNullException(nameof(perLanguageDefaults));
}
this.Feature = feature;
this.Name = name;
this.DefaultValue = defaultValue;
this._perLanguageDefaults =
(perLanguageDefaults as IImmutableDictionary<string, T>) ??
ImmutableDictionary.CreateRange<string, T>(perLanguageDefaults);
}
Type IOption.Type
......@@ -106,11 +65,6 @@ bool IOption.IsPerLanguage
get { return true; }
}
object IOption2.GetDefaultValue(string language)
{
return this.GetDefaultValue(language);
}
public override string ToString()
{
return string.Format("{0} - {1}", this.Feature, this.Name);
......
......@@ -393,7 +393,6 @@
<Compile Include="FindSymbols\DeclaredSymbolInfo.cs" />
<Compile Include="FindSymbols\FindReferences\Finders\ILanguageServiceReferenceFinder.cs" />
<Compile Include="LinkedFileDiffMerging\LinkedFileDiffMergingLogger.cs" />
<Compile Include="Options\IOption2.cs" />
<Compile Include="Packaging\IPackageInstallerService.cs" />
<Compile Include="Packaging\IPackageSearchService.cs" />
<Compile Include="FindSymbols\SymbolTree\ISymbolTreeInfoCacheService.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册