Thank you for your interest in contributing to EasyAppDev.Blazor.Icons! This document provides guidelines and instructions for contributing to this project.
- Code of Conduct
- Getting Started
- Prerequisites
- Development Setup
- Architecture Overview
- Making Changes
- Code Style Guidelines
- Submitting Changes
- Reporting Issues
We are committed to providing a welcoming and inclusive environment for all contributors. Please be respectful and professional in all interactions.
Before you begin:
- Check existing issues and pull requests to avoid duplicating work
- For major changes, open an issue first to discuss your proposed changes
- Make sure you have the required prerequisites installed
Before contributing, ensure you have the following installed:
- .NET 9 SDK - Download here
- Python 3.x - Required only if regenerating icons from SVG sources
- Git - For version control
- IDE - Visual Studio 2022, Visual Studio Code, or JetBrains Rider
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR-USERNAME/EasyAppDev.Blazor.Icons.git
cd EasyAppDev.Blazor.Icons# Build all projects
dotnet build
# Or build specific packages
dotnet build src/EasyAppDev.Blazor.Icons.Lucide/EasyAppDev.Blazor.Icons.Lucide.csprojThe source generator runs automatically during build and generates icon components from the IconData files.
# Run the Blazor sample application
dotnet run --project samples/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample.csprojOpen http://localhost:5090 in your browser to view the sample application.
# Build in Release mode to test
dotnet build -c Release
# Publish to test trimming
dotnet publish samples/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample.Client/ -c Release
# Verify trimmed DLL sizes
ls -lh samples/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample.Client/bin/Release/net9.0/publish/wwwroot/_framework/ | grep EasyAppDevThis library uses a source generation approach to create fully trimmable Blazor icon components:
-
Icon Data (
IconData/**/*.cs): SVG content stored as const strings in partial classes- Split across multiple files for manageability
- Excluded from compilation but included as AdditionalFiles
- Read by source generator at compile-time
-
Source Generator (
IconSourceGenerator.cs): Compile-time generator that:- Reads icon data from IconData files using Roslyn
- Creates individual sealed ComponentBase classes
- Embeds SVG content directly in component code
- Generates ~11,000 components automatically
-
Generated Components: Individual sealed classes like:
namespace EasyAppDev.Blazor.Icons.Lucide { public sealed class Activity : ComponentBase { ... } }
-
Direct Usage: No services or configuration needed:
<Activity />
- Individual sealed classes for each icon (not source generated into consumer's assembly)
- Direct references only (no reflection, no dictionaries)
- Embedded SVG content (no runtime loading)
- .NET trimmer removes unused components automatically
To add new icons or update existing icon sources:
-
Place SVG files in the appropriate directory:
src/BlazorIcons.Generator/icon-sources/lucide/ src/BlazorIcons.Generator/icon-sources/bootstrap/ src/BlazorIcons.Generator/icon-sources/materialdesign/
-
Run the icon generator script:
cd src/BlazorIcons.Generator python3 generate-icons.py cd ../..
-
Rebuild the solution:
dotnet build
The Python script will:
- Read SVG files from
icon-sources/ - Extract inner SVG content
- Generate
IconData/**/*.csfiles with const strings - Source generator picks these up during build
SVG filenames are converted to PascalCase C# identifiers:
home.svg→Homearrow-right.svg→ArrowRight123-icon.svg→_123Icon(prefixed with underscore if starts with number)
To update icon sources from upstream libraries:
-
Update npm packages (in
src/BlazorIcons.Generator/):cd src/BlazorIcons.Generator npm update lucide-static bootstrap-icons @mdi/svg cd ../..
-
Regenerate icon data:
cd src/BlazorIcons.Generator python3 generate-icons.py cd ../..
-
Rebuild and test:
dotnet build dotnet run --project samples/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample/EasyAppDev.Blazor.Icons.Sample.csproj
The source generator is located at:
src/EasyAppDev.Blazor.Icons.SourceGenerator/IconSourceGenerator.cs
When modifying the source generator:
- Update the generator code
- Rebuild the solution (source generator runs automatically)
- Inspect generated components to verify changes
- Test with sample application
- Verify trimming still works correctly
This project follows standard .NET coding conventions:
- Indentation: 4 spaces
- Line endings: LF (Unix-style)
- Encoding: UTF-8
- Naming conventions: Follow Microsoft's C# naming guidelines
- PascalCase for public members, types, namespaces
- camelCase for private fields (prefixed with underscore)
- Null handling: Use nullable reference types (
enable) - File organization: One class per file (except partial classes)
- Indentation: 2 spaces for Razor files
- @using directives: At the top of the file
- Component parameters: Use PascalCase
- Indentation: 2 spaces
- Formatting: Follow standard JSON/YAML conventions
The project includes an .editorconfig file that enforces these conventions. Most IDEs will automatically apply these settings.
- Write clean, readable code with meaningful names
- Add XML documentation comments for public APIs
- Keep methods focused and concise
- Follow SOLID principles where applicable
- Avoid unnecessary complexity
-
Create a feature branch from
main:git checkout -b feature/your-feature-name
-
Make your changes following the code style guidelines
-
Test your changes thoroughly:
- Build the solution without errors
- Run the sample application
- Test trimming if applicable
- Verify icons display correctly
-
Commit your changes with clear commit messages:
git add . git commit -m "Add: Brief description of changes"
Commit message conventions:
Add:for new featuresFix:for bug fixesUpdate:for improvements to existing featuresRefactor:for code refactoringDocs:for documentation changes
-
Push to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub:
- Provide a clear title and description
- Reference any related issues
- Complete the PR checklist
- Ensure all CI checks pass
- Keep PRs focused on a single feature or fix
- Write clear PR descriptions explaining what and why
- Update documentation if needed
- Add tests if applicable
- Be responsive to feedback and review comments
- Keep PRs reasonably sized for easier review
When reporting a bug, please include:
- Clear, descriptive title
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Environment details:
- .NET version
- Blazor hosting model (Server, WebAssembly, Hybrid)
- Browser and version (if applicable)
- Operating system
- Code samples or screenshots if applicable
Use the Bug Report issue template when available.
When requesting a feature:
- Describe the feature clearly
- Explain the use case and why it's valuable
- Consider how it fits with the library's goals
- Provide examples or mockups if helpful
Use the Feature Request issue template when available.
To request specific icons:
- Specify the icon library (Lucide, Bootstrap, Material Design)
- Provide the icon name from the source library
- Include use case or reason for request
- Check if the icon already exists under a different name
Use the Icon Request issue template when available.
If you have questions about contributing:
- Check the README.md for project documentation
- Check the CLAUDE.md for architecture details
- Open a GitHub Discussion
- Open an issue with your question
By contributing to EasyAppDev.Blazor.Icons, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing!