public override void PopulateValue(object target, IArgumentList args, IDiagnostics diags) { var arg = args.GetLastArg(OptionId); var valueString = arg?.Value ?? attribute.DefaultValue; if (valueString is null) { return; } var converter = TypeDescriptor.GetConverter(Property.PropertyType); if (!converter.CanConvertFrom(typeof(string))) { diags.ReportError( "Type converter for option '{0}' cannot convert from '{1}'.", arg.Option.PrefixedName, typeof(string).Name); return; } object value; try { value = converter.ConvertFromInvariantString(valueString); } catch (NotSupportedException) { diags.ReportError("Invalid value '{1}' in '{0}{1}'", arg.Spelling, valueString); return; } Property.SetValue(target, value); }