halildurmus / dartwinrt

Idiomatic Dart projection of the modern Windows Runtime (WinRT) APIs.
BSD 3-Clause "New" or "Revised" License
50 stars 3 forks source link

feat!: methods with `out` parameters now return a `Record` #299

Closed halildurmus closed 1 year ago

halildurmus commented 1 year ago

Description

Here are three scenarios to consider when modifying method signatures:

1-) void methods with a single out parameter

When dealing with void methods that have a single out parameter, the return type of the method is replaced with the type of the out parameter.

For instance, consider the following method:

  static void tryCreate(String regionCode, PhoneNumberFormatter? formatter)  {...}

The modified signature would look like this:

  static PhoneNumberFormatter? tryCreate(String regionCode)  {...}

2-) void methods with multiple out parameters

In the case of void methods with multiple out parameters, the return type is changed to a Record with named parameters corresponding to the out parameters' types.

For example:

  void split(IMapView<String, Object?>? first, IMapView<String, Object?>? second) {...}

The updated signature would be:

  ({IMapView<String, Object?>? first, IMapView<String, Object?>? second}) split() {...}

3-) non-void methods with out parameter(s)

Finally, when dealing with non-void methods that have out parameter(s), the return type is transformed into a Record with one positional parameter representing the original return type and named parameters representing the out parameters' types.

For instance:

  int getMany(int itemsSize, List<String> items) {...}

The modified signature would be:

  (int, {List<String> items}) getMany(int itemsSize) {...}

Related Issue

Fixes #284

Type of Change