refactor(source-generators): improve type casting and output generation#254
Merged
Conversation
…rCastCall - Removed BuildHandlerSignature method from DelegateInfoExtensions. - Updated MapHandlerSources to use BuildHandlerCastCall instead. - Modified signature construction to use Utilities.Cast for handler processing.
…ullable reference types - Added explicit null-forgiveness operator for Build methods in unit tests. - Updated LambdaHostOutputGenerator to include additional namespace and utility class in generated output. - Simplified and refactored code template files by removing duplicate using statements. - Enhanced handler signature casting with improved clarity in MapHandler template.
- Updated `Version` property in Directory.Build.props to reflect the new prerelease version.
Signed-off-by: Jonas Ha <61319894+j-d-ha@users.noreply.github.com>
…lity - Added `Utilities.Cast` method to simplify and enhance handler signature casting. - Updated snapshot file with organized `using` directives and new casting approach. - Improved accuracy and clarity in generated handler processing logic.
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #254 +/- ##
==========================================
+ Coverage 88.41% 88.49% +0.07%
==========================================
Files 130 130
Lines 3125 3129 +4
Branches 344 340 -4
==========================================
+ Hits 2763 2769 +6
+ Misses 229 227 -2
Partials 133 133
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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
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 refactors the source generator's type casting mechanism and output generation to improve code quality and maintainability. The changes replace the string-based handler signature building approach with a more type-safe generic casting method, and consolidate the generated code structure.
Key improvements:
BuildHandlerSignaturemethod withBuildHandlerCastCallthat uses a genericUtilities.Cast<T>helper(Func<string>)handler) to default parameter type inference (e.g.,Utilities.Cast(handler, string () => throw null!))Utilitiesclass to centralize the generic Cast method✅ Checklist
🧪 Related Issues or PRs
N/A
💬 Notes for Reviewers
This is purely a refactoring change with no functional differences. All test snapshots have been updated to reflect the new generated code format. The new casting approach is more maintainable and reduces the complexity of string-based type signature building.
The generic
Cast<T>method uses a default parameter pattern to infer the target delegate type, which is cleaner and more type-safe than constructing type strings.