From d2babf4e0b1cdd2e6abcc6403b09dca0420299f2 Mon Sep 17 00:00:00 2001 From: Thomas Anderson Date: Thu, 5 Dec 2024 06:18:09 +0000 Subject: [PATCH] Copied across the from cdms for the sensitive data, so it uses the json property name attribute --- Btms.SensitiveData/SensitiveFieldsProvider.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Btms.SensitiveData/SensitiveFieldsProvider.cs b/Btms.SensitiveData/SensitiveFieldsProvider.cs index b56f5d2..1589aca 100644 --- a/Btms.SensitiveData/SensitiveFieldsProvider.cs +++ b/Btms.SensitiveData/SensitiveFieldsProvider.cs @@ -1,5 +1,6 @@ using System.Reflection; using System.Text.Json; +using System.Text.Json.Serialization; namespace Btms.SensitiveData; @@ -49,8 +50,10 @@ private static List GetSensitiveFields(string root, Type type) var list = new List(); foreach (var property in type.GetProperties()) { + var jsonPropertyNameAttribute = property.GetCustomAttribute(); + var propertyName = jsonPropertyNameAttribute != null ? jsonPropertyNameAttribute.Name : property.Name; string currentPath; - currentPath = string.IsNullOrEmpty(root) ? $"{namingPolicy.ConvertName(property.Name)}" : $"{namingPolicy.ConvertName(root)}.{namingPolicy.ConvertName(property.Name)}"; + currentPath = string.IsNullOrEmpty(root) ? $"{namingPolicy.ConvertName(propertyName)}" : $"{namingPolicy.ConvertName(root)}.{namingPolicy.ConvertName(propertyName)}"; if (property.CustomAttributes.Any(x => x.AttributeType == typeof(SensitiveDataAttribute))) {