Open LittleLittleCloud opened 4 weeks ago
Hi @LittleLittleCloud! This task seems to be interesting! Can I work on this task?
@prithvi2226 that would be awesome!
@LittleLittleCloud If possible, could you please assign this task to me? However, if this action doesn't make a significant difference, I am fine with it. The main priority is to ensure the issue is resolved and the repository progresses smoothly.
@prithvi2226 Any update on this issue
@prithvi2226 Any update on this issue
Hey @LittleLittleCloud , I am still working on it, been remote for a while, I can give you an update by Tuesday!? If that's okay?
@prithvi2226 Do you need more time on this one? Also please let me know if you need help!
Hi @LittleLittleCloud! Thank you very much for checking up on me, and thank you very much for taking the time to help me out with this. I am very sorry from my side, for not giving an update, to solve this bug.
Please Correct me if I am wrong, I have decided to work on the file dotnet/src/AutoGen.SourceGenerator/DocumentCommentExtension.cs
, and DocumentCommentExtension
class contains methods for handling documentation comments, and it's where I am going to add the logic to escape double quotes in the comments. And, in the method 'GetParameterDescriptionFromDocumentationCommentTriviaSyntax' looks like it processes descriptions for parameters from documentation comments. I hope I am on the right track! Thank you very much!
@prithvi2226 Thanks for your response.
IMO you don't need to go that further into DocumentCommentExtension.cs, the quickest solution is to encode "
properly in https://github.com/microsoft/autogen/blob/80ecbf900ca9c2bc7db519702ae132ec6b6c6a3f/dotnet/src/AutoGen.SourceGenerator/Template/FunctionCallTemplate.tt#L84. ("
-> ""
)
For example, when the comment contains "
/// <summary>
/// I have " in the summary and the generated code is breaking!
/// </summary>
/// <param name="city"></param>
/// <returns></returns>
[Function]
public async Task<string> GetWeatherAsync(string city)
{
return await Task.FromResult($"The weather in {city} is sunny.");
}
The generated code is
As you can see, "
breaks the generated code because FunctionTemplate.tt
encodes description using @"...."
and didn't process the "
in the comment description.
The quickest fix is to encode "
in description by doubling it (""
). This is how "
is encoded as well in verbatim string.
e.g.
Hi @LittleLittleCloud ,
Thank you very much for your guidance. Based on your suggestion, I will implement the fix directly in the FunctionCallTemplate.tt file. Here are the steps I plan to take:
Planned Changes:
Locating the line that assigns the description (around line 84):
Description = @"<#=parameter.Description#>",
I will modify this line to properly encode double quotes by doubling them (""), like so:
Description = @"<#= parameter.Description.Replace("\"", "\"\"") #>",
This approach should correctly handle double quotes in comments and prevent the generated code from breaking.
Please let me know if this solution looks good to you, and I will proceed with making these changes.
Thank you once again for your assistance!
Best regards, Prithvi
You nailed it!
Hi @LittleLittleCloud ! I have created a pull request, let me know what you think about it. Thank you very much for your guidance and support. I would love to connect with you on Github or Slack to continue supporting this project.
Describe the bug
When the content in structural comments contains
"
, the generated code won't get compiled because the"
breaks the string.Steps to reproduce
No response
Model Used
No response
Expected Behavior
No response
Screenshots and logs
No response
Additional Information
No response