Skip to content

Commit

Permalink
Respect accessibility of generated accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Dec 27, 2024
1 parent 1dadd4d commit f456963
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ static string GetExpressionWithTrailingSpace(Accessibility accessibility)
if (propertyInfo.IsLocalCachingEnabled)
{
writer.WriteLine($$"""
get => field;
set
{{GetExpressionWithTrailingSpace(propertyInfo.GetterAccessibility)}}get => field;
{{GetExpressionWithTrailingSpace(propertyInfo.SetterAccessibility)}}set
{
On{{propertyInfo.PropertyName}}Set(ref value);
Expand Down Expand Up @@ -602,15 +602,15 @@ static string GetExpressionWithTrailingSpace(Accessibility accessibility)
// would introduce a lot of overhead. If callers really do want to have a callback being invoked, they can implement
// the one wired up to the property metadata directly. We can still invoke the ones only using the new value, though.
writer.WriteLine($$"""
get
{{GetExpressionWithTrailingSpace(propertyInfo.GetterAccessibility)}}get
{
object? __boxedValue = GetValue({{propertyInfo.PropertyName}}Property);
On{{propertyInfo.PropertyName}}Get(ref __boxedValue);
return __boxedValue;
}
set
{{GetExpressionWithTrailingSpace(propertyInfo.SetterAccessibility)}}set
{
On{{propertyInfo.PropertyName}}Set(ref value);
Expand All @@ -624,7 +624,7 @@ static string GetExpressionWithTrailingSpace(Accessibility accessibility)
{
// Same as above but with the extra typed hook for both accessors
writer.WriteLine($$"""
get
{{GetExpressionWithTrailingSpace(propertyInfo.GetterAccessibility)}}get
{
object? __boxedValue = GetValue({{propertyInfo.PropertyName}}Property);
Expand All @@ -636,7 +636,7 @@ static string GetExpressionWithTrailingSpace(Accessibility accessibility)
return __unboxedValue;
}
set
{{GetExpressionWithTrailingSpace(propertyInfo.SetterAccessibility)}}set
{
On{{propertyInfo.PropertyName}}Set(ref value);
Expand Down
Loading

0 comments on commit f456963

Please sign in to comment.