GetCSharpTaskListItemsAsync(TextDocument razorDocument, CancellationToken cancellationToken)
+ {
+ var generatedDocument = await TryGetGeneratedDocumentAsync(razorDocument, cancellationToken).ConfigureAwait(false);
+ if (generatedDocument is null)
+ {
+ return [];
+ }
+
+ var supportsVisualStudioExtensions = _clientCapabilitiesService.ClientCapabilities.SupportsVisualStudioExtensions;
+ var csharpTaskItems = await ExternalHandlers.Diagnostics.GetTaskListAsync(generatedDocument, supportsVisualStudioExtensions, cancellationToken).ConfigureAwait(false);
+ return [.. csharpTaskItems];
+ }
+
internal TestAccessor GetTestAccessor() => new(this);
internal readonly struct TestAccessor(CohostDocumentPullDiagnosticsEndpoint instance)
diff --git a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs
index e82db07ca4d..cd30a002dc7 100644
--- a/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs
+++ b/src/Razor/test/Microsoft.AspNetCore.Razor.Test.Common.Cohosting/CohostTestBase.cs
@@ -137,7 +137,7 @@ protected virtual TextDocument CreateProjectAndRazorDocument(
return CreateProjectAndRazorDocument(remoteWorkspace, projectId, miscellaneousFile, documentId, documentFilePath, contents, additionalFiles, inGlobalNamespace);
}
- protected TextDocument CreateProjectAndRazorDocument(CodeAnalysis.Workspace workspace, ProjectId projectId, bool miscellaneousFile, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace)
+ protected static TextDocument CreateProjectAndRazorDocument(CodeAnalysis.Workspace workspace, ProjectId projectId, bool miscellaneousFile, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles, bool inGlobalNamespace)
{
// We simulate a miscellaneous file project by not having a project file path.
var projectFilePath = miscellaneousFile ? null : TestProjectData.SomeProject.FilePath;
diff --git a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs
index 7516a2a2993..49822f1b6a5 100644
--- a/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs
+++ b/src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs
@@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.LanguageServer.Test;
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.CodeAnalysis.Razor.Diagnostics;
@@ -409,6 +408,10 @@ public Task TODOComments()
=> VerifyDiagnosticsAsync("""
@using System.Threading.Tasks;
+ // TODO: This isn't C#
+
+ TODO: Nor is this
+
@*{|TODO: TODO: This does |}*@
@@ -416,6 +419,11 @@ public Task TODOComments()
@* TODONT: This doesn't *@
+
+ @code {
+ // This looks different because Roslyn only reports zero width ranges for task lists
+ // {|TODO:|}TODO: Write some C# code too
+ }
""",
taskListRequest: true);
@@ -448,7 +456,8 @@ private async Task VerifyDiagnosticsAsync(TestCode input, VSInternalDiagnosticRe
});
var testOutput = input.Text;
- foreach (var (index, text) in markers.OrderByDescending(i => i.index))
+ // Ordering by text last means start tags get sorted before end tags, for zero width ranges
+ foreach (var (index, text) in markers.OrderByDescending(i => i.index).ThenByDescending(i => i.text))
{
testOutput = testOutput.Insert(index, text);
}