Skip to content

Commit

Permalink
AstAnalyze of Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Aug 6, 2024
1 parent bff16e1 commit e1e601f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ps12exe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,21 @@ $AstAnalyzeResult.UsedNonConstFunctions | ForEach-Object {
}
}
}
$NotFindedTypes = @()
$AstAnalyzeResult.UsedNonConstTypes | ForEach-Object {
if (!($_ -as [Type])) {
$NotFindedTypes += $_
}
}
if ($FindedCmdlets) {
Write-I18n Warning SomeCmdletsMayNotAvailable $($FindedCmdlets -join '')
}
if ($NotFindedCmdlets) {
Write-I18n Warning SomeNotFindedCmdlets $($NotFindedCmdlets -join '')
}
if ($NotFindedTypes) {
Write-I18n Warning SomeNotFindedTypes $($NotFindedTypes -join '')
}
try {
. $PSScriptRoot\src\InitCompileThings.ps1
#_if PSScript
Expand Down Expand Up @@ -676,6 +685,7 @@ $($_ | Format-List | Out-String)
}
Write-I18n Host OppsSomethingWentWrong -ForegroundColor Yellow
$versionNow = Get-Module -ListAvailable ps12exe | Sort-Object -Property Version -Descending | Select-Object -First 1
if ($versionNow.Version -eq '0.0.0') { break }
$versionOnline = Find-Module ps12exe | Sort-Object -Property Version -Descending | Select-Object -First 1
if ("$($versionNow.Version)" -ne "$($versionOnline.Version)") {
Write-I18n Host TryUpgrade $($versionOnline.Version) -ForegroundColor Yellow
Expand Down
7 changes: 7 additions & 0 deletions src/AstAnalyze.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function AstAnalyze($Ast) {
ImporttedExternalScripts = $false
UsedNonConstVariables = @()
UsedNonConstFunctions = @()
UsedNonConstTypes = @()
}
$script:ConstTypes = $script:ConstTypes | ForEach-Object { ($_ -as [Type]).FullName } | Where-Object { $_ -ne $null }
function IsConstType([string]$typename) {
Expand Down Expand Up @@ -90,6 +91,12 @@ function AstAnalyze($Ast) {
$script:ConstCommands = $ConstCommandsBackup
$script:ConstVariables = $ConstVariablesBackup
}
elseif ($Ast -is [System.Management.Automation.Language.AttributeAst]) {
if ($script:ConstTypes -notcontains $Ast.TypeName.FullName) {
$script:AnalyzeResult.IsConst = $false
$script:AnalyzeResult.UsedNonConstTypes += $Ast.TypeName.FullName
}
}
return $false
}
[void]$Ast.Find($function:AstMapper, $true)
Expand Down
1 change: 1 addition & 0 deletions src/locale/en-UK.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
CombinedArg_NoConfigFile_winFormsDPIAware = "Forcing generation of a config file, since the option -winFormsDPIAware requires this"
SomeCmdletsMayNotAvailable = "Cmdlets {0} used but may not available in runtime, make sure you've checked it!"
SomeNotFindedCmdlets = "Unknown functions {0} used"
SomeNotFindedTypes = "Unknown types {0} used"
CompilingFile = "Compiling file..."
CompilationFailed = "Compilation failed!"
OutputFileNotWritten = "Output file {0} not written"
Expand Down
1 change: 1 addition & 0 deletions src/locale/es-ES.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
CombinedArg_NoConfigFile_winFormsDPIAware = "Forzando la generación de un archivo de configuración, ya que la opción -winFormsDPIAware lo requiere"
SomeCmdletsMayNotAvailable = "¡Se usaron cmdlets {0} pero pueden no estar disponibles en tiempo de ejecución, asegúrese de haberlos verificado!"
SomeNotFindedCmdlets = "Se usaron funciones desconocidas {0}"
SomeNotFindedTypes = "Se usaron tipos desconocidos {0}"
CompilingFile = "Compilando archivo..."
CompilationFailed = "¡Falló la compilación!"
OutputFileNotWritten = "No se escribió el archivo de salida {0}"
Expand Down
1 change: 1 addition & 0 deletions src/locale/hi-IN.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
CombinedArg_NoConfigFile_winFormsDPIAware = "एक कॉन्फ़िगरेशन फ़ाइल के निर्माण को मजबूर करना, क्योंकि विकल्प -winFormsDPIAware को इसकी आवश्यकता होती है"
SomeCmdletsMayNotAvailable = "उपयोग किए गए Cmdlets {0} लेकिन रनटाइम में उपलब्ध नहीं हो सकते हैं, सुनिश्चित करें कि आपने उनकी जांच की है!"
SomeNotFindedCmdlets = "अज्ञात कार्यों {0} का उपयोग किया गया"
SomeNotFindedTypes = "अज्ञात प्रकारों {0} का उपयोग किया गया"
CompilingFile = "संकलन..."
CompilationFailed = "संकलन विफल!"
OutputFileNotWritten = "आउटपुट फ़ाइल {0} नहीं लिखी गई"
Expand Down
1 change: 1 addition & 0 deletions src/locale/ja-JP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
CombinedArg_NoConfigFile_winFormsDPIAware = "オプション -winFormsDPIAware はこの設定ファイルを必要とするため、設定ファイルの生成を強制します"
SomeCmdletsMayNotAvailable = "実行時に利用できない可能性のあるコマンドレット {0} が使用されています。確認してください!"
SomeNotFindedCmdlets = "未知の命令 {0} が使用されています"
SomeNotFindedTypes = "未知の型 {0} が使用されています"
CompilingFile = "コンパイル中..."
CompilationFailed = "コンパイルに失敗しました!"
OutputFileNotWritten = "出力ファイル {0} が書き込まれませんでした"
Expand Down
1 change: 1 addition & 0 deletions src/locale/zh-CN.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
CombinedArg_NoConfigFile_winFormsDPIAware = "强制生成配置文件,因为选项 -winFormsDPIAware 需要此配置文件"
SomeCmdletsMayNotAvailable = "使用了可能会在运行时不可用的命令 {0},确保已检查它们!"
SomeNotFindedCmdlets = "使用了未知的命令 {0}"
SomeNotFindedTypes = "使用了未知的类型 {0}"
CompilingFile = "编译中..."
CompilationFailed = "编译失败!"
OutputFileNotWritten = "未写入输出文件 {0}"
Expand Down

0 comments on commit e1e601f

Please sign in to comment.