# Frozen .NET objects

**URL:** <https://www.ruby-forum.com/t/frozen-net-objects/180021>\
**Category:** IronRuby\
**Created:** [December 9, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/frozen-net-objects/180021 "2009-12-09T21:47:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [December 9, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/frozen-net-objects/180021/1 "2009-12-09T21:47:42Z")

</div>

I’ve noticed calling .freeze on a native .NET class does not have any  
effect (other than making #frozen? Return true)

Is this by design?

Thanks,

Nathan

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [December 9, 2009, 11:07pm UTC](https://www.ruby-forum.com/t/frozen-net-objects/180021/2 "2009-12-09T23:07:18Z")

</div>

It has an effect:

> > > System::Collections::ArrayList.freeze  
> > > =\> System::Collections::ArrayList  
> > > class System::Collections::ArrayList  
> > > … def foo  
> > > … end  
> > > … end  
> > > :0: can’t modify frozen class (TypeError)

Is there another effect you expect?

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Nathan Stults  
Sent: Wednesday, December 09, 2009 12:47 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Frozen .NET objects

I’ve noticed calling .freeze on a native .NET class does not have any  
effect (other than making #frozen? Return true)

Is this by design?

Thanks,

Nathan

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [December 9, 2009, 11:11pm UTC](https://www.ruby-forum.com/t/frozen-net-objects/180021/3 "2009-12-09T23:11:24Z")

</div>

I was freezing a live instance of a custom .NET class and half expecting  
property setters to become immutable, but I can imagine that would be  
pretty hard to implement. I do have a related question though - I would  
like to provide a read-only copy of some custom .NET DTO’s to a ruby  
script - my thinking was to inherit an adapter from DynamicObject and  
provide no-op implementation for all by TryGetMember - which is easy  
enough to do via reflection, but is there an easy way to tap into the  
DLR’s capability of doing this in a name-mangling way - i.e. a way to  
implement TryGetMember that somehow re-uses what the DLR is doing behind  
the scenes when integrating with a native .NET object?

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Tomas M.  
Sent: Wednesday, December 09, 2009 2:06 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Frozen .NET objects

It has an effect:

> > > System::Collections::ArrayList.freeze

=\> System::Collections::ArrayList

> > > class System::Collections::ArrayList

… def foo

… end

… end

:0: can’t modify frozen class (TypeError)

Is there another effect you expect?

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Nathan Stults  
Sent: Wednesday, December 09, 2009 12:47 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Frozen .NET objects

I’ve noticed calling .freeze on a native .NET class does not have any  
effect (other than making #frozen? Return true)

Is this by design?

Thanks,

Nathan
