[英]VB.net CA1062 validate parameter
Working on an old .net 3.5 vb web application Getting over 1000 warnings on public property methods such as the following CA1062 : Microsoft.Design : In externally visible method 'TheClass.TheMethod.Set(String)', validate parameter 'value' before using it. 在旧的.net 3.5 vb Web应用程序上工作在公共属性方法(如以下CA1062)上收到1000多个警告:Microsoft.Design:在外部可见的方法'TheClass.TheMethod.Set(String)'中,在使用前验证参数'value'它。
Original: 原版的:
Public Property DealerBMRName() As String
Get
Return hdBMRName.Value
End Get
Set(ByVal value As String)
hdBMRName.Value = value.Trim()
End Set
End Property
modified yet still throwing the error: 修改后仍然抛出错误:
Public Property DealerBMRName() As String
Get
Return hdBMRName.Value
End Get
Set(ByVal value As String)
If value Is Nothing Then
hdBMRName.Value = ""
Else
hdBMRName.Value = CStr(value)
End If
End Set
End Property
Pretty sure I am following MSDN suggested workaround: http://msdn.microsoft.com/en-us/library/ms182182(v=vs.100).aspx 可以肯定地说,我正在遵循MSDN建议的解决方法: http : //msdn.microsoft.com/zh-cn/library/ms182182 (v= vs.100).aspx
Any ideas what I might be missing apart from the fact that the code itself is ugly? 除了代码本身很丑外,还有什么想法我可能会缺少的吗? I can't remove the error even with something as basic as:
即使使用以下基本内容,我也无法消除错误:
Set(ByVal value As String)
hdBMRName.Value = "SomeValue"
End Set
Using VS2010 and resharper. 使用VS2010和resharper。
The issue resolved itself when I fixed a bad line entry in my web.config. 当我修复web.config中的错误行条目时,该问题自行解决。 It had nothing to do with the error but may have been throwing the issue.
它与错误无关,但可能是引发了该问题。 PS: I needed to use .Value as the object is an asp:hiddenField.
PS:我需要使用.Value,因为该对象是asp:hiddenField。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.