Adding static constructor to StyleHelper class#7295
Merged
dipeshmsft merged 1 commit intomainfrom Dec 28, 2022
Merged
Conversation
batzen
approved these changes
Nov 17, 2022
lindexi
reviewed
Nov 18, 2022
| internal static void RegisterAlternateExpressionStorage() | ||
| { | ||
| DependencyObject.RegisterForAlternativeExpressionStorage( | ||
| if(_getExpression == null) |
Member
There was a problem hiding this comment.
After we register in static constructor, the _getExpression never be null when the other code call this method. And I think the RegisterAlternateExpressionStorage can be private and only called by static constructor.
Contributor
There was a problem hiding this comment.
@lindexi - Actually this method gets called from Style class's static ctor as well. That's when we'll have a case where _getExpression has already setup via StyleHelper's static ctor. Hence, this check prevents dual registration of the delegate.
miloush
approved these changes
Nov 20, 2022
Contributor
miloush
left a comment
There was a problem hiding this comment.
Checked both repros are fixed.
dipeshmsft
approved these changes
Dec 28, 2022
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #7205
Fixes #7291
Description
Adding static constructor to StyleHelper class to do the required initialization i.e. registering the "alternative Expression storage". Also, adding check to "RegisterAlternateExpressionStorage" function to avoid re-registration being called.
Customer Impact
An attempt to call the BindingOperations.GetBindingExpression method in .NET 7.0 leads to Null Reference Exception.
Regression
Yes
Testing
In progress
Risk
NA
Microsoft Reviewers: Open in CodeFlow