From a113695b2edb090f22d600b69b93259349fcaf54 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 12 Apr 2026 23:51:39 +0000 Subject: [PATCH 1/2] Normalize line endings in web/package.json https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX --- web/package.json | 70 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/web/package.json b/web/package.json index 4bf84f8e..e735702e 100644 --- a/web/package.json +++ b/web/package.json @@ -1,35 +1,35 @@ -{ - "name": "codeconverter", - "version": "10.0.0", - "private": true, - "type": "module", - "scripts": { - "dev": "vite", - "start": "vite", - "test": "vitest", - "build": "tsc && vite build", - "preview": "vite preview", - "lint": "eslint ./src/" - }, - "dependencies": { - "@monaco-editor/react": "^4.7.0", - "axios": "^1.13.5", - "bootstrap": "^5.3.8", - "monaco-editor": "^0.55.1", - "react": "^19.2.4", - "react-dom": "^19.2.4", - "react-router-bootstrap": "^0.26.3", - "react-router-dom": "^7.13.0", - "reactstrap": "^9.2.3" - }, - "devDependencies": { - "@types/node": "^22.10.5", - "@types/react": "^19.2.13", - "@types/react-dom": "^19.2.3", - "@vitejs/plugin-react": "^4.3.4", - "jsdom": "^27.0.1", - "typescript": "~5.7.2", - "vite": "^6.4.2", - "vitest": "^3.2.4" - } -} +{ + "name": "codeconverter", + "version": "10.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "start": "vite", + "test": "vitest", + "build": "tsc && vite build", + "preview": "vite preview", + "lint": "eslint ./src/" + }, + "dependencies": { + "@monaco-editor/react": "^4.7.0", + "axios": "^1.13.5", + "bootstrap": "^5.3.8", + "monaco-editor": "^0.55.1", + "react": "^19.2.4", + "react-dom": "^19.2.4", + "react-router-bootstrap": "^0.26.3", + "react-router-dom": "^7.13.0", + "reactstrap": "^9.2.3" + }, + "devDependencies": { + "@types/node": "^22.10.5", + "@types/react": "^19.2.13", + "@types/react-dom": "^19.2.3", + "@vitejs/plugin-react": "^4.3.4", + "jsdom": "^27.0.1", + "typescript": "~5.7.2", + "vite": "^6.4.2", + "vitest": "^3.2.4" + } +} From 5889f2d7fea53474cc0d1a77e131cc45edbbc384 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Apr 2026 00:02:59 +0000 Subject: [PATCH 2/2] Fix #1242: NullReferenceException in WinformsConversions.CreatePropertyAssignment When InitializeComponent contains a bare identifier assignment (e.g. `Button1 = New Button()` without the `Me.` prefix), s.Left is a VBSyntax.IdentifierNameSyntax. Calling LastOrDefaultDescendant() 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 --- CodeConverter/CSharp/WinformsConversions.cs | 4 +- Tests/CSharp/MemberTests/EventMemberTests.cs | 126 +++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/CodeConverter/CSharp/WinformsConversions.cs b/CodeConverter/CSharp/WinformsConversions.cs index ee5ddee8..f26c29c7 100644 --- a/CodeConverter/CSharp/WinformsConversions.cs +++ b/CodeConverter/CSharp/WinformsConversions.cs @@ -56,7 +56,9 @@ private IEnumerable GetAssignmentsFromInitializeComponent(VBSyntax.M return CreateNameAssignment(maes.Expression.LastOrDefaultDescendant()); } } else if (ShouldReassignProperty(s)){ - return CreatePropertyAssignment(s.Left.LastOrDefaultDescendant()); + var id = s.Left is VBSyntax.IdentifierNameSyntax directId ? directId : s.Left.LastOrDefaultDescendant(); + if (id == null) return null; + return CreatePropertyAssignment(id); } return null; diff --git a/Tests/CSharp/MemberTests/EventMemberTests.cs b/Tests/CSharp/MemberTests/EventMemberTests.cs index fbc19bc1..0ad43198 100644 --- a/Tests/CSharp/MemberTests/EventMemberTests.cs +++ b/Tests/CSharp/MemberTests/EventMemberTests.cs @@ -734,6 +734,132 @@ private void _dep_SomeEvent(object sender, EventArgs e) "); } + [Fact] + public async Task Issue1242_WinformsNullRefOnBareIdentifierInInitializeComponentAsync() + { + // Regression test: bare identifier (no Me. prefix) in InitializeComponent caused a NullReferenceException + // in WinformsConversions.CreatePropertyAssignment when s.Left is IdentifierNameSyntax and + // LastOrDefaultDescendant returns null (since DescendantNodes does not include the node itself). + await TestConversionVisualBasicToCSharpAsync(@"Imports System +Imports System.Windows.Forms +Imports Microsoft.VisualBasic.CompilerServices + +Partial Class BaseForm + Inherits Form + Friend WithEvents BaseButton As Button +End Class + + +Partial Class BaseForm + Inherits System.Windows.Forms.Form + + Private Sub InitializeComponent() + BaseButton = New Button() + End Sub +End Class + + +Partial Class Form1 + Inherits BaseForm + Private Sub InitializeComponent() + Me.Button1 = New Button() + End Sub + Friend WithEvents Button1 As Button +End Class + +Partial Class Form1 + Private Sub MultiClickHandler(sender As Object, e As EventArgs) Handles Button1.Click, + BaseButton.Click + End Sub +End Class", @"using System; +using System.Runtime.CompilerServices; +using System.Windows.Forms; +using Microsoft.VisualBasic.CompilerServices; // Install-Package Microsoft.VisualBasic + +internal partial class BaseForm : Form +{ + private Button _BaseButton; + + internal virtual Button BaseButton + { + [MethodImpl(MethodImplOptions.Synchronized)] + get + { + return _BaseButton; + } + + [MethodImpl(MethodImplOptions.Synchronized)] + set + { + _BaseButton = value; + } + } + + public BaseForm() + { + InitializeComponent(); + BaseButton = _BaseButton; + } +} + +[DesignerGenerated] +internal partial class BaseForm : Form +{ + + private void InitializeComponent() + { + _BaseButton = new Button(); + } +} + +[DesignerGenerated] +internal partial class Form1 : BaseForm +{ + internal override Button BaseButton + { + [MethodImpl(MethodImplOptions.Synchronized)] + get + { + return base.BaseButton; + } + + [MethodImpl(MethodImplOptions.Synchronized)] + set + { + if (base.BaseButton != null) + { + base.BaseButton.Click -= MultiClickHandler; + } + + base.BaseButton = value; + if (base.BaseButton != null) + { + base.BaseButton.Click += MultiClickHandler; + } + } + } + + public Form1() + { + InitializeComponent(); + } + private void InitializeComponent() + { + Button1 = new Button(); + Button1.Click += new EventHandler(MultiClickHandler); + } + internal Button Button1; +} + +internal partial class Form1 +{ + private void MultiClickHandler(object sender, EventArgs e) + { + } +} +"); + } + [Fact] public async Task Test_Issue701_MultiLineHandlesSyntaxAsync() {