From bf6d6c0d95c3684d741483768affd54213d6a43b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Apr 2026 21:27:20 +0000 Subject: [PATCH] Add regression test for issue #1091: interface DefaultMember Value access When an interface or type has [DefaultMember("Value")] and VB code explicitly accesses .Value, the converter was incorrectly stripping the member access, producing `p` instead of `p.Value`. The fix (already in commit 924785a) adds `&& p.Parameters.Any()` to the `isDefaultProperty` check in ConvertMemberAccessExpressionAsync. This ensures only truly indexed (parameterized) default properties are stripped, while parameterless default members like Value retain their explicit access. This commit adds a regression test covering the exact scenario from issue #1091: an interface with where VB code explicitly reads and writes the .Value property. https://claude.ai/code/session_01AkwUvu3XuCdj3D4axoX4UX --- .../DefaultMemberAttributeTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Tests/CSharp/MemberTests/DefaultMemberAttributeTests.cs b/Tests/CSharp/MemberTests/DefaultMemberAttributeTests.cs index 547a3fef..40022bba 100644 --- a/Tests/CSharp/MemberTests/DefaultMemberAttributeTests.cs +++ b/Tests/CSharp/MemberTests/DefaultMemberAttributeTests.cs @@ -49,6 +49,45 @@ public void S() y.Caption = ""World""; } } +"); + } + + /// + /// Regression test for https://github.com/icsharpcode/CodeConverter/issues/1091 + /// When an interface has [DefaultMember(""Value"")] and VB code explicitly accesses .Value, + /// the converter must NOT strip the .Value member access in the C# output. + /// + [Fact] + public async Task Issue1091_ExplicitAccessToDefaultMemberPropertyIsPreservedAsync() + { + await TestConversionVisualBasicToCSharpAsync( + @" + +Public Interface IWithDefaultValue + Property Value As Object +End Interface + +Public Module Module1 + Sub Test(p As IWithDefaultValue) + Dim v = p.Value + p.Value = v + End Sub +End Module", @"using System.Reflection; + +[DefaultMember(""Value"")] +public partial interface IWithDefaultValue +{ + object Value { get; set; } +} + +public static partial class Module1 +{ + public static void Test(IWithDefaultValue p) + { + var v = p.Value; + p.Value = v; + } +} "); } }