-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bgen] Add support for marking API bindings as preview APIs using the…
… Experimental attribute. (#20591)
- Loading branch information
1 parent
4ba38c7
commit c5f93a2
Showing
6 changed files
with
278 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Preview APIs | ||
|
||
The APIs listed here are currently marked as preview APIs, and as such may | ||
change in the future (we don't guarante binary or source compatibility between | ||
releases for these APIs). | ||
|
||
We've marked these APIs using the [Experimental][1] attribute, which means | ||
that compilation error will be shown if they're used: | ||
|
||
> error APL0001: 'PreviewAPI' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. | ||
This means that it's not possible to use these preview APIs by accident, the diagnostic has to be explicitly ignored. | ||
|
||
Example program consuming preview API: | ||
|
||
```cs | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
class App | ||
{ | ||
public static void Main () | ||
{ | ||
Do.Something (); | ||
} | ||
} | ||
|
||
[Experimental ("APL0001")] | ||
class Do { | ||
public static void Something () {} | ||
} | ||
``` | ||
|
||
this will show: | ||
|
||
> Program.cs(8,9): error APL0001: 'Do' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. | ||
Then ignore the warning in order to make the code compile: | ||
|
||
```cs | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
class App | ||
{ | ||
public unsafe static void Main () | ||
{ | ||
#pragma warning disable APL0001 | ||
Do.Something (); | ||
#pragma warning restore APL0001 | ||
} | ||
} | ||
|
||
[Experimental ("APL0001")] | ||
class Do { | ||
public static void Something () {} | ||
} | ||
|
||
``` | ||
|
||
Our diagnostic IDs will be of the format `APL####` - for instance `APL0001` - | ||
where the number is just monotonically increasing since the previous number, | ||
without any specific meaning. | ||
|
||
References: | ||
|
||
* https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.experimentalattribute?view=net-8.0 | ||
* https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/preview-apis#experimentalattribute | ||
|
||
## Placeholder header for APL#### | ||
|
||
Coming soon! | ||
|
||
[1]: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.experimentalattribute?view=net-8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using Foundation; | ||
|
||
namespace Experimental { | ||
[Experimental ("BGEN0001")] | ||
[BaseType (typeof (NSObject))] | ||
interface T1 : P1 { | ||
[Experimental ("BGEN0002")] | ||
[Export ("initWithString:")] | ||
IntPtr Constructor (string p); | ||
|
||
[Experimental ("BGEN0003")] | ||
[Export ("method")] | ||
int Method (); | ||
|
||
[Experimental ("BGEN0004")] | ||
[Export ("property")] | ||
D Property { | ||
[Experimental ("BGEN0005")] | ||
get; | ||
[Experimental ("BGEN0006")] | ||
set; | ||
} | ||
} | ||
|
||
[Experimental ("BGEN0007")] | ||
delegate void D (); | ||
|
||
|
||
[Experimental ("BGEN0008")] | ||
[Protocol] | ||
interface P1 { | ||
[Experimental ("BGEN0009")] | ||
[Export ("method")] | ||
int PMethod (); | ||
|
||
[Experimental ("BGEN0010")] | ||
[Export ("property")] | ||
int PProperty { get; set; } | ||
|
||
[Experimental ("BGEN0011")] | ||
[Abstract] | ||
[Export ("methodRequired")] | ||
int PAMethod (); | ||
|
||
[Experimental ("BGEN0012")] | ||
[Abstract] | ||
[Export ("propertyRequired")] | ||
int PAProperty { get; set; } | ||
} | ||
|
||
[Experimental ("BGEN0013")] | ||
[BaseType (typeof (NSObject))] | ||
interface TG1<T, U> | ||
where T : NSObject | ||
where U : NSObject { | ||
|
||
[Experimental ("BGEN0014")] | ||
[Export ("method")] | ||
int TGMethod (); | ||
|
||
[Experimental ("BGEN0015")] | ||
[Export ("property")] | ||
int TGProperty { get; set; } | ||
|
||
[Experimental ("BGEN0016")] | ||
[Export ("method2:")] | ||
void TGMethod2 (TG1<T, U> value); | ||
} | ||
|
||
[Experimental ("BGEN0017")] | ||
public enum E1 { | ||
[Experimental ("BGEN0018")] | ||
Value1, | ||
} | ||
|
||
[Experimental ("BGEN0019")] | ||
[BaseType (typeof (NSObject))] | ||
interface Notification1 { | ||
[Experimental ("BGEN0020")] | ||
[Notification] | ||
[Field ("NSANotification", LibraryName = "__Internal")] | ||
NSString ANotification { get; } | ||
} | ||
|
||
[Experimental ("BGEN0021")] | ||
enum E2 { | ||
[Experimental ("BGEN0022")] | ||
[Field ("E2A", LibraryName = "__Internal")] | ||
A, | ||
} | ||
|
||
[Experimental ("BGEN0023")] | ||
[ErrorDomain ("E3Domain", LibraryName = "__Internal")] | ||
enum E3 { | ||
[Experimental ("BGEN0024")] | ||
ErrorA, | ||
} | ||
|
||
[Experimental ("BGEN0025")] | ||
[Flags] | ||
enum E4 { | ||
[Experimental ("BGEN0026")] | ||
Bit1 = 1, | ||
[Experimental ("BGEN0027")] | ||
Bit3 = 4, | ||
} | ||
|
||
[Experimental ("BGEN0028")] | ||
[Protocol, Model] | ||
interface PM1 { | ||
[Experimental ("BGEN0029")] | ||
[Export ("method")] | ||
int PMethod (); | ||
|
||
[Experimental ("BGEN0030")] | ||
[Export ("property")] | ||
int PProperty { get; set; } | ||
|
||
[Experimental ("BGEN0031")] | ||
[Abstract] | ||
[Export ("methodRequired")] | ||
int PAMethod (); | ||
|
||
[Experimental ("BGEN0032")] | ||
[Abstract] | ||
[Export ("propertyRequired")] | ||
int PAProperty { get; set; } | ||
} | ||
|
||
} |
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.