This documentation covers both the NetFabric.CodeAnalysis and NetFabric.Reflection packages. These packages offer overlapping functionality designed for different phases of code execution.
Having both packages within the same repository facilitates the sharing of common data sets among unit tests.
The NetFabric.CodeAnalysis package serves the purpose of code analysis during compile time. It finds application in Roslyn analyzers' implementation and code generation tasks.
The NetFabric.Reflection package, on the other hand, is geared towards runtime code analysis. It proves valuable in scenarios such as unit testing or any other runtime code execution.
Moreover, it offers expression trees that facilitate dynamic code generation during runtime.
Both packages boast extensive capabilities for analyzing enumerables. In C#, the 'foreach' statement seamlessly handles enumerables, with the compiler generating code to iterate over them. This involves invoking the 'GetEnumerator' method on the enumerable, repeatedly calling 'MoveNext' on the enumerator until it returns false, and utilizing the 'Current' property to access the current value. The compiler also takes care of invoking the 'Dispose' method on the enumerator upon 'foreach' statement completion.
Hence, merely checking if a type implements IEnumerable
or IEnumerable<T>
is insufficient for identifying its enumerability. These packages offer a rich array of functionality to ascertain whether a type is enumerable and to gather comprehensive information about it.
Documentation is available here.
- Efficient Data Processing: Leveraging C#'s foreach Loop by Antão Almada
- Handling enumerables in Roslyn Analyzers and Code Generators by Antão Almada
- Handling enumerables when using reflection by Antão Almada
The following open-source projects are used to build and test this project:
This project is licensed under the MIT license. See the LICENSE file for more info.