fxcop

我应该使用int还是Int32

梦想与她 提交于 2020-03-08 09:44:10
在C#中, int 和 Int32 是同一件事,但是我读过很多次,没有给出原因, int 比 Int32 更可取。 有原因吗,我应该在乎吗? #1楼 在定义变量时,我总是使用别名类型(int,字符串等),在访问静态方法时,我总是使用真实名称: int x, y; ... String.Format ("{0}x{1}", x, y); 看到类似int.TryParse()的东西看起来很丑。 除了样式,我没有其他原因。 #2楼 根据Visual Studio 2012中的即时窗口,Int32为int,Int64为long。 这是输出: sizeof(int) 4 sizeof(Int32) 4 sizeof(Int64) 8 Int32 int base {System.ValueType}: System.ValueType MaxValue: 2147483647 MinValue: -2147483648 Int64 long base {System.ValueType}: System.ValueType MaxValue: 9223372036854775807 MinValue: -9223372036854775808 int int base {System.ValueType}: System.ValueType MaxValue: 2147483647

常量的C#命名约定?

拈花ヽ惹草 提交于 2020-02-25 23:22:21
private const int THE_ANSWER = 42; 要么 private const int theAnswer = 42; 我个人认为,对于现代IDE,我们应该使用camelCase,因为ALL_CAPS看起来很奇怪。 你怎么看? #1楼 Microsoft在其文章 Constants(C#编程指南)中 给出了以下示例: class Calendar3 { const int months = 12; const int weeks = 52; const int days = 365; const double daysPerWeek = (double) days / (double) weeks; const double daysPerMonth = (double) days / (double) months; } 因此,对于常量, 看来 Microsoft建议使用 camelCasing 。 但是请注意,这些常量是 在本地 定义的。 可以说,外部可见常量的命名引起了人们的极大兴趣。 实际上,Microsoft在.NET类库中将其 公共常量 记录为 field 。 这里有些例子: Int32.MaxValue String.Empty (实际上是 static readonly ) 数学PI 数学 前两个是 PascalCasing 示例。

MsBuild and FxCop problems

♀尐吖头ヾ 提交于 2020-01-25 00:56:08
问题 I'm trying to make a build file to run with msbuild using cmd or jenkins build job. The structure of the project is the demo is here: www.saramgsilva.com/wp7/sarasilvademo.rar Now i have 3 diferents ways to run fxcop, but i have problems in all. 1) In cmd go to the root file and then run C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7.build /target:FxCop this show a error: exit with code 128 2) In cmd go to the root file and then run C:\Windows\Microsoft.NET

Why does FxCop flag GC.KeepAlive() as a violation?

馋奶兔 提交于 2020-01-24 16:56:06
问题 what is so bad about GC.KeepAlive() that FxCop flags this as a violation? 回答1: Probably because it's considered bad practice to be calling it, just like it's a generally a bad idea to call GC.Collect -- it has generally negative consequences on the collector and/or is a possible indication of a design flaw on your end. You should be able to reconfigured FxCop to not consider calls to the method a problem if you need to call it, however. There are valid reasons to do so, after all. 回答2: It's

Sonar to display results generated by FxCop

半世苍凉 提交于 2020-01-15 15:36:41
问题 How can I use Sonar to display results of the output produced by FxCop. I used FxCop to run static code analysis on .NET Project and FxCop generate the result report in an XML format. Can I use Sonar to take this XML file an input and display the output with it? How can this be done? I am looking for an open source dash board tool to present the output the result produced by FxCop to the end user. 回答1: Sonar has a C# plug-in, documented here: http://docs.codehaus.org/display/SONAR/C-Sharp

Sonar to display results generated by FxCop

眉间皱痕 提交于 2020-01-15 15:36:12
问题 How can I use Sonar to display results of the output produced by FxCop. I used FxCop to run static code analysis on .NET Project and FxCop generate the result report in an XML format. Can I use Sonar to take this XML file an input and display the output with it? How can this be done? I am looking for an open source dash board tool to present the output the result produced by FxCop to the end user. 回答1: Sonar has a C# plug-in, documented here: http://docs.codehaus.org/display/SONAR/C-Sharp

FxCop and GAC Madness

主宰稳场 提交于 2020-01-12 07:39:08
问题 Using FxCop when I try to analyze projects that rely on Patterns and Practices, Enterprise Library Data (among others) 2.0.0.0 - FxCop complains that it can’t: “Locate Assembly Reference” - even though the application dll being analyzed was complied against this version and its in the GAC. If I browse to the GAC try to select the same assembly (I've checked version and public key token) FxCop won't allow me "open" it. The application succeeds in running and definitely makes use of the problem

CA1047 'Make member raise private, public, or internal' and C++/CLI events

99封情书 提交于 2020-01-06 08:27:09
问题 When I declare a public event in a sealed C++/CLI class, I get Code Analysis warning CA1047. The warning seems to come from auto-generated protected member functions. How can I fix this warning? Here's an example. This code ref class Test sealed { public: event EventHandler^ blah; }; generates: warning: CA1047 : Microsoft.Design : Make member 'Test::blah::raise(Object^, EventArgs^)' private, public, or internal 回答1: I'll document the question better. This code ref class Test sealed { public:

Parser FxCop Results Xml file in C#

偶尔善良 提交于 2020-01-04 14:19:46
问题 I use VS2010 and Fxcop 10.0 (fxcopcmd.exe) programatically for generate fxcop analysis results (xml file) I would like parser xml file for fxcop analysis results. In java language I've found this: http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.hudson.plugins/violations/0.7.7/hudson/plugins/violations/types/fxcop/FxCopParser.java any suggestions for parser C#? 回答1: I use this code to get number of issues in the report. You can retrieve actual messages from XElement as well public

Parser FxCop Results Xml file in C#

半腔热情 提交于 2020-01-04 14:19:46
问题 I use VS2010 and Fxcop 10.0 (fxcopcmd.exe) programatically for generate fxcop analysis results (xml file) I would like parser xml file for fxcop analysis results. In java language I've found this: http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.hudson.plugins/violations/0.7.7/hudson/plugins/violations/types/fxcop/FxCopParser.java any suggestions for parser C#? 回答1: I use this code to get number of issues in the report. You can retrieve actual messages from XElement as well public