-
Notifications
You must be signed in to change notification settings - Fork 405
Open
Labels
Feature-Language-ServicePopulating the Roslyn workspace with references, source files, analyzers, etcPopulating the Roslyn workspace with references, source files, analyzers, etcTriage-ApprovedReviewed and prioritizedReviewed and prioritized
Milestone
Description
Currently we use ILanguageServiceHostEnvironment
to control whether the language service should be initialized or not.
Lines 10 to 34 in fa20f2b
[Export(typeof(ILanguageServiceHostEnvironment))] | |
internal sealed class LanguageServiceHostEnvironment : ILanguageServiceHostEnvironment | |
{ | |
private readonly AsyncLazy<bool> _isEnabled; | |
[ImportingConstructor] | |
public LanguageServiceHostEnvironment(IVsUIService<SVsShell, IVsShell> vsShell, JoinableTaskContext joinableTaskContext) | |
{ | |
_isEnabled = new( | |
async () => | |
{ | |
await joinableTaskContext.Factory.SwitchToMainThreadAsync(); | |
// If VS is running in command line mode (e.g. "devenv.exe /build my.sln"), | |
// the language service host is not enabled. | |
return ErrorHandler.Succeeded(vsShell.Value.GetProperty((int)__VSSPROPID.VSSPROPID_IsInCommandLineMode, out object resultObj)) | |
&& resultObj is bool result | |
&& !result; // negate: enabled when not in command line mode | |
}, | |
joinableTaskContext.Factory); | |
} | |
public Task<bool> IsEnabledAsync(CancellationToken cancellationToken) => _isEnabled.GetValueAsync(cancellationToken); | |
} |
Today, we use this interface to prevent the language service from doing redundant work during devenv /build
.
The current design requires calling code to check this flag. It would be cleaner to control this via project capabilities.
Metadata
Metadata
Assignees
Labels
Feature-Language-ServicePopulating the Roslyn workspace with references, source files, analyzers, etcPopulating the Roslyn workspace with references, source files, analyzers, etcTriage-ApprovedReviewed and prioritizedReviewed and prioritized