Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion util/Setup/Setup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="Handlebars.Net" Version="2.1.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 21 additions & 5 deletions util/Setup/YamlComments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public CommentGatheringTypeInspector(ITypeInspector innerTypeDescriptor)
_innerTypeDescriptor = innerTypeDescriptor ?? throw new ArgumentNullException(nameof(innerTypeDescriptor));
}

public override string GetEnumName(Type enumType, string name)
{
return _innerTypeDescriptor.GetEnumName(enumType, name);
}

public override string GetEnumValue(object enumValue)
{
return _innerTypeDescriptor.GetEnumValue(enumValue);
}

public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object container)
{
return _innerTypeDescriptor.GetProperties(type, container).Select(d => new CommentsPropertyDescriptor(d));
Expand All @@ -33,13 +43,19 @@ private sealed class CommentsPropertyDescriptor : IPropertyDescriptor
public CommentsPropertyDescriptor(IPropertyDescriptor baseDescriptor)
{
_baseDescriptor = baseDescriptor;
Name = baseDescriptor.Name;
}

public string Name { get; set; }
public int Order { get; set; }
public string Name => _baseDescriptor.Name;
public int Order
{
get => _baseDescriptor.Order;
set => _baseDescriptor.Order = value;
}
public Type Type => _baseDescriptor.Type;
public bool CanWrite => _baseDescriptor.CanWrite;
public bool AllowNulls => _baseDescriptor.AllowNulls;
public bool Required => _baseDescriptor.Required;
public Type ConverterType => _baseDescriptor.ConverterType;

public Type TypeOverride
{
Expand Down Expand Up @@ -95,7 +111,7 @@ public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor
public CommentsObjectGraphVisitor(IObjectGraphVisitor<IEmitter> nextVisitor)
: base(nextVisitor) { }

public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context)
public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context, ObjectSerializer serializer)
{
if (value is CommentsObjectDescriptor commentsDescriptor && commentsDescriptor.Comment != null)
{
Expand All @@ -105,6 +121,6 @@ public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor val
context.Emit(new Comment(comment, false));
}
}
return base.EnterMapping(key, value, context);
return base.EnterMapping(key, value, context, serializer);
}
}
Loading