diff --git a/src/Features/Core/Portable/Completion/CompletionService.cs b/src/Features/Core/Portable/Completion/CompletionService.cs index 77938d3170f800bda4efdeaf107d442487a2814a..8910990e69d06bc11130ec72b8a29ee16b59fdda 100644 --- a/src/Features/Core/Portable/Completion/CompletionService.cs +++ b/src/Features/Core/Portable/Completion/CompletionService.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Completion { internal static class CompletionService { - private static readonly Task s_emptyCompletionListTask = Task.FromResult(new CompletionList(ImmutableArray.Empty)); + private static Task s_emptyCompletionListTask; public static IEnumerable GetDefaultCompletionListProviders(Document document) { @@ -51,6 +51,12 @@ public static CompletionRules GetCompletionRules(Document document) } else { + if (s_emptyCompletionListTask == null) + { + var value = Task.FromResult(new CompletionList(ImmutableArray.Empty)); + Interlocked.CompareExchange(ref s_emptyCompletionListTask, value, null); + } + return s_emptyCompletionListTask; } }