@@ -14,7 +14,7 @@ public class AttributesUpdaterTests
14
14
{
15
15
[ Test ]
16
16
[ Category ( "AttributesUpdater" ) ]
17
- public void AddAttributeAddsMemberAttributeBelowMember ( )
17
+ public void AddAttributeAddsMemberAttributeBelowFirstLineOfMember ( )
18
18
{
19
19
const string inputCode =
20
20
@"VERSION 1.0 CLASS
@@ -36,9 +36,9 @@ End Sub
36
36
Attribute VB_Name = ""ClassKeys""
37
37
Attribute VB_GlobalNameSpace = False
38
38
Public Sub Foo(bar As String)
39
+ Attribute Foo.VB_Description = ""The MyFunc Description""
39
40
bar = vbNullString
40
41
End Sub
41
- Attribute Foo.VB_Description = ""The MyFunc Description""
42
42
" ;
43
43
var attributeToAdd = "Foo.VB_Description" ;
44
44
var attributeValues = new List < string > { "\" The MyFunc Description\" " } ;
@@ -60,6 +60,50 @@ End Sub
60
60
Assert . AreEqual ( expectedCode , actualCode ) ;
61
61
}
62
62
63
+ [ Test ]
64
+ [ Category ( "AttributesUpdater" ) ]
65
+ public void AddAttributeAddsMemberAttributeBelowOneLineMember ( )
66
+ {
67
+ const string inputCode =
68
+ @"VERSION 1.0 CLASS
69
+ BEGIN
70
+ MultiUse = -1 'True
71
+ END
72
+ Attribute VB_Name = ""ClassKeys""
73
+ Attribute VB_GlobalNameSpace = False
74
+ Public Sub Foo(bar As String) : bar = vbNullString : End Sub
75
+ " ;
76
+
77
+ const string expectedCode =
78
+ @"VERSION 1.0 CLASS
79
+ BEGIN
80
+ MultiUse = -1 'True
81
+ END
82
+ Attribute VB_Name = ""ClassKeys""
83
+ Attribute VB_GlobalNameSpace = False
84
+ Public Sub Foo(bar As String) : bar = vbNullString : End Sub
85
+ Attribute Foo.VB_Description = ""The MyFunc Description""
86
+ " ;
87
+ var attributeToAdd = "Foo.VB_Description" ;
88
+ var attributeValues = new List < string > { "\" The MyFunc Description\" " } ;
89
+
90
+ string actualCode ;
91
+ var ( component , rewriteSession , state ) = TestSetup ( inputCode ) ;
92
+ using ( state )
93
+ {
94
+ var fooDeclaration = state . DeclarationFinder
95
+ . UserDeclarations ( DeclarationType . Procedure )
96
+ . First ( decl => decl . IdentifierName == "Foo" ) ;
97
+ var attributesUpdater = new AttributesUpdater ( state ) ;
98
+
99
+ attributesUpdater . AddAttribute ( rewriteSession , fooDeclaration , attributeToAdd , attributeValues ) ;
100
+ rewriteSession . TryRewrite ( ) ;
101
+
102
+ actualCode = component . CodeModule . Content ( ) ;
103
+ }
104
+ Assert . AreEqual ( expectedCode , actualCode ) ;
105
+ }
106
+
63
107
[ Test ]
64
108
[ Category ( "AttributesUpdater" ) ]
65
109
public void MultipleAddAttributeWorkForMembers ( )
@@ -84,10 +128,10 @@ End Sub
84
128
Attribute VB_Name = ""ClassKeys""
85
129
Attribute VB_GlobalNameSpace = False
86
130
Public Sub Foo(bar As String)
87
- bar = vbNullString
88
- End Sub
89
131
Attribute Foo.VB_Description = ""The MyFunc Description""
90
132
Attribute Foo.VB_HelpID = 2
133
+ bar = vbNullString
134
+ End Sub
91
135
" ;
92
136
var firstAttributeToAdd = "Foo.VB_Description" ;
93
137
var firstAttributeValues = new List < string > { "\" The MyFunc Description\" " } ;
0 commit comments