private T CoerceArgumentValue <T>(ArgumentValue argument)
        {
            var value = argument.Value;

            // if the argument is final and has an already coerced
            // runtime version we can skip over parsing it.
            if (!argument.IsFinal)
            {
                value = _parser.ParseLiteral(argument.ValueLiteral !, argument.Argument, typeof(T));
            }

            if (value is null)
            {
                // if there was a non-null violation the exception would already been triggered.
                return(default !);
        private T CoerceArgumentValue <T>(ArgumentValue argument)
        {
            object?value = argument.Value;

            // if the argument is final and has an already coerced
            // runtime version we can skip over parsing it.
            if (!argument.IsFinal)
            {
                value = argument.Type.ParseLiteral(argument.ValueLiteral !);
                value = argument.Formatter is not null
                    ? argument.Formatter.OnAfterDeserialize(value)
                    : value;
            }

            if (value is null)
            {
                // if there was a non-null violation the exception would already been triggered.
                return(default !);
Esempio n. 3
0
 public bool TryGetValue(NameString key, [MaybeNullWhen(false)] out ArgumentValue value) =>
 _arguments.TryGetValue(key, out value);