Skip to content

Akka.Util: improve Result<T> - #7520

Merged
Aaronontheweb merged 4 commits into
akkadotnet:devfrom
Aaronontheweb:result-nullability
Mar 13, 2025
Merged

Akka.Util: improve Result<T>#7520
Aaronontheweb merged 4 commits into
akkadotnet:devfrom
Aaronontheweb:result-nullability

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Mar 13, 2025

Copy link
Copy Markdown
Member

Changes

Designed to support our work on #7518

Makes the following changes to Result<T>:

  • Enables nullability
  • Converts fields to properties (should have been that way from the beginning IMHO) - this might be a binary compatibility issue but I doubt it though as this is mostly used internally by Akka.Streams and other components.
  • Redesigns the struct to be a readonly record struct so it an automatically benefit from equality by value and other compiler optimizations

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

@Aaronontheweb Aaronontheweb added this to the 1.5.39 milestone Mar 13, 2025
public static Akka.Util.Result<T> From<T>(System.Func<T> func) { }
public static Akka.Util.Result<T> FromTask<T>(System.Threading.Tasks.Task<T> task) { }
public static Akka.Util.Result<T> Success<T>(T value) { }
[return: System.Runtime.CompilerServices.NullableAttribute(new byte[] {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API change - make fields into nullable properties.

@Arkatufus Arkatufus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb

Copy link
Copy Markdown
Member Author

Reverted back to using fields here instead of properties, out of an abundance of caution WRT binary compatibility

@Aaronontheweb
Aaronontheweb merged commit 10b8223 into akkadotnet:dev Mar 13, 2025
@Aaronontheweb
Aaronontheweb deleted the result-nullability branch March 13, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants