Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changes to AnalyzerConfigOptions #41839

Merged
merged 2 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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