private static async Task TestCachingAsync(string markup, params string[][] expectedArray) { using var workspace = TestWorkspace.CreateCSharp(markup); var testDocument = workspace.Documents.Single(); var spans = testDocument.AnnotatedSpans; var snapshot = testDocument.GetTextBuffer().CurrentSnapshot; var languageDebugInfo = new CachedProximityExpressionsGetter(new CSharpProximityExpressionsService()); var document = workspace.CurrentSolution.GetDocument(testDocument.Id); for (var i = 0; i < expectedArray.Length; i++) { int position; var key = spans.Keys.FirstOrDefault(k => k.StartsWith(i + "-", StringComparison.Ordinal)); if (key != null) { var parts = key.Split('-'); if (parts[1] == "OnDebugModeChanged") { languageDebugInfo.OnDebugModeChanged((DebugMode)Enum.Parse(typeof(DebugMode), parts[2])); } position = spans[key].First().Start; } else { position = spans[i.ToString()].First().Start; } var expected = expectedArray[i]; var result = await languageDebugInfo.DoAsync(document, position, string.Empty, CancellationToken.None); AssertEx.Equal(expectedArray[i], result); } }
public VsLanguageDebugInfo( Guid languageId, TLanguageService languageService, HostLanguageServices languageServiceProvider, IWaitIndicator waitIndicator) { Contract.ThrowIfNull(languageService); Contract.ThrowIfNull(languageServiceProvider); _languageId = languageId; _languageService = languageService; _languageDebugInfo = languageServiceProvider.GetService <ILanguageDebugInfoService>(); _breakpointService = languageServiceProvider.GetService <IBreakpointResolutionService>(); _proximityExpressionsService = languageServiceProvider.GetService <IProximityExpressionsService>(); _cachedProximityExpressionsGetter = new CachedProximityExpressionsGetter(_proximityExpressionsService); _waitIndicator = waitIndicator; }