And*_*hns 14 resharper naming-conventions pageload
通常当Page_LoadVisual 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)
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
但是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);
// ...
}
Run Code Online (Sandbox Code Playgroud)
但我似乎记得,OnLoad和PageLoad不完全一样?
Aak*_*shM 44
为了完整起见,我想我会在这里添加你在jetbrains.net上询问时从一个"David Benson"得到的答案:
如果您转到ReSharper选项,请在语言下选择C#命名样式.选择高级设置...按钮,然后在中
Event subscriptions on fields:删除它所On在的前面.这应该删除警告.$event$$object$_$event$
对我来说,这是面对大型现有Web应用程序代码库来安抚ReSharper的最简单方法.
| 归档时间: |
|
| 查看次数: |
3939 次 |
| 最近记录: |