Thank you for considering a contribution! Here's everything you need to get started.
# Clone
git clone https://github.com/Swevo/AutoMap.Generator.git
cd AutoMap.Generator
# Build
dotnet build
# Test
dotnet testAll tests live in tests/AutoMap.Tests/MappingTests.cs.
src/AutoMap/
AutoMapGenerator.cs ← the Roslyn IIncrementalGenerator (all generation logic)
AutoMapAnalyzer.cs ← diagnostic analyser (AM001–AM007)
AutoMapCodeFixProvider.cs← code-fix lightbulb actions
tests/AutoMap.Tests/
MappingTests.cs ← xUnit tests covering every feature
benchmarks/AutoMap.Benchmarks/
Program.cs ← BenchmarkDotNet comparison vs AutoMapper / Mapperly
docs/
index.html ← GitHub Pages documentation site
AutoMapGenerator is an IIncrementalGenerator. It:
- Finds all types decorated with
[Map]or[MapFrom]attributes. - Resolves source/destination property pairs (handling nested objects, collections, enums, flattening, etc.).
- Emits a single
AutoMapExtensions.g.csfile containing all extension methods, partial hooks, andIAutoMapper<T, R>singletons.
The attributes themselves (MapAttribute, MapFromAttribute, etc.) are defined as inner sealed class types inside AutoMapGenerator.cs and injected into the consumer's compilation at build time.
- Edit
AutoMapGenerator.csfor new mapping behaviour, orAutoMapAnalyzer.csfor new diagnostics. - Add a test in
MappingTests.cs— each scenario is a small xUnit[Fact]. - Run
dotnet testto confirm nothing regresses. - Open a PR with a clear description of what you changed and why.
- Define the attribute as a
sealed classconstant string near the top ofAutoMapGenerator.cs(search forMapIgnoreAttributeas a reference). - Parse it in
BuildMappingModelwhere properties are analysed. - Apply the parsed value during code emission in
EmitExtensions. - Add at least one test per new behaviour.
cd benchmarks/AutoMap.Benchmarks
dotnet run -c ReleaseResults compare AutoMap.Generator against Mapperly, AutoMapper, and hand-written code.
Please open an issue with:
- A minimal repro (the class definitions +
[Map]attributes you used) - The error or incorrect generated code you observed
- Your .NET version and AutoMap.Generator version
- Match the style of the surrounding code.
- No new external runtime dependencies.
- Keep generated code readable — a developer should be able to step through it in a debugger.
By contributing, you agree that your contribution will be licensed under the MIT Licence.