Skip to content

Claude/fix issue 557 char string default param#1255

Open
GrahamTheCoder wants to merge 4 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-557-char-string-default-param
Open

Claude/fix issue 557 char string default param#1255
GrahamTheCoder wants to merge 4 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-557-char-string-default-param

Conversation

@GrahamTheCoder
Copy link
Copy Markdown
Member

Fixes #557

claude added 4 commits April 13, 2026 22:18
…s null + null-coalescing assignment

When VB has Optional ByVal strParam As String = charConst, C# can't use
a char literal as a string default. Replace the default with null and
prepend strParam = strParam ?? charConst.ToString() in the method body.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
…r string parameter

Two tests cover the fix for converting VB Optional string parameters with
char default values: one using a const reference and one using an inline
char literal.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
…ts.cs

The TestOverridableAutoPropertyBackingFieldAccessAsync test (issue icsharpcode#827)
was mistakenly added to this branch, which only contains the fix for
issue icsharpcode#557. The icsharpcode#827 fix code is in a separate PR (icsharpcode#1252) and is not
present here, so the test would always fail.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
…lt for String params

ExplicitDefaultValue is normalized to the parameter's declared type, so
checking `ExplicitDefaultValue is not char` was always true for String params.
Instead, retrieve the VB syntax default expression and check its actual type
via the semantic model.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX

// Replace the default value with null
updatedParams[i] = csParam.WithDefault(
CS.SyntaxFactory.EqualsValueClause(ValidSyntaxFactory.NullExpression));
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.

This pattern of mutating previously set values is not recommended. We should set it to be null at the point of creation, then separately here we should add the null coalesce and use comments to mention the other place. This is obviously also not ideal, but a conceptual dependency from a distance is generally better than a concrete one where someone else might intercept it in between in the same style otherwise.

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#: You can’t assign char to string directly

2 participants