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