Don't try to offer a conversion to SG COM when properties are involved#119375
Don't try to offer a conversion to SG COM when properties are involved#119375jkoritzinsky merged 2 commits intodotnet:mainfrom
Conversation
Properties aren't supported and the analyzer was crashing on the cast to MethodDeclarationSyntax later due to this.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a crash in the COM interface generator analyzer when it encounters properties in interfaces marked with [ComImport]. The analyzer was incorrectly trying to cast property accessors to MethodDeclarationSyntax, causing failures.
- Adds validation to skip code fix suggestions when non-ordinary methods (like property accessors) are present
- Adds a test case to verify the analyzer doesn't crash or offer fixes for interfaces with properties
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ConvertComImportToGeneratedComInterfaceAnalyzer.cs | Adds check to return early when non-ordinary methods are encountered |
| ConvertToGeneratedComInterfaceTests.cs | Adds test case for property scenario to prevent regression |
|
Tagging subscribers to this area: @dotnet/interop-contrib |
|
/ba-g android timeout unrelated |
|
/backport to release/9.0-staging |
|
/backport to release/10.0 |
|
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/17501405268 |
|
Started backporting to release/10.0: https://github.com/dotnet/runtime/actions/runs/17501408485 |
Properties aren't supported and the analyzer was crashing on the cast to MethodDeclarationSyntax later due to this.