Skip to content

Commit

Permalink
Merge pull request #41839 from JoeRobich/revert-analyzerconfigoptions
Browse files Browse the repository at this point in the history
Revert changes to AnalyzerConfigOptions
  • Loading branch information
JoeRobich authored Feb 21, 2020
2 parents a3145c0 + 8864ebc commit 3a8ef2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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;
}
}
1 change: 0 additions & 1 deletion src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
// 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
{
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. See https://github.com/dotnet/roslyn/issues/41840
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 3a8ef2d

Please sign in to comment.