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

Redefine GridLength as readonly struct to prevent defensive copies #9905

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Contributor

@h3xds1nz h3xds1nz commented Oct 7, 2024

Description

Since GridLength is immutable by design, we should adjust it to readonly struct. This will also prevent defensive copies. It will also improve code quality. This is not a breaking change.

  • I've also simplified the ctor a bit, which will also offer a very minor performance benefit (it does not matter).
  • Minor cleanup of the usual IEquatable functions to save precious code lines and simplify it.
  • The value was being set to 0.0 in case of Auto but when queried, it is set to 1.0.

Customer Impact

Possibly a bit of perf and a clear directive that GridLength and all its methods are not adjusting the state of the struct.

Regression

No.

Testing

Local build, base testing, type creation, etc.

Risk

I do not asses any, since the struct is immutable and this is not a breaking change. It is a change to a public type but such changes have been done previously in runtime, see for example #97421.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners October 7, 2024 18:34
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Change Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants