<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>It should be possible. However, note that you create the .dll
using clr.GetSubclassedTypes (and clr.CompileSubclassedTypes) which requires
you to run your application with all the scenarios you care about. You can&#8217;t
just run a simple command line like &#8220;csc.exe foo.cs&#8221; and get a dll.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";
color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext'> users-bounces@lists.ironpython.com
[mailto:users-bounces@lists.ironpython.com] <b>On Behalf Of </b>Lukas Cenovsky<br>
<b>Sent:</b> Monday, November 02, 2009 9:29 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] .NET attributes for methods<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I was thinking about this... Does ir mean that (after adding
such support to clrtype) and building a .dll from the interface class, this
class can be used from c#?<br>
<br>
--<br>
-- Lukáš<br>
<br>
<br>
Shri Borde wrote: <o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The clrtype module could be extended to make it possible to
declare CLR interfaces in Python code. Something like:</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";
color:#1F497D'>class IFoo(object):</span><o:p></o:p></p>

<p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Courier New";
color:red'>&nbsp;&nbsp;&nbsp; __metaclass__ = ClrType.ClrInterface # Proposed
way to indicate an interface</span></b><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";
color:#1F497D'>&nbsp;&nbsp;&nbsp; @clrtype.accepts(int, str)</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";
color:#1F497D'>&nbsp;&nbsp;&nbsp; @clrtype.returns(int)</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";
color:#1F497D'>&nbsp;&nbsp;&nbsp;
@clrtype.attribute(OperationContractAttribute)()</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Courier New";
color:#1F497D'>&nbsp;&nbsp;&nbsp; def foo(i, s):raise RuntimeError(&quot;this
should not get called&quot;)</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>This does not work today&#8230;</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<div>

<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;
border-color:-moz-use-text-color -moz-use-text-color'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif";
color:windowtext'>From:</span></b><span style='font-size:10.0pt;font-family:
"Tahoma","sans-serif";color:windowtext'> <a
href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a>
[<a href="mailto:users-bounces@lists.ironpython.com">mailto:users-bounces@lists.ironpython.com</a>]
<b>On Behalf Of </b>Lukas Cenovsky<br>
<b>Sent:</b> Friday, October 30, 2009 10:41 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] .NET attributes for methods</span><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

<p class=MsoNormal>Thanks.<br>
<br>
I wanted to implement WCF service in pure Ironpython but I overlooked the
[OperationContract] method attribute is used in the interface declaration.
Anyway, thanks to class attributes it is now possible to implement the WCF
service in IronPython and have only the interface done in C#. See my blog post:<br>
<br>
<a href="http://gui-at.blogspot.com/2009/10/wcf-service-in-ironpython.html">http://gui-at.blogspot.com/2009/10/wcf-service-in-ironpython.html</a><br>
<br>
DllImport is good to have too - I can get rid of of my Win32API.dll when <a
href="http://gui-at.blogspot.com/2008/07/simulate-users-input.html">simulating
user's input</a> :-)<br>
<br>
--<br>
-- Lukáš<br>
<br>
<br>
Shri Borde wrote: <o:p></o:p></p>

<pre>The following files extend DevHawk's blog and adds support for typed methods with attributes. It will be available as part of the samples released with the 2.6 RTM (over the next month). Do let us know if it works for you. <o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>Also, I would be curious to know what scenario you need method attributes for (other than DllImport for pinvokes)...<o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>-----Original Message-----<o:p></o:p></pre><pre>From: <a
href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a> [<a
href="mailto:users-bounces@lists.ironpython.com">mailto:users-bounces@lists.ironpython.com</a>] On Behalf Of Lukas Cenovsky<o:p></o:p></pre><pre>Sent: Thursday, October 22, 2009 10:37 AM<o:p></o:p></pre><pre>To: Discussion of IronPython<o:p></o:p></pre><pre>Subject: [IronPython] .NET attributes for methods<o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>Hi,<o:p></o:p></pre><pre>I have read all DewHawk blogposts about .Net attributes in IronPython <o:p></o:p></pre><pre>via __clrtype__ metaclass <o:p></o:p></pre><pre>(<a
href="http://devhawk.net/CategoryView,category,__clrtype__.aspx">http://devhawk.net/CategoryView,category,__clrtype__.aspx</a>). He <o:p></o:p></pre><pre>describes how to add attributes to classes but not to methods. Is there <o:p></o:p></pre><pre>any example how to add attributes to a method. It looks like method <o:p></o:p></pre><pre>generation is necessary (like for getter and setter or in <o:p></o:p></pre><pre><a
href="http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659">http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659</a>) <o:p></o:p></pre><pre>but this is kind of deep magic for me...<o:p></o:p></pre><pre>Thanks.<o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>--<o:p></o:p></pre><pre>-- Lukáš<o:p></o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>Users mailing list<o:p></o:p></pre><pre><a
href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><o:p></o:p></pre><pre><a
href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>&nbsp; <o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre
style='text-align:center'><o:p>&nbsp;</o:p></pre><pre style='text-align:center'>

<hr size=4 width="90%" align=center>

</pre><pre style='text-align:center'><o:p>&nbsp;</o:p></pre><pre
style='text-align:center'><o:p>&nbsp;</o:p></pre><pre style='text-align:center'>  <o:p></o:p></pre><pre>&nbsp;<o:p></o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>Users mailing list<o:p></o:p></pre><pre><a
href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><o:p></o:p></pre><pre><a
href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></pre><pre>&nbsp; <o:p></o:p></pre>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

<pre><o:p>&nbsp;</o:p></pre><pre style='text-align:center'>

<hr size=4 width="90%" align=center>

</pre><pre><o:p>&nbsp;</o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>Users mailing list<o:p></o:p></pre><pre><a
href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><o:p></o:p></pre><pre><a
href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></pre><pre>  <o:p></o:p></pre>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>