public IChildAdapter CreateForTesting(RemoteValue remoteValue, IRemoteValueFormat remoteValueFormat, VarInfoBuilder varInfoBuilder, string formatSpecifier, int maxCountPerRange) => RemoteValueRangedAdapter.First( maxCountPerRange, new RemoteValueChildAdapter(remoteValue, remoteValueFormat, varInfoBuilder, formatSpecifier));
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}"); }
public void TestWhenFormatSpecifierIsEmpty() { bool validFormat = RemoteValueFormatProvider.IsValidFormat(""); IRemoteValueFormat format = RemoteValueFormatProvider.Get(""); Assert.That(validFormat, Is.False); Assert.That(format, Is.Not.Null); }
public void TestFallBackOnDefaultFormatWithRawSpecifier() { bool validFormat = RemoteValueFormatProvider.IsValidFormat("!unsupportedSpecifier"); IRemoteValueFormat format = RemoteValueFormatProvider.Get("!unsupportedSpecifier"); Assert.That(validFormat, Is.False); Assert.That(format, Is.Not.Null); }
void CheckPointerFormat(string formatSpecifier, int valueInt, string expectedValue) { var remoteValue = RemoteValueFakeUtil.CreatePointer("int*", "int", valueInt.ToString()); IRemoteValueFormat format = RemoteValueFormatProvider.Get(formatSpecifier); Assert.AreEqual(format.FormatValueAsAddress(remoteValue), expectedValue); Assert.IsTrue(format.ShouldInheritFormatSpecifier()); }
RemoteValueChildAdapter(RemoteValue remoteValue, IRemoteValueFormat remoteValueFormat, VarInfoBuilder varInfoBuilder, string formatSpecifier) { _remoteValue = remoteValue; _remoteValueFormat = remoteValueFormat; _varInfoBuilder = varInfoBuilder; _formatSpecifier = formatSpecifier; }
public void TestGetWithRawFormatSpecifier( [Values(FormatSpecifierUtil.RawFormatSpecifier + SPECIFIER_1, FormatSpecifierUtil.InheritableRawFormatSpecifier + SPECIFIER_2)] string specifier) { bool validFormat = RemoteValueFormatProvider.IsValidFormat(specifier); IRemoteValueFormat format = RemoteValueFormatProvider.Get(specifier); Assert.That(validFormat, Is.True); }
void CheckFormat(string formatSpecifier, ValueFormat expectedFormat, int valueInt, string expectedValue) { var remoteValue = RemoteValueFakeUtil.CreateSimpleInt("test", valueInt); IRemoteValueFormat format = RemoteValueFormatProvider.Get(formatSpecifier); Assert.AreEqual(format.FormatValue(remoteValue, ValueFormat.Default), expectedValue); Assert.AreEqual(remoteValue.GetFormat(), expectedFormat); Assert.IsTrue(format.ShouldInheritFormatSpecifier()); }
public void ShouldInheritFormatSpecifier() { string[] formats = { "B", "b", "y", "Y", "c", "C", "F", "s", "d", "i", "E", "en", "x", "h", "X", "H", "f", "o", "O", "U", "U32", "u", "p", "I", "a" }; foreach (string formatSpecifier in formats) { IRemoteValueFormat format = RemoteValueFormatProvider.Get(formatSpecifier); Assert.That(format, Is.Not.Null); Assert.That(format.ShouldInheritFormatSpecifier(), Is.True); } }
public async Task InheritableFormatSpecifiersAreInheritedAsync() { IRemoteValueFormat lldbFormat = RemoteValueFormatProvider.Get("x"); Assert.That(lldbFormat, Is.Not.Null); Assert.That(lldbFormat.ShouldInheritFormatSpecifier(), Is.True); var childAdapter = new RemoteValueChildAdapter.Factory().Create( remoteValue, lldbFormat, varInfoBuilder, formatSpecifier: "x"); CollectionAssert.AreEqual(new[] { "x", "x", "x", "x" }, await GetAllChildFormatSpecifiersAsync(childAdapter)); }
public RemoteValueVariableInformation(VarInfoBuilder varInfoBuilder, string formatSpecifier, IRemoteValueFormat remoteValueFormat, ValueFormat fallbackValueFormat, RemoteValue remoteValue, string displayName, CustomVisualizer customVisualizer, IRemoteValueChildAdapterFactory childAdapterFactory) { _varInfoBuilder = varInfoBuilder; _remoteValueFormat = remoteValueFormat; _remoteValue = remoteValue; _childAdapterFactory = childAdapterFactory; DisplayName = displayName; FormatSpecifier = formatSpecifier; FallbackValueFormat = fallbackValueFormat; CustomVisualizer = customVisualizer; Id = Guid.NewGuid().ToString(); }
public void ReturnsError() { const string errorStr = "error"; string error = null; var remoteValue = Substitute.For <RemoteValue>(); remoteValue.GetPointeeAsByteString(1, Arg.Any <uint>(), out error) .Returns(x => { x[2] = errorStr; return(null); }); IRemoteValueFormat format = RemoteValueFormatProvider.Get("s"); Assert.AreEqual(errorStr, format.FormatValue(remoteValue, _fallback)); Assert.IsNull(format.FormatStringView(remoteValue, _fallback)); }
public IChildAdapter Create(RemoteValue remoteValue, IRemoteValueFormat remoteValueFormat, VarInfoBuilder varInfoBuilder, string formatSpecifier) => CreateForTesting(remoteValue, remoteValueFormat, varInfoBuilder, formatSpecifier, _remoteValueCountPerRange);