Skip to content

Claude/fix issue 827 myclass backing field#1252

Open
GrahamTheCoder wants to merge 7 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-827-myclass-backing-field
Open

Claude/fix issue 827 myclass backing field#1252
GrahamTheCoder wants to merge 7 commits intoicsharpcode:masterfrom
GrahamTheCoder:claude/fix-issue-827-myclass-backing-field

Conversation

@GrahamTheCoder
Copy link
Copy Markdown
Member

Fixes #827

GrahamTheCoder and others added 7 commits March 25, 2026 00:11
This commit fixes issue icsharpcode#827 where accessing the auto-generated backing
field (e.g. `_Prop`) of an overridable (virtual) property in VB.NET was
incorrectly converted to the virtual property access (`Prop`) in C#.

It now correctly maps these accesses to the explicitly generated
non-virtual backing property `MyClassProp` and ensures that the
MyClassProp property is correctly generated when such an access occurs.

A test case has been added to MemberTests.cs to verify the correct
translation of such field access.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit fixes issue icsharpcode#827 where accessing the auto-generated backing
field (e.g. `_Prop`) of an overridable (virtual) property in VB.NET was
incorrectly converted to the virtual property access (`Prop`) in C#.

It now correctly maps these accesses to the explicitly generated
non-virtual backing property `MyClassProp` and ensures that the
MyClassProp property is correctly generated when such an access occurs.

A test case has been added to MemberTests.cs to verify the correct
translation of such field access.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
…Prop for virtual auto-properties

When VB accesses _Prop (the backing field of a virtual auto-property),
the converter now emits MyClassProp instead of Prop, matching the C# backing
property name and avoiding virtual dispatch to child class overrides.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
…ent indentation

- Add TestOverridableAutoPropertyBackingFieldAccessAsync to
  Tests/CSharp/MemberTests/PropertyMemberTests.cs (VB->CS tests) covering
  the exact issue icsharpcode#827 scenario: _Prop = 10 converts to MyClassProp = 10
- Remove duplicate test from Tests/VB/MemberTests.cs where VB->CS tests
  do not belong
- Fix indentation of comment in CommonConversions.cs

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
…yClassAccessedNames call

The method was changed to instance method using _semanticModel directly, but
the call site still passed _semanticModel as an argument causing a compilation error.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
…branch

Tests TestCharDefaultValueForStringParameterAsync and TestCharLiteralDefaultValueForStringParameterAsync
require the FixCharDefaultsForStringParams fix which is in a separate PR. Removing them from
the issue-827 branch to prevent test failures.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
… access

When _Prop is accessed via MyClass._Prop, NameExpressionNodeVisitor.cs
already adds the MyClass prefix via "$MyClass{ConvertIdentifier(...).ValueText}".
The new ConvertIdentifier code was also returning MyClassProp for _Prop,
causing a double prefix MyClassMyClassProp.

Fix: detect when _Prop is part of a MyClass._Prop member access and
return the bare property name so NameExpressionNodeVisitor can prefix it.

https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX
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.

Rare MyClass case converts incorrectly

2 participants