@@ -377,11 +377,12 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
377377 {
378378 int value = mapEntries [ k ] . Value ;
379379 string valueName = new string ( ( char * ) ( & enumBuffer [ mapEntries [ k ] . NameOffset ] ) ) . Trim ( ) ;
380- string stringId = $ "map_{ MakeStringId ( enumName ) } { MakeStringId ( valueName ) } ";
380+ string escapedValueName = XmlUtilities . XmlEscape ( valueName ) ;
381+ string stringId = XmlUtilities . XmlEscape ( $ "map_{ enumName } { valueName } ") ;
381382 enumWriter . WriteLine ( " <map value=\" 0x{0:x}\" message=\" $(string.{1})\" />" , value , stringId ) ;
382383 if ( emittedStringIds . Add ( stringId ) )
383384 {
384- enumLocalizations . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , stringId , XmlUtilities . XmlEscape ( valueName ) ) ;
385+ enumLocalizations . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , stringId , escapedValueName ) ;
385386 }
386387 }
387388 if ( enumInfo ->Flag == MAP_FLAGS . EVENTMAP_INFO_FLAG_MANIFEST_VALUEMAP )
@@ -459,12 +460,13 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
459460 manifest . WriteLine ( " <keywords>" ) ;
460461 foreach ( var keyValue in keywords )
461462 {
462- string stringId = $ "keyword_{ MakeStringId ( keyValue . Value ) } ";
463+ string escapedValue = XmlUtilities . XmlEscape ( keyValue . Value ) ;
464+ string stringId = XmlUtilities . XmlEscape ( $ "keyword_{ keyValue . Value } ") ;
463465 manifest . WriteLine ( " <keyword name=\" {0}\" message=\" $(string.{1})\" mask=\" 0x{2:x}\" />" ,
464- XmlUtilities . XmlEscape ( keyValue . Value ) , stringId , keyValue . Key ) ;
466+ escapedValue , stringId , keyValue . Key ) ;
465467 if ( emittedStringIds . Add ( stringId ) )
466468 {
467- localizedStrings . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , stringId , XmlUtilities . XmlEscape ( keyValue . Value ) ) ;
469+ localizedStrings . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , stringId , escapedValue ) ;
468470 }
469471 }
470472 manifest . WriteLine ( " </keywords>" ) ;
@@ -474,25 +476,27 @@ public static string GetManifestForRegisteredProvider(Guid providerGuid)
474476 foreach ( var taskValue in tasks . Keys )
475477 {
476478 var task = tasks [ taskValue ] ;
477- string taskStringId = $ "task_{ MakeStringId ( task . Name ) } ";
478- manifest . WriteLine ( " <task name=\" {0}\" message=\" $(string.{1})\" value=\" {2}\" {3}>" , XmlUtilities . XmlEscape ( task . Name ) , taskStringId , taskValue ,
479+ string escapedTaskName = XmlUtilities . XmlEscape ( task . Name ) ;
480+ string taskStringId = XmlUtilities . XmlEscape ( $ "task_{ task . Name } ") ;
481+ manifest . WriteLine ( " <task name=\" {0}\" message=\" $(string.{1})\" value=\" {2}\" {3}>" , escapedTaskName , taskStringId , taskValue ,
479482 task . Opcodes == null ? "/" : "" ) ; // If no opcodes, terminate immediately.
480483 if ( emittedStringIds . Add ( taskStringId ) )
481484 {
482- localizedStrings . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , taskStringId , XmlUtilities . XmlEscape ( task . Name ) ) ;
485+ localizedStrings . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , taskStringId , escapedTaskName ) ;
483486 }
484487 if ( task . Opcodes != null )
485488 {
486489 manifest . WriteLine ( ">" ) ;
487490 manifest . WriteLine ( " <opcodes>" ) ;
488491 foreach ( var keyValue in task . Opcodes )
489492 {
490- string opcodeStringId = $ "opcode_{ MakeStringId ( task . Name ) } { MakeStringId ( keyValue . Value ) } ";
493+ string escapedOpcodeName = XmlUtilities . XmlEscape ( keyValue . Value ) ;
494+ string opcodeStringId = XmlUtilities . XmlEscape ( $ "opcode_{ task . Name } { keyValue . Value } ") ;
491495 manifest . WriteLine ( " <opcode name=\" {0}\" message=\" $(string.{1})\" value=\" {2}\" />" ,
492- XmlUtilities . XmlEscape ( keyValue . Value ) , opcodeStringId , keyValue . Key ) ;
496+ escapedOpcodeName , opcodeStringId , keyValue . Key ) ;
493497 if ( emittedStringIds . Add ( opcodeStringId ) )
494498 {
495- localizedStrings . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , opcodeStringId , XmlUtilities . XmlEscape ( keyValue . Value ) ) ;
499+ localizedStrings . WriteLine ( " <string id=\" {0}\" value=\" {1}\" />" , opcodeStringId , escapedOpcodeName ) ;
496500 }
497501 }
498502 manifest . WriteLine ( " </opcodes>" ) ;
@@ -573,15 +577,6 @@ private static string MakeLegalIdentifier(string name)
573577 return name ;
574578 }
575579
576- /// <summary>
577- /// Creates a string ID suitable for use in XML manifest string tables.
578- /// XML-escapes the value to make it a valid XML attribute value.
579- /// </summary>
580- private static string MakeStringId ( string value )
581- {
582- return XmlUtilities . XmlEscape ( value ) ;
583- }
584-
585580 /// <summary>
586581 /// Generates a space separated list of set of keywords 'keywordSet' using the table 'keywords'
587582 /// It will generate new keyword names if needed and add them to 'keywords' if they are not present.
0 commit comments