-
Nov 30th, 2022, 12:18 AM
#1
Thread Starter
Frenzied Member
Parse(extract) class names and method names from C# code
I need to use VB6 to parse(extract) the class name (including the properties of the class) and the method name (including the method parameters) in the C#. I now have two ideas:
Method 1: Use a third-party COM-lib or JS-lib to generate AST of C# code, and then parse(extract) out the class name and method name in AST string. I'd like to know what COM libs or JS libs can do this. Thanks.
Method 2: Parse the C# code character by character, and then extract the class names and method names in the C# code. This method has a certain difficulty, I'd like to know if there are some easy ways or helper tools. Thanks!
Last edited by SearchingDataOnly; Nov 30th, 2022 at 12:41 AM.
-
Nov 30th, 2022, 12:38 AM
#2
Thread Starter
Frenzied Member
Get the AST (Json String) of C# code
I want to use VB6 or VB.NET to get the AST (Json String) of C# code, and I know that CodeDom and Roslyn can be used to parse C# code precisely and generate AST node collections and AST json strings. But this approach is too complicated, I really just want to get the class names and method names (including class properties and method parameters) from the C# code. I wonder if there are some smaller COM libs or JS libs or VB helper classes to generate AST strings from C# code? Thank!
-
Nov 30th, 2022, 10:21 AM
#3
Re: Get the AST (Json String) of C# code
If you add the C# class to your VB.NET project, you could use reflection to get those details.
-
Nov 30th, 2022, 08:25 PM
#4
Thread Starter
Frenzied Member
Re: Get the AST (Json String) of C# code
Originally Posted by dday9
If you add the C# class to your VB.NET project, you could use reflection to get those details.
I want to be able to get AST strings without reflection, because eventually I still need to convert these VB.NET algorithms to VB6 code. If reflection is used, the conversion will not work.
Also, I'm parsing (parsing) C# code, not adding C# Classes to VB.NET project. Or to put it this way, I want to write a lightweight C# parser in VB6.
My parser doesn't need to be as precise as CodeDom, Roslyn, and ANTL4, it just needs to get some structural information about the C# code.
Last edited by SearchingDataOnly; Nov 30th, 2022 at 08:44 PM.
-
Dec 1st, 2022, 09:53 AM
#5
Re: Parse(extract) class names and method names from C# code
Moderator Actions: Merged the original VB6 thread with the VB.NET thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|