提交 312a0827 编写于 作者: J Joey Robichaud

Revert changes to AnalyzerConfigOptions

上级 b92b63b9
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -22,11 +23,6 @@ public abstract class AnalyzerConfigOptions
/// Get an analyzer config value for the given key, using the <see cref="KeyComparer"/>.
/// </summary>
public abstract bool TryGetValue(string key, out string value);
/// <summary>
/// Get the keys of the defined options.
/// </summary>
public abstract IEnumerable<string> Keys { get; }
}
internal sealed class CompilerAnalyzerConfigOptions : AnalyzerConfigOptions
......@@ -41,7 +37,5 @@ public CompilerAnalyzerConfigOptions(ImmutableDictionary<string, string> propert
}
public override bool TryGetValue(string key, out string value) => _backing.TryGetValue(key, out value);
public override IEnumerable<string> Keys => _backing.Keys;
}
}
......@@ -21,7 +21,6 @@ Microsoft.CodeAnalysis.SarifVersion.Latest = 2147483647 -> Microsoft.CodeAnalysi
Microsoft.CodeAnalysis.SarifVersion.Sarif1 = 1 -> Microsoft.CodeAnalysis.SarifVersion
Microsoft.CodeAnalysis.SarifVersion.Sarif2 = 2 -> Microsoft.CodeAnalysis.SarifVersion
Microsoft.CodeAnalysis.SarifVersionFacts
abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions.Keys.get -> System.Collections.Generic.IEnumerable<string>
Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions.IncludeNotNullableReferenceTypeModifier = 256 -> Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions
static Microsoft.CodeAnalysis.SarifVersionFacts.TryParse(string version, out Microsoft.CodeAnalysis.SarifVersion result) -> bool
Microsoft.CodeAnalysis.IMethodSymbol.IsConditional.get -> bool
......
// 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.Immutable;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Options
{
......@@ -11,15 +10,17 @@ internal static class EditorConfigStorageLocationExtensions
{
public static bool TryGetOption(this IEditorConfigStorageLocation editorConfigStorageLocation, AnalyzerConfigOptions analyzerConfigOptions, Type type, out object value)
{
var optionDictionary = analyzerConfigOptions.Keys.ToImmutableDictionary(
key => key,
key =>
{
analyzerConfigOptions.TryGetValue(key, out var optionValue);
return optionValue;
});
// This is a workaround until we have an API for enumeratings AnalyzerConfigOptions.
var backingField = analyzerConfigOptions.GetType().GetField("_backing", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var backing = backingField?.GetValue(analyzerConfigOptions);
return editorConfigStorageLocation.TryGetOption(optionDictionary, type, out value);
if (backing is IReadOnlyDictionary<string, string> backingDictionary)
{
return editorConfigStorageLocation.TryGetOption(backingDictionary, type, out value);
}
value = null;
return false;
}
}
}
......@@ -319,8 +319,6 @@ public WorkspaceAnalyzerConfigOptions(AnalyzerConfigOptionsResult analyzerConfig
}
public override bool TryGetValue(string key, out string value) => _backing.TryGetValue(key, out value);
public override IEnumerable<string> Keys => _backing.Keys;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册