|
6 | 6 | using System.Diagnostics; |
7 | 7 | using System.Diagnostics.CodeAnalysis; |
8 | 8 | using System.Globalization; |
| 9 | +using System.Reflection; |
9 | 10 | using System.Security.Cryptography; |
10 | 11 | using System.Text; |
11 | 12 | using Microsoft.AspNetCore.Components.Reflection; |
@@ -76,18 +77,23 @@ public void Subscribe(ComponentState subscriber, in CascadingParameterInfo param |
76 | 77 | }, subscriber.Renderer.GetComponentRenderMode(subscriber.Component)); |
77 | 78 | } |
78 | 79 |
|
79 | | - private static PropertyGetter ResolvePropertyGetter([DynamicallyAccessedMembers(LinkerFlags.Component)] Type type, string propertyName) |
| 80 | + private static PropertyGetter ResolvePropertyGetter(Type type, string propertyName) |
80 | 81 | { |
81 | | - return _propertyGetterCache.GetOrAdd((type, propertyName), (key) => |
| 82 | + return _propertyGetterCache.GetOrAdd((type, propertyName), PropertyGetterFactory); |
| 83 | + } |
| 84 | + |
| 85 | + private static PropertyGetter PropertyGetterFactory((Type type, string propertyName) key) |
| 86 | + { |
| 87 | + var (type, propertyName) = key; |
| 88 | + var propertyInfo = GetPropertyInfo(type, propertyName); |
| 89 | + if (propertyInfo == null) |
82 | 90 | { |
83 | | - var (type, propertyName) = key; |
84 | | - var propertyInfo = type.GetProperty(propertyName); |
85 | | - if (propertyInfo == null) |
86 | | - { |
87 | | - throw new InvalidOperationException($"Property {propertyName} not found on type {type.FullName}"); |
88 | | - } |
89 | | - return new PropertyGetter(type, propertyInfo); |
90 | | - }); |
| 91 | + throw new InvalidOperationException($"Property {propertyName} not found on type {type.FullName}"); |
| 92 | + } |
| 93 | + return new PropertyGetter(type, propertyInfo); |
| 94 | + |
| 95 | + static PropertyInfo? GetPropertyInfo([DynamicallyAccessedMembers(LinkerFlags.Component)] Type type, string propertyName) |
| 96 | + => type.GetProperty(propertyName); |
91 | 97 | } |
92 | 98 |
|
93 | 99 | public void Unsubscribe(ComponentState subscriber, in CascadingParameterInfo parameterInfo) |
|
0 commit comments