Skip to content

Commit 8d53ef0

Browse files
committed
[tests] Update expected whitespace.
1 parent 007b35b commit 8d53ef0

File tree

122 files changed

+1114
-970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1114
-970
lines changed

src/Xamarin.SourceWriter/CodeWriter.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,34 @@ public void Write (string value)
3333

3434
public void WriteLine ()
3535
{
36-
WriteIndent ();
3736
stream.WriteLine ();
3837
need_indent = true;
3938
}
4039

4140
public void WriteLine (string value)
4241
{
43-
WriteIndent ();
42+
if (value?.Length > 0)
43+
WriteIndent ();
44+
4445
stream.WriteLine (value);
4546
need_indent = true;
4647
}
4748

4849
public void WriteLine (string format, params object[] args)
4950
{
50-
WriteIndent ();
51+
if (format?.Length > 0)
52+
WriteIndent ();
53+
5154
stream.WriteLine (format, args);
5255
need_indent = true;
5356
}
5457

58+
public void WriteLineNoIndent (string value)
59+
{
60+
stream.WriteLine (value);
61+
need_indent = true;
62+
}
63+
5564
public void Indent (int count = 1) => indent += count;
5665
public void Unindent (int count = 1) => indent -= count;
5766

src/Xamarin.SourceWriter/Models/ClassWriter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public override void WriteConstructors (CodeWriter writer)
2020
ctor.Write (writer);
2121
writer.WriteLine ();
2222
}
23+
24+
if (Constructors.Count > 0)
25+
writer.WriteLine ();
2326
}
2427
}
2528
}

src/Xamarin.SourceWriter/Models/CommentWriter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ public CommentWriter (string value)
1616

1717
public virtual void Write (CodeWriter writer)
1818
{
19-
writer.WriteLine (Value);
19+
if (Value.StartsWith ("#pragma"))
20+
writer.WriteLineNoIndent (Value);
21+
else
22+
writer.WriteLine (Value);
2023
}
2124
}
2225
}

src/Xamarin.SourceWriter/Models/PropertyWriter.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,43 @@ protected virtual void WriteBody (CodeWriter writer)
156156

157157
protected virtual void WriteAutomaticPropertyBody (CodeWriter writer)
158158
{
159-
writer.Write ("{ ");
159+
var need_unindent = false;
160+
161+
writer.Write ("{");
160162

161163
if (HasGet) {
164+
if (GetterComments.Count > 0 || GetterAttributes.Count > 0) {
165+
writer.WriteLine ();
166+
writer.Indent ();
167+
need_unindent = true;
168+
}
169+
162170
WriteGetterComments (writer);
163171
WriteGetterAttributes (writer);
164172
writer.Write ("get; ");
173+
174+
if (need_unindent) {
175+
writer.WriteLine ();
176+
writer.Unindent ();
177+
need_unindent = false;
178+
}
165179
}
166180

167181
if (HasSet) {
182+
if (SetterComments.Count > 0 || SetterAttributes.Count > 0) {
183+
writer.WriteLine ();
184+
writer.Indent ();
185+
need_unindent = true;
186+
}
187+
168188
WriteSetterComments (writer);
169189
WriteSetterAttributes (writer);
170190
writer.Write ("set; ");
191+
192+
if (need_unindent) {
193+
writer.WriteLine ();
194+
writer.Unindent ();
195+
}
171196
}
172197

173198
writer.WriteLine ("}");

src/Xamarin.SourceWriter/Models/TypeWriter.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,9 @@ public virtual void WriteMembers (CodeWriter writer)
158158

159159
WriteConstructors (writer);
160160

161-
writer.WriteLine ();
162161
WriteEvents (writer);
163-
writer.WriteLine ();
164162
WriteDelegates (writer);
165-
writer.WriteLine ();
166163
WriteProperties (writer);
167-
writer.WriteLine ();
168164
WriteMethods (writer);
169165
}
170166

@@ -194,6 +190,9 @@ public virtual void WriteEvents (CodeWriter writer)
194190
ev.Write (writer);
195191
writer.WriteLine ();
196192
}
193+
194+
if (Events.Count > 0)
195+
writer.WriteLine ();
197196
}
198197

199198
public virtual void WriteFields (CodeWriter writer)
@@ -202,6 +201,9 @@ public virtual void WriteFields (CodeWriter writer)
202201
field.Write (writer);
203202
writer.WriteLine ();
204203
}
204+
205+
if (Fields.Count > 0)
206+
writer.WriteLine ();
205207
}
206208

207209
public virtual void WriteMethods (CodeWriter writer)
@@ -210,6 +212,9 @@ public virtual void WriteMethods (CodeWriter writer)
210212
method.Write (writer);
211213
writer.WriteLine ();
212214
}
215+
216+
if (Methods.Count > 0)
217+
writer.WriteLine ();
213218
}
214219

215220
public virtual void WriteProperties (CodeWriter writer)
@@ -218,6 +223,9 @@ public virtual void WriteProperties (CodeWriter writer)
218223
prop.Write (writer);
219224
writer.WriteLine ();
220225
}
226+
227+
if (Properties.Count > 0)
228+
writer.WriteLine ();
221229
}
222230

223231
public virtual void WriteDelegates (CodeWriter writer)
@@ -226,6 +234,9 @@ public virtual void WriteDelegates (CodeWriter writer)
226234
del.Write (writer);
227235
writer.WriteLine ();
228236
}
237+
238+
if (Delegates.Count > 0)
239+
writer.WriteLine ();
229240
}
230241

231242
public virtual void WriteTypeClose (CodeWriter writer)

tests/Xamarin.SourceWriter-Tests/ClassWriterTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public void Basics ()
3434
var expected =
3535
@"public partial class MyClass : System.Object {
3636
public bool my_field;
37-
37+
3838
// Test comment
39-
39+
4040
public void MyMethod (bool test)
4141
{
4242
}
43-
43+
4444
}
4545
";
4646

tests/Xamarin.SourceWriter-Tests/InterfaceWriterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Basics ()
3131
var expected =
3232
@"public partial interface IMyInterface : IDisposable {
3333
void MyMethod (bool test);
34-
34+
3535
}
3636
";
3737

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/ObsoleteInterfaceAlternativeClass.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[Register ("com/xamarin/android/Parent", DoNotGenerateAcw=true)]
22
[global::System.Obsolete ("Use the 'Com.Xamarin.Android.IParent' type. This class will be removed in a future release.")]
33
public abstract class Parent : Java.Lang.Object {
4-
54
internal Parent ()
65
{
76
}
@@ -28,6 +27,7 @@ public abstract class Parent : Java.Lang.Object {
2827
return JNIEnv.GetString (__v.Handle, JniHandleOwnership.TransferLocalRef);
2928
}
3029
}
30+
3131
// Metadata.xml XPath method reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/method[@name='comparing' and count(parameter)=0]"
3232
[Obsolete (@"Use 'Com.Xamarin.Android.IParent.Comparing'. This class will be removed in a future release.")]
3333
[Register ("comparing", "()I", "")]
@@ -54,8 +54,8 @@ public abstract class Parent : Java.Lang.Object {
5454
}
5555
}
5656

57-
5857
static readonly JniPeerMembers _members = new JniPeerMembers ("com/xamarin/android/Parent", typeof (Parent));
58+
5959
}
6060

6161
// Metadata.xml XPath interface reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']"
@@ -101,7 +101,6 @@ public partial interface IParent : IJavaObject, IJavaPeerable {
101101

102102
[global::Android.Runtime.Register ("com/xamarin/android/Parent", DoNotGenerateAcw=true)]
103103
internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
104-
105104
static readonly JniPeerMembers _members = new JniPeerMembers ("com/xamarin/android/Parent", typeof (IParentInvoker));
106105

107106
static IntPtr java_class_ref {
@@ -130,8 +129,7 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
130129
static IntPtr Validate (IntPtr handle)
131130
{
132131
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
133-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.",
134-
JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
132+
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "com.xamarin.android.Parent"));
135133
return handle;
136134
}
137135

@@ -151,4 +149,3 @@ internal partial class IParentInvoker : global::Java.Lang.Object, IParent {
151149
}
152150

153151
}
154-

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/JavaInterop1/WriteClass.txt

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
// Metadata.xml XPath class reference: path="/api/package[@name='java.code']/class[@name='MyClass']"
22
[global::Android.Runtime.Register ("java/code/MyClass", DoNotGenerateAcw=true)]
3-
public partial class MyClass {
4-
3+
public partial class MyClass {
54
static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/MyClass", typeof (MyClass));
5+
66
internal static IntPtr class_ref {
7-
get {
8-
return _members.JniPeerType.PeerReference.Handle;
9-
}
7+
get { return _members.JniPeerType.PeerReference.Handle; }
108
}
119

12-
protected MyClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) {}
10+
protected MyClass (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer)
11+
{
12+
}
1313

1414
// Metadata.xml XPath constructor reference: path="/api/package[@name='java.code']/class[@name='MyClass']/constructor[@name='MyClass' and count(parameter)=0]"
1515
[Register (".ctor", "()V", "")]
16-
unsafe MyClass ()
17-
: base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
16+
unsafe MyClass () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
1817
{
1918
const string __id = "()V";
2019

@@ -31,8 +30,7 @@ public partial class MyClass {
3130

3231
// Metadata.xml XPath constructor reference: path="/api/package[@name='java.code']/class[@name='MyClass']/constructor[@name='MyClass' and count(parameter)=1 and parameter[1][@type='java.lang.String']]"
3332
[Register (".ctor", "(Ljava/lang/String;)V", "")]
34-
unsafe MyClass (string p0)
35-
: base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
33+
unsafe MyClass (string p0) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
3634
{
3735
const string __id = "(Ljava/lang/String;)V";
3836

@@ -52,6 +50,7 @@ public partial class MyClass {
5250
}
5351

5452
static Delegate cb_get_Count;
53+
5554
#pragma warning disable 0169
5655
static Delegate Getget_CountHandler ()
5756
{
@@ -68,6 +67,7 @@ public partial class MyClass {
6867
#pragma warning restore 0169
6968

7069
static Delegate cb_set_Count_I;
70+
7171
#pragma warning disable 0169
7272
static Delegate Getset_Count_IHandler ()
7373
{
@@ -108,6 +108,7 @@ public partial class MyClass {
108108
}
109109

110110
static Delegate cb_get_Key;
111+
111112
#pragma warning disable 0169
112113
static Delegate Getget_KeyHandler ()
113114
{
@@ -124,6 +125,7 @@ public partial class MyClass {
124125
#pragma warning restore 0169
125126

126127
static Delegate cb_set_Key_Ljava_lang_String_;
128+
127129
#pragma warning disable 0169
128130
static Delegate Getset_Key_Ljava_lang_String_Handler ()
129131
{
@@ -191,6 +193,7 @@ public partial class MyClass {
191193
}
192194

193195
static Delegate cb_get_AbstractCount;
196+
194197
#pragma warning disable 0169
195198
static Delegate Getget_AbstractCountHandler ()
196199
{
@@ -207,6 +210,7 @@ public partial class MyClass {
207210
#pragma warning restore 0169
208211

209212
static Delegate cb_set_AbstractCount_I;
213+
210214
#pragma warning disable 0169
211215
static Delegate Getset_AbstractCount_IHandler ()
212216
{
@@ -224,12 +228,16 @@ public partial class MyClass {
224228

225229
public abstract int AbstractCount {
226230
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_AbstractCount' and count(parameter)=0]"
227-
[Register ("get_AbstractCount", "()I", "Getget_AbstractCountHandler")] get;
231+
[Register ("get_AbstractCount", "()I", "Getget_AbstractCountHandler")]
232+
get;
233+
228234
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_AbstractCount' and count(parameter)=1 and parameter[1][@type='int']]"
229-
[Register ("set_AbstractCount", "(I)V", "Getset_AbstractCount_IHandler")] set;
235+
[Register ("set_AbstractCount", "(I)V", "Getset_AbstractCount_IHandler")]
236+
set;
230237
}
231238

232239
static Delegate cb_GetCountForKey_Ljava_lang_String_;
240+
233241
#pragma warning disable 0169
234242
static Delegate GetGetCountForKey_Ljava_lang_String_Handler ()
235243
{
@@ -264,6 +272,7 @@ public partial class MyClass {
264272
}
265273

266274
static Delegate cb_Key;
275+
267276
#pragma warning disable 0169
268277
static Delegate GetKeyHandler ()
269278
{
@@ -303,6 +312,7 @@ public partial class MyClass {
303312
}
304313

305314
static Delegate cb_AbstractMethod;
315+
306316
#pragma warning disable 0169
307317
static Delegate GetAbstractMethodHandler ()
308318
{

0 commit comments

Comments
 (0)