VB -> C#: omitted parentheses cause conversion failures in delegates and custom-event raise accessors
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start in the DeclarationNodeVisitor.VisitDelegateStatement path, where a null parameter list reaches SyntaxFactory.DelegateDeclaration; supply an empty C# parameter list as ordinary methods already do. Then check how a parameterless RaiseEvent accessor is converted so that the On<EventName>() method is not dropped. Done when both VB inputs with and without parentheses produce identical C# output, matching the expected delegate lines.
Written by the indexing model from the issue text.
Description
VB.Net input code
Public Delegate Sub Callback
Public Delegate Function Provider As Integer
Erroneous output
Cannot convert DelegateStatementSyntax, CONVERSION ERROR:
Value cannot be null. (Parameter 'parameterList')
at Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DelegateDeclaration(...)
at ICSharpCode.CodeConverter.CSharp.DeclarationNodeVisitor.VisitDelegateStatement(...)
Expected output
public delegate void Callback();
public delegate int Provider();
Details
- Product in use: VS extension, built locally from master.
- Version in use: 10.0.1, local development build.
- Did you see it working in a previous version, which? No.
- Related to #1296: VB.NET permits parameterless delegate declarations without parentheses. Adding
()afterCallbackorProvideravoids the failure, but both forms should convert identically. - The delegate visitor passes a null parameter list to the C# syntax factory when parentheses are omitted. Supplying an empty C# parameter list resolves the issue, consistent with the existing handling for ordinary methods and external declarations.
- The same problem also affects a custom event's parameterless
RaiseEventaccessor when declared without parentheses. In that case, the generated C# event is retained, but its correspondingOn<EventName>()method is silently omitted.
- Dominant language
- C#
- Stars
- 916
- Forks
- 242
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from icsharpcode/CodeConverter
-
VB -> C#
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
icsharpcode/CodeConverter#1301 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
icsharpcode/CodeConverter#1271 · 1 comment ·
Maintainers usually reply within 3 days
-
VB -> C#: Generic extension method inference widens element types when using a base-type comparerOpenVB -> C#
Difficulty 4/5 3-5 days Newbie friendliness 55/100
icsharpcode/CodeConverter#1302 ·
Maintainers usually reply within 3 days
-
VB -> C#
Difficulty 3/5 1-2 days Newbie friendliness 68/100
icsharpcode/CodeConverter#1300 ·
Maintainers usually reply within 3 days
-
VB -> C#
Difficulty 3/5 1-2 days Newbie friendliness 62/100
icsharpcode/CodeConverter#1299 ·
Maintainers usually reply within 3 days
All issues in icsharpcode/CodeConverter
Similar issues
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
CarlosAdrianM/Nesto#610 ·
-
area/resource-registry status/triage
Difficulty 1/5 1-3 hours Newbie friendliness 76/100
Altinn/altinn-auth#4821 ·
Maintainers usually reply within 1 day
-
a11y community:contribution
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/fluentui-blazor#5590 · 1 comment ·
Maintainers usually reply within 1 day
-
bug mcp small
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day