public void IncorrectNumberOfIndices() { dynamic d = new int[2, 2, 2]; RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => d[1] = 0); Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4] = 0); Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); ex = Assert.Throws <RuntimeBinderException>(() => d[1]); Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4]); Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); d = new int[2]; ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4] = 0); Assert.Contains("[]", ex.Message); Assert.Contains("'1'", ex.Message); ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4]); Assert.Contains("[]", ex.Message); Assert.Contains("'1'", ex.Message); }
public void NonIndexerParameterizedSetterOnlyIndexAccess() { dynamic d = GetObjectWithNonIndexerParameterProperty(false, true); RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => d.ItemProp[2] = 9); // Similar message to CS1546 advises about setter method. Assert.Contains("set_ItemProp", ex.Message); }
public void InnerExceptionCtor() { string message = "This is a test message."; Exception inner = new Exception("This is a test exception"); RuntimeBinderException rbe = new RuntimeBinderException(message, inner); Assert.Same(inner, rbe.InnerException); }
public TreeNode Fallback(IAstObject item, RuntimeBinderException excException) { if (ReferenceEquals(item, null)) { return(new TreeNode("Null Node!")); } return(new TreeNode("Unhandled Node Object")); }
public void NullaryCtor() { RuntimeBinderException rbe = new RuntimeBinderException(); Assert.Null(rbe.InnerException); Assert.Empty(rbe.Data); Assert.True((rbe.HResult & 0xFFFF0000) == 0x80130000); // Error from .NET Assert.Contains(rbe.GetType().FullName, rbe.Message); // Localized, but should contain type name. }
public void InnerExceptionCtor() { string message = "This is a test message."; Exception inner = new Exception("This is a test exception"); RuntimeBinderException rbe = new RuntimeBinderException(message, inner); Assert.Same(inner, rbe.InnerException); BinaryFormatterHelpers.AssertRoundtrips(rbe); }
public void NonIndexerParameterizedGetterAndSetterIndexAccess() { dynamic d = GetObjectWithNonIndexerParameterProperty(true, true); RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => d.ItemProp[2] = 3); // Similar message to CS1545 advises about getter and setter methods. Assert.Contains("get_ItemProp", ex.Message); Assert.Contains("set_ItemProp", ex.Message); }
public virtual void Fallback(ISyntaxTreeElement objItem, RuntimeBinderException excException) { //If the object is null do nothing if (objItem == null) { return; } AddInternalComment("Syntax element not implemented: ", objItem.ToString()); }
public void MultiDimArrayTypeNames() { dynamic d = new int[3, 2, 1]; RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => { string s = d; }); Assert.Contains("int[,,]", ex.Message); d = Array.CreateInstance(typeof(int), new[] { 3, 2, 1 }, new[] { -2, 2, -0 }); ex = Assert.Throws <RuntimeBinderException>(() => { string s = d; }); Assert.Contains("int[,,]", ex.Message); }
public void ArrayTypeNames() { dynamic d = Array.CreateInstance(typeof(int), new[] { 8 }, new[] { -2 }); RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => { string s = d; }); Assert.Contains("int[*]", ex.Message); d = new int[3]; ex = Assert.Throws <RuntimeBinderException>(() => { string s = d; }); Assert.Contains("int[]", ex.Message); }
public void Fallback(IIronyAstObject objItem, RuntimeBinderException excException) { if (ReferenceEquals(objItem, null)) { Log.Append("<Unrecognized null object"); } else { Log.Append("<Unrecognized object " + objItem + ">"); } }
public void StringCtor() { string message = "This is a test message."; RuntimeBinderException rbe = new RuntimeBinderException(message); Assert.Null(rbe.InnerException); Assert.Empty(rbe.Data); Assert.True((rbe.HResult & 0xFFFF0000) == 0x80130000); // Error from .NET Assert.Same(message, rbe.Message); rbe = new RuntimeBinderException(null); Assert.Equal(new RuntimeBinderException().Message, rbe.Message); }
private void WrapRuntimeBinderExceptionAndRethrow( string errorProperty, RuntimeBinderException rbe) { throw new PackageJsonException( string.Format(@"Exception occurred retrieving {0} from package.json. The file may be invalid: you should edit it to correct an errors. The following error occurred: {1}", errorProperty, rbe)); }
public void MultiDimArrayTypeNames() { dynamic d = new int[3, 2, 1]; RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => { string s = d; }); Assert.Contains("int[,,]", ex.Message); if (PlatformDetection.IsNonZeroLowerBoundArraySupported) { d = Array.CreateInstance(typeof(int), new[] { 3, 2, 1 }, new[] { -2, 2, -0 }); ex = Assert.Throws <RuntimeBinderException>(() => { string s = d; }); Assert.Contains("int[,,]", ex.Message); } }
public void IncorrectNumberOfIndices() { dynamic d = new int[2, 2, 2]; RuntimeBinderException ex = Assert.Throws <RuntimeBinderException>(() => d[1] = 0); if (!PlatformDetection.IsNetNative) // .NET Native toolchain optimizes away Exception messages. { Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); } ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4] = 0); if (!PlatformDetection.IsNetNative) // .NET Native toolchain optimizes away Exception messages. { Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); } ex = Assert.Throws <RuntimeBinderException>(() => d[1]); if (!PlatformDetection.IsNetNative) // .NET Native toolchain optimizes away Exception messages. { Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); } ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4]); if (!PlatformDetection.IsNetNative) // .NET Native toolchain optimizes away Exception messages. { Assert.Contains("[]", ex.Message); Assert.Contains("'3'", ex.Message); } d = new int[2]; ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4] = 0); if (!PlatformDetection.IsNetNative) // .NET Native toolchain optimizes away Exception messages. { Assert.Contains("[]", ex.Message); Assert.Contains("'1'", ex.Message); } ex = Assert.Throws <RuntimeBinderException>(() => d[1, 2, 3, 4]); if (!PlatformDetection.IsNetNative) // .NET Native toolchain optimizes away Exception messages. { Assert.Contains("[]", ex.Message); Assert.Contains("'1'", ex.Message); } }
public void TestSerialization1() { var dish = new Dish { Recipes = new List <Recipe> { new Recipe { Name = "Recipe A", }, new Recipe { Name = "Recipe B", }, } }; var json = JsonConvert.SerializeObject(dish); dynamic ds = JsonConvert.DeserializeObject(json); object jRecipes = null; RuntimeBinderException exception = null; try { jRecipes = ds.recipes; } catch (RuntimeBinderException e) { exception = e; } Assert.That(exception, Is.Null, "recipes field should not be serialized."); Assert.That((string)ds.RecipesSummary[0].Name, Is.EqualTo("Recipe A")); Assert.That((string)ds.RecipesSummary[1].Name, Is.EqualTo("Recipe B")); }
private static PackageJsonException WrapRuntimeBinderException(string errorProperty, RuntimeBinderException rbe) { return(new PackageJsonException( string.Format(CultureInfo.CurrentCulture, @"Exception occurred retrieving {0} from package.json. The file may be invalid: you should edit it to correct an errors. The following error occurred: {1}", errorProperty, rbe))); }
public TreeNode Fallback(IIronyAstObject objItem, RuntimeBinderException excException) { return(new TreeNode("Unrecognized Node!")); }
public virtual ISyntaxTreeElement Fallback(ISyntaxTreeElement objItem, RuntimeBinderException excException) { return(objItem); }
/// <summary> /// The fall back method that is called if no matching visit method is found and UseExceptions flag is false /// </summary> /// <param name="value1"></param> /// <param name="value2"></param> /// <param name="excException"></param> /// <returns></returns> public abstract ILanguageValue Fallback(ILanguageValue value1, ILanguageValue value2, RuntimeBinderException excException);
public void Fallback(IIronyAstObject objItem, RuntimeBinderException excException) { throw new NotImplementedException(); }
public virtual void Fallback(IAstObject objItem, RuntimeBinderException excException) { }
public override ILanguageValue Fallback(ILanguageValue value1, RuntimeBinderException excException) { throw new NotImplementedException(); }
public void _01() { RuntimeBinderException exception = Assert.Throws <RuntimeBinderException>(() => { C10.Fn01(); }); Assert.Equal("Cannot implicitly convert type 'string' to 'int'", exception.Message); }
public void Fallback(IIronyAstObject objItem, RuntimeBinderException excException) { }