[Ironruby-core] CLR interop bug?

Ivan Porto Carrero ivan at flanders.co.nz
Tue Jun 9 15:27:47 EDT 2009


Hi
What is the nitty gritty around monkey patching CLR classes. When I'm monkey
patching I should be able to get to the protected members of a class right?
And the private members too (I see it kind of like partial classes)?

public class AggregatorRepository :
RepositoryBase<MediaAggregatorModelUnitOfWork>
{
    public
AggregatorRepository(UnitOfWorkScopeBase<MediaAggregatorModelUnitOfWork>
unitOfWorkScope) : base(unitOfWorkScope)
    {
    }

    //Some C# methods here that use Linq and Expressions for querying

}

Repository base defines a protected property UnitOfWorkScope

I monkey patched it like so

module MediaAggregator
  module Models
    module Lightspeed

      class AggregatorRepository

        def users
          uow.method(:find).of(User).call
        end

        def uow
          self.unit_of_work_scope.current
        end

      end
    end
  end
end

Calling the users method result in an error complaining about a protected
unit_of_work_scope method. And ironically the error talks about my situation
as being the solution:
*
*
*C**LR protected method `unit_of_work_scope' called for
MediaAggregator.Models.Lightspeed.AggregatorRepository:MediaAggregator::Models::Lightspeed::AggregatorRepository;
CLR protected methods can only be called with a receiver whose class is a
subclass of the class declaring the method*


Do I put this on codeplex or am I reading the error wrong? As far as I can
tell I am subclassing a class.



---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090609/789e76f7/attachment.html>


More information about the Ironruby-core mailing list