gpt4 book ai didi

naming-conventions - Resharper 建议 Page_Load = PageLoad

转载 作者:行者123 更新时间:2023-12-03 21:02:05 25 4
gpt4 key购买 nike

通常当Page_Load Visual Studio 将事件处理程序添加到代码隐藏文件中(例如,在设计器模式下双击页面),它最终看起来像这样:

/// <summary>
/// Handles the Load event of the Page control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void Page_Load(object sender, EventArgs e)
{
// ...
}

但 Resharper 建议 Name 'Page_Load' does not match rule 'Methods, properties and events'. Suggested name is 'PageLoad' .我猜有更好的方法来定义页面加载处理程序,但我不记得语法是什么,但我想它会解决这个 Resharper 警告?

也许是这样的:
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// ...
}

但我似乎记得 OnLoadPageLoad不完全一样吗?

最佳答案

为了完整起见,我想我会在这里添加您从“大卫·本森”中得到的答案 when you asked on jetbrains.net :

If you go to ReSharper Options, under Languages select C# Naming Style. Select the Advanced settings... button and in the Event subscriptions on fields:, remove the On in front of $event$ so it is $object$_$event$. That should remove the warning.



对我来说,这是在现有大型 Web 应用程序代码库面前安抚 ReSharper 的最简单方法。

关于naming-conventions - Resharper 建议 Page_Load = PageLoad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3684861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com