Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolodymyr Usarskyy <usarskyy@gmail.com>2012-03-26 17:23:32 +0400
committerVolodymyr Usarskyy <usarskyy@gmail.com>2012-03-26 17:23:32 +0400
commit62692c13d54261b68a9f63d239be1404978b8968 (patch)
tree8ef23499238d40ee0d0a7c92031a1564d2193634 /gendarme
parent2d9fc5f15447776ab3910a4ccce01dde9a2987c1 (diff)
AvoidDeepNamespaceHierarchyRule: Added overload of "Solution" property that is required when MaxDepth property has value different than 4
DisableDebuggingCodeRule & GetLastErrorMustBeCalledRightAfterPInvokeRule: fixed NullReferenceException-s (discovered during SharpSVN analyze)
Diffstat (limited to 'gendarme')
-rw-r--r--gendarme/rules/Gendarme.Rules.BadPractice/DisableDebuggingCodeRule.cs6
-rw-r--r--gendarme/rules/Gendarme.Rules.Interoperability/GetLastErrorMustBeCalledRightAfterPInvokeRule.cs9
-rw-r--r--gendarme/rules/Gendarme.Rules.Naming/AvoidDeepNamespaceHierarchyRule.cs14
3 files changed, 25 insertions, 4 deletions
diff --git a/gendarme/rules/Gendarme.Rules.BadPractice/DisableDebuggingCodeRule.cs b/gendarme/rules/Gendarme.Rules.BadPractice/DisableDebuggingCodeRule.cs
index ccb7a8a2..d5393756 100644
--- a/gendarme/rules/Gendarme.Rules.BadPractice/DisableDebuggingCodeRule.cs
+++ b/gendarme/rules/Gendarme.Rules.BadPractice/DisableDebuggingCodeRule.cs
@@ -151,7 +151,11 @@ namespace Gendarme.Rules.BadPractice {
continue;
// ... to System.Console ...
- MethodReference mr = (ins.Operand as MethodReference);
+ MethodReference mr = ins.Operand as MethodReference;
+
+ if (mr == null)
+ continue;
+
if (!mr.DeclaringType.IsNamed ("System", "Console"))
continue;
diff --git a/gendarme/rules/Gendarme.Rules.Interoperability/GetLastErrorMustBeCalledRightAfterPInvokeRule.cs b/gendarme/rules/Gendarme.Rules.Interoperability/GetLastErrorMustBeCalledRightAfterPInvokeRule.cs
index 63655d03..37b5dad9 100644
--- a/gendarme/rules/Gendarme.Rules.Interoperability/GetLastErrorMustBeCalledRightAfterPInvokeRule.cs
+++ b/gendarme/rules/Gendarme.Rules.Interoperability/GetLastErrorMustBeCalledRightAfterPInvokeRule.cs
@@ -135,12 +135,17 @@ namespace Gendarme.Rules.Interoperability {
//check if a method is called
if (ins.OpCode.FlowControl == FlowControl.Call) {
+ MethodReference mRef = ins.Operand as MethodReference;
- MethodDefinition mDef = (ins.Operand as MethodReference).Resolve ();
+ if (mRef == null) {
+ continue;
+ }
+
+ MethodDefinition mDef = mRef.Resolve();
if (mDef != null && mDef.IsPInvokeImpl) { //check if another pinvoke method is called, this counts as "GetLastError not called"
break;
}
-
+
string s = (mDef == null) ? String.Empty : mDef.DeclaringType.GetFullName ();
switch (s) {
case "System.Runtime.InteropServices.Marshal":
diff --git a/gendarme/rules/Gendarme.Rules.Naming/AvoidDeepNamespaceHierarchyRule.cs b/gendarme/rules/Gendarme.Rules.Naming/AvoidDeepNamespaceHierarchyRule.cs
index a49442f3..ac7756b1 100644
--- a/gendarme/rules/Gendarme.Rules.Naming/AvoidDeepNamespaceHierarchyRule.cs
+++ b/gendarme/rules/Gendarme.Rules.Naming/AvoidDeepNamespaceHierarchyRule.cs
@@ -96,7 +96,10 @@ namespace Gendarme.Rules.Naming {
[DefaultValue (DefaultMaxDepth)]
[Description ("The depth at which namespaces may be nested without triggering a defect.")]
public int MaxDepth {
- get { return max_depth; }
+ get
+ {
+ return max_depth;
+ }
set {
if (value < 1)
throw new ArgumentOutOfRangeException ("MaxDepth", "Minimum: 1");
@@ -149,5 +152,14 @@ namespace Gendarme.Rules.Naming {
}
return Runner.CurrentRuleResult;
}
+
+ public override string Solution
+ {
+ get
+ {
+ return string.Format("Try to keep the depth below {0}, with an additional one for specialization (e.g. Design, Interop, Permissions).",
+ MaxDepth);
+ }
+ }
}
}