1717using System ;
1818using System . Diagnostics ;
1919using System . Globalization ;
20+ using System . IO ;
2021using Microsoft . VisualStudio . Shell . Interop ;
2122
2223namespace Microsoft . NodejsTools . Project . NewFileMenuGroup {
2324 internal static class NewFileUtilities {
24- public static string GetTemplateFile ( string fileType ) {
25- string templateFileName = null ;
26-
27- switch ( fileType ) {
28- case NodejsConstants . JavaScript :
29- templateFileName = "EmptyJs.js" ;
30- break ;
31- case NodejsConstants . TypeScript :
32- templateFileName = "EmptyTs.ts" ;
33- break ;
34- case NodejsConstants . HTML :
35- templateFileName = "EmptyHTML.html" ;
36- break ;
37- case NodejsConstants . CSS :
38- templateFileName = "EmptyCSS.css" ;
39- break ;
40- }
41-
42- if ( templateFileName == null ) {
43- Debug . Fail ( string . Format ( CultureInfo . CurrentCulture , "Invalid file type: {0}" , fileType ) ) ;
44- }
45-
46- return NodejsToolsInstallPath . GetFile ( "FileTemplates\\ NewItem\\ " + templateFileName ) ;
47- }
48-
4925 private static string GetInitialName ( string fileType ) {
50-
5126 switch ( fileType ) {
5227 case NodejsConstants . JavaScript :
5328 return "JavaScript.js" ;
@@ -74,12 +49,9 @@ private static void CreateNewFile(NodejsProjectNode projectNode, uint containerI
7449 VSADDITEMOPERATION . VSADDITEMOP_CLONEFILE , // Indicate that we want to create this new file by cloning a template file.
7550 itemName ,
7651 1 , // Number of templates in the next parameter. Must be 1 if using VSADDITEMOP_CLONEFILE.
77- new string [ ] { GetTemplateFile ( fileType ) } , // Array contains the template file path.
52+ new string [ ] { Path . GetTempFileName ( ) } , // Array contains the template file path.
7853 IntPtr . Zero , // Handle to the Add Item dialog box. Must be Zero if using VSADDITEMOP_CLONEFILE.
79- pResult
80- ) ;
81-
82- // TODO: Do we need to check if result[0] = VSADDRESULT.ADDRESULT_Success here?
54+ pResult ) ;
8355 }
8456 }
8557 }
0 commit comments