-
Notifications
You must be signed in to change notification settings - Fork 4
Add OperationWalker support and fix implicit object creation expressions #52
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: eNeRGy164 <[email protected]>
Co-authored-by: eNeRGy164 <[email protected]>
Co-authored-by: eNeRGy164 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces OperationWalker support for method invocations and fixes the handling of implicit object creation expressions to improve analyzer productivity and language support.
- Fixes detection of implicit object creations in syntax analyzers.
- Adds a new OperationBasedInvocationsAnalyzer with unified handling of explicit and implicit invocations.
- Introduces comprehensive tests for both explicit and implicit object creation scenarios.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tests/DendroDocs.Tool.Tests/OperationWalkerIntegrationTests.cs | Added integration tests validating operation-based invocation handling. |
tests/DendroDocs.Tool.Tests/ImplicitObjectCreationTests.cs | Added tests to ensure both implicit and explicit object creation are correctly detected. |
src/DendroDocs.Tool/Analyzers/OperationBasedInvocationsAnalyzer.cs | New analyzer leveraging IOperation for language-neutral, enhanced semantic analysis. |
src/DendroDocs.Tool/Analyzers/InvocationsAnalyzer.cs | Updated to support ImplicitObjectCreationExpressionSyntax by adding a new visit method. |
Comments suppressed due to low confidence (1)
src/DendroDocs.Tool/Analyzers/OperationBasedInvocationsAnalyzer.cs:42
- [nitpick] When converting initializer expressions using Syntax.ToString(), verify that this approach accurately captures the intended semantics for more complex initializers.
var value = initializer switch
{ | ||
foreach (var argument in node.ArgumentList.Arguments) | ||
{ | ||
var argumentDescription = new ArgumentDescription(semanticModel.GetTypeDisplayString(argument.Expression), argument.Expression.ToString()); |
Copilot
AI
Jul 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] To improve performance and readability, consider storing the result of semanticModel.GetTypeDisplayString(argument.Expression) in a local variable rather than calling it inline multiple times.
var argumentDescription = new ArgumentDescription(semanticModel.GetTypeDisplayString(argument.Expression), argument.Expression.ToString()); | |
var argumentType = semanticModel.GetTypeDisplayString(argument.Expression); | |
var argumentDescription = new ArgumentDescription(argumentType, argument.Expression.ToString()); |
Copilot uses AI. Check for mistakes.
Pull Request Test Coverage Report for Build 15993184477Details
💛 - Coveralls |
Can you improve the code coverage, of at least the added new code. |
… and ImplicitObjectCreationTests Co-authored-by: eNeRGy164 <[email protected]>
Co-authored-by: eNeRGy164 <[email protected]>
I have significantly improved the code coverage for the newly added code. Here's what was added: Enhanced ImplicitObjectCreationTests (10 comprehensive tests):
New OperationWalkerCoverageTests (6 focused tests):
Coverage achieved for all OperationBasedInvocationsAnalyzer methods:
Result: 296/296 tests passing - comprehensive coverage for all new OperationWalker functionality while maintaining 100% backward compatibility. Commit: cc092e0 |
This PR addresses the design suggestion to use
IOperation
instead ofSyntaxNode
for better analyzer productivity and language support.Changes Made
✅ Fixed Implicit Object Creation Support
The core issue where
object obj = new();
wasn't working has been resolved by adding support forImplicitObjectCreationExpressionSyntax
in the existingInvocationsAnalyzer
:✅ Added OperationWalker Implementation
Created
OperationBasedInvocationsAnalyzer
that provides the benefits mentioned in the issue:IOperation
new object()
) and implicit (new()
) object creation✅ Backward Compatibility Maintained
SourceAnalyzer
constructor interface✅ Benefits Demonstrated
Before (syntax-based):
ObjectCreationExpressionSyntax
andImplicitObjectCreationExpressionSyntax
CONSTANT
instead of"Hello"
)After (operation-based):
IObjectCreationOperation
Testing
This implementation provides the foundation for future VB.NET support while immediately solving the implicit object creation issue.
Fixes #6.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.