Using Powershell to Generate Report of C# Classes versus Methods and Properties - powershell

Has anyone used Powershell to generate a report of C# classes versus methods and properties? I'll admit up front I'm not attempting first to write this myself, but someone out there has probably already done it, or would highly enjoy doing it. The challenge will be recognizing things like method signatures across multiple lines. You could join the string array returned by gc and search on that to make it easier. If no one answers, I'll eventually post a solution, but probably many weeks from now.
Update: I'm looking for a Powershell solution because that's already my main scripting language, and I'd like to be able to make changes over time, perhaps extend it to cover JavaScript for example, or change the report format, and I'd like it to work with any version of Visual Studio and C#. I'm also looking for a text report, nothing graphical, so that it's more searchable and manipulatable. I like simple fully programmable free things that impose no limits. :)
Thanks,
Mike

I'm sure you can access Reflection through PowerShell.
You should also look into NDepend, which can do a lot of this sort of thing.

Related

Create a docx (Word) document by using Perl (module)

I have been looking for some time now, and I decided to try some crowd sourcing.
I have searched (Googled) the answer and looked through Stack Overflow for some time now, and I cannot find a proper and relatively easy way of created DOCX documents via Perl.
I want to create a DOC file, and since DOCX is XML based, I was guessing that would be an easier way to achieve this.
I located a RTF::Writer module but its very limited in its capabilities.
There are more than one such library for PHP, and other languages, but I cannot use that, unfortunately.
I am not running on a Windows environment so I cannot use anything that would integrate with Office, in addition I don't want to start bundling Office with my product.
I am open to suggestions, but please provide sensible ones :) i.e. no, you are scr*wed DOCX is impossible.
Here is what I tried:
1) Take an existing DOCX, and modify the XML directly, all I achieved via this is caused Word to crash :) apparently Word is very sensitive on its attribute order
2) Googled for answers and I found some, like Win32::Word::Writer which only works on Windows and requires OLE and Office
3) Found a lot of posts from 2010, that say its impossible, well almost 4 years have passed, probably something is out there that can do it
4) Looked for commercial solutions, couldn't find one, I found FOP which is able to create RTF, which is pretty close, but it lacks a lot of the styling I would like to use
5) A lot of things (code and modules) that allow extracting data from DOCX, but nothing that can create one, weird
6) Found abandoned code like OpenOffice::OODoc which stopped being written in 2010, and of course requires OpenOffice to be installed, and potentially also requires a non-headless (i.e. requires a GUI system)
Thanks guys for any answers :}
One cheat that I've used in the past is to output HTML with a ".doc" file name.
This gives you less fine-grained control over the document formatting, but may be sufficient for your use case.
The closest I've ever managed is to generate an OpenOffice document and then use that to export as .docx (in headless mode).
You need some fonts installed, but no GUI for this. I use OpenOffice::OODoc, and it's enough to let me open up an existing document and add text/pictures.
The OpenOffice (LibreOffice) export process is not 100% reliable, but I've never been able to get a simple, repeatable test case to reproduce it - just hangs occasionally. I add a timer to kill the process and let it retry.
Not a perfect situation, I'm afraid and I hope someone has a better solution.

Handling multiple template files with playframework in complex application?

I recently found out that Scala is an absolutely interesting programming language.
Since I'm not a real desktop application developer but more a webdeveloper I wanted to try out the play framework and if it works well for my purposes.
So far, I really like it, it seems to be easy to use and the developers really think it through.
BUT
I wanted to create an application with different templates, like an "internal", "external" and "admin" area. I already figured out to try out the "modular application" thing which seems to work good but I can't see any possibility to create something like multiple "template" files..
After a few hours of googling, I thought I should just ask..
Has anybody of you done it yet? Any tips how to organise it the best way?
Thanks a lot!
You can have as many views as required and you can also organize them in packages (under the app.views package) in many levels. All you need is just to learn how to reference required view from the controller.
Take a look to this sample schema.
In other words the most importantis clear and comfortable for you order, which you will be able to work with after 3 years without additional notes.

Source Code Control / Version Control in MS Access

This is a general question about the topic. I ran across a post which gave VB script code for version control. I've been developing with Access for a while, but have learned entirely on my own and can be pretty ignorant of the the broader IT world. I got
the code to work for me, but I'm lost on how to put it to work as a system.
To give some context, I have an example situation that maybe this kind of thing could solve. I'm now working on two versions at once (1.2 and 1.3) because the first version we'd like to release has to be tested where it's to be used in China. They were out of the office for a week due to the Chinese new year, in the meantime, I'm working on 1.3. Now, any changes I have to make to 1.2 of course have to go into 1.3. Actually, it's worse than that because clarity over the fact that we'd have to do this in two separate releases didn't emerge until work had been done which in hindsight went further than we could incorporate in 1.2.
The code in the post basically dumps all of the info about forms, reports, VBA, and macros into a bunch of text files (for some reason not tables, and maybe that has something to do with the fact that I'm working with Access 2010 rather than whatever version this code was created for.) Apparently, it can then reconstruct an application from those same text files.
What do I need to understand about source code control to make such a thing work for me? I recognize that might not be something you'd want to explain in a post, but can you point me in the right direction information-wise?
While this question is 3 years old, it might be of interest to some to have an answer anyway.
AFAIK, accesssvn.codeplex.com -cited by #Robby Shaw - is not working and not maintained.
Today I see 2 products usable products for VCS inegration:
one is https://github.com/timabell/msaccess-vcs-integration which is quite active
the other one is Microsoft Access 2010 Source Code Control for which I don't know if it works with more recent versions of Access
Apart from VCS, you could also use a database compare tool like Microsoft's Database Compare 2013
Also worth considering, Accdbmerge, a tool to merge 2 databases.

advice on note keeping and navigating legacy code

I"m having to work with legacy code (mostly CFML) with very little or no documentation, no domain model of any sort to follow either.
To start building some sense out of it, I though 'start keeping notes', then wondered if plain old journal and pencil for text notes would do. Maybe a text document (searchable). Or is it best to take the plunge and UML the beast over time? If that's an overkill on one hand, on the other I repeatedly find myself feeling around the elephant over and over again. How do you build a up a map of the territory?
Sorry for the late answer, but I've ended in situations like this couple of times before. I'd suggest you not to create UML for that, since it will take much time and this code is not very nice, as you've noted (no domain model, no structure).
You could use pen and paper, or text file. Browse through the code, find the most important parts for you and write down where it is located, with some description. If there is no data structure, you could use file name, module, line number, etc. After spending some time doing this, you will have something like navigation plan for the part of the system and general understanding of how it works.
Also, you should refer to this question, there are some answers that can be useful.

What is the best Perl module to use for creating a .pdf from scratch?

There are quite a number of modules on CPAN relating to the creation and manipulation of .pdf files, and I'm hoping this community can save me some time going down blind alleys.
I am looking to create .pdf files from scratch, with only simple formatting such as bold/italic and left/right/center justify. Being able to use a template file would nice, from an MVC perspective, but if the best module doesn't support that, I'm ok. I want the best module for my narrow problem set.
Edit: let's add the constraint that it does have to be a Perl module, if not a pure-perl solution. Thanks for answers thus far!
Update: PDF creation is one difficult problem to decide how to approach. In addition to the good suggestions here, there seems to be about 1,000 different ways to solve this, and knowing which solution(s) to invest your time in is a real challenge. It is easy to acquire dependencies on outside executables in the process of building this solution, which is why I have been favoring doing everything in Perl if possible.
I went down the road of trying to use PDF::Create but found it too limiting. You have to give coordinates to place each string of text and there is no built-in concept of text wrapping... this is all work you have to do. Impossible amount of overhead for my task.
I am now using PDF::API2, which is much more powerful than PDF::Create, but still demands the PDF be assembled at a troublingly low level. Luckily, there is some help online. See Rick Measham's excellent PDF::API2 tutorial with accompanying text_block() subroutine, which thankfully does the heavy lifting on the text wrap problem.
Unless you see another update here, this is the solution that ended up working for me.
I'm the author of the CPAN module CAM::PDF which is definitely not the best tool for this job -- it's designed for high-performance editing, not creating.
Among free PDF creation libraries, I like PDF::API2 the best. It has a very rich feature set and good encryption support (inspired by CAM::PDF I might add!) The author, Alfredo, manages a popular email list. People sometimes complain about documentation, but I've found it to be adequate.
Among commercial libraries, I've had good experiences with pdflib.
Three modules for creating PDF come to mind (in no particular order)....
PDF::API2
PDF:::Create
PDF::Template
PDF::Template gives you that template option you maybe hankering for? PDF::Create seems more straightforward (at least from the docs) and may meet your "simple formatting" requirement more adequately.
However if you want to know what the "community" thinks then only PDF::API2 gets a rating on CPAN Ratings coming in with 4 out of 5 stars overall score.
Hope that helps.
PS. Disclaimer: I've not used any of these modules. In past I've always gone for XML/XSLT/XSL-FO using Apache FOP with Perl being used to create the initial XML data. This can be an overkill for something small and not always ideal if you want to embed PDF generation into your Perl app.
PPS. So I'll also be looking at these CPAN PDF modules at some point in near future!
Does it have to be a Perl module? You could always use LaTeX and convert that to PDF. Not quite as straight-forward, but it is another option.
G'day Marcus,
Glad you found the tutorial. I do a lot of work in PDF::API2, so if there's anything I can help with, just let me know.
Naturally, I recommend PDF::API2!
There's a guy Jay Hannah, who's currently turning the text block into a module for CPAN that does exactly what you want: bold, italic, etc. If you check the mailing list, you'll see his posts at the top.
Cheers!
Rick Measham
Yeah, tough to answer without knowing exactly what your constraints are. If pure-Perl is not a necessity, I'd be inclined towards DocBook.
The initial markup you'll generate can be very simple XML; and the transformation requires just an XSL processor and shelling out to something like Apache's FOP.
how to save a online pdf file using perl?
http://www.nwcc.bc.ca/FNC/pdfs/Stepping%20Stones%20to%20improved%20Relationships%20-%20web.pdf
I am using file::download. but the problem is its not downloading url with url encoded strings.
sharma