99using System . Threading ;
1010using System . Threading . Tasks ;
1111using Microsoft . CodeAnalysis . Editor ;
12- using Microsoft . CodeAnalysis . Editor . Shared . Extensions ;
1312using Microsoft . CodeAnalysis . Host . Mef ;
13+ using Microsoft . CodeAnalysis . Internal . Log ;
1414using Microsoft . CodeAnalysis . Remote ;
1515using Microsoft . CodeAnalysis . Text ;
1616using Microsoft . CodeAnalysis . Text . Shared . Extensions ;
@@ -27,13 +27,13 @@ namespace Microsoft.CodeAnalysis.Copilot;
2727internal sealed class RoslynProposalAdjusterProvider ( ) : ProposalAdjusterProviderBase
2828{
2929 public override Task < ProposalBase > AdjustProposalBeforeDisplayAsync ( ProposalBase proposal , string providerName , CancellationToken cancellationToken )
30- => AdjustProposalAsync ( proposal , providerName , cancellationToken ) ;
30+ => AdjustProposalAsync ( proposal , providerName , before : true , cancellationToken ) ;
3131
3232 public override Task < ProposalBase > AdjustProposalAfterAcceptAsync ( ProposalBase proposal , string providerName , CancellationToken cancellationToken )
33- => AdjustProposalAsync ( proposal , providerName , cancellationToken ) ;
33+ => AdjustProposalAsync ( proposal , providerName , before : false , cancellationToken ) ;
3434
3535 private async Task < ProposalBase > AdjustProposalAsync (
36- ProposalBase proposal , string providerName , CancellationToken cancellationToken )
36+ ProposalBase proposal , string providerName , bool before , CancellationToken cancellationToken )
3737 {
3838 // Ensure we're only operating on one solution. It makes the logic much simpler, as we don't have to
3939 // worry about edits that touch multiple solutions.
@@ -80,9 +80,33 @@ private async Task<ProposalBase> AdjustProposalAsync(
8080
8181 // No adjustments were made. Don't touch anything.
8282 if ( ! adjustmentsProposed )
83+ {
84+ using var _3 = Logger . LogBlock ( FunctionId . Copilot_AdjustProposal , KeyValueLogMessage . Create ( static ( d , args ) =>
85+ {
86+ var ( providerName , before ) = args ;
87+ d [ "ProviderName" ] = providerName ;
88+ d [ "Before" ] = before ;
89+ d [ "AdjustmentsProposed" ] = false ;
90+ } ,
91+ args : ( providerName , before ) ) ,
92+ cancellationToken ) ;
93+
8394 return proposal ;
95+ }
8496
8597 var newProposal = Proposal . TryCreateProposal ( proposal , finalEdits ) ;
98+
99+ using var _4 = Logger . LogBlock ( FunctionId . Copilot_AdjustProposal , KeyValueLogMessage . Create ( static ( d , args ) =>
100+ {
101+ var ( providerName , before , newProposal ) = args ;
102+ d [ "ProviderName" ] = providerName ;
103+ d [ "Before" ] = before ;
104+ d [ "AdjustmentsProposed" ] = true ;
105+ d [ "AdjustmentsAccepted" ] = newProposal != null ;
106+ } ,
107+ args : ( providerName , before , newProposal ) ) ,
108+ cancellationToken ) ;
109+
86110 return newProposal ?? proposal ;
87111 }
88112
0 commit comments