适用于Linux和/或MonoDevelop的C#代码格式化程序

时间:2023-01-14 15:24:38

MonoDevelop 1.0 doesn't appear to have a code-formatter like Eclipse does for Java. Is there a preferred shell script (or MonoDevelop add-in?) that you've found to work well?

MonoDevelop 1.0似乎没有像Eclipse那样的Java代码格式化程序。是否有一个首选的shell脚本(或MonoDevelop插件?),你发现它运行良好?

3 个解决方案

#1


6  

At the moment, source code formatting in MonoDevelop is marked as a future enhancement: https://bugzilla.novell.com/show_bug.cgi?id=321946

目前,MonoDevelop中的源代码格式标记为未来的增强功能:https://bugzilla.novell.com/show_bug.cgi?id = 321946

In the meantime, you may want to check out Artistic Style for C# formatting: http://astyle.sourceforge.net/

在此期间,您可能需要查看C#格式的艺术风格:http://astyle.sourceforge.net/

I'm planning to see how this might be wired up as an external tool within MonoDevelop. If I get to that, I will edit my answer with the information. UPDATE: I don't have enough reputation to leave a comment, so I'll make one here: Nice job, Dustin, and patch for MonoDevelop too :-) I wonder how recent the version is that is included with Ubuntu... Either way, I'm glad you found something that works for you.

我打算在MonoDevelop中看到它如何作为外部工具连接起来。如果我这样做,我将用信息编辑我的答案。更新:我没有足够的声誉留下评论,所以我会在这里做一个:好工作,Dustin,以及MonoDevelop的补丁:-)我想知道Ubuntu附带的版本最近有多少...无论哪种方式,我很高兴你发现了适合你的东西。

#2


2  

Thanks, Brandon. I submitted a patch to MonoDevelop. The issue with MonoDevelop add-ins is that there is a mono compiler bug that doesn't handle anonymous delegates correctly. (bug report: https://bugzilla.novell.com/show_bug.cgi?id=394347)

谢谢,布兰登。我向MonoDevelop提交了一个补丁。 MonoDevelop插件的问题在于有一个单声道编译器错误,它无法正确处理匿名委托。 (错误报告:https://bugzilla.novell.com/show_bug.cgi?id = 394347)

The patch/workaround is to just cast the anonymous delegate to the proper delegate type. (bug report & patch: https://bugzilla.novell.com/show_bug.cgi?id=369538)

补丁/解决方法是将匿名委托强制转换为正确的委托类型。 (错误报告和补丁:https://bugzilla.novell.com/show_bug.cgi?id = 369538)

I'm running with the patched version now and am able to execute AStyle on the current edited document by simply creating a new External Tool setting with the following settings:

我现在正在使用修补版本运行,只需使用以下设置创建一个新的外部工具设置,就可以在当前编辑的文档上执行AStyle:

TITLE: A_Style (put in underscore to enable hotkeys) COMMAND: astyle ARGUMENTS: ${ItemPath}

TITLE:A_Style(放入下划线以启用热键)命令:astyle ARGUMENTS:$ {ItemPath}

Then, just execute it using Tools->AStyle (or ALT-T, S)

然后,使用Tools-> AStyle(或ALT-T,S)执行它

9/25/08 Edit -- I just put up a blog posting on how to patch MonoDevelop 1.0 and get it working with AStyle : http://dustinbreese.blogspot.com/2008/09/auto-formatting-code-in-monodevelop-10.html

9/25/08编辑 - 我刚刚发布了一篇关于如何修补MonoDevelop 1.0的博客文章并让它与AStyle合作:http://dustinbreese.blogspot.com/2008/09/auto-formatting-code-in- MonoDevelop的-10.html

#3


1  

It's a nice programming exercise to write your own formatter . I wrote one for C++ , and it was a nice challenge . You could learn a lot by writing it :)

编写自己的格式化程序是一个很好的编程练习。我为C ++写了一个,这是一个很好的挑战。你可以通过写它来学到很多东西:)

#1


6  

At the moment, source code formatting in MonoDevelop is marked as a future enhancement: https://bugzilla.novell.com/show_bug.cgi?id=321946

目前,MonoDevelop中的源代码格式标记为未来的增强功能:https://bugzilla.novell.com/show_bug.cgi?id = 321946

In the meantime, you may want to check out Artistic Style for C# formatting: http://astyle.sourceforge.net/

在此期间,您可能需要查看C#格式的艺术风格:http://astyle.sourceforge.net/

I'm planning to see how this might be wired up as an external tool within MonoDevelop. If I get to that, I will edit my answer with the information. UPDATE: I don't have enough reputation to leave a comment, so I'll make one here: Nice job, Dustin, and patch for MonoDevelop too :-) I wonder how recent the version is that is included with Ubuntu... Either way, I'm glad you found something that works for you.

我打算在MonoDevelop中看到它如何作为外部工具连接起来。如果我这样做,我将用信息编辑我的答案。更新:我没有足够的声誉留下评论,所以我会在这里做一个:好工作,Dustin,以及MonoDevelop的补丁:-)我想知道Ubuntu附带的版本最近有多少...无论哪种方式,我很高兴你发现了适合你的东西。

#2


2  

Thanks, Brandon. I submitted a patch to MonoDevelop. The issue with MonoDevelop add-ins is that there is a mono compiler bug that doesn't handle anonymous delegates correctly. (bug report: https://bugzilla.novell.com/show_bug.cgi?id=394347)

谢谢,布兰登。我向MonoDevelop提交了一个补丁。 MonoDevelop插件的问题在于有一个单声道编译器错误,它无法正确处理匿名委托。 (错误报告:https://bugzilla.novell.com/show_bug.cgi?id = 394347)

The patch/workaround is to just cast the anonymous delegate to the proper delegate type. (bug report & patch: https://bugzilla.novell.com/show_bug.cgi?id=369538)

补丁/解决方法是将匿名委托强制转换为正确的委托类型。 (错误报告和补丁:https://bugzilla.novell.com/show_bug.cgi?id = 369538)

I'm running with the patched version now and am able to execute AStyle on the current edited document by simply creating a new External Tool setting with the following settings:

我现在正在使用修补版本运行,只需使用以下设置创建一个新的外部工具设置,就可以在当前编辑的文档上执行AStyle:

TITLE: A_Style (put in underscore to enable hotkeys) COMMAND: astyle ARGUMENTS: ${ItemPath}

TITLE:A_Style(放入下划线以启用热键)命令:astyle ARGUMENTS:$ {ItemPath}

Then, just execute it using Tools->AStyle (or ALT-T, S)

然后,使用Tools-> AStyle(或ALT-T,S)执行它

9/25/08 Edit -- I just put up a blog posting on how to patch MonoDevelop 1.0 and get it working with AStyle : http://dustinbreese.blogspot.com/2008/09/auto-formatting-code-in-monodevelop-10.html

9/25/08编辑 - 我刚刚发布了一篇关于如何修补MonoDevelop 1.0的博客文章并让它与AStyle合作:http://dustinbreese.blogspot.com/2008/09/auto-formatting-code-in- MonoDevelop的-10.html

#3


1  

It's a nice programming exercise to write your own formatter . I wrote one for C++ , and it was a nice challenge . You could learn a lot by writing it :)

编写自己的格式化程序是一个很好的编程练习。我为C ++写了一个,这是一个很好的挑战。你可以通过写它来学到很多东西:)