public static string GetChildFormatSpecifier(string formatSpecifier, IRemoteValueFormat valueFormat) { formatSpecifier = Clean(formatSpecifier); if (!TrySplitSpecifier(formatSpecifier, out string size, out string raw, out string baseSpecifier)) { // If we do not have the plain base formatter, let us inherit 'view' and // inheritable raw formatter (we ignore 'expand' as it is not inherited). raw = formatSpecifier.StartsWith(InheritableRawFormatSpecifier) ? InheritableRawFormatSpecifier : ""; baseSpecifier = RemoveRawFormatSpecifierPrefix(formatSpecifier); if (string.IsNullOrEmpty(NatvisViewsUtil.ParseViewFormatSpecifier(baseSpecifier))) { baseSpecifier = ""; } return(raw + baseSpecifier); } // Remove the non-inheritable ! specifier. if (raw == RawFormatSpecifier) { raw = ""; } // Let the valueFormat decide whether to inherit the type. Note: Some types are not // represented as IRemoteValueFormat, e.g "na". These are not inherited, though. if (!valueFormat.ShouldInheritFormatSpecifier()) { baseSpecifier = ""; } return($"{raw}{baseSpecifier}"); }
/// <summary> /// Returns true if |formatSpecifier| is a valid format specifier, i.e. if it's handled /// by some base formatter (possibly with size and raw specifiers) or if it's a misc other /// format specifier like "view(foo)" that maps to RemoteValueFormat.Default. /// </summary> public static bool IsValidFormat(string formatSpecifier) { // TODO We should support more combinations of formatters, e.g., // size specifier can be combined with 'view', etc. // Pass a dummy size to correctly resolve the case when size specifier is an expression. return(ParseFormat(formatSpecifier, 0U) != null || ExpandFormatSpecifierUtil.TryParseExpandFormatSpecifier(formatSpecifier, out _) || !string.IsNullOrEmpty(NatvisViewsUtil.ParseViewFormatSpecifier(formatSpecifier))); }