Find out what packages, classes and methods the Jar file contains - c#

I have a Java code editor with syntax highlighting, with a code hint menu and quick actions. The editor is written in C#. Once again, this editor is for editing Java code! I need to know what packages, classes, methods are in the Jar library (Jar file) for further
code hinting and syntax highlighting.
I have an idea about decompiling the Jar to find out "its contents", but I suspect that there is another more efficient way to implement this.
This is what my editor looks like:

It turned out to be relatively simple. I found the 'jd-gui' repository (https://github.com/java-decompiler/jd-gui), here is the app: (http://java-decompiler.github.io/). The program itself is written in java and is a very good java decompiler based on the jd-core core (https://github.com/java-decompiler/jd-core).
I liked this application, because. it implements a detailed overview of the entire decompiled application (you can see what packages, classes, methods, fields are in the jar), that's exactly what I needed! Because it was an open source repository, I just tweaked it a little, and now when decompiling, the program saves the xml file with the "contents of the jar file". And then I wrote an xml parser in c# to load data and further work with them. That's all...
Code with edited jd-gui saving xml file with jar content: https://drive.google.com/drive/folders/1_opg0BBIrmHoZ125F0Fyl9n_0o4xutiL?usp=sharing When loading a jar file, next to it (in the same folder) an xml file with the contents of this file will be saved.

Related

how to add documentation to undocumented production library

I use a production library (namely itextsharp) in my project, this library doesn't ship with intellisense documentation.
I'd like to build (partial) documentation project.
Is this possible without access to the source code?
I think that intellisense data for external libraries are defined in a xml file which should ship alongside the said library. It should also have the same named but an xml extension instead of dll.
There are a bunch of xml tags that Intellisense will expect which are documented on msdn. Also some open source libraries come with such documentation, like Unity for instance, which will give you a "working" example of such a xml file. You can find an example here on github

Using XslCompiledTransform in C# : xlst file compared to compiled dll

We're developing a program that generates DOCX files using XML and transforms. Currently one person is responsible for development of the XML and XSLT files and another for the C# program that puts it all together. I'm the one developing the C# side. Using the .xslt file the transform works fantastic. The issue I'm having is that the manager of this project doesn't want me to distribute the .xslt's. Instead I'm compiling the file into a dll assembly. No I'm getting errors such as:
An error occurred while loading document ". See InnerExeption for a complete description of this error. This operation is not supported for a relative URI.
I know it's probably something simple I've probably missed. Does anyone know of a good article that outlines the implementation difference between using the xlst file and a compiled dll.
Thanks.

How do you get all project macros and their values from .vcxproj file

I'm trying to parse a group of vcxproj files and am running into difficulties with their use of macros in properties.
A trivial example is
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
$(Outdir) and $(ProjectName) are generally relatively easy to infer from the file, although this particular one has quite a few different configurations.
I was wondering, rather than reinventing the wheel (again), is there a utility or library (preferably C#) which will derive from a project file all of its macros and their associated values?
Obviously msBuild and Visual Studio are able to extract this information, so it seems like they might share some library or program to do it.
It looks like the
Microsoft.Build.Evaluation.Project
class has what I need in it's Properties field

c# Codedom write Program Settings to Generated File

I would ask if its Possible to use Settings with Codedom like this
Example:
Write settings to Fresh Generated Executable file ,like Resources or something smiliar.
I have searched on msdn but didnt find something.
Not directly with CodeDom. As its name suggests, Code Dom is about, well, code, and what you can do with it. You can in theory generate an assembly via CodeDom, and then manipulate it using other libraries to embed the resources on it.

Creating extra type definitions at compile time

Recently I've been working with MSTest, and I noticed that the testframework generates accessor classes dynamically at compile time. How can one do this?
There's an xml file in a VS2010 C# project. I'd like to make an enum out of certain data in this xml file. Can this be done? And if so, how?
I'd recommend T4 templates myself. Very easy to use and specifically designed to allow you to generate code during the build. http://msdn.microsoft.com/en-us/library/bb126445.aspx
Method A) Read the xml file, parse it, generate C# code from it, write out the C# code to a temp file, compile that code; delete the temp file.
Method B) Read the xml file, parse it. Generate IL code directly from it using method in the System.Reflection.Emit namespace, or those in the System.CodeDom namespace.
MSTest achieves this in a couple of different ways. In short they essentially do the following IIRC
Hook into the build system
At the start of the build they generate their acessor's into hidden files in the project
After the build completes they remove their files
You can achieve a similar effect via the same process. However hooking into the build system is a bit complicated. A much simpler approach is to build a custom tool / code generator and hook. This allows you to process a file at build time and spit out a corresponding code file to include in the build.
There are several examples on the web on how to achieve this. Here are a couple
http://www.raboof.com/Projects/VsCodeGeneratorShim/
http://www.ramymostafa.com/?p=204
The System.CodeDom Namespace is one option you have.
It allows you to automatically generate a class using C# Code and compile it as well.
You can maybe call this code as a postbuild during your build of your project.
This example shows how to create a class using this namespace

Categories