loc - Lines of Code

Overview

The loc command counts lines of code in your .NET projects and solutions. It provides accurate line counts for C# source files, helping you measure project size and track growth over time.

Syntax

nmbl loc <ProjectOrSolution>

Arguments

Output

Displays line counts for each file and provides totals, helping you understand the size and distribution of your codebase.

Examples

Count Lines in a Project

nmbl loc src/MyProject/MyProject.csproj

Shows line counts for all C# files in the specified project.

Count Lines in a Solution

nmbl loc MySolution.slnx

Counts lines across all projects in the solution.

Track Growth Over Time

# Create a baseline
nmbl loc MySolution.slnx > metrics/loc-baseline.txt

# After development
nmbl loc MySolution.slnx > metrics/loc-current.txt

# Compare the files to see growth

Measure Specific Components

nmbl loc src/Core/Core.csproj
nmbl loc src/Infrastructure/Infrastructure.csproj
nmbl loc src/Web/Web.csproj

Compare sizes of different components in your architecture.

Understanding the Results

The line count includes:

This metric can help you:

Tips

Combine with Other Metrics

# Get comprehensive metrics
nmbl loc MySolution.slnx
nmbl cc MySolution.slnx
nmbl cogc MySolution.slnx
nmbl regions MySolution.slnx
nmbl todos MySolution.slnx

Automation

# Add to CI/CD pipeline
nmbl loc MySolution.slnx | tee build-artifacts/loc-report.txt

Include line count reports in your build artifacts.