Fix Bit.SourceGenerators issues with interfaces containing properties with attributes (#9916)#9920
Fix Bit.SourceGenerators issues with interfaces containing properties with attributes (#9916)#9920msynk merged 2 commits intobitfoundation:developfrom yasmoradi:9916
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe modifications update the collection initializations in syntax receiver classes to use empty array initializers instead of constructor calls. Additionally, error handling in the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Code Invoker
participant SR as SyntaxReceiver
participant Proc as Processing Logic
participant Catch as Error Handler
Caller->>SR: Visit Syntax Node
SR->>Proc: Execute processing logic (e.g., marking members, properties, classes)
alt Processing is successful
Proc-->>SR: Return normal result
SR->>Caller: Continue normal flow
else Exception occurs
Proc-->>SR: Exception thrown
SR->>Catch: Catch exception in try-catch
Catch->>SR: Wrap exception with InvalidOperationException (with context)
SR->>Caller: Propagate error
end
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/SourceGenerators/Bit.SourceGenerators/AutoInject/AutoInjectSyntaxReceiver.cs (1)
12-13: Consider using ICollection instead of Collection.While the collection initialization is correct, consider using
ICollection<T>instead ofCollection<T>in the property declarations to follow interface-based programming and allow for more flexible implementations.- public Collection<ISymbol> EligibleMembers { get; } = []; - public Collection<INamedTypeSymbol> EligibleClassesWithBaseClassUsedAutoInject { get; } = []; + public ICollection<ISymbol> EligibleMembers { get; } = []; + public ICollection<INamedTypeSymbol> EligibleClassesWithBaseClassUsedAutoInject { get; } = [];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/SourceGenerators/Bit.SourceGenerators/AutoInject/AutoInjectSyntaxReceiver.cs(2 hunks)src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorParameterPropertySyntaxReceiver.cs(2 hunks)src/SourceGenerators/Bit.SourceGenerators/HttpClientProxy/HttpClientProxySyntaxReceiver.cs(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build and test
🔇 Additional comments (4)
src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorParameterPropertySyntaxReceiver.cs (2)
19-46: LGTM! Enhanced error handling with detailed context.The try-catch block provides valuable debugging information by including both the property name and file path in the error message.
12-12:Details
✅ Verification successful
Verify .NET version compatibility.
The code uses C# 12's collection expression syntax
[]. Ensure that the project targets .NET 8 or later to support this feature.
🏁 Script executed:
#!/bin/bash # Check target framework version in project file fd -e csproj | xargs cat | grep -A 5 "TargetFramework"Length of output: 26725
.NET Target Frameworks Confirm Compatibility
The project is targeting .NET 8.0 and .NET 9.0, both of which support C# 12’s collection expression syntax. No further changes are required for the syntax used in this file.
src/SourceGenerators/Bit.SourceGenerators/AutoInject/AutoInjectSyntaxReceiver.cs (1)
17-26: LGTM! Comprehensive error handling for all marking operations.The try-catch block effectively wraps all marking operations and provides clear error context with the file path.
src/SourceGenerators/Bit.SourceGenerators/HttpClientProxy/HttpClientProxySyntaxReceiver.cs (1)
17-99: LGTM! Enhanced error handling and improved code structure.The changes improve the code in two ways:
- Added comprehensive error handling with detailed context
- Better code organization with explicit condition checking for controllers
closes #9916
Summary by CodeRabbit
Bug Fixes
Refactor