Open ganeshnj opened 4 years ago
I played around with node deserilization classes and able to correctly parse the short form intrinsic functions. (Using YamlDotNet 4.2.1.0)
class NodeDeserializer : INodeDeserializer
{
private readonly HashSet<string> intrinsicFunctionShortForms;
private readonly IDeserializer deserializer;
public IntrinsicFunctionShortFormNodeDeserializer(IDeserializer deserializer)
{
this.deserializer = deserializer;
}
public IntrinsicFunctionShortFormNodeDeserializer(IDeserializer deserializer, HashSet<string> intrinsicFunctionShortForms)
{
this.deserializer = deserializer;
this.intrinsicFunctionShortForms = intrinsicFunctionShortForms;
}
public bool Deserialize(IParser reader, Type expectedType, Func<IParser, Type, object> nestedObjectDeserializer, out object value)
{
if (reader.Accept<Scalar>(out var scalar))
{
if (intrinsicFunctionShortForms.Contains(scalar.Tag))
{
value = $"{scalar.Tag} {scalar.Value}";
reader.MoveNext();
return true;
}
}
value = null;
return false;
}
}
class NodeTypeResolver : INodeTypeResolver
{
private readonly HashSet<string> intrinsicFunctionShortForms;
public IntrinsicFunctionShortFormINodeTypeResolver(HashSet<string> intrinsicFunctionShortForms)
{
this.intrinsicFunctionShortForms = intrinsicFunctionShortForms;
}
public bool Resolve(NodeEvent nodeEvent, ref Type currentType)
{
if (!string.IsNullOrEmpty(nodeEvent.Tag) && intrinsicFunctionShortForms.Contains(nodeEvent.Tag))
{
currentType = typeof(string);
return true;
}
return false;
}
}
Any update on this?
What is intrinsic functions? AWS CloudFormation provides several built-in functions that help you manage your stacks. Use intrinsic functions in your templates to assign values to properties that are not available until runtime. Read more
Syntax for the full function name:
Syntax for the short form:
Issue Short form intrinsic function deserialization fails with
Sample project ConsoleApp1.zip