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.
|
/// First checks IId match (different instance, same Id), then falls back to ReferenceEquals.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[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)
|
if (!UseReferenceHandling)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace AyCode.Core.Serializers.Binaries;
|
||||||
|
|
||||||
public static partial class AcBinarySerializer
|
public static partial class AcBinarySerializer
|
||||||
{
|
{
|
||||||
internal sealed class BinaryTypeMetadata : TypeMetadataBase<BinaryTypeMetadata>
|
internal sealed class BinarySerializeTypeMetadata : TypeMetadataBase<BinarySerializeTypeMetadata>
|
||||||
{
|
{
|
||||||
public BinaryPropertyAccessor[] Properties { get; }
|
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!
|
// Use pre-computed WritableProperties directly - no method call overhead!
|
||||||
var orderedProperties = WritableProperties;
|
var orderedProperties = WritableProperties;
|
||||||
|
|
@ -1250,13 +1250,13 @@ public static partial class AcBinarySerializer
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets type metadata with ThreadLocal caching for hot path optimization.
|
/// 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>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static BinaryTypeMetadata GetTypeMetadata(Type type)
|
private static BinarySerializeTypeMetadata GetTypeMetadata(Type type)
|
||||||
=> BinaryTypeMetadata.GetOrCreateMetadata(type, static t => new BinaryTypeMetadata(t, HasJsonIgnoreAttribute));
|
=> 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
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
@ -9,14 +9,14 @@ namespace AyCode.Core.Serializers.Jsons;
|
||||||
public static partial class AcJsonSerializer
|
public static partial class AcJsonSerializer
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static JsonTypeMetadata GetTypeMetadata(in Type type)
|
private static JsonSerializeTypeMetadata GetTypeMetadata(in Type type)
|
||||||
=> JsonTypeMetadata.GetOrCreateMetadata(type, static t => new JsonTypeMetadata(t));
|
=> 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 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!
|
// Use pre-computed ReadableProperties directly - no method call overhead!
|
||||||
Properties = ReadableProperties
|
Properties = ReadableProperties
|
||||||
|
|
@ -298,7 +298,7 @@ public static partial class AcToonSerializer
|
||||||
/// Get final type description with fallback chain and placeholder resolution.
|
/// Get final type description with fallback chain and placeholder resolution.
|
||||||
/// Priority: ToonDescription (with placeholders) > Microsoft [Description] > Smart inference
|
/// Priority: ToonDescription (with placeholders) > Microsoft [Description] > Smart inference
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string GetFinalTypeDescription(Type type, ToonTypeMetadata metadata)
|
private static string GetFinalTypeDescription(Type type, ToonSerializeTypeMetadata metadata)
|
||||||
{
|
{
|
||||||
// 1. ToonDescription.Description (if not empty)
|
// 1. ToonDescription.Description (if not empty)
|
||||||
var customDesc = metadata.CustomDescription?.Description;
|
var customDesc = metadata.CustomDescription?.Description;
|
||||||
|
|
@ -327,7 +327,7 @@ public static partial class AcToonSerializer
|
||||||
/// Get final type purpose with fallback chain and placeholder resolution.
|
/// Get final type purpose with fallback chain and placeholder resolution.
|
||||||
/// Priority: ToonDescription.Purpose (with placeholders) > Smart inference (empty for classes)
|
/// Priority: ToonDescription.Purpose (with placeholders) > Smart inference (empty for classes)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string GetFinalTypePurpose(Type type, ToonTypeMetadata metadata)
|
private static string GetFinalTypePurpose(Type type, ToonSerializeTypeMetadata metadata)
|
||||||
{
|
{
|
||||||
var customPurpose = metadata.CustomDescription?.Purpose;
|
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.
|
/// Cached metadata for a type including properties, type name, and descriptions.
|
||||||
/// Uses TypeMetadataBase infrastructure for shared caching across all serializers.
|
/// Uses TypeMetadataBase infrastructure for shared caching across all serializers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private sealed class ToonTypeMetadata : TypeMetadataBase<ToonTypeMetadata>
|
private sealed class ToonSerializeTypeMetadata : TypeMetadataBase<ToonSerializeTypeMetadata>
|
||||||
{
|
{
|
||||||
public string TypeName { get; }
|
public string TypeName { get; }
|
||||||
public string ShortTypeName { get; }
|
public string ShortTypeName { get; }
|
||||||
|
|
@ -22,7 +22,7 @@ public static partial class AcToonSerializer
|
||||||
public Type? ElementType { get; }
|
public Type? ElementType { get; }
|
||||||
public ToonDescriptionAttribute? CustomDescription { get; }
|
public ToonDescriptionAttribute? CustomDescription { get; }
|
||||||
|
|
||||||
public ToonTypeMetadata(Type type) : base(type, HasToonIgnoreAttribute)
|
public ToonSerializeTypeMetadata(Type type) : base(type, HasToonIgnoreAttribute)
|
||||||
{
|
{
|
||||||
TypeName = type.FullName ?? type.Name;
|
TypeName = type.FullName ?? type.Name;
|
||||||
ShortTypeName = type.Name;
|
ShortTypeName = type.Name;
|
||||||
|
|
@ -322,12 +322,12 @@ public static partial class AcToonSerializer
|
||||||
#region Type Metadata
|
#region Type Metadata
|
||||||
|
|
||||||
/// <summary>
|
/// <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.
|
/// This uses the shared GlobalMetadataCache and ThreadLocal cache for optimal performance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static ToonTypeMetadata GetTypeMetadata(Type type)
|
private static ToonSerializeTypeMetadata GetTypeMetadata(Type type)
|
||||||
=> ToonTypeMetadata.GetOrCreateMetadata(type, static t => new ToonTypeMetadata(t));
|
=> ToonSerializeTypeMetadata.GetOrCreateMetadata(type, static t => new ToonSerializeTypeMetadata(t));
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public abstract class TypeMetadataBase
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Global shared cache for all metadata types.
|
/// Global shared cache for all metadata types.
|
||||||
/// Key: (Type sourceType, Type metadataType) - ensures each type can have multiple metadata representations
|
/// 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.
|
/// This single cache is shared across Binary/JSON Serializers/Deserializers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected static readonly ConcurrentDictionary<(Type, Type), TypeMetadataBase> GlobalMetadataCache = new();
|
protected static readonly ConcurrentDictionary<(Type, Type), TypeMetadataBase> GlobalMetadataCache = new();
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace AyCode.Services.SignalRs
|
||||||
.ConfigureLogging(logging =>
|
.ConfigureLogging(logging =>
|
||||||
{
|
{
|
||||||
// alap minimális MS log level
|
// 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
|
// regisztráljuk az AcLoggerProvider-t úgy, hogy visszaadja a meglévő Logger példányt
|
||||||
logging.AddAcLogger(_ => Logger);
|
logging.AddAcLogger(_ => Logger);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue