Skip to content

Commit

Permalink
Updating YamlDotNet to latest version (#354)
Browse files Browse the repository at this point in the history
Fixes #353

YamlDotNet added new parameters to the `IYamlTypeConverter` methods in
[v16.0](https://github.com/aaubry/YamlDotNet/releases/tag/v16.0.0).

This PR updates the `YamlDotNet` package to latest version (v16.1.2) and
adapts custom converters to this breaking change.
  • Loading branch information
jirikopecky authored Sep 27, 2024
1 parent 01e6b9c commit 0436646
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Improvements-354.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
component: sdk/auto
kind: Improvements
body: Updating YamlDotNet to v16.1.2
time: 2024-09-26T11:55:37.551918+02:00
custom:
PR: "354"
2 changes: 1 addition & 1 deletion sdk/Pulumi.Automation/Pulumi.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</PackageReference>
<PackageReference Include="CliWrap" Version="3.3.2" />
<PackageReference Include="Grpc.AspNetCore.Server" version="2.63.0" />
<PackageReference Include="YamlDotNet" Version="11.1.1" />
<PackageReference Include="YamlDotNet" Version="16.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class ProjectRuntimeOptionsYamlConverter : IYamlTypeConverter

public bool Accepts(Type type) => type == _type;

public object ReadYaml(IParser parser, Type type)
public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
{
if (!parser.TryConsume<MappingStart>(out _))
throw new YamlException($"Unable to deserialize [{type.FullName}]. Expecting object.");
Expand Down Expand Up @@ -54,7 +54,7 @@ public object ReadYaml(IParser parser, Type type)
};
}

public void WriteYaml(IEmitter emitter, object? value, Type type)
public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
{
if (!(value is ProjectRuntimeOptions options))
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class ProjectRuntimeYamlConverter : IYamlTypeConverter

public bool Accepts(Type type) => type == _type;

public object ReadYaml(IParser parser, Type type)
public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
{
if (parser.TryConsume<Scalar>(out var nameValueScalar))
{
Expand Down Expand Up @@ -50,7 +50,7 @@ public object ReadYaml(IParser parser, Type type)
if (!parser.Accept<MappingStart>(out _))
throw new YamlException($"Unable to deserialize [{type.FullName}]. Runtime options property should be an object.");

var runtimeOptionsObj = this._optionsConverter.ReadYaml(parser, _optionsType);
var runtimeOptionsObj = this._optionsConverter.ReadYaml(parser, _optionsType, rootDeserializer);
if (!(runtimeOptionsObj is ProjectRuntimeOptions runtimeOptions))
throw new YamlException("There was an issue deserializing the runtime options object.");

Expand All @@ -69,7 +69,7 @@ static ProjectRuntimeName DeserializeName(Scalar nameValueScalar, Type type)
}
}

public void WriteYaml(IEmitter emitter, object? value, Type type)
public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
{
if (!(value is ProjectRuntime runtime))
return;
Expand All @@ -86,7 +86,7 @@ public void WriteYaml(IEmitter emitter, object? value, Type type)
emitter.Emit(new Scalar(runtime.Name.ToString().ToLower()));

emitter.Emit(new Scalar("options"));
this._optionsConverter.WriteYaml(emitter, runtime.Options, _optionsType);
this._optionsConverter.WriteYaml(emitter, runtime.Options, _optionsType, serializer);

emitter.Emit(new MappingEnd());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class StackSettingsConfigValueYamlConverter : IYamlTypeConverter

public bool Accepts(Type type) => type == _type;

public object ReadYaml(IParser parser, Type type)
public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
{
// check if plain string
if (parser.Accept<Scalar>(out var stringValue))
Expand Down Expand Up @@ -64,7 +64,7 @@ public object ReadYaml(IParser parser, Type type)
return new StackSettingsConfigValue(serializedToJson, false);
}

public void WriteYaml(IEmitter emitter, object? value, Type type)
public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer)
{
if (!(value is StackSettingsConfigValue configValue))
return;
Expand Down

0 comments on commit 0436646

Please sign in to comment.