You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Rider中实现接口时移除默认的Throw new System.NotImplementedException()行

在JetBrains Rider中修改接口实现的默认代码模板
  • 打开Rider设置:使用快捷键Ctrl+Alt+S(Windows/Linux)或Cmd+,(Mac),也可通过顶部菜单File → Settings(Windows/Linux)或Rider → Settings(Mac)进入设置界面。
  • 定位到代码模板选项:在左侧导航栏依次展开 Editor → File and Code Templates,切换到Code标签页。
  • 找到接口方法体模板:在右侧模板列表中找到Method body for interface method(部分版本可能显示为Interface Method Body)。
  • 修改模板内容:将默认的throw new NotImplementedException();删除,替换为空白的大括号{ }(或你需要的其他默认内容)。
  • 保存设置:点击界面底部的Apply和OK按钮完成设置。

修改完成后,再实现接口时生成的方法就不会自动添加抛出异常的代码,示例如下:

public class CharacterA : MonoBehaviour, ICharacterController
{
    public void UpdateRotation(ref Quaternion currentRotation, float deltaTime)
    {
    }
}

内容的提问来源于stack exchange,提问作者KiynL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 01:25:24