From 11ac2beb711b900874d5c948e9941dc72791bb79 Mon Sep 17 00:00:00 2001 From: Loretta Date: Mon, 26 Jan 2026 11:53:08 +0100 Subject: [PATCH] Add IsStringInternProperty to BinaryPropertyAccessorBase Introduce IsStringInternProperty to cache the [AcStringIntern] attribute value for each property. Update the constructor to initialize this property, and revise class documentation to reflect the new addition. This enables efficient access to string interning settings per property. --- .../Binaries/BinaryPropertyAccessorBase.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/AyCode.Core/Serializers/Binaries/BinaryPropertyAccessorBase.cs b/AyCode.Core/Serializers/Binaries/BinaryPropertyAccessorBase.cs index 15c653c..b68b09a 100644 --- a/AyCode.Core/Serializers/Binaries/BinaryPropertyAccessorBase.cs +++ b/AyCode.Core/Serializers/Binaries/BinaryPropertyAccessorBase.cs @@ -7,7 +7,7 @@ namespace AyCode.Core.Serializers.Binaries; /// /// Binary-specific property accessor. /// Inherits typed getters from PropertyAccessorBase. -/// Adds Binary-specific property: PropertyIndex. +/// Adds Binary-specific properties: PropertyIndex, IsStringInternProperty. /// public abstract class BinaryPropertyAccessorBase : PropertyAccessorBase { @@ -18,14 +18,26 @@ public abstract class BinaryPropertyAccessorBase : PropertyAccessorBase /// public int PropertyIndex { get; internal set; } = -1; + /// + /// Cached string intern attribute value for this property. + /// null = no attribute (use global StringInterningMode setting) + /// true = [AcStringIntern(true)] - always intern + /// false = [AcStringIntern(false)] - never intern + /// + public bool? IsStringInternProperty { get; } + /// /// Object getter for property filter context. /// public Func DynamicGetter => _dynamicGetter; - protected BinaryPropertyAccessorBase(PropertyInfo prop, Type declaringType) + protected BinaryPropertyAccessorBase(PropertyInfo prop, Type declaringType) : base(prop, declaringType) { // All typed getters are initialized in PropertyAccessorBase + + // Cache string intern attribute (inherit: true to check base class properties) + var attr = prop.GetCustomAttribute(inherit: true); + IsStringInternProperty = attr?.Enabled; } }