[StyleCleanUp] Add readonly modifiers in PresentationBuildTasks #10729
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.
Fixes #10726
Description
Fixes occurences of fields that are only written during construction to be
readonly
inPresentationBuildTasks
.In case they were being initialized to non-default value (e.g. initialized to
string.Empty
) but are always overwritten in the constructor, I have removed such assigment. This is a case which analyzers won't flag and imho there's no better time to do it than when resolvingIDE0044
and changing fields toreadonly
.Customer Impact
Increased performance due to the fields being treated as JIT-time constant in case of
static readonly
and better code-gen inreadonly
cases. These changes unlock #10724 since full sweep can only be done after the fields are marked appropriately.Regression
No.
Testing
Local build.
Risk
Full test pass will be required, even in cases where no manual changes are done.
Microsoft Reviewers: Open in CodeFlow