Search

Option to control the visibility of the generated preprocessed T4 template class by Aethon Invictus

Closed
as Duplicate Help for as Duplicate

3
0
Sign in
to vote
Type: Suggestion
ID: 632269
Opened: 12/17/2010 12:37:17 PM
Access Restriction: Public
1
Workaround(s)
There is no method of changing the visibility of the class generated by a T4 preprocessed template. This causes all preprocessed templates to appear on the public interface of the class library, even though they often are private implementation details. It would be very useful to have a property or directive to set the visibility to internal.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

 

Steps to reproduce

1. Create a new preprocessed template item.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

There is no method to indicate the visibility of the generated class.

Expected results

Some method to indicate the visibility of the generated class.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/28/2011 at 7:48 PM
This has been fixed for the next release of Visual Studio.
Posted by Microsoft on 4/2/2011 at 9:30 PM
This suggestion was copied to our backlog, to be processed
Best regards
Jean-Marc Prieur
Posted by Aethon Invictus on 12/20/2010 at 7:28 AM
You marked this as resolved. Can you point me to the release that I can find the resolution in?

Oh, I see that you indicated that it was a duplicate of some other issue. Can you link me to that issue so that I can track it (and also vote it up)?

Thanks
Posted by Microsoft on 12/20/2010 at 6:11 AM
Thanks for this feedback.
This is something that was asked already internally. We'll consider it for future versions of Visual Studio.
Thanks again
Best regards
Jean-Marc Prieur, Senior Program Manager | Visual Studio Ultimate | Modeling Platform eXperience
Posted by Microsoft on 12/19/2010 at 5:46 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)
Sign in to post a workaround.
Posted by v-ram on 6/5/2011 at 8:58 PM
Add a default constuctor in the template file, mark it as internal or private.
This works as generated code creates a partial class with no default costructor.
The scheme will break if future T4 processors choose to add a default constructor.

Sample:

<#@ template language="C#" #>
Hello! This template is protected by internal constructor...
<#+
internal TemplateWithInternalConstructor()
{
     // Making an internal (ir private) default constructor will make template internal use only.
}
    
public static TemplateWithInternalConstructor Create(string s1, int i1)
{
    return new TemplateWithInternalConstructor();    
}
#>