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; + } +} "); } }