如何在FxCop中显示System.String.Concat()参数值 [英] How to display the System.String.Concat() parameter value in FxCop
问题描述
我在FxCop中编写自定义规则以检查"地址格式化"。以下是我需要验证的代码:
I am writing the custom rule in FxCop to check the "Address formatting". Here is the code that I need to verify:
string firstName =" abc";
string firstName="abc";
string middleName =" xyz";
string middleName="xyz";
string lastName =" uvw";
string lastName="uvw";
string name = firstName +" " + middleName +" " + lastName
string name=firstName + " " + middleName + " " + lastName
我可以使用FxCop中的Method类在System.String.Concat方法中找到违规。但我也希望显示所有3个变量的值以及违规的一部分。
I am able to find the violation in System.String.Concat method using the Method class in FxCop. But I also want to display the values of all 3 variables as well as part of the violation.
我该如何实现?
此致,
Kuntal
推荐答案
嗨Kunsha,
Hi Kunsha,
您的意思是说您希望将所有值显示为分辨率的一部分吗?然后,您可以在规则中指定如下xml
Do you mean to say you want to display all values as a part of resolution? Then you can specify as below in you rules xml
< Resolution Name =" AddressFormatting">值"{0}","{1}"和"{2}"<分辨率>
<Resolution Name="AddressFormatting"> Address formating is not correct for values '{0}', '{1}' and '{2}'<Resolution>
和
在您的代码中如下:
Problems.Add(新问题(GetNamedResolution(" AddressFormating",firstname,secondname,thirdname)));
Problems.Add(new Problem(GetNamedResolution("AddressFormating",firstname, secondname, thirdname)));
我希望这能回答你的问题。
I hope this answers your question.
谢谢
Sharad
这篇关于如何在FxCop中显示System.String.Concat()参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!