Are list accessors working in 2008?<p align=left>Hello-</p> <p align=left> </p> <p align=left>I just finished running through the TFS intro labs, and decided to try making a new unit test.  The Board class in the TicTacToe example exposes a Cells property that's of type List&lt;Cell&gt;.  Both this property and the Cell type are internal to the app assembly, so I right-clicked in the Board's editor and said &quot;Create Private Accessor&quot; like the demos suggested.</p> <p align=left> </p> <p align=left>In my unit test, I then added:</p><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p></font><font color="#2b91af" size=2><font color="#2b91af" size=2>Board_Accessor</font></font><font size=2> board = </font><font color="#0000ff" size=2><font color="#0000ff" size=2>new</font></font><font size=2> </font><font color="#2b91af" size=2><font color="#2b91af" size=2>Board_Accessor</font></font><font size=2>();</font><font size=2></p></blockquote></font> <p align=left> </p> <p align=left>Cool so far, but the next line will throw a type cast exception:</p><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>object</font></font><font size=2> cell = board.Cells[3];</p></blockquote></font> <p align=left> </p> <p align=left>It seems that the generated List&lt;Cell_accessor&gt; and the original List&lt;Cell&gt; types are not compatible.</p> <p align=left> </p> <p align=left>Is this expected?  Is there a workaround?</p> <p>Thanks,</p> <p align=left>Eric</p>© 2009 Microsoft Corporation. All rights reserved.Tue, 04 Aug 2009 09:40:04 Z6ee0766f-329a-464f-a526-f89accca4f07http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/6ee0766f-329a-464f-a526-f89accca4f07#6ee0766f-329a-464f-a526-f89accca4f07http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/6ee0766f-329a-464f-a526-f89accca4f07#6ee0766f-329a-464f-a526-f89accca4f07EricAllhttp://social.msdn.microsoft.com/Profile/en-US/?user=EricAllAre list accessors working in 2008?<p align=left>Hello-</p> <p align=left> </p> <p align=left>I just finished running through the TFS intro labs, and decided to try making a new unit test.  The Board class in the TicTacToe example exposes a Cells property that's of type List&lt;Cell&gt;.  Both this property and the Cell type are internal to the app assembly, so I right-clicked in the Board's editor and said &quot;Create Private Accessor&quot; like the demos suggested.</p> <p align=left> </p> <p align=left>In my unit test, I then added:</p><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p></font><font color="#2b91af" size=2><font color="#2b91af" size=2>Board_Accessor</font></font><font size=2> board = </font><font color="#0000ff" size=2><font color="#0000ff" size=2>new</font></font><font size=2> </font><font color="#2b91af" size=2><font color="#2b91af" size=2>Board_Accessor</font></font><font size=2>();</font><font size=2></p></blockquote></font> <p align=left> </p> <p align=left>Cool so far, but the next line will throw a type cast exception:</p><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p></font><font color="#0000ff" size=2><font color="#0000ff" size=2>object</font></font><font size=2> cell = board.Cells[3];</p></blockquote></font> <p align=left> </p> <p align=left>It seems that the generated List&lt;Cell_accessor&gt; and the original List&lt;Cell&gt; types are not compatible.</p> <p align=left> </p> <p align=left>Is this expected?  Is there a workaround?</p> <p>Thanks,</p> <p align=left>Eric</p>Tue, 02 Sep 2008 19:10:39 Z2008-09-04T04:14:29Zhttp://social.msdn.microsoft.com/Forums/en-US/vststest/thread/6ee0766f-329a-464f-a526-f89accca4f07#b2795547-2323-4c36-b53a-874e2046a731http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/6ee0766f-329a-464f-a526-f89accca4f07#b2795547-2323-4c36-b53a-874e2046a731Joe Allan Muharsky - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Joe%20Allan%20Muharsky%20-%20MSFTAre list accessors working in 2008?<p align=left><font face=Arial size=2></font> </p> <p>Hi Eric,</p> <p align=left> </p> <p align=left>There are issues with doing deep copies of generic arrays and lists in the publicize functionality, much of it deriving from the .NET behavior you indicated; when A : B, List&lt;A&gt; is not compatible with List&lt;B&gt;.  As you're using internal members, however, the easiest path for you would be to make your assembly's internal visible to the test assembly, and then public accessors will not be neccessary at all for test code making use of internal members.  You can read more about InternalsVisibleTo at <a title="http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx" href="http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx">http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx</a>.  At a high level, the implementation will look like:</p> <p align=left> </p> <p align=left>[assembly:InternalsVisibleTo(&quot;MyTestAssembly&quot;)]<br></p> <p align=left>Hope this helps,</p>Wed, 03 Sep 2008 18:19:50 Z2008-09-04T04:14:29Z