forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Separate IEditorConfigOptionMappingService from IGlobalOption…
…Service (dotnet#61899)" This reverts commit 29a29d5.
- Loading branch information
Showing
29 changed files
with
410 additions
and
250 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
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
39 changes: 39 additions & 0 deletions
39
src/Features/Core/Portable/Diagnostics/AnalyzerConfigOptionSet+AnalyzerConfigOptionsImpl.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis.PooledObjects; | ||
|
||
namespace Microsoft.CodeAnalysis.Diagnostics | ||
{ | ||
internal sealed partial class AnalyzerConfigOptionSet | ||
{ | ||
private sealed class AnalyzerConfigOptionsImpl : AnalyzerConfigOptions | ||
{ | ||
private readonly AnalyzerConfigOptions _options; | ||
private readonly AnalyzerConfigOptions _fallbackOptions; | ||
|
||
public AnalyzerConfigOptionsImpl(AnalyzerConfigOptions options, AnalyzerConfigOptions fallbackOptions) | ||
{ | ||
_options = options; | ||
_fallbackOptions = fallbackOptions; | ||
} | ||
|
||
public override bool TryGetValue(string key, [NotNullWhen(true)] out string? value) | ||
{ | ||
if (_options.TryGetValue(key, out value)) | ||
{ | ||
return true; | ||
} | ||
|
||
return _fallbackOptions.TryGetValue(key, out value); | ||
} | ||
|
||
public override IEnumerable<string> Keys | ||
=> _options.Keys.Concat(_fallbackOptions.Keys.Where(key => !_options.TryGetValue(key, out _))); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/Features/Core/Portable/Diagnostics/AnalyzerConfigOptionSet.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.CodeAnalysis.Options; | ||
|
||
namespace Microsoft.CodeAnalysis.Diagnostics | ||
{ | ||
/// <summary> | ||
/// This class proxies requests for option values first to the <see cref="AnalyzerConfigOptions" /> then to a backup <see cref="OptionSet" /> if provided. | ||
/// </summary> | ||
internal sealed partial class AnalyzerConfigOptionSet : OptionSet | ||
{ | ||
private readonly AnalyzerConfigOptions _analyzerConfigOptions; | ||
private readonly OptionSet? _optionSet; | ||
|
||
public AnalyzerConfigOptionSet(AnalyzerConfigOptions analyzerConfigOptions, OptionSet? optionSet) | ||
{ | ||
_analyzerConfigOptions = analyzerConfigOptions; | ||
_optionSet = optionSet; | ||
} | ||
|
||
private protected override object GetOptionCore(OptionKey optionKey) | ||
{ | ||
// First try to find the option from the .editorconfig options parsed by the compiler. | ||
if (_analyzerConfigOptions.TryGetEditorConfigOption<object>(optionKey.Option, out var value)) | ||
{ | ||
return value; | ||
} | ||
|
||
// Fallback to looking for option from the document's optionset if unsuccessful. | ||
return _optionSet?.GetOption(optionKey) ?? optionKey.Option.DefaultValue!; | ||
} | ||
|
||
public override OptionSet WithChangedOption(OptionKey optionAndLanguage, object? value) | ||
=> throw new NotImplementedException(); | ||
|
||
private protected override AnalyzerConfigOptions CreateAnalyzerConfigOptions(ILegacyWorkspaceOptionService optionService, string? language) | ||
{ | ||
if (_optionSet is null) | ||
{ | ||
return _analyzerConfigOptions; | ||
} | ||
|
||
return new AnalyzerConfigOptionsImpl(_analyzerConfigOptions, _optionSet.AsAnalyzerConfigOptions(optionService, language)); | ||
} | ||
|
||
internal override IEnumerable<OptionKey> GetChangedOptions(OptionSet optionSet) | ||
=> throw new NotImplementedException(); | ||
} | ||
} |
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
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: 21 additions & 0 deletions
21
...VisualStudio/VisualStudioDiagnosticsToolWindow/OptionPages/InternalComponentsOnOffPage.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Options; | ||
|
||
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Options | ||
{ | ||
[Guid(Guids.RoslynOptionPageFeatureManagerComponentsIdString)] | ||
internal class InternalComponentsOnOffPage : AbstractOptionPage | ||
{ | ||
protected override AbstractOptionPageControl CreateOptionPage(IServiceProvider serviceProvider, OptionStore optionStore) | ||
{ | ||
return new InternalOptionsControl(nameof(EditorComponentOnOffOptions), optionStore); | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.