chore: memberInfo.HasAttribute method added
This commit is contained in:
parent
a3a8fb4e84
commit
336e7e16e7
@ -62,7 +62,7 @@ public class InstanceConverter : IEngineTypeYamlConverter
|
||||
|
||||
foreach (PropertyInfo propertyInfo in typeData.Properties)
|
||||
{
|
||||
if (propertyInfo.GetCustomAttribute<IgnoreSerializationAttribute>() is not null)
|
||||
if (propertyInfo.HasAttribute<IgnoreSerializationAttribute>())
|
||||
continue;
|
||||
|
||||
emitter.Emit(new Scalar(propertyInfo.Name));
|
||||
@ -78,11 +78,11 @@ public class InstanceConverter : IEngineTypeYamlConverter
|
||||
|
||||
foreach (FieldInfo fieldInfo in typeData.Fields)
|
||||
{
|
||||
if (fieldInfo.GetCustomAttribute<System.Runtime.CompilerServices.CompilerGeneratedAttribute>() is not null)
|
||||
if (fieldInfo.HasAttribute<System.Runtime.CompilerServices.CompilerGeneratedAttribute>())
|
||||
continue;
|
||||
|
||||
// if (fieldInfo.GetCustomAttribute<SerializeAttribute>() is null)
|
||||
// continue;
|
||||
if (!fieldInfo.HasAttribute<SerializeAttribute>())
|
||||
continue;
|
||||
|
||||
emitter.Emit(new Scalar(fieldInfo.Name));
|
||||
object? fieldValue = fieldInfo.GetValue(value);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Engine.Core\Engine.Core.csproj" />
|
||||
<ProjectReference Include="..\..\YamlDotNet\YamlDotNet\YamlDotNet.csproj" />
|
||||
<ProjectReference Include="..\YamlDotNet\YamlDotNet\YamlDotNet.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -4,6 +4,7 @@ namespace Syntriax.Engine.Serialization;
|
||||
|
||||
internal static class Utils
|
||||
{
|
||||
internal static bool HasAttribute<T>(this MemberInfo memberInfo) where T : Attribute => memberInfo.GetCustomAttribute<T>() is not null;
|
||||
internal static bool IsEnumerable(this Type type) => typeof(System.Collections.IEnumerable).IsAssignableFrom(type) && type != typeof(string);
|
||||
|
||||
internal static TypeData GetTypeData(this Type objectType)
|
||||
|
Loading…
x
Reference in New Issue
Block a user