You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Steps to Reproduce:
Paste this code in VisualStudio, then press Format document (Ctrl+K, Ctrl+D).
namespace ConsoleApp.Classes
{/// <summary>/// Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}`////// </summary>internalclassClass1{publicvoidFoo(){///do not format correct comment when the comment in the same line of bracket///Also do not auto add '///' when user enter new line when curent line comnent in the same line of bracket///Err
DoAction(/*apple*/"banana","orange","coconut","grape","mango");while(true){// do som thing
Console.WriteLine("");break;}}/// <summary>/// Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}`\////// </summary>/// <param name="paras"></param>publicvoidDoAction(paramsstring[] paras){/* * Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}` */
Console.WriteLine("");}}}
Expected Behavior:
namespace ConsoleApp.Classes
{/// <summary>/// Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}`////// </summary>internalclassClass1{publicvoidFoo(){///do not format correct comment when the comment in the same line of bracket///Also do not auto add '///' when user enter new line when curent line comnent in the same line of bracket///Err
DoAction(/*apple*/"banana","orange","coconut","grape","mango");while(true){// do som thing
Console.WriteLine("");break;}}/// <summary>/// Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}`\////// </summary>/// <param name="paras"></param>publicvoidDoAction(paramsstring[] paras){/* * Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}` */
Console.WriteLine("");}}}
Actual Behavior:
namespace ConsoleApp.Classes
{/// <summary>/// Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}`////// </summary>internalclassClass1{publicvoidFoo(){///do not format correct comment when the comment in the same line of bracket///Also do not auto add '///' when user enter new line when curent line comnent in the same line of bracket///Err
DoAction(/*apple*/"banana","orange","coconut","grape","mango");while(true){// do som thing
Console.WriteLine("");break;}}/// <summary>/// Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}`\////// </summary>/// <param name="paras"></param>publicvoidDoAction(paramsstring[] paras){/* * Error `format doc comment "Ctrl+K, Ctrl+D"` do not format correct comment when the comment in the same line of bracket `{` or `}` */
Console.WriteLine("");}}}
Video demo:
The text was updated successfully, but these errors were encountered:
Doc comments can only be leading trivia. So it's likely the tree is not in a good state for the formatter to work with. Would likely need special casing to handle this.
@CyrusNajmabadi The tree would always be in a consistent state for the formatter after a paste operation. It can only enter a bad state through the SyntaxFactory APIs, but the paste operation would involve direct text manipulation and go back through the parser.
@CyrusNajmabadi The tree would always be in a consistent state for the formatter after a paste operation.
I didn't mean that it's an invalidly constructed tree. Just a tree that is not in a good state for the formatter. For example, the formatter wound would need to deal with the very weird case of doc comments spread over trailing and leading trivia.
OH, that's fascinating and even more bizarre :) I guess then the formatter could see these tokens without any appropraite end of line and add such a thing. I would be ok with that.
Version Used: VisualStudio 2022 17.6.4
Steps to Reproduce:
Paste this code in VisualStudio, then press
Format document (Ctrl+K, Ctrl+D)
.Expected Behavior:
Actual Behavior:
Video demo:
The text was updated successfully, but these errors were encountered: