11import * as path from 'path' ;
22
3- export function generateDesignerCode ( resxPath : string , resources : { [ key : string ] : { value : string ; comment ?: string } } , accessLevel : 'public' | 'internal' = 'public' ) : string {
3+ export function generateDesignerCode ( resxPath : string , resources : { [ key : string ] : { value : string ; comment ?: string } } , accessLevel : 'public' | 'internal' = 'public' , existingNamespace ?: string ) : string {
44 const fileName = path . basename ( resxPath , '.resx' ) ;
5- const namespaceName = fileName . includes ( '.' ) ? fileName . split ( '.' ) [ 0 ] : 'Resources' ;
5+ // Use existing namespace if available, otherwise compute from filename
6+ const namespaceName = existingNamespace || ( fileName . includes ( '.' ) ? fileName . split ( '.' ) [ 0 ] : 'Resources' ) ;
67 const className = fileName . includes ( '.' ) ? fileName . split ( '.' ) [ 1 ] : fileName ;
78
89 let code = `//------------------------------------------------------------------------------
@@ -18,9 +19,14 @@ export function generateDesignerCode(resxPath: string, resources: { [key: string
1819namespace ${ namespaceName } {
1920 using System;
2021
22+
2123 /// <summary>
2224 /// A strongly-typed resource class, for looking up localized strings, etc.
2325 /// </summary>
26+ // This class was auto-generated by the StronglyTypedResourceBuilder
27+ // class via a tool like ResGen or Visual Studio.
28+ // To add or remove a member, edit your .ResX file then rerun ResGen
29+ // with the /str option, or rebuild your VS project.
2430 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("VS Code RESX Editor", "1.0.0.0")]
2531 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
2632 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@@ -66,11 +72,14 @@ namespace ${namespaceName} {
6672
6773 // Generate a property for each resource
6874 for ( const [ key , resource ] of Object . entries ( resources ) ) {
75+ // Always add a summary - either the comment or a default message
76+ code += ` /// <summary>\n` ;
6977 if ( resource . comment ) {
70- code += ` /// <summary>\n` ;
7178 code += ` /// ${ resource . comment } \n` ;
72- code += ` /// </summary>\n` ;
79+ } else {
80+ code += ` /// Looks up a localized string similar to ${ resource . value } \n` ;
7381 }
82+ code += ` /// </summary>\n` ;
7483 code += ` ${ accessLevel } static string ${ key } {
7584 get {
7685 return ResourceManager.GetString("${ key } ", resourceCulture);
0 commit comments