Skip to content

Claude/fix issue 892 char empty comparison#1256

Draft
GrahamTheCoder wants to merge 3 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-892-char-empty-comparison
Draft

Claude/fix issue 892 char empty comparison#1256
GrahamTheCoder wants to merge 3 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-892-char-empty-comparison

Conversation

@GrahamTheCoder
Copy link
Copy Markdown
Member

Fixes #892

GrahamTheCoder and others added 3 commits March 25, 2026 00:14
Map VB.NET char comparison with an empty string to char.MinValue to match runtime behavior and prevent logic errors during compilation. Added a unit test.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Map VB.NET char comparison with an empty string to char.MinValue to match runtime behavior and prevent logic errors during compilation.
For `Option Compare Text`, map it appropriately using `Microsoft.VisualBasic.CompilerServices.Conversions.ToString` to prevent `char` being compared to an empty string.
Added characterization tests.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…omparison fix

Remove leftover patch artifacts (.orig, .rej, patch file) and temporary TestDotNet
debugging files that were committed by mistake. Expand the regression test to also
cover the not-equal (<>) operator case.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
((lhsTypeInfo.Type?.SpecialType == SpecialType.System_Char && rhsTypeInfo.Type?.SpecialType == SpecialType.System_String && _visualBasicEqualityComparison.IsNothingOrEmpty(node.Right)) ||
(rhsTypeInfo.Type?.SpecialType == SpecialType.System_Char && lhsTypeInfo.Type?.SpecialType == SpecialType.System_String && _visualBasicEqualityComparison.IsNothingOrEmpty(node.Left)))) {
if (lhsTypeInfo.Type?.SpecialType == SpecialType.System_Char) {
rhs = CS.SyntaxFactory.MemberAccessExpression(CS.SyntaxKind.SimpleMemberAccessExpression, CS.SyntaxFactory.PredefinedType(CS.SyntaxFactory.Token(CS.SyntaxKind.CharKeyword)), CS.SyntaxFactory.IdentifierName("MinValue"));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look like a hack to make the specific test case work rather than the general fix to the root cause

@GrahamTheCoder GrahamTheCoder marked this pull request as draft April 13, 2026 22:48
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#: wrong result for empty char comparisation

2 participants