Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Common Development Commands

### Build and Test
```bash
dotnet build # Build the solution
dotnet test # Run all tests
dotnet test --logger "console;verbosity=detailed" # Run tests with detailed output
dotnet pack # Create NuGet packages
```

### Development Workflow
```bash
dotnet build LayeredCraft.StructuredLogging.sln # Build entire solution
dotnet test test/LayeredCraft.StructuredLogging.Tests/ # Run specific test project
dotnet run --project test/LayeredCraft.StructuredLogging.Tests/ # Run test project directly
```

## Project Architecture

### Core Structure
- **src/LayeredCraft.StructuredLogging/** - Main library containing all logging extensions
- **test/LayeredCraft.StructuredLogging.Tests/** - Comprehensive test suite with xUnit3, AutoFixture, and NSubstitute

### Key Components
- **LoggerExtensionsBase.cs** - Internal base class providing optimized logging methods with level checks
- **Extension Classes** - Individual files for each log level (Debug, Information, Warning, Error, Critical, Verbose)
- **Specialized Extensions**:
- **ScopeExtensions.cs** - Scope management and timed operations
- **EnrichmentExtensions.cs** - Contextual logging with UserId, RequestId, CorrelationId
- **PerformanceExtensions.cs** - Performance monitoring and timing utilities
- **Testing/TestingExtensions.cs** - Testing framework with TestLogger and assertions

### Target Frameworks
- Multi-target: .NET 8.0, .NET 9.0, .NET Standard 2.1, .NET Standard 2.0
- Uses modern C# features with nullable reference types enabled

### Dependencies
- **Microsoft.Extensions.Logging.Abstractions** - Core logging abstraction
- **Test Dependencies**: xUnit3, AutoFixture, NSubstitute, AwesomeAssertions

## Development Guidelines

### Code Organization
- Each log level has its own extension class (e.g., `InformationExtensions.cs`)
- All extensions use the internal `LoggerExtensionsBase` for performance-optimized logging
- Performance checks (`logger.IsEnabled(logLevel)`) are built into base methods
- Comprehensive XML documentation is required for all public APIs

### Testing Strategy
- Test project uses xUnit3 with AutoFixture for test data generation
- NSubstitute for mocking ILogger instances
- AwesomeAssertions for fluent test assertions
- TestLogger framework provides specialized logging test utilities
- Tests are organized by feature area matching the main library structure

### Package Configuration
- NuGet package metadata is defined in the main project file
- Version is controlled via Directory.Build.props (currently 1.1.0)
- Package includes icon.png and README.md
- Source linking and symbol packages are enabled for debugging

### CI/CD Integration
- GitHub Actions workflow uses LayeredCraft shared templates
- Builds on .NET 8.0 and 9.0
- Automated package building and publishing on tags/releases
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>1.1.0</VersionPrefix>
<!-- SPDX license identifier for MIT -->
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net9.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>default</LangVersion>

<!-- Package metadata -->
Expand Down Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.7" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

Expand Down
Loading