-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Adopt editor InlinePromptService for documentation comments #84282
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
Merged
akhera99
merged 11 commits into
dotnet:main
from
cdblake1:dev/calebblake/inlineprompt-doc-comment
Jul 29, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c496f25
Adopt editor InlinePromptService for documentation comments
calebblake331 40d2a34
Merge remote-tracking branch 'origin/main' into dev/calebblake/inline…
calebblake331 552e50e
Merge remote-tracking branch 'upstream' into dev/calebblake/inlinepro…
akhera99 6654db9
update versions
akhera99 5b6412c
Merge branch 'main' into dev/calebblake/inlineprompt-doc-comment
akhera99 68e7e58
fix test
akhera99 e202229
Merge branch 'main' into dev/calebblake/inlineprompt-doc-comment
akhera99 759e689
Potential fix for pull request finding
akhera99 9a690de
Merge branch 'main' into dev/calebblake/inlineprompt-doc-comment
akhera99 fb5c92e
Merge branch 'dev/calebblake/inlineprompt-doc-comment' of https://git…
akhera99 aec96ed
update resource string
akhera99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...rFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationApplyEditsTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Collections.Immutable; | ||
| using System.Linq; | ||
| using Microsoft.CodeAnalysis.DocumentationComments; | ||
| using Microsoft.CodeAnalysis.Test.Utilities; | ||
| using Microsoft.CodeAnalysis.Text; | ||
| using Roslyn.Test.Utilities; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.DocumentationComments; | ||
|
|
||
| [UseExportProvider] | ||
| [Trait(Traits.Feature, Traits.Features.DocumentationComments)] | ||
| public sealed class CopilotGenerateDocumentationApplyEditsTests | ||
| { | ||
| [WpfFact] | ||
| public void ApplyEdits_TranslatesSpansToCurrentSnapshotAndInsertsText() | ||
| { | ||
| const string code = """ | ||
| class C | ||
| { | ||
| /// <summary></summary> | ||
| void M() { } | ||
| } | ||
| """; | ||
| using var workspace = EditorTestWorkspace.CreateCSharp(code); | ||
| var buffer = workspace.Documents.Single().GetTextBuffer(); | ||
|
|
||
| // Capture the snapshot the edit spans are relative to, as the InlinePrompt accept path does when the | ||
| // chip is shown. | ||
| var snapshot = buffer.CurrentSnapshot; | ||
| var insertionPoint = snapshot.GetText().IndexOf("<summary>", StringComparison.Ordinal) + "<summary>".Length; | ||
|
|
||
| var edits = ImmutableArray.Create( | ||
| new DocumentationCommentEdit(new TextSpan(insertionPoint, 0), "A short summary.")); | ||
|
|
||
| // Mutate the buffer AFTER capturing the snapshot so ApplyEdits must translate the edit span across | ||
| // versions before applying it. | ||
| buffer.Insert(0, "// prefix\r\n"); | ||
|
|
||
| CopilotGenerateDocumentationCommentManager.ApplyEdits(buffer, snapshot, edits); | ||
|
|
||
| var result = buffer.CurrentSnapshot.GetText(); | ||
| Assert.StartsWith("// prefix", result); | ||
| Assert.Contains("<summary>A short summary.</summary>", result); | ||
| } | ||
|
|
||
| [WpfFact] | ||
| public void ApplyEdits_AppliesMultipleEditsInOneTransaction() | ||
| { | ||
| const string code = """ | ||
| class C | ||
| { | ||
| /// <summary></summary> | ||
| /// <returns></returns> | ||
| int M() => 0; | ||
| } | ||
| """; | ||
| using var workspace = EditorTestWorkspace.CreateCSharp(code); | ||
| var buffer = workspace.Documents.Single().GetTextBuffer(); | ||
|
|
||
| var snapshot = buffer.CurrentSnapshot; | ||
| var text = snapshot.GetText(); | ||
| var summaryPoint = text.IndexOf("<summary>", StringComparison.Ordinal) + "<summary>".Length; | ||
| var returnsPoint = text.IndexOf("<returns>", StringComparison.Ordinal) + "<returns>".Length; | ||
|
|
||
| var edits = ImmutableArray.Create( | ||
| new DocumentationCommentEdit(new TextSpan(summaryPoint, 0), "Returns zero."), | ||
| new DocumentationCommentEdit(new TextSpan(returnsPoint, 0), "always zero")); | ||
|
|
||
| CopilotGenerateDocumentationCommentManager.ApplyEdits(buffer, snapshot, edits); | ||
|
|
||
| var result = buffer.CurrentSnapshot.GetText(); | ||
| Assert.Contains("<summary>Returns zero.</summary>", result); | ||
| Assert.Contains("<returns>always zero</returns>", result); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.