Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bgen] Implement support for using default interface members to bind protocols. #20681

Merged
merged 18 commits into from
Jun 7, 2024

Commits on Jun 4, 2024

  1. Configuration menu
    Copy the full SHA
    f95f903 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    151c107 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d72619a View commit details
    Browse the repository at this point in the history
  4. [bgen] Fix rendering types needing global qualifier depending on loca…

    …tion by fixing location.
    rolfbjarne committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    3ea1348 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7b76386 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d4f4382 View commit details
    Browse the repository at this point in the history
  7. [bgen] Implement support for using default interface members to bind …

    …protocols.
    
    Given the following API definition:
    
    ```cs
    [Protocol]
    public interface Protocol {
        [Abstract]
        [Export ("requiredMethod")]
        void RequiredMethod ();
    
        [Export ("optionalMethod")]
        void OptionalMethod ();
    }
    ```
    
    we're now binding it like this:
    
    ```cs
    [Protocol ("Protocol")]
    public interface IProtocol : INativeObject {
        [RequiredMember]
        [Export ("requiredMethod")]
        public void RequiredMethod () { /* default implementation */ }
    
        [OptionalMember]
        [Export ("optionalMethod")]
        public void OptionalMethod () { /* default implementation */ }
    }
    ```
    
    The main difference from before is that the only difference between required
    and optional members is the [RequiredMember]/[OptionalMember] attributes.
    
    This has one major advantage: it's now possible to switch a member from being
    required to being optional, or vice versa, without breaking neither source nor
    binary compatibility.
    
    It also improves intellisense for optional members. In the past optional
    members were implemented using extension methods, which were not very
    discoverable when you were supposed to implement a protocol in your own class.
    
    The main downside is that the C# compiler won't enforce developers to
    implement required protocol members (which is a necessary side effect of the
    fact that we want to be able to switch members between being required and
    optional without breaking compatibility). If this turns out to be a problem,
    we can implement a custom source analyzer and/or linker step that detects
    missing implementations and issue warnings/errors.
    
    Also:
    
    * Add numerous tests.
    * Add documentation.
    * Handle numerous corner cases, which are documented in code and docs.
    
    Fixes xamarin#13294.
    rolfbjarne committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    8390f51 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    437176c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    2a948d9 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    4e8df9c View commit details
    Browse the repository at this point in the history
  11. Fix breaking API.

    rolfbjarne committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    ae939ca View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2024

  1. 1 Configuration menu
    Copy the full SHA
    3d35ded View commit details
    Browse the repository at this point in the history

Commits on Jun 6, 2024

  1. Fix doc id generation.

    rolfbjarne committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    4417249 View commit details
    Browse the repository at this point in the history
  2. Update tests.

    rolfbjarne committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    1e3c521 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    de28527 View commit details
    Browse the repository at this point in the history
  4. 1 Configuration menu
    Copy the full SHA
    247b7d6 View commit details
    Browse the repository at this point in the history
  5. 1 Configuration menu
    Copy the full SHA
    dc0e7aa View commit details
    Browse the repository at this point in the history

Commits on Jun 7, 2024

  1. 3 Configuration menu
    Copy the full SHA
    eed33cb View commit details
    Browse the repository at this point in the history