Skip to content

Fix parameterless delegates and RaiseEvent accessors declared without parentheses - #4

Closed
GrahamTheCoder wants to merge 1 commit into
masterfrom
claude/fix-1298-parameterless-parens
Closed

GrahamTheCoder wants to merge 1 commit into
masterfrom
claude/fix-1298-parameterless-parens

Conversation

@GrahamTheCoder

Copy link
Copy Markdown
Owner

Fixes icsharpcode#1298

Summary

VB lets the parentheses be omitted when there are no parameters, leaving a null ParameterList.

  • Delegate Sub Callback / Delegate Function Provider As Integer crashed with "Value cannot be null (parameterList)".
  • A custom event's RaiseEvent accessor without parentheses silently lost its generated On<Event>() method.

Root cause: each call site handled the null parameter list on its own, and some did not handle it at all. Fix: a shared AcceptParameterListAsync extension (in SyntaxNodeVisitorExtensions) that returns an empty C# parameter list for null. It is now used at every VB parameter list conversion: delegates, methods, Declare, constructors, operators, lambdas and the property/RaiseEvent accessor paths. The existing ad-hoc ?? ParameterList() fallbacks were replaced by it.

Tests added

  • Delegates: Delegate Sub Callback, Delegate Function Provider As Integer, and the generic form without parentheses.
  • Custom event with a parameterless RaiseEvent accessor without parentheses: OnMyEvent() is now emitted and called.
  • Parameterless Declare Sub/Declare Function, Sub New, Sub and Function without parentheses.

The delegate and RaiseEvent tests were confirmed red for the right reason before the fix.

For the reviewer

  • The helper and the call-site changes are in one commit rather than a separate pure-refactor commit first.
  • The blind subagent review round was not run. I had no way to spawn a subagent in this session.
  • Coverage on the changed lines was not collected.

Full suite

1429 passed, 0 failed, 5 skipped. The master baseline file was empty, so there was nothing to compare against, but there were no failures.


Generated by Claude Code

…tently

VB allows parentheses to be omitted for parameterless delegates and
RaiseEvent accessors, leaving a null ParameterList. Delegates crashed with
a null parameterList and RaiseEvent accessors silently lost their On<Event>
method. Add AcceptParameterListAsync and use it everywhere a VB parameter
list is converted (methods, delegates, accessors, Declare, operators,
constructors, lambdas) instead of ad-hoc null fallbacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019FEr8FVAmHV9bscZ82CChg
@GrahamTheCoder

Copy link
Copy Markdown
Owner Author

Superseded: icsharpcode#1311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VB -> C#: omitted parentheses cause conversion failures in delegates and custom-event raise accessors

2 participants