# Code metrics with macro code expanded?

**URL:** <https://forum.crystal-lang.org/t/code-metrics-with-macro-code-expanded/7635>\
**Category:** Help & Support\
**Created:** [January 22, 2025, 7:28am UTC](https://forum.crystal-lang.org/t/code-metrics-with-macro-code-expanded/7635 "2025-01-22T07:28:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlazar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/vlazar/32/31_2.png) [@vlazar](https://forum.crystal-lang.org/u/vlazar)\
**Post date:** [January 22, 2025, 7:28am UTC](https://forum.crystal-lang.org/t/code-metrics-with-macro-code-expanded/7635/1 "2025-01-22T07:28:50Z")

</div>

Is there an easy way to get the program source code as seen by Crystal compiler after all macros being expanded?

I want to print code metrics at that point, such as lines of code per file/class/module/method etc.

---

<div class="post-metadata">

**Author:** ![bcardiff](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/bcardiff/32/3_2.png) [@bcardiff](https://forum.crystal-lang.org/u/bcardiff)\
**Post date:** [January 22, 2025, 8:47am UTC](https://forum.crystal-lang.org/t/code-metrics-with-macro-code-expanded/7635/2 "2025-01-22T08:47:30Z")

</div>

I think [RFC: Ability to expand macro (recursively) · Issue #2324 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues/2324) is still accurate.

\*.You can expand one location. (either debug() or the expand tool)

- Macros might have macros and those will be expanded (even by the compiler) only if used.

Additionally you will need to expand defs to their specialized versions since a macro expansion inside of them could expand to different code. I don’t think there’s support for that.
