https://github.com/netfabric/netfabric.codeanalysis
Extensions to System.CodeAnalysis (Roslyn) and System.Reflection.
https://github.com/netfabric/netfabric.codeanalysis
async-enumerable codeanalysis csharp dotnet enumerables expression-trees loop-iteration nuget-package reflection roslyn
Last synced: 2 months ago
JSON representation
Extensions to System.CodeAnalysis (Roslyn) and System.Reflection.
- Host: GitHub
- URL: https://github.com/netfabric/netfabric.codeanalysis
- Owner: NetFabric
- License: mit
- Created: 2019-11-17T16:13:14.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T13:14:33.000Z (almost 2 years ago)
- Last Synced: 2025-04-01T08:12:15.904Z (9 months ago)
- Topics: async-enumerable, codeanalysis, csharp, dotnet, enumerables, expression-trees, loop-iteration, nuget-package, reflection, roslyn
- Language: C#
- Homepage: https://netfabric.github.io/NetFabric.CodeAnalysis/
- Size: 6.28 MB
- Stars: 8
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/NetFabric/NetFabric.CodeAnalysis/commits/main)
[](https://github.com/NetFabric/NetFabric.CodeAnalysis/actions)
[](https://coveralls.io/github/NetFabric/NetFabric.CodeAnalysis)
[](https://www.nuget.org/packages/NetFabric.CodeAnalysis/)
[](https://www.nuget.org/packages/NetFabric.CodeAnalysis/)
[](https://www.nuget.org/packages/NetFabric.Reflection/)
[](https://www.nuget.org/packages/NetFabric.Reflection/)
# NetFabric.CodeAnalysis and NetFabric.Reflection Documentation
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.
## NetFabric.CodeAnalysis
The NetFabric.CodeAnalysis package serves the purpose of code analysis during compile time. It finds application in Roslyn analyzers' implementation and code generation tasks.
## NetFabric.Reflection
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.
# Enumerable Analysis
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` 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
Documentation is available [here](https://netfabric.github.io/NetFabric.CodeAnalysis/).
# References
- [Efficient Data Processing: Leveraging C#'s foreach Loop](https://www.linkedin.com/pulse/efficient-data-processing-leveraging-cs-foreach-loop-ant%C3%A3o-almada) by Antão Almada
- [Handling enumerables in Roslyn Analyzers and Code Generators](https://www.linkedin.com/pulse/handling-enumerables-roslyn-analyzers-code-generators-ant%C3%A3o-almada) by Antão Almada
- [Handling enumerables when using reflection](https://www.linkedin.com/pulse/handling-enumerables-when-using-reflection-ant%C3%A3o-almada) by Antão Almada
# Credits
The following open-source projects are used to build and test this project:
- [.NET](https://github.com/dotnet)
- [coveralls](https://coveralls.io)
- [coverlet](https://github.com/tonerdo/coverlet)
- [IsExternalInit](https://github.com/manuelroemer/IsExternalInit)
- [Nullable](https://github.com/manuelroemer/Nullable)
- [ReadableExpressions](https://github.com/agileobjects/ReadableExpressions)
- [ReflectionAnalyzers](https://github.com/DotNetAnalyzers/ReflectionAnalyzers)
- [xUnit.net](https://xunit.net/)
# License
This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.