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 55c5ce2
Browse filesBrowse the repository at this point in the historyBrowse files
Improve reflection for readonly, dynamic, extension attributes
Refactored attribute handling to use new constants and generic methods for DynamicAttribute and ExtensionAttribute. Enhanced parameter and property metadata logic, including IsDynamic and IsGeneric support, and clarified readonly/ref/in/out semantics. Removed redundant readonly property logic and updated init-only detection. Improved attribute lookup performance and code clarity with switch expressions and better documentation.
Copy file name to clipboardExpand all lines: src/BionicCode.Utilities.Net.Common/ReflectionConstants.cs
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,4 @@
1
1
namespaceBionicCode.Utilities.Net;
2
-
3
-
usingSystem.ComponentModel;
4
-
usingSystem.Runtime.InteropServices;
5
-
6
2
/// <summary>
7
3
/// 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.
8
4
/// </summary>
@@ -89,4 +85,6 @@ public static class ReflectionConstants
/// Gets a value indicating whether the parameter is passed by reference.
196
+
/// Gets a value indicating whether the parameter is passed by reference (<see langword="in"/>, <see langword="out"/>, <see langword="ref"/> or <see langword="ref"/><see langword="readonly"/>).
/// <value><see langword="true"/> if the property does not have a setter and is therefore read-only; otherwise, <see langword="false"/>.</value>
924
920
internalboolIsReadOnly=>!CanWrite;
925
921
926
-
/// <summary>
927
-
/// Gets whether the property’s set accessor is a <see langword="readonly"/> instance member (struct-only), meaning it doesn’t modify the struct’s instance state.
/// Gets whether the property’s get accessor is a <see langword="readonly"/> instance member (struct-only), meaning it doesn’t modify the struct’s instance state.
/// Gets whether the property itself is a <see langword="readonly"/> instance member on a struct type, meaning it doesn’t modify the struct’s instance state. This is determined by checking if the property has the <see cref="IsReadOnlyAttribute"/> applied, which is used by the C# compiler to indicate that a struct member is readonly. If the property does not have this attribute, this property returns <see langword="false"/>. Note that for reference types, this property will always return <see langword="false"/>, as the concept of a readonly instance member only applies to value types (structs).
0 commit comments