FXCOP

Can anybody tell me the new function for ISMEthodCall() in older version?
Thanks
[84 byte] By [smartneraj] at [2008-2-5]
# 1

Update: Updated to include the OpCode.Jmp instruction.

Sounds like you could be using my AvoidComplicatedMethods rule and you have not included the RuleHelper class.

Anyway here is its implementation:


public static bool IsMethodCall(Instruction instruction)
{
if (instruction == null)
throw new ArgumentNullException("instruction");

switch (instruction.OpCode)
{
case OpCode.Callvirt:
case OpCode.Call:
case OpCode.Calli:
case OpCode.Jmp:
return true;
}

return false;
}


DavidM.Kean at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...
# 2
Just a note, I'm not sure that I've ever seen this in real-world IL, but OpCode.Jmp will transfer execution to a method body. And also, of course, a NewObj instruction will call a constructor method.

I'm sure you've omitted the latter intentionally, just pointing this out for others who might grab this helper code for another purpose. 8)

Michael

MichaelFanning-MS at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...
# 3

Michael,

Didn't know about the Jmp instruction (my IL is still a bit lacking - still waiting for my copy of Inside Microsoft .NET IL Assembler), however as you stated I did omit the NewObj intentionally. Will update the rule to check for the Jmp instruction.

Do you know of any language that uses the Jmp instruction?

My AvoidComplicatedMethods rule really needs to be rewritten to take into account the cyclomatic complexity of a method rather than simply counting the number of method calls within it. There are a number of tools out there to measure this, so I might investigate this further.

David

DavidM.Kean at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...
# 4
We actually have a cyclomatic complexity rule that will ship in VS 2005 Team System. I'll be glad to show you around that code in the near future. 8)

We'd also like to develop some analysis that accounts for other interesting test-related metrics, such as Halstead statistics. Another interesting idea for you to consider taking on in the future.

Nearly forgot to mention: I am not aware of a compiler that actually emits the jmp opcode, but I haven't investigated very deeply. I'll send a mail to a couple of IL experts here to see if they have any information on this.

Michael

MichaelFanning-MS at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...

Visual Studio Team System

Site Classified