Madhavan281981

HI,

I am in the process of developing a generic tool (Code Checker) in .net framework 2.0. The application will check the input file whether it has followed the mentioned coding standard (Method name, variable names should be wither in camel casing or pascal casing) guidelines. Can any one explain me how to get or identify user defined method names from a file given as input.

Short description

The application will get a file (vb or cs) as input and will look for the coding standard which should be checked (available in the config file). The application should read the file and identify the public methods with events, user defined methods, variables and constants.

The application will parse the text file and give a detailed report to the end user showing the lines which have voilated the coding standard rules (comapring the method names using string comaprison with case sensitive option)

Also can any one give me some inputs on how to develop this solution. If this tool is developed then it will save enormous time to the developers on checking the coding standards before submitting their code to the clients or for auditing




Re: Visual C# Language Identifying public methods and user defined methods with in a class file

David M. Kean - MSFT

I'm not sure whether you posted this in the Code Analysis forum, or whether someone moved this post in here.

FxCop and Visual Studio Code Analysis can provide you with this information, with one exception - it analyzes binaries (ie .dll, .exe) and not source files.

For more information on starting, check out the following blog posts:

FAQ: How do I integrate custom rules with Visual Studio

FAQ: Can I create custom rules that target both Visual Studio and FxCop






Re: Visual C# Language Identifying public methods and user defined methods with in a class file

Madhavan281981

Hi,

I am trying to develop this application related to my project. we have some security issues to use a third party s/w. so i started to develop my own solution. can you help me to develop my solution rather than going for a third party s/w






Re: Visual C# Language Identifying public methods and user defined methods with in a class file

Todd King - MSFT

So when you say you don't want to use third party software you mean you don't want to use FxCop What security issues are you concerned about in using FxCop

The charter of this forum is to primarily help FxCop users, not to help people make their own tool, however I'll take a stab at your two original questions:

Madhavan281981 wrote:

Can any one explain me how to get or identify user defined method names from a file given as input.

There is no fool proof way to do this. The FxCop team has developed a set of heuristics to help us identify compiler generated code. One thing to look for is the presense of a CompilerGeneratedAttribute or a GeneratedCodeAttribute. Once again, you could get this functionality for free if you simply wrote your own FxCop rule.

Madhavan281981 wrote:

Also can any one give me some inputs on how to develop this solution.

So if you're determined to write your own tool that reads in source code your first step is to develop a parser for each language you want to support this involves finding a parser generator and then passing it a grammar file for each language you want to support. You may have to create your own grammar file if you can't find grammar files for any of the languages you want to support. Then you'll want to build an AST (Abstract Syntax Tree) from the parser. Now with that AST you want walk the tree and examine each member and check the naming of it.

Good luck, this is probably going to be a big project.

-Todd King