dotnet / dotnet/wpf

Update structs to use new readonly member modifier

Open
#812 0 comments 0 reactions 0 assignees View on GitHub
Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

We have multitudes of structs being non-readonly, and making them readonly would be a breaking change. As some of these structs may be used with the in modifier in user code they will be defensively copied each time a member is accessed or a function is called on the struct. The new c# 8 feature, readonly members allows the compiler to ellide the defensive copy when accessing readonly members. We have tons of places where we easily make these changes without breaking anything (GetHashCode and Equals on structs should NEVER mutate them). This is a mirror of the ticket [here](https://github.com/dotnet/corefx/issues/36586)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.