From a6a49316d17cfa5f2add4aef4b70bd6c835f539e Mon Sep 17 00:00:00 2001 From: ayende Date: Sat, 9 Feb 2008 20:26:35 +0000 Subject: [PATCH] Fixing MR-378 git-svn-id: https://svn.castleproject.org/svn/castle/trunk@4786 73e77b4c-caa6-f847-a29a-24ab75ae54b6 --- .../BrailBugsTestCase.cs | 17 +++++++++++++++++ ...Expressions_WorkaroundForDuplicateVirtualMethods.cs | 18 +++++++++++++----- MonoRail/TestSiteBrail/TestSiteBrail-vs2005.csproj | 1 + MonoRail/TestSiteBrail/Views/bugs/mr_378.brail | 1 + 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 MonoRail/TestSiteBrail/Views/bugs/mr_378.brail diff --git a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs index de5d2d86a..ffd4de46b 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail.Tests/BrailBugsTestCase.cs @@ -70,5 +70,22 @@ namespace Castle.MonoRail.Views.Brail.Tests ProcessView_StripRailsExtension("bugs/inlineSubView.rails"); AssertReplyContains("Success"); } + + [Test] + public void MS_378_AccessingIndexers() + { + PropertyBag["Data"] = new Data(); + ProcessView("bugs/mr_378"); + } + + public class Data + { + public string[] array = new string[] { "one", "two", "three" }; + + public string[] Items + { + get { return array; } + } + } } } \ No newline at end of file diff --git a/MonoRail/Castle.MonoRail.Views.Brail/ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.cs b/MonoRail/Castle.MonoRail.Views.Brail/ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.cs index 1c8b1fff9..b41f20215 100644 --- a/MonoRail/Castle.MonoRail.Views.Brail/ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.cs +++ b/MonoRail/Castle.MonoRail.Views.Brail/ExpandDuckTypedExpressions_WorkaroundForDuplicateVirtualMethods.cs @@ -202,7 +202,11 @@ namespace Castle.MonoRail.Views.Brail } case MemberTypes.Property: { - GetSetMethod((PropertyInfo) member).Invoke(target, args); + PropertyInfo prop = (PropertyInfo)member; + if (prop.GetIndexParameters().Length != 0) + GetSetMethod(prop).Invoke(target, args); + else + SetArraySlice(GetGetMethod(prop).Invoke(target, new object[0]), args); break; } default: @@ -254,10 +258,14 @@ namespace Castle.MonoRail.Views.Brail return method.Invoke(target, args); } case MemberTypes.Property: - { - return GetGetMethod((PropertyInfo) member).Invoke(target, args); - } - default: + { + PropertyInfo prop = (PropertyInfo) member; + if (prop.GetIndexParameters().Length != 0) + return GetGetMethod(prop).Invoke(target, args); + else + return GetArraySlice(GetGetMethod(prop).Invoke(target, new object[0]), args); + } + default: { MemberNotSupported(member); return null; // this line is never reached diff --git a/MonoRail/TestSiteBrail/TestSiteBrail-vs2005.csproj b/MonoRail/TestSiteBrail/TestSiteBrail-vs2005.csproj index 3f44b5520..91351eb2a 100644 --- a/MonoRail/TestSiteBrail/TestSiteBrail-vs2005.csproj +++ b/MonoRail/TestSiteBrail/TestSiteBrail-vs2005.csproj @@ -208,6 +208,7 @@ + diff --git a/MonoRail/TestSiteBrail/Views/bugs/mr_378.brail b/MonoRail/TestSiteBrail/Views/bugs/mr_378.brail new file mode 100644 index 000000000..73500f215 --- /dev/null +++ b/MonoRail/TestSiteBrail/Views/bugs/mr_378.brail @@ -0,0 +1 @@ +${Data.Items[0]} \ No newline at end of file -- 2.11.4.GIT