Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop)  
Author Message
Guns





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

hi,

i need to write a rule that should check "Are function calls returning constants avoided within loops". Give suggestions on writing this.

Thanks in advance.




Visual Studio Team System8  
 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

I'm sorry but I don't understand, can you give a code sample that shows the pattern you want to check for

 
 
Guns





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

That is i need to check is the return value of the function is constant such as object.size()

 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

Can you show me a code sample

 
 
Guns





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

david,

Sorry for the late reply.

I dont have any code samples.

These rules are created for the program that is not yet written. The program will be written some time later. It is the requirement "The return type of a function should not be a constatnt such as object.size()".

Thanks



 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

Guns,

I can't give any hints on how to write a rule which I don't understand. What is object.size() Are you talking about Marshal.SizeOf()

If you can't provide a code sample of the pattern (it doesn't have to be real code) you are trying to find, then how can you write a rule to check for it



 
 
Andrew Skalkin





PostPosted: Visual Studio Code Analysis and Code Metrics, Rule to check "Are function calls returning constants avoided within loops?(eg object.size() ion for loop) Top

Guns,

I think I understand what you are saying. The problem is that there are no const methods (in C++ terms) in .Net :)

-Andrew