Skip to content

Commit 6d1ae4e

Browse files
authored
[generator] Remove [Obsolete] style compatibility hacks. (#1025)
`generator` was inconsistent with the style in which it generated `[Obsolete]` attributes, emitting variations such as: [Obsolete] [Obsolete ("")] [Obsolete (@"")] [ObsoleteAttribute] [global::System.Obsolete] We wrote a temporary compatibility layer to preserve these variations in commit 440c05e. This allowed us to do a source code level text compare against a large corpus of generated code in `Mono.Android`, AndroidX, and GooglePlayServices, to ensure there were no changes. Now that we are passed this phase, we can standardize on: [global::System.Obsolete] [global::System.Obsolete (@"message")]
1 parent 440c05e commit 6d1ae4e

File tree

20 files changed

+40
-51
lines changed

20 files changed

+40
-51
lines changed

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1-NRT/WriteInterface.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class MyInterface : Java.Lang.Object {
2020
}
2121

2222
[Register ("java/code/IMyInterface", DoNotGenerateAcw=true)]
23-
[global::System.Obsolete ("Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
23+
[global::System.Obsolete (@"Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
2424
public abstract class MyInterfaceConsts : MyInterface {
2525
private MyInterfaceConsts ()
2626
{

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
[Register ("com/xamarin/android/Parent", DoNotGenerateAcw=true)]
2-
[global::System.Obsolete ("Use the 'Com.Xamarin.Android.IParent' type. This class will be removed in a future release.")]
2+
[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 {
44
internal Parent ()
55
{
66
}
77

88
// Metadata.xml XPath field reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/field[@name='ACCEPT_HANDOVER']"
99
[Register ("ACCEPT_HANDOVER")]
10-
[Obsolete ("Use 'Com.Xamarin.Android.IParent.AcceptHandover'. This class will be removed in a future release.")]
10+
[global::System.Obsolete (@"Use 'Com.Xamarin.Android.IParent.AcceptHandover'. This class will be removed in a future release.")]
1111
public const string AcceptHandover = (string) "android.permission.ACCEPT_HANDOVER";
1212

1313
// Metadata.xml XPath field reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/field[@name='ALREADY_OBSOLETE']"
1414
[Register ("ALREADY_OBSOLETE")]
15-
[Obsolete ("deprecated")]
15+
[global::System.Obsolete (@"deprecated")]
1616
public const string AlreadyObsolete = (string) "android.permission.ACCEPT_HANDOVER";
1717

1818

1919
// Metadata.xml XPath field reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/field[@name='API_NAME']"
2020
[Register ("API_NAME")]
21-
[Obsolete ("Use 'Com.Xamarin.Android.IParent.ApiName'. This class will be removed in a future release.")]
21+
[global::System.Obsolete (@"Use 'Com.Xamarin.Android.IParent.ApiName'. This class will be removed in a future release.")]
2222
public static string ApiName {
2323
get {
2424
const string __id = "API_NAME.Ljava/lang/String;";
@@ -29,7 +29,7 @@ public abstract class Parent : Java.Lang.Object {
2929
}
3030

3131
// Metadata.xml XPath method reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/method[@name='comparing' and count(parameter)=0]"
32-
[Obsolete (@"Use 'Com.Xamarin.Android.IParent.Comparing'. This class will be removed in a future release.")]
32+
[global::System.Obsolete (@"Use 'Com.Xamarin.Android.IParent.Comparing'. This class will be removed in a future release.")]
3333
[Register ("comparing", "()I", "")]
3434
public static unsafe int Comparing ()
3535
{
@@ -42,7 +42,7 @@ public abstract class Parent : Java.Lang.Object {
4242
}
4343

4444
// Metadata.xml XPath method reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/method[@name='comparingOld' and count(parameter)=0]"
45-
[Obsolete (@"deprecated")]
45+
[global::System.Obsolete (@"deprecated")]
4646
[Register ("comparingOld", "()I", "")]
4747
public static unsafe int ComparingOld ()
4848
{
@@ -69,7 +69,7 @@ public partial interface IParent : IJavaObject, IJavaPeerable {
6969

7070
// Metadata.xml XPath field reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/field[@name='ALREADY_OBSOLETE']"
7171
[Register ("ALREADY_OBSOLETE")]
72-
[Obsolete ("deprecated")]
72+
[global::System.Obsolete (@"deprecated")]
7373
public const string AlreadyObsolete = (string) "android.permission.ACCEPT_HANDOVER";
7474

7575

@@ -97,7 +97,7 @@ public partial interface IParent : IJavaObject, IJavaPeerable {
9797
}
9898

9999
// Metadata.xml XPath method reference: path="/api/package[@name='com.xamarin.android']/interface[@name='Parent']/method[@name='comparingOld' and count(parameter)=0]"
100-
[Obsolete (@"deprecated")]
100+
[global::System.Obsolete (@"deprecated")]
101101
[Register ("comparingOld", "()I", "")]
102102
public static unsafe int ComparingOld ()
103103
{

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterface.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class MyInterface : Java.Lang.Object {
2020
}
2121

2222
[Register ("java/code/IMyInterface", DoNotGenerateAcw=true)]
23-
[global::System.Obsolete ("Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
23+
[global::System.Obsolete (@"Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
2424
public abstract class MyInterfaceConsts : MyInterface {
2525
private MyInterfaceConsts ()
2626
{

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteInterfaceFieldAsDimProperty.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public abstract class MyInterface : Java.Lang.Object {
3333
}
3434

3535
[Register ("com/xamarin/android/MyInterface", DoNotGenerateAcw=true)]
36-
[global::System.Obsolete ("Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
36+
[global::System.Obsolete (@"Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
3737
public abstract class MyInterfaceConsts : MyInterface {
3838
private MyInterfaceConsts ()
3939
{

tests/generator-Tests/Unit-Tests/CodeGeneratorExpectedResults/XAJavaInterop1/WriteStaticInterfaceMethod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class MyInterface : Java.Lang.Object {
2020
}
2121

2222
[Register ("java/code/IMyInterface", DoNotGenerateAcw=true)]
23-
[global::System.Obsolete ("Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
23+
[global::System.Obsolete (@"Use the 'MyInterface' type. This type will be removed in a future release.", error: true)]
2424
public abstract class MyInterfaceConsts : MyInterface {
2525
private MyInterfaceConsts ()
2626
{

tests/generator-Tests/Unit-Tests/CodeGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public void ObsoleteBoundMethodAbstractDeclaration ()
528528
generator.Context.ContextTypes.Pop ();
529529

530530
// Ensure [Obsolete] was written
531-
Assert.True (writer.ToString ().Contains ("[Obsolete (@\"This is so old!\")]"), writer.ToString ());
531+
Assert.True (writer.ToString ().Contains ("[global::System.Obsolete (@\"This is so old!\")]"), writer.ToString ());
532532
}
533533

534534
[Test]

tests/generator-Tests/expected.ji/Constructors/Xamarin.Test.SomeObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected SomeObject (ref JniObjectReference reference, JniObjectReferenceOption
2020
}
2121

2222
// Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=0]"
23-
[Obsolete (@"deprecated")]
23+
[global::System.Obsolete (@"deprecated")]
2424
public unsafe SomeObject () : base (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None)
2525
{
2626
const string __id = "()V";

tests/generator-Tests/expected.ji/NormalMethods/Xamarin.Test.SomeObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public virtual unsafe void VoidMethodWithParams (string astring, int anint, glob
126126
}
127127

128128
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='ObsoleteMethod' and count(parameter)=0]"
129-
[Obsolete (@"Deprecated please use IntegerMethod instead")]
129+
[global::System.Obsolete (@"Deprecated please use IntegerMethod instead")]
130130
public virtual unsafe int ObsoleteMethod ()
131131
{
132132
const string __id = "ObsoleteMethod.()I";

tests/generator-Tests/expected.ji/StaticMethods/Xamarin.Test.SomeObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static unsafe string MethodAsString ()
4444
}
4545

4646
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='Obsoletemethod' and count(parameter)=0]"
47-
[Obsolete (@"Deprecated please use methodAsString")]
47+
[global::System.Obsolete (@"Deprecated please use methodAsString")]
4848
[global::Java.Interop.JniMethodSignature ("Obsoletemethod", "()Ljava/lang/String;")]
4949
public static unsafe string Obsoletemethod ()
5050
{

tests/generator-Tests/expected.xaji/Constructors/Xamarin.Test.SomeObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected SomeObject (IntPtr javaReference, JniHandleOwnership transfer) : base
3838

3939
// Metadata.xml XPath constructor reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/constructor[@name='SomeObject' and count(parameter)=0]"
4040
[Register (".ctor", "()V", "")]
41-
[Obsolete (@"deprecated")]
41+
[global::System.Obsolete (@"deprecated")]
4242
public unsafe SomeObject () : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
4343
{
4444
const string __id = "()V";

0 commit comments

Comments
 (0)