VS2010 C# Unit Tests wizard generates code with private accessor errors for covariant generic parameters - by W Thomas

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 609849 Comments
Status Closed Workarounds
Type Bug Repros 4
Opened 10/3/2010 9:54:26 AM
Access Restriction Public


I created a project which contained interfaces that use covariant generic (<out T>) types.  The project compiled without error.  When I then used the VS2010 Unit Test wizard to create unit tests for the project, the first build of the unit test project had errors on the private accessors that Visual Studio had generated:

Could not load type 'MultiTree.ITreeNode_Impl`1' from assembly 'MultiTree_Accessor, Version=, Culture=neutral, PublicKeyToken=null' because it declares a covariant or contravariant type parameter and is not an interface or delegate. MultiTree Unit Tests

I tried modifying the unit tests to use explicit types in the tests, but kept getting the error with every build of anything in the original project or of the unit test project.  The only way I discovered to eliminate the error was  to rename (or remove) the .accessor file, explicitly remove the generated C# unit test files from the unit test project, re-add the reference to the dll under test, and start with clean "basic" unit test files added to the unit test project.  

The manually-coded unit tests then would build and run without generating this error.  If I let Visual Studio generate any unit tests for this project, the error returns.

This apparently has to do with problems related to "Generation of Private Accessors (Publicize) and Code Generation for Visual Studio 2010" on the Visual Studio Test Team's blog.  See http://blogs.msdn.com/b/vstsqualitytools/archive/2010/01/18/publicize-and-code-generation-for-visual-studio-2010.aspx 

See also the discussion at   http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/0bad3473-787c-4a8d-9b11-6c345bde780c?prof=required
Sign in to post a comment.
Posted by W Thomas on 11/18/2010 at 11:23 AM
This was not a request to support private accessor code. It was a request to fix the bad code generated by Visual Studio itself when creating unit test stubs for interfaces and methods that use covariant generic parameters, whatever that takes.
(By your response, you essentially seem to refuse to fix your own bug where code is generated by Visual Studio that cannot compile. If there are workarounds, they are workarounds that you need to implement in Visual Studio test case generation.)

-- Thomas
Posted by Abhishek [MSFT] on 10/13/2010 at 7:51 AM

As discussed in the blog below, private accessor code generation is deprecated and we are not supporting this feature. We will not be making further fixes in this feature. Please use the work-around or guidance as described in the blog


Visual Studio Product Team

Posted by Microsoft on 10/3/2010 at 10:03 PM
Thanks for your feedback. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 10/3/2010 at 6:21 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)