In Visual Studio, I can right-click a class or method and choose "Find usages". That gives me a list of places in my solution where that piece of code is used. How can I do the same from my code?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.
To start using C, you need two things: A text editor, like Notepad, to write C code. A compiler, like GCC, to translate the C code into a language that the computer will understand.
Show activity on this post. &= is and equals , |= is or equals . These perform bit-wise operations with the left hand and right hand arguments, and assign the result into the left hand side.
You would need to parse your code to do this. I don't think you could do it with reflection. MS have been working on a project called Roslyn. This is kind of an API for the .NET compiler. It should provide you with what you need. Check out this post for details of the Roslyn project.
Quote from the post:
This opens up new opportunities for VS extenders to write powerful refactorings and language analysis tools, as well as allow anyone to incorporate our parsers, semantic engines, code generators and scripting in their own applications.
This post demonstrates working with symbols.
This post answers the question of getting all references.
To be honest, I never did that before, as I never needed kind of thing.
For access to kind of information you need to have access to Token Tree
of the compiler, constructed for semantic analysis
.
That kind of information, for sure you can have access from Roslyn (API for C# compiler). Where you can push into the API function a C#
text, run a compiler over it and recover Tokens tree
.
The Roslyn Project Overview
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With