You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1dae9c0
Browse filesBrowse the repository at this point in the historyBrowse files
Enhance attribute handling and refactor reflection API
- Add IsDefined/HasCompilerAttribute methods for robust attribute detection
- Replace GetMemberInfo/GetMethodBase with properties for clarity
- Centralize cache entry creation with GetOrCreateCacheEntry methods
- Refactor TypeListBuilder and TypeList for better API and lookup support
- Change ToTypeData/ToMethodData to return view interfaces
- Improve PropertyData/MethodData for readonly/init-only detection
- Add ReflectionConstants for well-known attribute names
- Make SymbolReflectionInfoCacheKey struct properties readonly
- Improve documentation and code comments throughout
Copy file name to clipboardExpand all lines: src/BionicCode.Utilities.Net.Common/ReflectionConstants.cs
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,8 @@
1
1
namespaceBionicCode.Utilities.Net;
2
2
3
+
usingSystem.ComponentModel;
4
+
usingSystem.Runtime.InteropServices;
5
+
3
6
/// <summary>
4
7
/// Provides a set of constant string values that are commonly used in reflection scenarios, particularly when working with properties, indexers, events, delegates, and operator methods in .NET. These constants can be used to ensure consistency and avoid hardcoding string literals throughout the codebase when performing reflection operations or generating code dynamically.
5
8
/// </summary>
@@ -81,4 +84,9 @@ public static class ReflectionConstants
internalboolCanAdd=>_canAdd??=_addMethodDatais not null||(_addMethodData=EventInfo.GetAddMethod(true)?.ToMethodData())is not null;
215
+
internalboolCanAdd=>_canAdd??=_addMethodDatais not null||(EventInfo.GetAddMethod(true)isMethodInfoaddMethodInfo&&(_addMethodData=GetOrCreateCacheEntry(addMethodInfo))is not null);
216
216
217
-
internalboolCanRemove=>_canRemove??=_removeMethodDatais not null||(_removeMethodData=EventInfo.GetRemoveMethod(true)?.ToMethodData())is not null;
217
+
internalboolCanRemove=>_canRemove??=_removeMethodDatais not null||(EventInfo.GetRemoveMethod(true)isMethodInforemoveMethodInfo&&(_removeMethodData=GetOrCreateCacheEntry(removeMethodInfo))is not null);
/// The declaring type handle of the member. This is the runtime type handle of the type that declares the member. For example, for a method declared in a class, this would be the runtime type handle of that class.
61
64
/// <para/>For an explicit interface implementation, this would be the runtime type handle of the interface that declares the member.
TypeDataimplementingType=methodData.MethodInfo.DeclaringType?.ToTypeData()??thrownewInvalidOperationException("Declaring type handle is not available.");
1439
+
TypeDataimplementingType=GetOrCreateCacheEntry(methodData.MethodInfo.DeclaringType??thrownewInvalidOperationException("Declaring type is not available."));
0 commit comments