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

feature: Make ValidationText immutable, and add Empty property. #141

Closed
thargy opened this issue Oct 19, 2020 · 2 comments
Closed

feature: Make ValidationText immutable, and add Empty property. #141

thargy opened this issue Oct 19, 2020 · 2 comments

Comments

@thargy
Copy link
Contributor

thargy commented Oct 19, 2020

Describe the solution you'd like
Currently ValidationText is mutable, allowing additional texts to be added, or for the collection to be cleared. This functionality is not currently used in the library and has performance and thread-safety implications.

Describe alternatives you've considered
Having an alternative immutable implementation that can be used interchangeably with the existing mutable version, does not remove the thread-safety issues of accessing the collection whilst it may be being mutated.

Describe suggestions on how to achieve the feature
The Add() and Clear() methods should be removed, and the underlying list changed to a nullable array of _texts (null for empty). Although this is a breaking change, it is worth it as it allows a static readonly ValidationText.Empty singleton property to be added and reduces memory utilisation.

Ideally, the current constructors should be deprecated for a factory method that returns Empty when supplied with an empty enumerable.

Additional context

thargy added a commit to thargy/ReactiveUI.Validation that referenced this issue Oct 19, 2020
thargy added a commit to thargy/ReactiveUI.Validation that referenced this issue Oct 19, 2020
… to provide a `ValidationText.Empty` property).
thargy added a commit to thargy/ReactiveUI.Validation that referenced this issue Oct 19, 2020
…ate, so that `Empty` contains single empty string.

Updated use of obsolete constructors.
glennawatson added a commit that referenced this issue Oct 20, 2020
…rformance and thread-safety of ValidationText (#144)

* Suggested initial implementation of #141, to prepare migration to immutability.

* Fixes #142, (note depends on implementation of #141 to provide a `ValidationText.Empty` property).

* #141 Enhanced backwards compatibility of ValidationText update, so that `Empty` contains single empty string.

Updated use of obsolete constructors.

* Updated API verification.

Passed tests.

* Added ExcludeFromCodeCoverage attributes.

* Updated API definitions to include code coverage attributes.

Restored UAP target.

* ValidationText.None added, and used to indicate a ValidationText with no items - this is used when initialising a ValidationContext.

ValidationText.Empty always contains a single item which is string.Empty.

Previous usages of the constructors have been changed to make use of the Create methods, and the Create methods correctly re-use the singletons where possible.

* Added safety checks to prevent modification of the new Empty/None properties.

* Reverted removal of UAP target.

* Update src/ReactiveUI.Validation.Tests/ValidationTextTests.cs

Co-authored-by: Artyom V. Gorchakov <[email protected]>

* Update src/ReactiveUI.Validation/Collections/ValidationText.cs

Co-authored-by: Artyom V. Gorchakov <[email protected]>

* Update src/ReactiveUI.Validation/Collections/ValidationText.cs

Co-authored-by: Glenn <[email protected]>
Co-authored-by: Artyom V. Gorchakov <[email protected]>
@worldbeater
Copy link
Collaborator

Should be resolved in #144

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants