Skip to content
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

Show TODO Razor comments in the Task List in VS #11540

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

davidwengier
Copy link
Member

Fixes #4446

@davidwengier davidwengier requested a review from a team as a code owner February 24, 2025 05:17
# Conflicts:
#	src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/LanguageClient/Cohost/CohostDocumentPullDiagnosticsEndpoint.cs
#	src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostDocumentPullDiagnosticsTest.cs
@davidwengier
Copy link
Member Author

Test insertion to make sure I don't annoy RPS: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/614387

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good! A couple of points:

  1. Consider whether you want to add a new integration test. I think this feature probably warrants one to verify that the TODO comments actually show up in VS Task List.
  2. It looks like the test insertion uncovered a regression in non-devdiv methods JIT'd. I'm not sure how that could happen from this PR, but it looks like the regression was in all five iterations of the run.

@@ -60,4 +73,37 @@ private static FormattingFlags GetFormattingFlags(ClientSettings settings)

return flags;
}

public virtual bool Equals(RazorLSPOptions? other)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend for new records to be derived from RazorLSPOptions? If not, please mark RazorLSPOptions as sealed. If you do want RazorLSPOptions to be subtyped, add a check here to compare EqualityContract and add it to `GetHashCode() as well. Otherwise, equality between subtypes will be incorrect.

@@ -60,4 +73,37 @@ private static FormattingFlags GetFormattingFlags(ClientSettings settings)

return flags;
}

public virtual bool Equals(RazorLSPOptions? other)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this virtual rather than override?

Comment on lines +39 to +41
if (i + token.Length + 2 > comment.EndCommentStar.SpanStart || // Enough room in the comment for the token and some content?
!Matches(source, i, token) || // Does the prefix match?
char.IsLetter(source[i + token.Length + 1])) // Is there something after the prefix, so we don't match "TODOLOL"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like the first and last checks could be pulled into Matches. At the very least, the last check could be moved after the loop in Matches so that all of the character tests are in one place.

ErrorHandler.ThrowOnFailure(taskListService.EnumTokens(out var enumerator));
ErrorHandler.ThrowOnFailure(enumerator.Next((uint)count, tokens, out var numFetched));

using var tokensBuilder = new PooledArrayBuilder<string>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the size is known ahead of tiume, pass count to PooledArrayBuilder<string>().

Comment on lines +155 to +164
public ClientAdvancedSettings GetAdvancedSettings() => new(FormatOnType,
AutoClosingTags,
AutoInsertAttributeQuotes,
ColorBackground,
CodeBlockBraceOnNextLine,
CommitElementsWithSpace,
Snippets,
LogLevel,
FormatOnPaste,
TaskListDescriptors);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: When expression bodies get large, I prefer to just move the => to the next line. That would probably have been enough for this case rather than breaking the arguments onto separate lines.

Comment on lines +45 to +49
Assert.Equal(2, serverCapabilities.DiagnosticProvider.DiagnosticKinds.Length);

// use the expected value directly; if the underlying library changes values, there is likely a downstream impact
Assert.Equal("syntax", serverCapabilities.DiagnosticProvider.DiagnosticKinds[0].Value);
Assert.Equal("task", serverCapabilities.DiagnosticProvider.DiagnosticKinds[1].Value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider switchin this over to Assert.Collection(...)

@@ -23,7 +23,7 @@ public RazorLSPOptionsMonitorTest(ITestOutputHelper testOutput)
public async Task UpdateAsync_Invokes_OnChangeRegistration()
{
// Arrange
var expectedOptions = new RazorLSPOptions(FormattingFlags.Disabled, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true);
var expectedOptions = new RazorLSPOptions(FormattingFlags.Disabled, AutoClosingTags: true, InsertSpaces: true, TabSize: 4, AutoShowCompletion: true, AutoListParams: true, AutoInsertAttributeQuotes: true, ColorBackground: false, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: true, TaskListDescriptors: []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap these and share the same RazorLSPOptions instance across tests that have the same values. (All are identical in this diff.)

@@ -82,7 +82,7 @@ public void Update_TriggersChangedIfAdvancedSettingsAreDifferent()
var manager = new ClientSettingsManager(_clientSettingsChangeTriggers);
var called = false;
manager.ClientSettingsChanged += (caller, args) => called = true;
var settings = new ClientAdvancedSettings(FormatOnType: false, AutoClosingTags: true, AutoInsertAttributeQuotes: true, ColorBackground: true, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: false, SnippetSetting: default, LogLevel: default, FormatOnPaste: false);
var settings = new ClientAdvancedSettings(FormatOnType: false, AutoClosingTags: true, AutoInsertAttributeQuotes: true, ColorBackground: true, CodeBlockBraceOnNextLine: false, CommitElementsWithSpace: false, SnippetSetting: default, LogLevel: default, FormatOnPaste: false, TaskListDescriptors: []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap the arguments. Also, you can use 0 instead of default for the enum values at the end to shorten it a bit.

@davidwengier
Copy link
Member Author

The RPS and Speedometer regressions are also present in our main branch insertions and my System.Text.JSON test insertions, so whatever they are, I'm confident they're not caused by this change.

@DustinCampbell
Copy link
Member

DustinCampbell commented Feb 28, 2025

The RPS and Speedometer regressions are also present in our main branch insertions and my System.Text.JSON test insertions, so whatever they are, I'm confident they're not caused by this change.

Awesome! Adding my approval then, though do consider whether an integration test for the end-to-end would be valuable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Razor TODO comments should be listed in the task list
2 participants