Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentOutOfRangeException in RuntimeBinder.Syntax.NameTable.Add(String key, Int32 length) when invoking dynamic object #23477

Closed
conniey opened this issue Sep 7, 2017 · 2 comments

Comments

@conniey
Copy link
Member

conniey commented Sep 7, 2017

Repro Steps
Execute the following:

  • git clone -b updateToNetCore https://github.com/conniey/RazorEngine.git
  • dotnet restore .\src\RazorEngine.NetCore.sln
  • dotnet build .\src\RazorEngine.NetCore.sln
  • dotnet test .\src\test\Test.RazorEngine.Core\Test.RazorEngine.Core.NetCore.csproj --no-build --filter "FullyQualifiedName~Issue67_CollectionOfAnonymous" --framework netcoreapp2.0

Expected
It passes. It passes when executed on .NET 4.6.2 and used to work on .NET Core 2.0 preview.

  • dotnet test .\src\test\Test.RazorEngine.Core\Test.RazorEngine.Core.NetCore.csproj --no-build --filter "FullyQualifiedName~Issue67_CollectionOfAnonymous" --framework net462

Actual
Test fails with an ArgumentOutOfRangeException. I checked the output binaries for .NET 4.6.2 and .NET Core 2.0. They appear exactly the same, aside from references to .NET Framework in the first case and the .NET Core references in the other. (The files are output to a folder like: %TEMP%\RazorEngine_.)

Test Name:  Issue67_CollectionOfAnonymous
Test FullName:  RazorEngine.Tests.TestTypes.Issues.Release_3_6_TestFixture.Issue67_CollectionOfAnonymous
Test Source:    D:\git\conniey\RazorEngine\src\test\Test.RazorEngine.Core\Issues\Release_3_6_TestFixture.cs : line 81
Test Outcome:   Failed
Test Duration:  0:00:00.579
Result Message: 
System.ArgumentOutOfRangeException : Length cannot be less than zero.
Parameter name: length
Result StackTrace:  
at System.String.Substring(Int32 startIndex, Int32 length)
   at Microsoft.CSharp.RuntimeBinder.Syntax.NameTable.Add(String key, Int32 length)
   at Microsoft.CSharp.RuntimeBinder.Syntax.NameManager.Add(String key, Int32 length)
   at Microsoft.CSharp.RuntimeBinder.SymbolTable.GetName(Type type)
   at Microsoft.CSharp.RuntimeBinder.SymbolTable.LoadSymbolsFromType(Type originalType)
   at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.InitializeCallingContext(ICSharpBinder payload)
   at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.BindCore(ICSharpBinder payload, Expression[] parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)
   at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload, Expression[] parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)
   at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, DynamicMetaObject[] args, IEnumerable`1 arginfos, DynamicMetaObject onBindingError)
   at Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
   at System.Dynamic.DynamicMetaObject.BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
   at System.Dynamic.InvokeMemberBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args)
   at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
   at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at RazorEngine.Compilation.ImpromptuInterface.Optimization.InvokeHelper.InvokeMemberTargetType[TTarget,TReturn](CallSite& callsite, Type binderType, Int32 knownType, LazyBinder binder, String_OR_InvokeMemberName name, Boolean staticContext, Type context, String[] argNames, TTarget target, Object[] args) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\DynamicObject\Impromtu\InvokeHelper.cs:line 317
   at RazorEngine.Compilation.ImpromptuInterface.Optimization.InvokeHelper.InvokeMember[TReturn](CallSite& callsite, Type binderType, Int32 knownType, LazyBinder binder, String_OR_InvokeMemberName name, Boolean staticContext, Type context, String[] argNames, Object target, Object[] args) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\DynamicObject\Impromtu\InvokeHelper-Regular.cs:line 298
   at RazorEngine.Compilation.ImpromptuInterface.Optimization.InvokeHelper.InvokeMemberCallSite(Object target, String_OR_InvokeMemberName name, Object[] args, String[] tArgNames, Type tContext, Boolean tStaticContext, CallSite& callSite) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\DynamicObject\Impromtu\InvokeHelper-Regular.cs:line 445
   at RazorEngine.Compilation.ImpromptuInterface.Impromptu.InvokeMember(Object target, String_OR_InvokeMemberName name, Object[] args) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\DynamicObject\Impromtu\Impromtu.cs:line 179
   at RazorEngine.Compilation.ImpromptuInterface.Dynamic.Invocation.Invoke(Object target, Object[] args) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\DynamicObject\Impromtu\Invocation.cs:line 242
   at RazorEngine.Compilation.ImpromptuInterface.Dynamic.Invocation.InvokeWithStoredArgs(Object target) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\DynamicObject\Impromtu\Invocation.cs:line 302
   at RazorEngine.Compilation.RazorDynamicObject.MarshalWrapper.GetResult(Invocation invocation) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\RazorDynamicObject.cs:line 140
   at RazorEngine.Compilation.RazorDynamicObject.RemoteInvoke(Invocation invocation, Object& result) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\RazorDynamicObject.cs:line 462
   at RazorEngine.Compilation.RazorDynamicObject.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Compilation\RazorDynamicObject.cs:line 600
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at ActLike_IEnumerator`1_9c672819f42145cd95938ca2764cccd5.MoveNext()
   at CompiledRazorTemplates.Dynamic.RazorEngine_2b03143873ed48859513f94d70844003.<Execute>d__1.MoveNext() in C:\Users\conniey\AppData\Local\Temp\RazorEngine_0mbewxcu.exl\CompiledRazorTemplates.Dynamic.RazorEngine_2b03143873ed48859513f94d70844003.cs:line 1
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at RazorEngine.Templating.TemplateBase.<Run>d__32.MoveNext() in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\TemplateBase.cs:line 230
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at RazorEngine.Templating.RazorEngineCore.<RunTemplate>d__12.MoveNext() in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineCore.cs:line 155
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineService.cs:line 278
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineService.cs:line 257
   at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\DynamicWrapperService.cs:line 102
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineServiceExtensions.cs:line 142
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineServiceExtensions.cs:line 254
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineServiceExtensions.cs:line 222
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineServiceExtensions.cs:line 254
   at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag) in D:\git\conniey\RazorEngine\src\source\RazorEngine.Core\Templating\RazorEngineServiceExtensions.cs:line 326
   at RazorEngine.Tests.TestTypes.Issues.Release_3_6_TestFixture.<>c.<Issue67_CollectionOfAnonymous>b__1_0(IRazorEngineService service) in D:\git\conniey\RazorEngine\src\test\Test.RazorEngine.Core\Issues\Release_3_6_TestFixture.cs:line 95
   at Test.RazorEngine.RazorEngineServiceTestFixture.RunTestHelper(Action`1 test, Action`1 withConfig) in D:\git\conniey\RazorEngine\src\test\Test.RazorEngine.Core\RazorEngineServiceTestFixture.cs:line 49
   at RazorEngine.Tests.TestTypes.Issues.Release_3_6_TestFixture.Issue67_CollectionOfAnonymous() in D:\git\conniey\RazorEngine\src\test\Test.RazorEngine.Core\Issues\Release_3_6_TestFixture.cs:line 82
@JonHanna
Copy link
Contributor

JonHanna commented Sep 7, 2017

Duplicate of #22544

@karelz
Copy link
Member

karelz commented Sep 8, 2017

Closing as dupe of #22544

@karelz karelz closed this as completed Sep 8, 2017
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants