<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.eiffelroom.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>eiffelroom - Create .NET Properties in Eiffel - Comments</title>
 <link>http://www.eiffelroom.org/article/create_net_properties_in_eiffel</link>
 <description>Comments for &quot;Create .NET Properties in Eiffel&quot;</description>
 <language>en</language>
<item>
 <title>Create .NET Properties in Eiffel</title>
 <link>http://www.eiffelroom.org/article/create_net_properties_in_eiffel</link>
 <description>&lt;p&gt;.NET properties are a fundamental part of the CLR and CTS. They are used in a plethora of ways by Microsoft, ISVs and your other developers. For a number of users .NET properties are just a syntactical sugar unifying a getter function and setter routine, and opening up access to encapsulated internal fields. Other common uses of properties provide a means validate client input on a setter and raising an exception if the input does not conform, or supporting performance scenarios such as lazy evaluation and caching.&lt;/p&gt;

&lt;p&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Although DbC, in the case of validating client input, can been seen as a replacement for the exception model it&#039;s not the be all and end all when working with .NET. When you release your assembly it typically will not contain contracts, unless you specifically release a &amp;quot;debug&amp;quot; version also (&lt;em&gt;It is not recommended to release only a debug version because the contracts bulk code size and decrease performance.&lt;/em&gt;) When using your assembly from another language those contracts will not be checked, It is therefore important to raise the correct exception when necessary. When your working to interop with the .NET world you should be working using .NET rules, conventions and other practices.&lt;/p&gt;

&lt;/p&gt;

&lt;p&gt;Properties open up the whole new world of development scenarios, from creating Windows Forms/WPF controls, web services, true reflection based applications and much, much more. EiffelEnvision is now written in Eiffel for .NET and makes heavy use of properties. EiffelEnvision&#039;s integration into &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/wea2sca5.aspx&quot;&gt;MsBuild&lt;/a&gt; would be an impossibility without Eiffel for .NET properties.&lt;/p&gt;


&lt;h2 id=&quot;toc0&quot;&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;The Eiffel language (what is refer to as &amp;quot;classic&amp;quot; Eiffel) has not been changed to support Eiffel for .NET. With the classic version of the language remaining the same, Eiffel Software had to provide extension points to support Eiffel for .NET, which is done through using the &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;indexing&lt;/span&gt;&lt;/code&gt; clauses (Soon to be &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;note&lt;/span&gt;&lt;/code&gt; due to ECMA conformance.) It is actually possible to write a .NET application using just Eiffel libraries and compile it upon a Linux installation, using classic code generation. The vice versa is also equally possible&lt;/p&gt;

&lt;p&gt;Now lets get on with examples. Take the following snippet of Eiffel code:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;deferred&lt;/span&gt; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;class&lt;/span&gt; TEXT_BASE&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;feature&lt;/span&gt; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Access&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; text: SYSTEM_STRING&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Actual text representation&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;invariant&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; not_text_is_empty: &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;is_null_or_empty&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;text&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;The examples introduces the class &lt;code class=&quot;geshifilter eiffel&quot;&gt;TEXT_BASE&lt;/code&gt;, for all descendants whom wish to expose a representation in a textual form. In Eiffel clients of &lt;code class=&quot;geshifilter eiffel&quot;&gt;TEXT_BASE&lt;/code&gt; have access to &lt;code class=&quot;geshifilter eiffel&quot;&gt;text&lt;/code&gt;, by default, because &lt;code class=&quot;geshifilter eiffel&quot;&gt;text&lt;/code&gt; is implicitly exported to &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+ANY&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;ANY&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When compiled for .NET the implementation class for &lt;code class=&quot;geshifilter eiffel&quot;&gt;TEXT_BASE&lt;/code&gt; with contain a .NET field with the name &amp;quot;&lt;code class=&quot;geshifilter csharp&quot;&gt;$$text&lt;/code&gt;&amp;quot; returning a &lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;String&lt;/span&gt;&lt;/code&gt;. The name &amp;quot;&lt;code class=&quot;geshifilter csharp&quot;&gt;$$text&lt;/code&gt;&amp;quot; is a mangled name and is not intended for direct use (Implementation types are not meant to be used from other languages and contain many implementation specifics that have no valuable used except to the internals of the assembly generated.)&lt;/p&gt;

&lt;p&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The .NET framework does not support multiple inheritance and probably will not for a very long time, if ever. Eiffel for .NET on the other hand is Eiffel so it does support multiple inheritance. To support multiple inheritance an Eiffel class is represented as three different .NET type entities in a generated assembly. There is; an implementation class, an interface and a factory type used for instantiating Eiffel types from other languages. I&#039;m not going to go into details of how this works because that is an article in itself. As noted, this is not a beginner article.&lt;/p&gt;

&lt;/p&gt;

&lt;p&gt;Consumers of an assembly written in Eiffel for .NET have access to &lt;code class=&quot;geshifilter eiffel&quot;&gt;text&lt;/code&gt; through a function call defined on &lt;code class=&quot;geshifilter eiffel&quot;&gt;TEXT_BASE&lt;/code&gt;&#039;s generated interface. It is a function call because .NET interfaces prohibit field definitions for obvious reasons. A function call is not the most respected way to retrieve an object attribute as it implies some logical computation to arrive at the result and, in many cases, indicates that an object reference that is return will differ on subsequent calls. What is really needed is a property!&lt;/p&gt;

&lt;p&gt;Through the use of &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;indexing&lt;/span&gt;&lt;/code&gt; and an Eiffel for .NET specific indexing term, &lt;code class=&quot;geshifilter eiffel&quot;&gt;property&lt;/code&gt;, a property can be defined on a generated Eiffel class&#039; interface.&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;text: SYSTEM_STRING&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Actual text representation&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;indexing&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; property: auto&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;In C#, a consuming project would be able to use&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter csharp&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;// C# code for retrieving the value of a TEXT_BASE&#039;s text property.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt; GetText &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;TEXT_BASE tb&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt; tb.&lt;span style=&quot;color: #000000;&quot;&gt;text&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Note that &lt;code class=&quot;geshifilter eiffel&quot;&gt;text&lt;/code&gt; has been augmented with an indexing clauses and property term. The reserved property term value &lt;code class=&quot;geshifilter eiffel&quot;&gt;auto&lt;/code&gt; is used to instruct the compiler to automatically generate a property name based on the Eiffel attribute name. Alternatively a different name can be supplied for the property for external consumers of the generated assembly. To accomplish this, instead of specify &lt;code class=&quot;geshifilter eiffel&quot;&gt;auto&lt;/code&gt; specify an identifier name as an Eiffel string:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;text: SYSTEM_STRING&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Actual text representation&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;indexing&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; property: &lt;span style=&quot;color: #0080A0;&quot;&gt;&amp;quot;my_text_property&amp;quot;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;C# consumer clients will then have to use the &lt;code class=&quot;geshifilter csharp&quot;&gt;my_text_property&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter csharp&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;// C# code for retrieving the value of a TEXT_BASE&#039;s text property.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt; GetText &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;TEXT_BASE tb&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt; tb.&lt;span style=&quot;color: #000000;&quot;&gt;my_text_property&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000;&quot;&gt;// The following comment code will not compile if uncommented as the property text does not exist.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000;&quot;&gt;// return tb.text;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;That&#039;s it, properties in Eiffel for .NET.&lt;/p&gt;


&lt;h2 id=&quot;toc1&quot;&gt;But Wait... There&#039;s More&lt;/h2&gt;
&lt;p&gt;So far you&#039;ve only seen read-only property. Any attempt to set the property will result in a compilation error, because there is no associated property setter. Eiffel for .NET properties do not magical inherit new semantics to support setting without explicitly defining those semantics. To do so would break one of the core principles of Eiffel, allowing external the modification of a object&#039;s state.&lt;/p&gt;

&lt;p&gt;The new assigner mechanism defined in the ECMA standard give way to the solution for creating a .NET property that is both read/write.&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;deferred&lt;/span&gt; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;class&lt;/span&gt; TEXT_BASE&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;feature&lt;/span&gt; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Access&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; text: SYSTEM_STRING &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;assign&lt;/span&gt; set_text&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Actual text representation&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;indexing&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; property: auto&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;feature&lt;/span&gt; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Element change&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; set_text &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;a_text: &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;like&lt;/span&gt; text&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Set `text&#039; with `a_text&#039;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;require&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; not_a_text_is_empty: &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;is_null_or_empty&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;a_text&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; text := a_text&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;ensure&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; text_set: &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;equals&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;text, a_text&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;invariant&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; not_text_is_empty: &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;is_null_or_empty&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;text&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;code class=&quot;geshifilter eiffel&quot;&gt;text&lt;/code&gt; attribute mark with and assigner (using the &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;assign&lt;/span&gt;&lt;/code&gt; keyword), C# users will be able to do the following:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter csharp&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;// C# code for setting a TEXT_BASE&#039;s text property.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0000FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000FF;&quot;&gt;void&lt;/span&gt; SetText &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;TEXT_BASE tb, &lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt; text&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;tb == &lt;span style=&quot;color: #0000FF;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;throw&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ArgumentException &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;tb&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;IsNullOrEmpty&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;text&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000FF;&quot;&gt;throw&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ArgumentException &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000;&quot;&gt;// Valid because the generated .NET property &#039;text&#039; has a setter&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; tb.&lt;span style=&quot;color: #000000;&quot;&gt;text&lt;/span&gt; = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; Debug.&lt;span style=&quot;color: #000000;&quot;&gt;Assert&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;text == tb.&lt;span style=&quot;color: #000000;&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;In addition, due to the declaration of an assigner, Eiffel clients of TEXT_BASE will also be able to use a similar code style convention:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;feature&lt;/span&gt; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Basic operations&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; set_text &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;tb: TEXT_BASE; text: SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;require&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tb_attached: tb /= &lt;span style=&quot;color: #800080;&quot;&gt;Void&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; not_text_is_empty: &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;is_null_or_empty&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;text&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Valid because the the Eiffel attribute `text&#039; has the assigner `set_text&#039;.&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tb.&lt;span style=&quot;color: #000060;&quot;&gt;text&lt;/span&gt; := text&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;ensure&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; text_set: &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;SYSTEM_STRING&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;equals&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#40;&lt;/span&gt;text, tb.&lt;span style=&quot;color: #000060;&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;In both cases for C# and Eiffel the resulting call to the above assignment is always a call to &lt;code class=&quot;geshifilter eiffel&quot;&gt;TEXT_BASE.&lt;span style=&quot;color: #000060;&quot;&gt;set_text&lt;/span&gt;&lt;/code&gt;. &lt;code class=&quot;geshifilter eiffel&quot;&gt;text&lt;/code&gt; will never be set directly.&lt;/p&gt;


&lt;h2 id=&quot;toc2&quot;&gt;What Next?&lt;/h2&gt;
&lt;p&gt;In a move to make your Eiffel assemblies look and feel more like other assemblies created in other languages, I&#039;ll be publishing future articles that discuss &amp;quot;Single Types&amp;quot; and .NET constructors in Eiffel. Using a compound of these features allows consumers of Eiffel for .NET assemblies to use a more standard way to instantiating type and accessing members. I&#039;ll guide you through the simple steps it takes to convert code used with Eiffel assemblies:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter csharp&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;// Using Eiffel from C#&lt;/span&gt;&lt;br /&gt;
GREETING t = Create.&lt;span style=&quot;color: #000000;&quot;&gt;GREETING&lt;/span&gt;.&lt;span style=&quot;color: #000000;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
t.&lt;span style=&quot;color: #000000;&quot;&gt;set_name&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Paul&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
t.&lt;span style=&quot;color: #000000;&quot;&gt;say_hello&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;...into...&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter csharp&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;// Using a single type in Eiffel from C#&lt;/span&gt;&lt;br /&gt;
Greeting t = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Greeting &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
t.&lt;span style=&quot;color: #000000;&quot;&gt;Name&lt;/span&gt; = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Paul&amp;quot;&lt;/span&gt;;&lt;br /&gt;
t.&lt;span style=&quot;color: #000000;&quot;&gt;SayHello&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/p&gt;

</description>
 <comments>http://www.eiffelroom.org/article/create_net_properties_in_eiffel#comments</comments>
 <category domain="http://www.eiffelroom.org/taxonomy/term/3">Tutorial</category>
 <category domain="http://www.eiffelroom.org/taxonomy/term/8">Intermediate</category>
 <category domain="http://www.eiffelroom.org/tag/net_0">.NET</category>
 <category domain="http://www.eiffelroom.org/tag/language">language</category>
 <category domain="http://www.eiffelroom.org/tag/properties">properties</category>
 <pubDate>Wed, 28 Feb 2007 11:26:55 -0800</pubDate>
 <dc:creator>paulbates</dc:creator>
 <guid isPermaLink="false">109 at http://www.eiffelroom.org</guid>
</item>
</channel>
</rss>
