stylecop

Why does StyleCop recommend prefixing method or property calls with “this”?

最后都变了- 提交于 2019-11-26 06:35:30
问题 I have been trying to follow StyleCop\'s guidelines on a project, to see if the resulting code was better in the end. Most rules are reasonable or a matter of opinion on coding standard, but there is one rule which puzzles me, because I haven\'t seen anyone else recommend it, and because I don\'t see a clear benefit to it: SA1101: The call to {method or property name} must begin with the \'this.\' prefix to indicate that the item is a member of the class. On the downside, the code is clearly

Should 'using' directives be inside or outside the namespace?

柔情痞子 提交于 2019-11-25 22:22:48
问题 I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using directives inside instead of outside the namespace? 回答1: There is actually a (subtle) difference between the two. Imagine you have the following code in File1.cs: // File1.cs using System; namespace Outer.Inner { class Foo { static void Bar() { double d = Math.PI; } } } Now imagine that someone adds another file