How to use Roslyn to inpect code for both c# and vb.net - roslyn

Is there a more abstract way to parse .Net code?
Seems all the classes are specific to the .Net language, you would think there would be a abstract class for say Class, Member, similar as what is done reflection.
I'm looking for a way to inspect the parsed code but using shared classes for both c# or vb.net.
Also most of the links seem to be outdated, so if anyone has some new links I would appreciate it.
Any links or guidance would be appreciated.

Related

how to port VB code in C++

I want to use VB.NET code in win32 (C++) (I dont want to convert my code). I have heard about wrapping VB code in COM but i don't know how to do it. Also, I am not aware if there is an alternative (or any better) way of porting the code.
Any help is appereciated.
Update: I created a class library in vb and saved it as a dll after setting the comvisible attribute to true, then imported it in my c++ project and accessed the interfaces via COM
*thank you everone for helping me out !!!!!!! *
You cannot call .NET code directly from a native C++ application, so there is some work involved.
Of course, your question leaves us guessing at why you're wanting to do this, but unless you are still going to be using the library from a .NET application, I would be a strong advocate in favor of porting it (like your title suggests) to C++.
But if you don't want to do this, you have a couple of other options:
Write a wrapper around the VB.NET code using C++/CLI. This would probably be the simpler solution, especially if you're reasonably familiar with both the VB.NET and C++ languages.
Expose the VB.NET methods you need as COM functions, using the <ComVisible(true)> attribute. This is going to be a bit trickier to get going, especially if you're uncomfortable or unfamiliar with COM programming in C++. It's too much to explain in a Stack Overflow answer; investigate purchasing a good book on COM programming. And although you're using VB.NET, the steps are basically the same for C#, for which you'll have much better luck finding examples.
You can't directly port VB into C++, but if you are looking to just switch to a more powerful language and still use the GUI libraries, you can check out C#. It uses very similar code, and a quick google search provided me this program: C# converter. If you really need C++, you could probably then convert the C# code to C++, but there really wouldn't be a need to since C# is VERY close to C++. Just googling that I found this: C++ converter.
I hope this will help you.

How to use code from native dll non-statically in vb.net?

My question is more on the concept and less on the actual code.
I have an app in vb.net. I want to port a few classes to native c++ code (not cli) for various reasons. What I want to do is to be able to instantiate and use these classes, like i do in the fully managed app.
I understand that I can call static functions from a native dll, but this is not the case here. I need to instantiate classes and use them through the lifetime of the app.
So the question is, is this possible? And if so, could you point me to the right direction to start?
maybe you can take a look here
Instantiating a C++ class in C# using P/Invoke via a pointer
and here
http://www.codeproject.com/Articles/18032/How-to-Marshal-a-C-Class

Something like unity but for C++ programmers

is there anything similar to unity but with the difference that instead of javascript I can use C++?
It is funny, I was looking to learn a little bit of unity as I seen it as requirement for some postings... and I found this question.
I think Ogre3D is great... it may be what you are looking for.
here is the link ogre3d.org
Ogre3D is what I used. http://www.ogre3d.org/
It is somewhat of a misconception that Unity uses Javascript. The so-called Javascript used in Unity is actually a dialect of Javascript that is CLI-compatible and is not exactly the same as the official Javascript. Also, you are not limited to using Javascript in Unity. You can also use C#, which is similar to C++ and Java in some ways or the less commonly used Boo script.
Personally, I would recommend using C# in Unity because it is very powerful and allows calling of native C/C++ functions via P/Invoke. Here is a link to the use of plugins:
http://unity3d.com/support/documentation/Manual/Plugins.html
Link to list of Game Engines. Please take your time to read and consider them:
http://en.wikipedia.org/wiki/List_of_game_engines
If you want accessibility offered by Unity, C++ is certainly wrong choice. Much better would be interpreted/script language, such as Python. They are more flexible in terms of working in web browser/many os-es.
If you're interested in targetting mobile platforms then Marmalade might be a good fit.
Panda3D It's not a think compared to Unity, but it can work as a web plugin, cross-platform. It has a lack of IDE, but it is opensource.
As far as I know, there is no need to use JavaScript or Boo with Unity, and there is nothing wrong with C# acting like script language ( which is really hard with C++ ).
as a unity developer, I liked to add c++ to by knowledge base as all AAA games are made by C++ and I was looking for something like unity but for CPP. the only good cpp engine is unreal that doesn't really support c++. the language is a dialect of c++ and there are big differences. like very
rare usages of pointer and references
more syntaxes like c# attributes(cpp has not attribute)
...
so you don't learn memory management. the nearest thing that I could find was COCOS2dx as the whole framework is written in pure standard c++ and many libraries like UI and Physics are already added. you can write your own engine and editor with it.
Unreal Engine uses C++
default standard is C++14
https://www.unrealengine.com

Photoshop COM and C++ (How to)

I would like to use Photoshop via COM using C++, but I'm not sure if I'm getting it right. I've seen lot's of tutorials on how to do that with C# and even tried one but as far as I know ideology of COM says that you can use any language you like since it's source is just binary. So, C++ is exactly what I want and to start I should have a photoshop interface class in my client programm, right ? So, the question is: Where can I get it (interface class) ? And even if I had one, how would I know about functions to operate photoshop instance. Or maybe I understanding COM + C++ wrong ? Your help is highly appreciate.
Thank you in advance!
You are right, COM is language-neutral, but it requires a lot of extra runtime work to ask the OS for pointers to the interfaces and methods you need. COM is a huge pain in C++. You're looking at 5-10 lines of code for a single function call. Microsoft's "helper" libraries like MFC and ATL can help make it easier, but it's still not pretty.
C# abstracts a lot of the details away and makes COM look like regular object-oriented code. In C++, you'd have to write the wrapper class yourself or find someone else's implementation. It won't necessarily be hard, but it will be tedious.
I work with COM in C++ and I would jump at the chance to do it with C# instead.

Using COM dll with unmanaged c++

I am still a bit new to Windows programming and sometimes find the documentation and tutorials I find confusing and sometimes contradictory but I hope I can make some sense and be corrected on any points I am mistaken about.
I am using an API where the documentation included is quite poor. It is made up of a number of DLLs that they envisioned would be added as a reference to VB projects (most of the users are biologists/chemists and are not very familiar with other languages, so they recommend VB). I thought they were .NET dlls at first but they cannot be registered with regasm and a tlb cannot be generated using this but can be registered with regsvr32, so I guess that means they are COM dlls...please correct me if I am wrong.
My understanding is that as this exposes the COM objects that I should be able to use this with .NET languages and unmanged c++. I have used it in C# but I would also like to use this in unmanged c++. I have seen tutorials like this:
http://cppkid.wordpress.com/2009/01/...nmanaged-code/
That import the type library but I do not have this, it was not supplied with the API. However using OLE viewer I was able to see that they were available (embedded in the dll?). I was wondering if anyone knows how I can go from this to actually using the dll in c++.
Cheers and thanks for any help.
I guess the easiest way to achive this would be to use the #import directive:
#import <mygreatlib.dll>
There are other ways though, like using #import with the ProgID of the entry point class of your dll, or using the MFC type library wizard