Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract Attributes from c# source code without Reflection

I want to extract custom attributes from source code from different .CS files. I have list of files .

Scenario is that i have Project A which reads files of Project B. It has to extract all attributes used in Project B.

My question is that how can i do that without using Reflection. Reflection deals with assemblies but i have source code.

Using Roslyn would be over kill?

what approaches are there?

I had another option to Compile using MSBuild but for large scale projects it would not be feasable due to heavy dependencies. and it seems not a good way to build application and then going for its assemblies

i just want to have some sort of thing that tells me what attribute was on what class and possible a UML diagram of relations of that classes.

Please give your suggestions

like image 864
Muhammad Umer Asif Avatar asked Apr 26 '12 13:04

Muhammad Umer Asif


People also ask

What is an example of extract by attribute?

Extraction by attribute Cells that meet a specified attribute query can be extracted to a new output raster with the Extract by Attributes tool. Examples of applications for this tool include the extraction of all cells that have a slope greater than 10 percent or the extraction of all cells attributed with zoning for commercial development.

How do I extract attribute information from a block?

The ability to extract attribute information from blocks into a table object or CSV file for use in another application can help save time and reduce costly errors that might occur from re-entering the data. The Data Extraction wizard is the most efficient way to extract attribute information from blocks inserted into a drawing.

What are attributes in C++?

Last Updated : 05 Dec, 2018 Attributes are one of the key features of modern C++ which allows the programmer to specify additional information to the compiler to enforce constraints (conditions), optimise certain pieces of code or do some specific code generation.

How do I get the source code equivalent of an attribute?

The key method is GetCustomAttributes, which returns an array of objects that are the run-time equivalents of the source code attributes. This method has several overloaded versions.


1 Answers

You could use NRefactory: https://github.com/icsharpcode/nrefactory (also available as a NuGet package)

like image 119
erikkallen Avatar answered Nov 15 '22 03:11

erikkallen