Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

  • Understand the current completion system and how TagHelper element completion works
  • Modify RazorCompletionItem.CreateTagHelperElement to support snippet mode
  • Update GetElementCompletions in TagHelperCompletionProvider to detect EditorRequired attributes
  • Build snippet text with placeholders for EditorRequired properties
  • Add comprehensive tests for the new snippet functionality
  • Validate the changes work correctly
  • Address PR feedback:
    • Changed to add a separate completion item for snippets (with "..." suffix) instead of modifying the existing item
    • Always add quotes in snippets (removed autoInsertAttributeQuotes parameter)
    • Use pooled StringBuilder instead of regular StringBuilder
    • Added test in CohostDocumentCompletionEndpointTest.cs
    • Simplified Cohost test to use VerifyCompletionListAsync helper
    • Optimized component tag helper lookup to use first Component kind tag helper only
  • Merged main into branch (test files moved to VS Code project)
  • Fixed test failure - snippet items don't need resolve, they already have complete insertText
  • Updated snippet display text to "{displayText} (and req'd attributes...)" for better clarity
  • Simplified test to use VerifyCompletionListAsync helper with verifySnippetItem callback
  • Optimized to avoid .Any() and .ToImmutableArray() allocation by changing method to accept IEnumerable
  • Added localized resource string for component completion label
  • Updated tests to use SR resource for consistent labeling
  • Extracted snippet completion logic to AddCompletionItemWithRequiredAttributesSnippet method
  • Inverted if statement for early exit and pass descriptionInfo from calling method
  • Merged latest main and resolved conflicts - both ComponentWithEditorRequiredAttributes and new Blazor data attribute tests now coexist
  • Added comment to SR.resx explaining "req'd" abbreviation for localization
Original prompt

This section details on the original issue you should resolve

<issue_title>Component completion snippet</issue_title>
<issue_description>Noticed today watching someone use the Razor editor: For components that have one or more properties that are [EditorRequired], we could do completion as a snippet, that includes the attributes for each required property (similar to how drag and drop will create attributes for them) and either puts the caret in the first one, or even puts placeholders in each and lets the user tab between them.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #6980


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

…ibutes

Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI changed the title [WIP] Add completion snippet for components with editor required properties Add snippet support for component completion with EditorRequired attributes Oct 13, 2025
Copilot AI requested a review from davidwengier October 13, 2025 01:41
Copilot finished work on behalf of davidwengier October 13, 2025 01:41
Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

@copilot Please create additional test(s) in CohostDocumentCompletionEndpointTest.cs with appropriate "itemToResolve" and "expected" output

… snippet as separate completion item

Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 13, 2025

@copilot Please create additional test(s) in CohostDocumentCompletionEndpointTest.cs with appropriate "itemToResolve" and "expected" output

Done in commit. Added ComponentWithEditorRequiredAttributes_SnippetsSupported test in CohostDocumentCompletionEndpointTest.cs that verifies both regular and snippet completion items are created for components with EditorRequired attributes.

Copilot AI requested a review from davidwengier October 13, 2025 03:24
Copilot finished work on behalf of davidwengier October 13, 2025 03:24
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI requested a review from davidwengier October 13, 2025 11:35
Copilot finished work on behalf of davidwengier October 13, 2025 11:35
@davidwengier
Copy link
Member

@copilot please merge main into your branch

Copy link
Contributor Author

Copilot AI commented Oct 14, 2025

@copilot please merge main into your branch

Done in commit 7272bb5. Merged main into the branch successfully. All tests pass.

Copilot finished work on behalf of davidwengier October 14, 2025 08:10
@davidwengier
Copy link
Member

@copilot it seems some tests failed in CI. Can you take a look? build.sh -test will run all tests in the repo

Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 15, 2025

@copilot it seems some tests failed in CI. Can you take a look? build.sh -test will run all tests in the repo

Fixed in commit. The test ComponentWithEditorRequiredAttributes_SnippetsSupported was failing because it tried to resolve a snippet completion item. Snippet items already have complete insertText and don't need resolution - they're ready to use as-is. Updated the test to directly verify the snippet's insertText instead of trying to resolve it. All tests now pass.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mobile.events.data.microsoft.com
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net9.0/Microsoft.VisualStudioCode.RazorExtension.Test.runtimeconfig.json --depsfile /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net9.0/Microsoft.VisualStudioCode.RazorExtension.Test.deps.json /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net9.0/testhost.dll --port 35261 --endpoint 127.0.0.1:035261 --role client --parentprocessid 13942 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net9.0/Microsoft.VisualStudioCode.RazorExtension.Test.runtimeconfig.json --depsfile /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net9.0/Microsoft.VisualStudioCode.RazorExtension.Test.deps.json /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net9.0/testhost.dll --port 34159 --endpoint 127.0.0.1:034159 --role client --parentprocessid 14012 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of davidwengier October 15, 2025 10:35
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI requested a review from davidwengier October 16, 2025 22:37
Copilot finished work on behalf of davidwengier October 16, 2025 22:37
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI requested a review from davidwengier October 16, 2025 22:51
Copilot finished work on behalf of davidwengier October 16, 2025 22:51
@davidwengier
Copy link
Member

@copilot please merge main and fix any conflicts or build errors

Copy link
Contributor Author

Copilot AI commented Oct 17, 2025

@copilot please merge main and fix any conflicts or build errors

Done in commit 1350ef3. Merged main into the branch and resolved conflicts in CohostDocumentCompletionEndpointTest.cs. Both the ComponentWithEditorRequiredAttributes test and the new Blazor data attribute tests from main now coexist. All tests pass.

Copilot finished work on behalf of davidwengier October 17, 2025 00:48
<value>Extract to {0}.css</value>
</data>
<data name="ComponentCompletionWithRequiredAttributesLabel" xml:space="preserve">
<value>{0} (and req'd attributes...)</value>
Copy link
Member

Choose a reason for hiding this comment

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

@copilot add a <comment> element under this that says The term "req'd" is an abbreviation for "required"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit. Added comment element explaining that "req'd" is an abbreviation for "required" to help with localization.

Copy link
Member

Choose a reason for hiding this comment

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

Why use an abbreviation in user visible text?

Copy link
Member

Choose a reason for hiding this comment

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

I just thought the full word pushed things out to be too wide. Happy to follow up if there is better wording here (but selfishly, I want to get this merged so copilot stops complaining about firewall rules in other PRs 😛)

Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI requested a review from davidwengier October 17, 2025 01:24
Copilot finished work on behalf of davidwengier October 17, 2025 01:24
<value>Extract to {0}.css</value>
</data>
<data name="ComponentCompletionWithRequiredAttributesLabel" xml:space="preserve">
<value>{0} (and req'd attributes...)</value>
Copy link
Member

Choose a reason for hiding this comment

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

Why use an abbreviation in user visible text?

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.

Component completion snippet

4 participants