Source code as objects in C# [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there any way to represent class's source code as objects? I'd like to navigate through methods, theirs body etc. How tools like stylecop, ReSharper do it in Visual Studio 2010? Are there any external libraries which take as input source code file and produce representation of objects? Which i could read, modify or analyze?

As for already compiled assembly. Reflection can give you most info about object structure. But to get real code, you need to get down to IL.
As for code, that is open in Visual Studio, then VS exposes COM interface, that many of those plugins use. EnvDTE is managed wrapper around this interface. But documentation is scarce.

NRefactory will do this for you:
http://wiki.sharpdevelop.net/NRefactory.ashx
Edit: This is a "parser" which is what you want. It converts C# code into an abstract syntax tree which can then be modified with code and translated back to C#.

If you'd like just to list method, class, property names, then Reflection is a good simple solution - e.g. see simple tutorial like http://www.java2s.com/Tutorial/CSharp/0400__Reflection/ListMethods.htm
If you want more detailed analysis, including method bodies, then it might be a good idea to start from the source code from one or more of the Reflector replacements - e.g.
ILSpy - http://wiki.sharpdevelop.net/ILSpy.ashx
smooth reflector http://blog.smoothfriction.nl/archive/2011/02/07/building-your-own-reflector-with-mono-cecil-and-the-codedom.aspx
list here - Open Source Alternatives to Reflector?

Related

Generate documentation from C# class library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have developed a C# class library which contains numerous projects. I am using this as a common library across multiple different projects.
A number of different developers have recently joined the team and not being familiar with the library they are not sure what is contained with it. I have it well commented with the help of ghostdoc.
Is it possible to auto generate documentation using any tool of the library? I would like to run a tool against it that would generate documentation for me that I could make the developers aware of to read. I presume such a tool would generate the documentation from the comments.
I recommend using Sandcasle Help File Builder to generate documentation from your source code. You will want to review XML Documentation Comments as the quality and robustness of your generated documentation is directly related to the richness of the XML comments you use.
SHFB can generate HTML and/or compiled help documentation.
If you're using Visual Studio go to the projects' properties, select Build, then uner Ouput tick the XML documentation file checkbox.
I've recently made a simple to use library that generates markdown documentation from C# code. All it takes is a class library dll file.
If you want to give it a try, here's a link on how to start using it with examples of generated documentation.
More informations : https://www.nuget.org/packages/BetaSoftware.AutoDocumentation

C Parser in C# or generally .Net [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
For my diploma thesis I need to implement certain static C code analysis and I am desperately looking for a framework/library that would allow me to parse C source code, split it up into single functions, for every function determine what variables are changed in the function body and derive certain annotations for the code automatically.
Is there any good framework written in C# or generally as .Net class for this purpose?
What about googling for "C Parser written in C#"?
I got this as first link: http://code.google.com/p/cpp-ripper/
Also, I think the C grammar can be found in quite a lot of places, so you might just want to open up your .NET variant of lex/yacc and go from there?
You might like to check ANTLR. It comes with versions of several versions, included C and C#. There are some free grammars on ANTLR web site, including C.
I had a similiar problem and having done a research about YACC tools for C# I have chosen Gold Parsing System with Semantic Engine. My project was parsing SQL queries and generating logical query plans (from T-SQL grammar subset).
I really recommend it. Those 2 libraries make parsing stuff painless and allow to map grammar to the object model in your code. It feels very intuitive and made my project successful :) However, it may lack some advanced ANTLR features, so recognize your needs carefully.
Gold Project http://www.devincook.com/goldparser/
Semantic Engine Lib http://code.google.com/p/bsn-goldparser
If you're ok with using GPL'd code, you might want to take a look at the GCC source code. If you need to do it within .Net, you can always use p/invoke to call code from the GCC libraries.

Convert VB.NET code to C# [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I have three projects written with VB.NET (2005) and have to convert them to C# code. (I know that i don't need to convert codes of .net languages at all). I have no time to rewrite them, need a tool or script to convert.
Note: they are console applications.
Reflector lets you inspect compiled assemblies in several different .Net languages. I've known people to cut and paste the output to convert between languages. Apparently it also has an export feature.
SharpDevelop can do this, but depending you your vb.net code a lot of manual work will remain.
http://converter.telerik.com/
Another option is using Carlos Aguilar's converter. Converts from VB.NET to C# and viceversa.
Experience shows me that different converters are better than others in certain areas so I'd recommend you to use more than one, if possible, and compare their output.
There is a cool .net code conveter tool available online here. Try this if it helps to you.
Free Online .Net Code Converter

Is there a C# tool that will let me execute an arbitrary block of code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm sure something like this exists, but I can't for the life of me remember what it is called.
I'm looking for an app where I can just execute an arbitrary block of C# code and see any console output.
http://www.sliver.com/dotnet/SnippetCompiler/
Snippet Compiler
Not necessarily a snippet compiler but I use it for that purpose also:
LINQPad
The neat thing about it is that you can dump intermediate results to the output and has very nice formatting for all types of objects so you won't have to write Console.WriteLine(...) statements.
You can also write only expressions, or simple statements or classes, and it will compile all of them.
There is also LINQ Pad. It will work as a snippet compiler and lets you run linq against sql server.
Mono has GSharp, which I personally use all the time.
http://tirania.org/blog/archive/2008/Nov-02.html
Another approach is offered by TestDriven.Net, which allows you to click on any method in the Visual Studio code editor and run it directly.
This can be useful for debugging code that's otherwise buried a little deep to conveniently access.
To round out the other answers, there's also:
Snippy (by Jon Skeet) - also check out the Reflector add-in (be sure to look for the latest version on the author's blog).
Matthew Manela's FastSharp.
LINQPad is my favorite :)

Is there a .NET based CSS abstraction library? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I've been working on a really large project for almost 2 years and the client requirements keep changing. These changes, of course, effect everything and I would like to find a way to work with the CSS in a more dynamic fashion.
I assume I could get one of the ruby or python CSS DSLs running under ironRuby/Python but this client is very very particular about what software/frameworks are installed.
I have not found a CSS DSL where the base programming language is vb or c#.
reference:
http://sandbox.pocoo.org/clevercss/ and http://nubyonrails.com/articles/dynamic-css
Less CSS for .NET was recently released.
http://www.dotlesscss.org/
I am not sure about any publicly available products, but I have written an ASP.NET HttpHandler for .css files a few times. Its a pretty simple task, and I usually add things like variable and basic expression support, realtime minification, comment stripping, etc. Is this what your looking for? If so, I think each time its taken maybe 10 hours of work max to write, debug, and implement the handler...not too bad given all the benefits.
You could also write your own DSL, using either the DSL Toolkit that's part of the Visual Studio SDK, or using Oslo. In the former case, the result could be .css files plus whatever else you needed, including API code for your ASP.NET application to call upon.

Categories