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

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

Merged
merged 1 commit into from
Jul 9, 2023
Merged

Conversation

halildurmus
Copy link
Owner

@halildurmus halildurmus commented Jul 8, 2023

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

  • feat -- New feature (non-breaking change which adds functionality)
  • 🛠️ fix -- Bug fix (non-breaking change which fixes an issue)
  • ! -- Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 refactor -- Code refactor
  • ci -- Build configuration change
  • 📝 docs -- Documentation
  • 🧪 test -- Test
  • 🗑️ chore -- Chore

@halildurmus halildurmus added type: feature New feature or request breaking change Introduces a breaking change labels Jul 8, 2023
@github-actions github-actions bot added pkg: windows_data The windows_data package pkg: windows_devices The windows_devices package pkg: windows_foundation The windows_foundation package pkg: windows_globalization The windows_globalization package pkg: windows_graphics The windows_graphics package pkg: windows_networking The windows_networking package pkg: windows_storage The windows_storage package pkg: windows_ui The windows_ui package pkg: winrtgen The winrtgen package pkg: windows_ai The windows_ai package pkg: windows_applicationmodel The windows_applicationmodel package labels Jul 8, 2023
@halildurmus halildurmus force-pushed the record branch 3 times, most recently from 0f7ea50 to d245566 Compare July 9, 2023 12:24
@halildurmus halildurmus marked this pull request as ready for review July 9, 2023 13:28
@halildurmus halildurmus merged commit 35ebf6f into main Jul 9, 2023
6 of 46 checks passed
@halildurmus halildurmus deleted the record branch July 9, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Introduces a breaking change pkg: windows_ai The windows_ai package pkg: windows_applicationmodel The windows_applicationmodel package pkg: windows_data The windows_data package pkg: windows_devices The windows_devices package pkg: windows_foundation The windows_foundation package pkg: windows_globalization The windows_globalization package pkg: windows_graphics The windows_graphics package pkg: windows_networking The windows_networking package pkg: windows_storage The windows_storage package pkg: windows_ui The windows_ui package pkg: winrtgen The winrtgen package type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Methods with out parameters should return a Record
1 participant