Skip to content

Commit 2d8b6d2

Browse files
authored
[generator] More AttributeTargets on SupportedOSPlatformAttribute (#1054)
Context: 1720628 Context: dotnet/android#7478 Context: https://github.com/buyaa-n/runtime/blob/7a62a22db186fda42dad6cbd681cf056fcf6aee6/src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/PlatformAttributes.cs#L52-L62 In order to compile classic MonoAndroid bindings that contain the new .NET `[SupportedOSPlatform]` attributes, we have a dummy copy that we can compile against. However this copy does not allow `AttributeTargets.Field`, so compiling with 1720628 causes: /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Dalvik.Bytecode.IOpcodes.cs(646,4): error CS0592: Attribute global::System.Runtime.Versioning.SupportedOSPlatformAttribute' is not valid on this declaration type. It is only valid on 'assembly, module, class, struct, constructor, method, property, indexer, event' declarations. Update our copy to have the same `AttributeTargets` as the .NET version so we can compile on classic.
1 parent 7dfbab6 commit 2d8b6d2

File tree

23 files changed

+23
-23
lines changed

23 files changed

+23
-23
lines changed

tests/generator-Tests/expected.xaji/AccessModifiers/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#if !NET
88
namespace System.Runtime.Versioning {
99
[System.Diagnostics.Conditional("NEVER")]
10-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
10+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1111
internal sealed class SupportedOSPlatformAttribute : Attribute {
1212
public SupportedOSPlatformAttribute (string platformName) { }
1313
}

tests/generator-Tests/expected.xaji/Adapters/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#if !NET
99
namespace System.Runtime.Versioning {
1010
[System.Diagnostics.Conditional("NEVER")]
11-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
11+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1212
internal sealed class SupportedOSPlatformAttribute : Attribute {
1313
public SupportedOSPlatformAttribute (string platformName) { }
1414
}

tests/generator-Tests/expected.xaji/Android.Graphics.Color/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#if !NET
99
namespace System.Runtime.Versioning {
1010
[System.Diagnostics.Conditional("NEVER")]
11-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
11+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1212
internal sealed class SupportedOSPlatformAttribute : Attribute {
1313
public SupportedOSPlatformAttribute (string platformName) { }
1414
}

tests/generator-Tests/expected.xaji/Arrays/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#if !NET
77
namespace System.Runtime.Versioning {
88
[System.Diagnostics.Conditional("NEVER")]
9-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
9+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1010
internal sealed class SupportedOSPlatformAttribute : Attribute {
1111
public SupportedOSPlatformAttribute (string platformName) { }
1212
}

tests/generator-Tests/expected.xaji/CSharpKeywords/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#if !NET
99
namespace System.Runtime.Versioning {
1010
[System.Diagnostics.Conditional("NEVER")]
11-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
11+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1212
internal sealed class SupportedOSPlatformAttribute : Attribute {
1313
public SupportedOSPlatformAttribute (string platformName) { }
1414
}

tests/generator-Tests/expected.xaji/Constructors/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#if !NET
77
namespace System.Runtime.Versioning {
88
[System.Diagnostics.Conditional("NEVER")]
9-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
9+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1010
internal sealed class SupportedOSPlatformAttribute : Attribute {
1111
public SupportedOSPlatformAttribute (string platformName) { }
1212
}

tests/generator-Tests/expected.xaji/Core_ClassParse/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#if !NET
88
namespace System.Runtime.Versioning {
99
[System.Diagnostics.Conditional("NEVER")]
10-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
10+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1111
internal sealed class SupportedOSPlatformAttribute : Attribute {
1212
public SupportedOSPlatformAttribute (string platformName) { }
1313
}

tests/generator-Tests/expected.xaji/Core_Jar2Xml/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if !NET
1010
namespace System.Runtime.Versioning {
1111
[System.Diagnostics.Conditional("NEVER")]
12-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
12+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1313
internal sealed class SupportedOSPlatformAttribute : Attribute {
1414
public SupportedOSPlatformAttribute (string platformName) { }
1515
}

tests/generator-Tests/expected.xaji/GenericArguments/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#if !NET
1010
namespace System.Runtime.Versioning {
1111
[System.Diagnostics.Conditional("NEVER")]
12-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
12+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1313
internal sealed class SupportedOSPlatformAttribute : Attribute {
1414
public SupportedOSPlatformAttribute (string platformName) { }
1515
}

tests/generator-Tests/expected.xaji/InterfaceMethodsConflict/__NamespaceMapping__.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#if !NET
88
namespace System.Runtime.Versioning {
99
[System.Diagnostics.Conditional("NEVER")]
10-
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
10+
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum | AttributeTargets.Event | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Module | AttributeTargets.Property | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
1111
internal sealed class SupportedOSPlatformAttribute : Attribute {
1212
public SupportedOSPlatformAttribute (string platformName) { }
1313
}

0 commit comments

Comments
 (0)