File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed
Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public async Task<CSharpSyntaxNode> ConvertMemberAccessExpressionAsync(VBasic.Sy
5252
5353 var simpleNameSyntax = await node . Name . AcceptAsync < SimpleNameSyntax > ( TriviaConvertingExpressionVisitor ) ;
5454
55- var isDefaultProperty = nodeSymbol is IPropertySymbol p && VBasic . VisualBasicExtensions . IsDefault ( p ) ;
55+ var isDefaultProperty = nodeSymbol is IPropertySymbol p && VBasic . VisualBasicExtensions . IsDefault ( p ) && p . Parameters . Any ( ) ;
5656 ExpressionSyntax left = null ;
5757 if ( node . Expression is VBasic . Syntax . MyClassExpressionSyntax && nodeSymbol != null ) {
5858 if ( nodeSymbol . IsStatic ) {
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+ using ICSharpCode . CodeConverter . Tests . TestRunners ;
3+ using Xunit ;
4+
5+ namespace ICSharpCode . CodeConverter . Tests . CSharp . MemberTests ;
6+
7+ public class DefaultMemberAttributeTests : ConverterTestBase
8+ {
9+ [ Fact ]
10+ public async Task TestDefaultMemberAttributeConversionAsync ( )
11+ {
12+ await TestConversionVisualBasicToCSharpAsync (
13+ @"
14+ <System.Reflection.DefaultMember(""Caption"")>
15+ Public Class ClassWithReflectionDefaultMember
16+ Public Property Caption As String
17+ End Class
18+
19+ <System.Reflection.DefaultMember(NameOf(LoosingProperties.Caption))>
20+ Public Class LoosingProperties
21+ Public Property Caption As String
22+
23+ Sub S()
24+ Dim x = New LoosingProperties()
25+ x.Caption = ""Hello""
26+
27+ Dim y = New ClassWithReflectionDefaultMember() 'from C#
28+ y.Caption = ""World""
29+ End Sub
30+ End Class" , @"
31+ using System.Reflection;
32+
33+ [DefaultMember(""Caption"")]
34+ public partial class ClassWithReflectionDefaultMember
35+ {
36+ public string Caption { get; set; }
37+ }
38+
39+ [DefaultMember(nameof(Caption))]
40+ public partial class LoosingProperties
41+ {
42+ public string Caption { get; set; }
43+
44+ public void S()
45+ {
46+ var x = new LoosingProperties();
47+ x.Caption = ""Hello"";
48+
49+ var y = new ClassWithReflectionDefaultMember(); // from C#
50+ y.Caption = ""World"";
51+ }
52+ }
53+ " ) ;
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments