1
1
import * as path from 'path' ;
2
2
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 {
4
4
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' ) ;
6
7
const className = fileName . includes ( '.' ) ? fileName . split ( '.' ) [ 1 ] : fileName ;
7
8
8
9
let code = `//------------------------------------------------------------------------------
@@ -18,9 +19,14 @@ export function generateDesignerCode(resxPath: string, resources: { [key: string
18
19
namespace ${ namespaceName } {
19
20
using System;
20
21
22
+
21
23
/// <summary>
22
24
/// A strongly-typed resource class, for looking up localized strings, etc.
23
25
/// </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.
24
30
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("VS Code RESX Editor", "1.0.0.0")]
25
31
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
26
32
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@@ -66,11 +72,14 @@ namespace ${namespaceName} {
66
72
67
73
// Generate a property for each resource
68
74
for ( const [ key , resource ] of Object . entries ( resources ) ) {
75
+ // Always add a summary - either the comment or a default message
76
+ code += ` /// <summary>\n` ;
69
77
if ( resource . comment ) {
70
- code += ` /// <summary>\n` ;
71
78
code += ` /// ${ resource . comment } \n` ;
72
- code += ` /// </summary>\n` ;
79
+ } else {
80
+ code += ` /// Looks up a localized string similar to ${ resource . value } \n` ;
73
81
}
82
+ code += ` /// </summary>\n` ;
74
83
code += ` ${ accessLevel } static string ${ key } {
75
84
get {
76
85
return ResourceManager.GetString("${ key } ", resourceCulture);
0 commit comments