Encountered an unresolved tag '!reference #1057
-
Given the yaml: variables:
JAVA_JDK_VERSION: 17
BUILD_NUMBER_OFFSET: 500
include:
- project: "eng-systems/templates"
file: "/build-types/java-lambda.yml"
octopus-deploy-release:
rules:
- !reference [.run_never, rules] And the code: var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.WithAttemptingUnquotedStringTypeDeserialization()
.Build();
return deserializer.Deserialize<object>(reader); We are seeing the error: Now, GitLab says we can simply add the following to
How do we account for this using the Anything else that could be tried? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You would use the var yaml = """
variables:
JAVA_JDK_VERSION: 17
BUILD_NUMBER_OFFSET: 500
include:
- project: "eng-systems/templates"
file: "/build-types/java-lambda.yml"
octopus-deploy-release:
rules:
- !reference [.run_never, rules]
""";
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.WithAttemptingUnquotedStringTypeDeserialization()
.WithTagMapping("!reference", typeof(object[]))
.Build(); Note, with the unquoted brackets it'll see it as an array. This serializes it to effectively the same yaml var o = deserializer.Deserialize<object>(yaml);
var serializer = new SerializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.WithTagMapping("!reference", typeof(object[]))
.Build();
var x = serializer.Serialize(o);
Console.WriteLine(x); Result: variables:
JAVA_JDK_VERSION: 17
BUILD_NUMBER_OFFSET: 500
include:
- project: eng-systems/templates
file: /build-types/java-lambda.yml
octopus-deploy-release:
rules:
- !reference
- .run_never
- rules |
Beta Was this translation helpful? Give feedback.
You would use the
.WithTagMapping
method on theDeserializerBuilder
.You can do
string
instead ofobject
and get the same result, just depends on what you want it to be in the end result.For example: