FXFop工具:一些感触
该控件下载地址:我要查看
老早就下载了这个控件,但一直没用过,最近开始使用该工具,分析一些程序集的语法书写规则,呵呵,一分析就会出现许多错误(自己都要吓自己一跳)而有一些规则我一直没搞明白是为什么,
一,过程的参数名为不能有下划线
代码:public sub addopus(byval photo_id as string)
错误提示:Remove the underscore from 'photo_id'.
详细说明:Some generated Visual Studio identifiers for applications contain underscore characters. Underscore characters should generally be avoided in public identifiers.
这个可以我可以理解!
二,使用shared关健字,
代码: Public Class AdminSiteLog
Public Shared Function UserIP() As String
错误提示:Remove the public constructors from 'AdminSiteLog'.
详细说明:Many compilers will automatically add a public default constructor if no constructor is specified. To prevent this, adding an empty private constructor may be required.
这点我就不太同意。使用shared主要就是免去我再使用new 来构造一个类,直接可以AdminSiteLog.userip
三,将数字转换字符
代码:Dim CustomerID As Integer=8
Return CustomerID.ToString
错误提示:The call to 'Int32.ToString()' does not explicitly provide IFormatProvider. This should be replaced with a call to an overload that does: Int32.ToString(IFormatProvider provider)
详细说明:Some methods in the common language runtime convert a value to or from a string representation and take a string parameter that contains one or more characters, called format specifiers, which indicate how the value is to be converted. If the meaning of the format specifier varies by culture, a formatting object supplies the actual characters used in the string representation. In scenarios where sorting and comparison behavior should never change between cultures, specify CultureInfo.InvariantCulture.
这一点我也不明白了,
四,过程的参数声明
代码: Public Shared Function GetRoles(ByVal CustomerId As String) As String '角色
错误提示:Correct the casing of parameter name 'CustomerId'.
详细说明:This convention formats the first letter of the first word in lowercase and capitalizes the first letter of all subsequent words, as in backgroundColor.
这个跟我大小写又有什么关系?
五,ID与Id
代码; Public Shared Function GetSpecialCustomerID(ByVal specialname As String)
错误提示:Correct the capitalization of member name 'SpecialComm.GetSpecialCustomerID' by changing 'ID' to 'Id'.
详细说明:Although it may be common practice for some two character acronyms to not be fully capitalized, violations of this rule should not be excluded for this reason. For example, 'DbConnection', is common but incorrect; use DBConnection. A violation of this rule might be required for compatibility with existing, non-managed symbol schemes. In general, however, these symbols should not be visible outside the assembly that uses them.
实在不敢再分析下去了:(
自己书写的习惯竟然都是不在MS定的规则范围之内,整个人都郁闷
