-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41839 from JoeRobich/revert-analyzerconfigoptions
Revert changes to AnalyzerConfigOptions
- Loading branch information
Showing
4 changed files
with
12 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 11 additions & 10 deletions
21
src/Workspaces/Core/Portable/Options/EditorConfig/EditorConfigStorageLocationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters