Skip to content

Claude/fix issue 1242 winforms nullref#1247

Merged
GrahamTheCoder merged 3 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-1242-winforms-nullref
Apr 13, 2026
Merged

Claude/fix issue 1242 winforms nullref#1247
GrahamTheCoder merged 3 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-1242-winforms-nullref

Conversation

@GrahamTheCoder
Copy link
Copy Markdown
Member

Fixes #1242

claude and others added 3 commits April 12, 2026 23:51
…reatePropertyAssignment

When InitializeComponent contains a bare identifier assignment (e.g. `Button1 = New Button()`
without the `Me.` prefix), s.Left is a VBSyntax.IdentifierNameSyntax. Calling
LastOrDefaultDescendant<IdentifierNameSyntax>() on it returns null because DescendantNodes()
does not include the node itself, causing a NullReferenceException in CreatePropertyAssignment.

Fix: detect when s.Left is itself an IdentifierNameSyntax and use it directly; also add a
null guard so other unexpected shapes fall through gracefully.

Regression test added based on the Issue774 test but with a bare identifier (no Me.) in
InitializeComponent's WithEvents field assignment.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
@GrahamTheCoder GrahamTheCoder merged commit 0e1ce42 into icsharpcode:master Apr 13, 2026
3 checks passed
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#: Nullref in WinformsConversions.CreatePropertyAssignment

2 participants