Refactor EntityMetadata to improve state consumption#195
Merged
jviau merged 4 commits intomicrosoft:feature/entitiesfrom Sep 25, 2023
Merged
Refactor EntityMetadata to improve state consumption#195jviau merged 4 commits intomicrosoft:feature/entitiesfrom
jviau merged 4 commits intomicrosoft:feature/entitiesfrom
Conversation
sebastianburckhardt
approved these changes
Sep 22, 2023
Member
sebastianburckhardt
left a comment
There was a problem hiding this comment.
some suggested changes to the comments, and one question about a possible simplification.
Otherwise looks good to me.
| public string? SerializedState { get; init; } | ||
| [MemberNotNullWhen(true, "State")] | ||
| [MemberNotNullWhen(true, "state")] | ||
| public bool IncludesState { get; } |
Member
There was a problem hiding this comment.
we could perhaps implement this more simply as
public bool IncludesState => this.state is not null;
Member
Author
There was a problem hiding this comment.
I don't have that to handle default value types. Basically, this has to be a pseudo Optional. Need to differentiate between state was fetched and it was a default value type, or state was not fetched at all (in which case the value is still default).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes to following:
includeStateistrueby default for all get entity methods (including get all)EntityMetadata<TState>, which has a strongly typed deserializedTState Stateproperty.SerializedData, which has aReadAs<T>()method.EntityMetadatanow implementsEntityMetadata<SerializedData>EntityMetadata<TState>now has abool IncludesStatewhich indicates if state was retrieved or not.EntityMetadata<TState>.Statenow throws ifIncludeState==falseGetEntityAsync<T>andGetAllEntitiesAsync<T>overloads to getEntityMetadata<T>