-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Improve editorconfig options caching on ProjectState #61131
Conversation
src/EditorFeatures/CSharpTest/Diagnostics/NamingStyles/EditorConfigNamingStyleParserTests.cs
Show resolved
Hide resolved
...oreTest/EditorConfigStorageLocation/NamingStylePreferenceEditorConfigStorageLocationTests.cs
Show resolved
Hide resolved
@333fred PTAL, compiler public API change. |
Compiler side changes LGTM, assuming we ok the overall API. |
src/EditorFeatures/Core/EditorConfigSettings/DataProvider/SettingsProviderBase.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler changes LGTM. The API needs to be reviewed by API design, but as long as this doesn't ship publicly before then it's ok to proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review started but giving early feedback to address the comparer validation
src/Workspaces/CoreTest/CodeStyle/EditorConfigCodeStyleParserTests.cs
Outdated
Show resolved
Hide resolved
...es/SharedUtilitiesAndExtensions/Compiler/Core/Diagnostics/StructuredAnalyzerConfigOptions.cs
Show resolved
Hide resolved
src/Compilers/Core/Portable/DiagnosticAnalyzer/DictionaryAnalyzerConfigOptions.cs
Show resolved
Hide resolved
@@ -513,7 +513,7 @@ private void InitializeCachedOptions(OptionSet solutionOptions) | |||
Interlocked.CompareExchange(ref _cachedOptions, newAsyncLazy, comparand: null); | |||
} | |||
|
|||
internal Task<ImmutableDictionary<string, string>> GetAnalyzerOptionsAsync(CancellationToken cancellationToken) | |||
internal async Task<AnalyzerConfigData?> GetAnalyzerOptionsAsync(CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 This seems like a good candidate for ValueTask<>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will follow up.
…o poison * upstream/features/required-members: (413 commits) [EE] Implement IDkmClrFullNameProvider2 in Roslyn's ResultProvider Formatter. (dotnet#60522) Remove parameter null-checking from the Language Feature Status list (dotnet#61302) Add pointer for `AnalysisLevel` to warning waves doc (dotnet#61196) Add an UWP OptProf test for IDE Add test Fix issue where we were getting a raw-string in a skipped token, causing a crash Fix several LSP completion kind mappings (dotnet#61243) Relax assertion in SyntheticBoundNodeFactory.Convert (dotnet#61287) Enable add usings on paste by default (dotnet#61299) Fix focus on rename UI opening (dotnet#60846) Update PublishData.json with new package Remove Razor and editor inference document option providers (dotnet#61091) Fix nested in generic type binding issues in enabled nullability context (dotnet#61182) Revert "Revert "Improve editorconfig options caching on ProjectState (dotnet#61131)" (dotnet#61216)" (dotnet#61283) Move MSBuild back to 16.5.0. Fix a few build and package issues (dotnet#61273) lint Revert workspaces msbuild changes. Use SegmentedHashSet<T> to eliminate LOH allocations in AsyncBatchingWorkQueue NRT ...
Fixes #41840 by adding a new compiler API:
Use this API in Code Style and Workspace layers to parse
NamingStylePreferences
from the options.ProjectState
maintains a cache of editorconfig options for given source file path. The cache holds on raw options in form ofImmutableDictionary<string, string>
as returned by the compiler editorconfig parser. We currently wrap that dictionary in a new instance ofDictionaryAnalyzerConfigOptions
every time options are queried for the path. Elsewhere in the code we also maintain conditional weak table of the raw options dictionary to parsedNameStylePreferences
for caching purposes. As a TODO in the code says this caching logic is rather fragile. In yet another place in the code we have reflection code that relies on the fact thatDictionaryAnalyzerConfigOptions
, and not any other type, is used to represent the options. This is also fragile since there is no direct relationship between the helper that uses reflection andDictionaryAnalyzerConfigOptions
type.This change introduces
StructuredAnalyzerConfigOptions
type that is used to cache both raw and parsed editorconfig options onProjectState
. The type itself provides facilities to cacheNameStylePreferences
(or possibly other expensive to parse options in future) as well as translation between Workspace, Compiler and Code Style layer representations of the options.