Forum: IronRuby r169 problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0e5987d3f0456799c5327d5ae47b72e1?d=identicon&s=25 Andrew Peters (Guest)
on 2008-11-05 00:09
(Received via mailing list)
Hi,

After trying out 169, all my previously passing tests are now failing
with:

failed: System.InvalidCastException : Unable to cast object of type
'IronRuby.Runtime.RubyTopLevelScope' to type
'IronRuby.Runtime.RubyContext'.
  C:\Dev\ironruby\trunk\src\ironruby\Runtime\Calls\CallArguments.cs(111,0):
at IronRuby.Runtime.Calls.CallArguments.get_RubyContext()
  C:\Dev\ironruby\trunk\src\ironruby\Runtime\Calls\MetaObjectBuilder.cs(137,0):
at
IronRuby.Runtime.Calls.MetaObjectBuilder.AddTargetTypeTest(CallArguments
args)
  C:\Dev\ironruby\trunk\src\ironruby\Runtime\Calls\RubyCallAction.cs(108,0):
at IronRuby.Runtime.Calls.RubyCallAction.Bind(MetaObjectBuilder
metaBuilder, String methodName, CallArguments args)
  C:\Dev\ironruby\trunk\src\ironruby\Runtime\Calls\RubyCallAction.cs(102,0):
at IronRuby.Runtime.Calls.RubyCallAction.Bind(MetaObject context,
MetaObject[] args)
  C:\Dev\ironruby\trunk\src\Microsoft.Scripting.Core\Actions\MetaObjectBinder.cs(61,0):
at System.Dynamic.Binders.MetaObjectBinder.Bind(Object[] args,
ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
  C:\Dev\ironruby\trunk\src\Microsoft.Scripting.Core\Actions\CallSiteOps.cs(53,0):
at
System.Runtime.CompilerServices.CallSiteOps.CreateNewRule[T](CallSite`1
site, CallSiteRule`1 oldRule, CallSiteRule`1 originalRule, Object[]
args)
  C:\Dev\ironruby\trunk\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs(428,0):
at
System.Dynamic.Binders.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2)
  at IronRuby.Classes.Template$1.CoreRender(TextWriter )
  C:\Dev\nhaml\trunk\src\NHaml\Template.cs(18,0): at
NHaml.Template.Render(TextWriter textWriter)
  at IronRuby.Classes.Template$1.Render(TextWriter )
  at _stub_$17##17(Closure , CallSite , Object , Object )
  C:\Dev\ironruby\trunk\src\Microsoft.Scripting.Core\Actions\UpdateDelegates.Generated.cs(299,0):
at
System.Dynamic.Binders.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite
site, T0 arg0, T1 arg1)
  C:\Dev\ironruby\trunk\src\Microsoft.Scripting\Runtime\DynamicOperations.cs(83,0):
at Microsoft.Scripting.Runtime.DynamicOperations.Invoke(Object obj,
Object[] parameters)
  C:\Dev\ironruby\trunk\src\Microsoft.Scripting\Hosting\ObjectOperations.cs(76,0):
at Microsoft.Scripting.Hosting.ObjectOperations.Call(Object obj,
Object[] parameters)
  C:\Dev\nhaml\trunk\src\NHaml.Compilers.IronRuby\IronRubyTemplateFactory.cs(58,0):
at
NHaml.Compilers.IronRuby.IronRubyTemplateFactory.DlrShimTemplate.Render(TextWriter
textWriter)

I'm roughly using the DLR like so:

scriptEngine = Ruby.CreateEngine();
scriptEngine.Execute(templateSource);
renderAction = _scriptEngine.CreateScriptSourceFromString(className +
".new.method(:render)").Execute();
scriptEngine.Operations.Call(renderAction, textWriter);

-- templateSource --

require 'C:\Dev\nhaml\trunk\src\Tests\bin\Debug\NHaml.dll'
require
'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll'
class Templates_IronRuby_Welcome_haml<NHaml::Template
def __a(as)
as.collect { |k,v|
next unless v
"#{k.to_s.gsub('_','-')}=\"#{v}\""
}.compact.join(' ')
end
def CoreRender(text_writer)
title = "Welcome to my ASP.NET MVC Application using NHaml!"
text_writer.Write('<h2')
text_writer.WriteLine('>')
text_writer.Write('  ')
text_writer.WriteLine(title)
text_writer.WriteLine('</h2>')
text_writer.Write('<p')
text_writer.WriteLine('>')
text_writer.Write('  ')
text_writer.WriteLine("Yeah Baby!")
text_writer.WriteLine('</p>')
end;end

-- NHaml::Template --

public abstract class Template
{
  private readonly OutputWriter _outputWriter = new OutputWriter();

  public virtual void Render(TextWriter textWriter)
  {
    Invariant.ArgumentNotNull(textWriter, "textWriter");

    _outputWriter.TextWriter = textWriter;

    PreRender(_outputWriter);
    CoreRender(textWriter);
  }

  protected virtual void PreRender(OutputWriter outputWriter)
  {
  }

  protected abstract void CoreRender(TextWriter textWriter);

  protected OutputWriter Output
  {
    get { return _outputWriter; }
  }
}

Any help appreciated.

Cheers,

Andrew.
0e5987d3f0456799c5327d5ae47b72e1?d=identicon&s=25 Andrew Peters (andrewpeters)
on 2008-11-18 07:38
Update: This is still broken on 172 except I had to change:

  def CoreRender(text_writer)

to:

  def core_render(text_writer)

first.

Cheers,

Andrew.
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2008-11-18 11:06
(Received via mailing list)
I just committed a fix for interop to our internal repository.  It
should be merged out shortly.
0e5987d3f0456799c5327d5ae47b72e1?d=identicon&s=25 Andrew Peters (andrewpeters)
on 2008-11-19 00:42
(Received via mailing list)
It works now, cheers.
This topic is locked and can not be replied to.