Skip to content

Commit

Permalink
Bump YamlDotNet from 15.3.0 to 16.0.0 in /src (#120)
Browse files Browse the repository at this point in the history
* Bump YamlDotNet from 15.3.0 to 16.0.0 in /src

Bumps YamlDotNet from 15.3.0 to 16.0.0.

---
updated-dependencies:
- dependency-name: YamlDotNet
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update API

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jan Trejbal <[email protected]>
  • Loading branch information
dependabot[bot] and trejjam authored Jul 15, 2024
1 parent b055c73 commit 1e51b2c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="YamlDotNet" Version="15.3.0" />
<PackageReference Include="YamlDotNet" Version="16.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/DockerComposeBuilder/DockerComposeBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" />
<PackageReference Include="YamlDotNet" Version="15.3.0" />
<PackageReference Include="YamlDotNet" Version="16.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using YamlDotNet.Core;
using YamlDotNet.Serialization;
Expand All @@ -12,7 +13,8 @@ public YamlIEnumerableSkipEmptyObjectGraphVisitor(IObjectGraphVisitor<IEmitter>
{
}

public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context)
public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context,
ObjectSerializer serializer)
{
var retVal = false;

Expand All @@ -23,19 +25,21 @@ public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor val

if (value.Value is IEnumerable enumerableObject)
{
var enumerator = enumerableObject.GetEnumerator();
using var _ = enumerator as IDisposable;
// We have a collection
if (enumerableObject.GetEnumerator().MoveNext()) // Returns true if the collection is not empty.
if (enumerator.MoveNext()) // Returns true if the collection is not empty.
{
// Don't skip this item - serialize it as normal.
retVal = base.EnterMapping(key, value, context);
retVal = base.EnterMapping(key, value, context, serializer);
}

// Else we have an empty collection and the initialized return value of false is correct.
}
else
{
// Not a collection, normal serialization.
retVal = base.EnterMapping(key, value, context);
retVal = base.EnterMapping(key, value, context, serializer);
}

return retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class YamlValueCollectionConverter : IYamlTypeConverter
{
public bool Accepts(Type type) => typeof(IValueCollection).IsAssignableFrom(type);

public object? ReadYaml(IParser parser, Type type) => throw new NotImplementedException();
public object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) => throw new NotImplementedException();

public void WriteYaml(IEmitter emitter, object? value, Type type)
public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
{
if (value is IValueCollection valueCollection)
{
Expand Down

0 comments on commit 1e51b2c

Please sign in to comment.