From 74320318d4ec4ad96791c9d5a404b28fe442e731 Mon Sep 17 00:00:00 2001 From: feast107 Date: Thu, 27 Jun 2024 15:31:04 +0800 Subject: [PATCH] Fix inherit member --- .../ComponentModel/ClaimTypeAttribute.cs | 7 +++++-- .../Antelcat.ClaimSerialization.csproj | 6 +++--- .../Metadata/Internal/RuntimeClaimTypeInfo.cs | 14 ++------------ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Antelcat.ClaimSerialization.Shared/ComponentModel/ClaimTypeAttribute.cs b/src/Antelcat.ClaimSerialization.Shared/ComponentModel/ClaimTypeAttribute.cs index 6c9dcfc..439ad4c 100644 --- a/src/Antelcat.ClaimSerialization.Shared/ComponentModel/ClaimTypeAttribute.cs +++ b/src/Antelcat.ClaimSerialization.Shared/ComponentModel/ClaimTypeAttribute.cs @@ -6,6 +6,9 @@ namespace Antelcat.ClaimSerialization.ComponentModel; /// /// Replace the of the /// -/// Special Types from +/// Special Types from [AttributeUsage(AttributeTargets.Property)] -public class ClaimTypeAttribute(string? Type = null) : Attribute; +public class ClaimTypeAttribute(string? type = null) : Attribute +{ + internal string? Type { get; } = type; +} diff --git a/src/Antelcat.ClaimSerialization/Antelcat.ClaimSerialization.csproj b/src/Antelcat.ClaimSerialization/Antelcat.ClaimSerialization.csproj index ab2cd91..e641fc8 100644 --- a/src/Antelcat.ClaimSerialization/Antelcat.ClaimSerialization.csproj +++ b/src/Antelcat.ClaimSerialization/Antelcat.ClaimSerialization.csproj @@ -7,9 +7,9 @@ true preview - 2.0.0-pre-alpha-1 - 2.0.0.0 - 2.0.0.0 + 2.0.0-pre-alpha-2 + 2.0.0.1 + 2.0.0.1 Antelcat Antelcat.ClaimSerialization diff --git a/src/Antelcat.ClaimSerialization/Metadata/Internal/RuntimeClaimTypeInfo.cs b/src/Antelcat.ClaimSerialization/Metadata/Internal/RuntimeClaimTypeInfo.cs index 0f6a001..bd2992e 100644 --- a/src/Antelcat.ClaimSerialization/Metadata/Internal/RuntimeClaimTypeInfo.cs +++ b/src/Antelcat.ClaimSerialization/Metadata/Internal/RuntimeClaimTypeInfo.cs @@ -29,18 +29,8 @@ public RuntimeClaimTypeInfo() Getters = ResolveGetHandlers(claimProps).ToArray(); } - private static string GetClaimType(MemberInfo property) - { - var claimType = property.Name; - var attr = property.CustomAttributes - .FirstOrDefault(x => x.AttributeType == typeof(ClaimTypeAttribute)); - if (attr != null) - { - claimType = attr.ConstructorArguments[0].Value as string ?? property.Name; - } - - return claimType; - } + private static string GetClaimType(MemberInfo property) => + property.GetCustomAttribute()?.Type ?? property.Name; private static IEnumerable ResolveSetHandlers( IEnumerable properties) =>