mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Fix our ResGen to make LocalAccounts work
This commit is contained in:
1 parent
ee4d6ab8b3
commit
60b6f7287d
1 file changed
+22
-15
+22
-15
@@ -884,21 +884,12 @@ function Start-ResGen
|
|||||||
"Microsoft.PowerShell.Security",
|
"Microsoft.PowerShell.Security",
|
||||||
"System.Management.Automation") | % {
|
"System.Management.Automation") | % {
|
||||||
$module = $_
|
$module = $_
|
||||||
Get-ChildItem "$PSScriptRoot/src/$module/resources" | % {
|
Get-ChildItem "$PSScriptRoot/src/$module/resources" -Filter '*.resx' | % {
|
||||||
$className = $_.Name.Replace('.resx', '')
|
$className = $_.Name.Replace('.resx', '')
|
||||||
$xml = [xml](Get-Content -raw $_.FullName)
|
$xml = [xml](Get-Content -raw $_.FullName)
|
||||||
|
|
||||||
$fileName = $className
|
$fileName = $className
|
||||||
$namespace = ''
|
$genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className
|
||||||
|
|
||||||
$lastIndexOfDot = $className.LastIndexOf(".")
|
|
||||||
if ($lastIndexOfDot -ne -1)
|
|
||||||
{
|
|
||||||
$namespace = $className.Substring(0, $lastIndexOfDot)
|
|
||||||
$className = $className.Substring($lastIndexOfDot + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
$genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName $module -ClassName $className -NamespaceName $namespace
|
|
||||||
$outPath = "$PSScriptRoot/src/$module/gen/$fileName.cs"
|
$outPath = "$PSScriptRoot/src/$module/gen/$fileName.cs"
|
||||||
Write-Verbose "ResGen for $outPath"
|
Write-Verbose "ResGen for $outPath"
|
||||||
New-Item -Type Directory -ErrorAction SilentlyContinue (Split-Path $outPath) > $null
|
New-Item -Type Directory -ErrorAction SilentlyContinue (Split-Path $outPath) > $null
|
||||||
@@ -996,7 +987,23 @@ function script:Start-NativeExecution([scriptblock]$sb)
|
|||||||
|
|
||||||
function script:Get-StronglyTypeCsFileForResx
|
function script:Get-StronglyTypeCsFileForResx
|
||||||
{
|
{
|
||||||
param($xml, $ModuleName, $ClassName, $NamespaceName = '')
|
param($xml, $ModuleName, $ClassName)
|
||||||
|
|
||||||
|
# Example
|
||||||
|
#
|
||||||
|
# $ClassName = Full.Name.Of.The.ClassFoo
|
||||||
|
# $shortClassName = ClassFoo
|
||||||
|
# $namespaceName = Full.Name.Of.The
|
||||||
|
|
||||||
|
$shortClassName = $ClassName
|
||||||
|
$namespaceName = $null
|
||||||
|
|
||||||
|
$lastIndexOfDot = $className.LastIndexOf(".")
|
||||||
|
if ($lastIndexOfDot -ne -1)
|
||||||
|
{
|
||||||
|
$namespaceName = $className.Substring(0, $lastIndexOfDot)
|
||||||
|
$shortClassName = $className.Substring($lastIndexOfDot + 1)
|
||||||
|
}
|
||||||
|
|
||||||
$banner = @'
|
$banner = @'
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -1046,7 +1053,7 @@ internal class {0} {{
|
|||||||
internal static global::System.Resources.ResourceManager ResourceManager {{
|
internal static global::System.Resources.ResourceManager ResourceManager {{
|
||||||
get {{
|
get {{
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {{
|
if (object.ReferenceEquals(resourceMan, null)) {{
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("{1}.resources.{0}", typeof({0}).GetTypeInfo().Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("{1}.resources.{3}", typeof({0}).GetTypeInfo().Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}}
|
}}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
@@ -1089,9 +1096,9 @@ internal class {0} {{
|
|||||||
}
|
}
|
||||||
} | Out-String
|
} | Out-String
|
||||||
|
|
||||||
$bodyCode = $body -f $ClassName,$ModuleName,$entries
|
$bodyCode = $body -f $shortClassName,$ModuleName,$entries,$ClassName
|
||||||
|
|
||||||
if ($NamespaceName -ne '')
|
if ($NamespaceName)
|
||||||
{
|
{
|
||||||
$bodyCode = $namespace -f $NamespaceName, $bodyCode
|
$bodyCode = $namespace -f $NamespaceName, $bodyCode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user