Refactor: Rename and reorganize serializer metadata classes
Replaces BinaryTypeMetadata, JsonTypeMetadata, and ToonTypeMetadata with BinarySerializeTypeMetadata, JsonSerializeTypeMetadata, and ToonSerializeTypeMetadata, moving each to its own file. Updates all references and documentation to use new names. Property accessor classes are retained and relocated. Also sets SignalR logging minimum level to Error. No changes to serialization logic; this is a structural/naming refactor for clarity and separation of concerns.
This commit is contained in:
parent
e3a66857aa
commit
63ab695a0b
|
|
@ -1159,7 +1159,7 @@ public static partial class AcBinarySerializer
|
|||
/// First checks IId match (different instance, same Id), then falls back to ReferenceEquals.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool TrackForScanningWithIId(object obj, BinaryTypeMetadata metadata, out int existingRefId)
|
||||
public bool TrackForScanningWithIId(object obj, BinarySerializeTypeMetadata metadata, out int existingRefId)
|
||||
{
|
||||
if (!UseReferenceHandling)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace AyCode.Core.Serializers.Binaries;
|
|||
|
||||
public static partial class AcBinarySerializer
|
||||
{
|
||||
internal sealed class BinaryTypeMetadata : TypeMetadataBase<BinaryTypeMetadata>
|
||||
internal sealed class BinarySerializeTypeMetadata : TypeMetadataBase<BinarySerializeTypeMetadata>
|
||||
{
|
||||
public BinaryPropertyAccessor[] Properties { get; }
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ public static partial class AcBinarySerializer
|
|||
|
||||
|
||||
|
||||
public BinaryTypeMetadata(Type type, Func<PropertyInfo, bool> ignorePropertyFilter) : base(type,ignorePropertyFilter)
|
||||
public BinarySerializeTypeMetadata(Type type, Func<PropertyInfo, bool> ignorePropertyFilter) : base(type,ignorePropertyFilter)
|
||||
{
|
||||
// Use pre-computed WritableProperties directly - no method call overhead!
|
||||
var orderedProperties = WritableProperties;
|
||||
|
|
@ -1250,13 +1250,13 @@ public static partial class AcBinarySerializer
|
|||
|
||||
/// <summary>
|
||||
/// Gets type metadata with ThreadLocal caching for hot path optimization.
|
||||
/// Uses built-in cache from BinaryTypeMetadata base class (zero ref parameter overhead).
|
||||
/// Uses built-in cache from BinarySerializeTypeMetadata base class (zero ref parameter overhead).
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static BinaryTypeMetadata GetTypeMetadata(Type type)
|
||||
=> BinaryTypeMetadata.GetOrCreateMetadata(type, static t => new BinaryTypeMetadata(t, HasJsonIgnoreAttribute));
|
||||
private static BinarySerializeTypeMetadata GetTypeMetadata(Type type)
|
||||
=> BinarySerializeTypeMetadata.GetOrCreateMetadata(type, static t => new BinarySerializeTypeMetadata(t, HasJsonIgnoreAttribute));
|
||||
|
||||
// Type metadata helpers moved to AcBinarySerializer.BinaryTypeMetadata.cs
|
||||
// Type metadata helpers moved to AcBinarySerializer.BinarySerializeTypeMetadata.cs
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -9,14 +9,14 @@ namespace AyCode.Core.Serializers.Jsons;
|
|||
public static partial class AcJsonSerializer
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static JsonTypeMetadata GetTypeMetadata(in Type type)
|
||||
=> JsonTypeMetadata.GetOrCreateMetadata(type, static t => new JsonTypeMetadata(t));
|
||||
private static JsonSerializeTypeMetadata GetTypeMetadata(in Type type)
|
||||
=> JsonSerializeTypeMetadata.GetOrCreateMetadata(type, static t => new JsonSerializeTypeMetadata(t));
|
||||
|
||||
private sealed class JsonTypeMetadata : TypeMetadataBase<JsonTypeMetadata>
|
||||
private sealed class JsonSerializeTypeMetadata : TypeMetadataBase<JsonSerializeTypeMetadata>
|
||||
{
|
||||
public PropertyAccessor[] Properties { get; }
|
||||
|
||||
public JsonTypeMetadata(Type type) : base(type, JsonUtilities.HasJsonIgnoreAttribute)
|
||||
public JsonSerializeTypeMetadata(Type type) : base(type, JsonUtilities.HasJsonIgnoreAttribute)
|
||||
{
|
||||
// Use pre-computed ReadableProperties directly - no method call overhead!
|
||||
Properties = ReadableProperties
|
||||
|
|
@ -298,7 +298,7 @@ public static partial class AcToonSerializer
|
|||
/// Get final type description with fallback chain and placeholder resolution.
|
||||
/// Priority: ToonDescription (with placeholders) > Microsoft [Description] > Smart inference
|
||||
/// </summary>
|
||||
private static string GetFinalTypeDescription(Type type, ToonTypeMetadata metadata)
|
||||
private static string GetFinalTypeDescription(Type type, ToonSerializeTypeMetadata metadata)
|
||||
{
|
||||
// 1. ToonDescription.Description (if not empty)
|
||||
var customDesc = metadata.CustomDescription?.Description;
|
||||
|
|
@ -327,7 +327,7 @@ public static partial class AcToonSerializer
|
|||
/// Get final type purpose with fallback chain and placeholder resolution.
|
||||
/// Priority: ToonDescription.Purpose (with placeholders) > Smart inference (empty for classes)
|
||||
/// </summary>
|
||||
private static string GetFinalTypePurpose(Type type, ToonTypeMetadata metadata)
|
||||
private static string GetFinalTypePurpose(Type type, ToonSerializeTypeMetadata metadata)
|
||||
{
|
||||
var customPurpose = metadata.CustomDescription?.Purpose;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public static partial class AcToonSerializer
|
|||
/// Cached metadata for a type including properties, type name, and descriptions.
|
||||
/// Uses TypeMetadataBase infrastructure for shared caching across all serializers.
|
||||
/// </summary>
|
||||
private sealed class ToonTypeMetadata : TypeMetadataBase<ToonTypeMetadata>
|
||||
private sealed class ToonSerializeTypeMetadata : TypeMetadataBase<ToonSerializeTypeMetadata>
|
||||
{
|
||||
public string TypeName { get; }
|
||||
public string ShortTypeName { get; }
|
||||
|
|
@ -22,7 +22,7 @@ public static partial class AcToonSerializer
|
|||
public Type? ElementType { get; }
|
||||
public ToonDescriptionAttribute? CustomDescription { get; }
|
||||
|
||||
public ToonTypeMetadata(Type type) : base(type, HasToonIgnoreAttribute)
|
||||
public ToonSerializeTypeMetadata(Type type) : base(type, HasToonIgnoreAttribute)
|
||||
{
|
||||
TypeName = type.FullName ?? type.Name;
|
||||
ShortTypeName = type.Name;
|
||||
|
|
@ -322,12 +322,12 @@ public static partial class AcToonSerializer
|
|||
#region Type Metadata
|
||||
|
||||
/// <summary>
|
||||
/// Gets or creates ToonTypeMetadata using TypeMetadataBase infrastructure.
|
||||
/// Gets or creates ToonSerializeTypeMetadata using TypeMetadataBase infrastructure.
|
||||
/// This uses the shared GlobalMetadataCache and ThreadLocal cache for optimal performance.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static ToonTypeMetadata GetTypeMetadata(Type type)
|
||||
=> ToonTypeMetadata.GetOrCreateMetadata(type, static t => new ToonTypeMetadata(t));
|
||||
private static ToonSerializeTypeMetadata GetTypeMetadata(Type type)
|
||||
=> ToonSerializeTypeMetadata.GetOrCreateMetadata(type, static t => new ToonSerializeTypeMetadata(t));
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public abstract class TypeMetadataBase
|
|||
/// <summary>
|
||||
/// Global shared cache for all metadata types.
|
||||
/// Key: (Type sourceType, Type metadataType) - ensures each type can have multiple metadata representations
|
||||
/// Value: TypeMetadataBase instance (BinaryTypeMetadata, JsonTypeMetadata, etc.)
|
||||
/// Value: TypeMetadataBase instance (BinarySerializeTypeMetadata, JsonTypeMetadata, etc.)
|
||||
/// This single cache is shared across Binary/JSON Serializers/Deserializers.
|
||||
/// </summary>
|
||||
protected static readonly ConcurrentDictionary<(Type, Type), TypeMetadataBase> GlobalMetadataCache = new();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace AyCode.Services.SignalRs
|
|||
.ConfigureLogging(logging =>
|
||||
{
|
||||
// alap minimális MS log level
|
||||
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Error);
|
||||
|
||||
// regisztráljuk az AcLoggerProvider-t úgy, hogy visszaadja a meglévő Logger példányt
|
||||
logging.AddAcLogger(_ => Logger);
|
||||
|
|
|
|||
Loading…
Reference in New Issue