简体   繁体   English

Visual Studio(C#)“替换热代码”

[英]Visual studio (C#) 'Hot code replace'

I've previously developed in Java use Eclipse IDE and was used to a feature call HCR . 我以前用Java开发的是Eclipse IDE,并且习惯了HCR的功能。 This features is, as far as I know, only available in Eclipse. 据我所知,此功能仅在Eclipse中可用。 It allows you to replace code while the application is being debugged. 它允许您在调试应用程序时替换代码。 No need to pause or stop the debugging session, just modify the file and, on save, replace the code in the JVM. 无需暂停或停止调试会话,只需修改文件,然后保存即可替换JVM中的代码。 There's a bit more details here is I'm not too clear. 这里还有更多细节,我不太清楚。

Now, I'm curious to know if there's a similar feature in Visual Studio (either a feature or an extension). 现在,我很想知道Visual Studio中是否有类似的功能(功能或扩展)。 I know about Edit and Continue , but this requires pausing the application execution and it doesn't allow to edit the file while the code is running. 我知道Edit and Continue ,但这需要暂停应用程序执行,并且不允许在代码运行时编辑文件。

You can edit while debugging when you broke into your code (eg by a breakpoint or an exception). 您可以在调试代码时(例如通过断点或异常)在调试时进行编辑。 However there are some limitations on what you can edit while in a debugging-session. 但是,在调试会话中可以编辑的内容存在一些限制。

Basically you can only change the internal but not the external behaviour of any member within your class. 基本上,您只能更改类中任何成员的内部行为,而不能更改其外部行为。 Having said this you cannot change the parameter-list or the return-value of your members or even their name. 话虽如此,您不能更改成员的参数列表或返回值,甚至不能更改其名称。 Furthermore there are some annyoing ones like lambdas, delegates and some conde-contracts that break the debgugger from continuing its work. 此外,还有一些令人目结舌的项目,例如lambda,代表和一些契约合同,这些破坏了degugger的继续工作。

There might be reasons you wish to change some of these features while debugging, but the VS-designers chosed a highly save appraoch that your changes will not make your application crash while debugging. 您可能有理由希望在调试时更改其中的某些功能,但是VS设计人员选择了一种高度节省的方法,即您所做的更改不会在调试时使应用程序崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM