-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add MSBuild property support for configurable source generation #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Moved `HashCodeTests.cs` to the `Utilities` folder. - Adjusted path of `EquatableArrayTests` to `Types/EquatableArray/`.
…r tools - Added a new test project, `LayeredCraft.SourceGeneratorTools.Generator.UnitTests`. - Configured multi-targeting for `net8.0`, `net9.0`, and `net10.0`. - Implemented `GeneratorTestHelpers` for verifying source generator outputs. - Added necessary package references (e.g., `Verify.SourceGenerators`, `xunit.v3`). - Updated solution file to include the new test project. - Adjusted `Directory.Packages.props` with updated dependency versions.
…t file - Removed the `RootNamespace` property from the test project file. - Added `ModuleInitializer` to initialize `VerifySourceGenerators` for tests.
- Added snapshot tests to verify generator outputs for `EquatableArray` and `HashCode`. - Updated `GeneratorTestHelpers` to support customizable analyzer options. - Added `Snapshots` folder to the test project file for organizing generated snapshots. - Introduced `EquatableArrayExtensions.g.cs` and `HashCode.g.cs` as test outputs. - Adjusted `.gitignore` to include rules for `*.received.*` snapshot files.
…utilities - Added `AwesomeAssertions`, `Microsoft.CodeAnalysis`, `Microsoft.CodeAnalysis.CSharp`, and `Microsoft.CodeAnalysis.Diagnostics` to `GeneratorTestHelpers`. - Added `JetBrains.Annotations` to `SourceGeneratorToolsGeneratorTests`.
…sage based on the changes.
…nfiguration - Introduced `TestAnalyzerConfigOptionsProvider` for unit tests to mock MSBuild properties. - Added `CompilationOptions` struct to support `Include`, `Exclude`, and `UsePublicModifier` properties. - Updated `SourceGeneratorToolsGenerator` for dynamic generation based on MSBuild properties. - Introduced `LayeredCraft.SourceGeneratorTools.Generator.props` file to define properties. - Modified feature generation logic with inclusion/exclusion handling based on MSBuild configuration. - Updated `GeneratorConstants` to define `AllFeatures` and simplify feature management.
- Replaced `EmitCompilerVisibleProperty` with `<CompilerVisibleProperty>` for streamlined property definition. - Updated test cases to include verification for `SourceGeneratorToolsUsePublicModifier` behavior. - Refined generator logic to handle properties dynamically and added `static` where applicable for optimization. - Included launch settings for debugging Roslyn components with an example project. - Updated feature generation logic to avoid null checks and ensure valid default behavior. - Enhanced test project to reflect new property-driven source generation and snapshot tests. - Included distinct file reference handling for better generator accuracy.
…`HashCode`, and related extensions - Added snapshot tests to verify source generator outputs for `EquatableArray` and `HashCode`. - Introduced `EquatableArray.g.cs`, `EquatableArrayExtensions.g.cs`, and `HashCode.g.cs` as test outputs. - Updated `GeneratorTestHelpers` to support customizable analyzer options. - Refined test project organization by adding output snapshots under the `Snapshots` folder. - Adjusted `.gitignore` to handle `*.received.*` snapshot files.
…perty behavior - Added unit tests for `SourceGeneratorToolsInclude` and `SourceGeneratorToolsExclude` properties. - Verified that `Include` supersedes `Exclude` behavior via snapshot tests. - Introduced corresponding snapshot files to validate generator outputs. - Updated test organization with new cases to improve coverage.
- Deleted `GeneratableFeature` as it is no longer used in the generator codebase. - Simplified the generator by eliminating unnecessary structures to maintain cleaner code.
- Added a detailed pull request template to guide contributors with summary, checklist, and notes. - Revised structure to include sections for related issues or PRs and specific reviewer notes. - Enhanced formatting for better readability in the markdown file.
- Deleted the `<EmitCompilerVisibleProperty>` group as it is no longer required. - Simplified the build configuration to maintain clarity and remove unused properties in MSBuild.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚀 Pull Request
📋 Summary
This PR adds comprehensive MSBuild property support to the source generator, allowing developers to control which features get generated through project configuration. The implementation includes:
SourceGeneratorToolsIncludeandSourceGeneratorToolsExcludeMSBuild propertiesSourceGeneratorToolsUsePublicModifierproperty to generate public APIs instead of internalHashCodeas a standalone generatable feature alongsideEquatableArray.propsfile for automatic property visibility and launch settings for debuggingKey changes:
CompilationOptionsstruct to encapsulate generator configurationGeneratorConstants.FeaturesfromGeneratableFeaturestruct to simplerDictionary<string, string[]>✅ Checklist
🧪 Related Issues or PRs
Enhances the source generator with user-requested configurability for feature generation.
💬 Notes for Reviewers
Testing approach: This PR uses Verify.SourceGenerators for snapshot testing, which provides reliable verification of generated source code across different scenarios.
MSBuild property logic:
SourceGeneratorToolsIncludeis set, only those features are generated (exclude is ignored)SourceGeneratorToolsExcludeis set, all features except excluded ones are generatedBreaking changes: None - all changes are additive and maintain backward compatibility.
Performance: Generator now uses incremental generation pipeline with proper caching of MSBuild properties.