Skip to content

Commit 77af877

Browse files
committed
[tests] Update expected whitespace.
1 parent 007b35b commit 77af877

File tree

122 files changed

+954
-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

+954
-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: 13 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

@@ -224,9 +222,12 @@ public partial class MyClass {
224222

225223
public abstract int AbstractCount {
226224
// 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;
225+
[Register ("get_AbstractCount", "()I", "Getget_AbstractCountHandler")]
226+
get;
227+
228228
// 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;
229+
[Register ("set_AbstractCount", "(I)V", "Getset_AbstractCount_IHandler")]
230+
set;
230231
}
231232

232233
static Delegate cb_GetCountForKey_Ljava_lang_String_;

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,40 @@
22
[Register ("java/code/IMyInterface", "", "java.code.IMyInterfaceInvoker")]
33
public partial interface IMyInterface : IJavaObject, IJavaPeerable {
44
private static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/IMyInterface", typeof (IMyInterface), isInterface: true);
5-
5+
66
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='IMyInterface']/method[@name='DoDeclaration' and count(parameter)=0]"
77
[Register ("DoDeclaration", "()V", "GetDoDeclarationHandler:java.code.IMyInterfaceInvoker, MyAssembly")]
88
void DoDeclaration ();
9-
9+
1010
private static Delegate cb_DoDefault;
11-
#pragma warning disable 0169
11+
#pragma warning disable 0169
1212
private static Delegate GetDoDefaultHandler ()
1313
{
1414
if (cb_DoDefault == null)
1515
cb_DoDefault = JNINativeWrapper.CreateDelegate ((_JniMarshal_PP_V) n_DoDefault);
1616
return cb_DoDefault;
1717
}
18+
1819
private static void n_DoDefault (IntPtr jnienv, IntPtr native__this)
1920
{
2021
var __this = global::Java.Lang.Object.GetObject<java.code.IMyInterface> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
2122
__this.DoDefault ();
2223
}
23-
#pragma warning restore 0169
24+
#pragma warning restore 0169
25+
2426
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='IMyInterface']/method[@name='DoDefault' and count(parameter)=0]"
2527
[Register ("DoDefault", "()V", "GetDoDefaultHandler:java.code.IMyInterface, MyAssembly")]
2628
virtual unsafe void DoDefault ()
2729
{
2830
const string __id = "DoDefault.()V";
2931
try {
30-
_members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null);
32+
_members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, null);
3133
} finally {
3234
}
3335
}
34-
36+
3537
}
38+
3639
[global::Android.Runtime.Register ("java/code/IMyInterface", DoNotGenerateAcw=true)]
3740
internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterface {
3841
static readonly JniPeerMembers _members = new JniPeerMembers ("java/code/IMyInterface", typeof (IMyInterfaceInvoker));
@@ -63,8 +66,7 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
6366
static IntPtr Validate (IntPtr handle)
6467
{
6568
if (!JNIEnv.IsInstanceOf (handle, java_class_ref))
66-
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.",
67-
JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
69+
throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));
6870
return handle;
6971
}
7072

@@ -108,4 +110,3 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
108110
}
109111

110112
}
111-

0 commit comments

Comments
 (0)