Skip to content

Commit d945087

Browse files
committed
Unify symbol info data views and cache access
Introduce ISymbolInfoDataView and SymbolInfoDataView for a consistent, cache-backed, exception-safe public API over all reflection symbol metadata. Refactor all symbol data classes to expose a .View property using the new infrastructure. Centralize cache access and exception handling for unloaded AssemblyLoadContexts. Update PropertyDataView and IPropertyDataView for clarity and safety. Remove obsolete members and improve documentation throughout.
1 parent f18d662 commit d945087

15 files changed

Lines changed: 886 additions & 66 deletions

‎src/BionicCode.Utilities.Reflection/ConstructorData.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal ConstructorData(SymbolReflectionInfoCacheKeyInternal symbolInfoDataCach
4545
}
4646

4747
internal IConstructorDataView View => _constructorDataView
48-
??= new ConstructorDataView(SymbolReflectionInfoCacheKey.CreateForConstructor(this));
48+
??= new ConstructorDataView(GetPublicCacheKey());
4949

5050
internal ConstructorInfo ConstructorInfo { get; }
5151

‎src/BionicCode.Utilities.Reflection/EventData.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal EventData(SymbolReflectionInfoCacheKeyInternal symbolInfoDataCacheKey)
5050
}
5151

5252
internal IEventDataView View => _eventDataView
53-
??= new EventDataView(SymbolReflectionInfoCacheKey.CreateForEvent(this));
53+
??= new EventDataView(GetPublicCacheKey());
5454

5555
protected override MemberInfo MemberInfo
5656
=> EventInfo;

src/BionicCode.Utilities.Reflection/Exceptions/ReflectionCacheEntryNotAvailable.cs renamed to src/BionicCode.Utilities.Reflection/Exceptions/ReflectionCacheEntryAlcNotAvailableException.cs

File renamed without changes.

‎src/BionicCode.Utilities.Reflection/FieldData.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal FieldData(SymbolReflectionInfoCacheKeyInternal symbolInfoDataCacheKey)
5252
ImplementingTypeHandle = DeclaringTypeHandle;
5353
}
5454
internal IFieldDataView View => _fieldDataView
55-
??= new FieldDataView(SymbolReflectionInfoCacheKey.CreateForField(this));
55+
??= new FieldDataView(GetPublicCacheKey());
5656

5757
internal FieldInfo FieldInfo { get; }
5858

‎src/BionicCode.Utilities.Reflection/IPropertyDataView.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public interface IPropertyDataView : IMemberDataView, ISymbolInfoDataView
1313
bool IsOverride { get; }
1414
bool IsReadOnly { get; }
1515
bool IsSealed { get; }
16-
bool IsSetMethodReadOnly { get; }
1716
IMethodDataView PropertyGetMethodData { get; }
1817
IParameterListView PropertyGetMethodParameters { get; }
1918
IMethodDataView PropertySetMethodData { get; }

‎src/BionicCode.Utilities.Reflection/ISymbolInfoDataView.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ public interface ISymbolInfoDataView
2626
SymbolAttributes SymbolAttributes { get; }
2727
SymbolComponentInfo SymbolComponentInfo { get; }
2828
SymbolKind SymbolKind { get; }
29-
}
29+
}

‎src/BionicCode.Utilities.Reflection/MethodData.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ internal MethodData(SymbolReflectionInfoCacheKeyInternal symbolReflectionInfoCac
9191
}
9292

9393
internal IMethodDataView View => _methodDataView
94-
??= new MethodDataView(SymbolReflectionInfoCacheKey.CreateForMethod(this));
94+
??= new MethodDataView(GetPublicCacheKey());
9595

9696
internal MethodInfo MethodInfo { get; }
9797

‎src/BionicCode.Utilities.Reflection/ParameterData.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal ParameterData(SymbolReflectionInfoCacheKeyInternal symbolInfoDataCacheK
5757
}
5858

5959
internal IParameterDataView View => _parameterDataView
60-
??= new ParameterDataView(SymbolReflectionInfoCacheKey.CreateForParameter(this));
60+
??= new ParameterDataView(GetPublicCacheKey());
6161

6262
internal RuntimeTypeHandle DeclaringTypeHandle => _declaringTypeHandle ??= ParameterInfo.Member.DeclaringType?.TypeHandle ?? throw new NotSupportedException($"The underlying '{typeof(ParameterInfo).FullName}' belongs to a member that does not return a declaring type.");
6363

‎src/BionicCode.Utilities.Reflection/PropertyData.cs‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ private void GetAccessors()
839839
}
840840

841841
internal IPropertyDataView View => _propertyDataView
842-
??= new PropertyDataView(SymbolReflectionInfoCacheKey.CreateForProperty(this));
842+
??= new PropertyDataView(GetPublicCacheKey());
843843

844844
internal bool IsIndexer => CanRead
845845
? PropertyGetMethodParameters.HasItems
@@ -912,11 +912,21 @@ internal AccessModifier GetAccessorAccessModifier
912912
internal bool CanRead => _canRead ??= PropertyInfo.CanRead;
913913

914914
/// <summary>
915-
/// Gets a value indicating whether the current property has a setter or not.
915+
/// Gets a value indicating whether the current property has a setter.
916916
/// </summary>
917-
/// <remarks>The <see cref="IsReadOnly"/> property is an alias for the inverted <see cref="CanWrite"/>:
918-
/// <br/><c>IsReadOnly == !CanWrite</c></remarks>
919-
/// <value><see langword="true"/> if the property does not have a setter and is therefore read-only; otherwise, <see langword="false"/>.</value>
917+
/// <remarks>
918+
/// <para>
919+
/// <see cref="IsReadOnly"/> is an alias for the inverted <see cref="CanWrite"/>:
920+
/// <c>IsReadOnly == !CanWrite</c>.
921+
/// </para>
922+
/// <para>
923+
/// Note: <see cref="CanWrite"/> is <see langword="true"/> if a set accessor exists (even if non-public).
924+
/// Init-only properties still have a setter, so they are not considered read-only by this flag.
925+
/// </para>
926+
/// </remarks>
927+
/// <value>
928+
/// <see langword="true"/> if the property does not have a set accessor; otherwise, <see langword="false"/>.
929+
/// </value>
920930
internal bool IsReadOnly => !CanWrite;
921931

922932
/// <summary>

‎src/BionicCode.Utilities.Reflection/PropertyDataView.cs‎

Lines changed: 59 additions & 50 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)