Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
<UseWPF>True</UseWPF>
</PropertyGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Resource Include="resources\Graphics\Add16.png" />
<Resource Include="resources\Graphics\CloseTile16.png" />
Expand All @@ -35,4 +31,10 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
<ProjectReference Include="..\Microsoft.PowerShell.Commands.Utility\Microsoft.PowerShell.Commands.Utility.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="10.0.5" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(IsWindows)' != 'true' ">
<Compile Remove="GetCounterCommand.cs" />
<Compile Remove="CounterSample.cs" />
Expand All @@ -29,4 +25,9 @@
<Compile Remove="NewWinEventCommand.cs" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
<ProjectReference Include="..\Microsoft.PowerShell.Security\Microsoft.PowerShell.Security.csproj" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup>
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
<PackageReference Include="System.Diagnostics.EventLog" Version="10.0.5" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.5" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
<PackageReference Include="Microsoft.PowerShell.MarkdownRender" Version="7.2.1" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
<PackageReference Include="System.Drawing.Common" Version="10.0.5" />
<PackageReference Include="JsonSchema.Net" Version="7.4.0" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(IsWindows)' != 'true' ">
<Compile Remove="WindowsTaskbarJumpList\*.cs" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
<PackageReference Include="System.Diagnostics.EventLog" Version="10.0.5" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
<ProjectReference Include="..\System.Management.Automation\System.Management.Automation.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.5" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
<PackageReference Include="System.Windows.Extensions" Version="10.0.5" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
</PropertyGroup>

<ItemGroup>
<!-- exclude code of source generators from compilation and IDEs (e.g. vscode and visual studio) -->
<Compile Remove="SourceGenerators\**\*.cs" />
Expand All @@ -78,4 +74,10 @@
<ItemGroup Condition=" '$(IsWindows)' == 'true' ">
<Compile Remove="engine\Interop\Unix\**\*.cs" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="resources\*\*.resx">
<ManifestResourceName>$(RootNamespace).resources.%(Filename)</ManifestResourceName>
</EmbeddedResource>
</ItemGroup>
</Project>
101 changes: 101 additions & 0 deletions test/powershell/engine/ResourceValidation/LocalizedResource.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

Describe "Localized resource files validation" -Tags "CI" {

BeforeAll {
$repoSrcDir = (Resolve-Path (Join-Path $PSScriptRoot ../../../../src)).Path

# Folders that exist in 'resources' folder but are not a localized resource directory.
$excludeDirs = @('Graphics')

# VS_Main_Languages set, the same as what .NET uses for localization.
$langSet = 'cs', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'pl', 'pt-BR', 'ru', 'tr', 'zh-Hans', 'zh-Hant'
$asmDirs = @(
'Microsoft.Management.Infrastructure.CimCmdlets'
'Microsoft.Management.UI.Internal'
'Microsoft.PowerShell.Commands.Diagnostics'
'Microsoft.PowerShell.Commands.Management'
'Microsoft.PowerShell.Commands.Utility'
'Microsoft.PowerShell.ConsoleHost'
'Microsoft.PowerShell.CoreCLR.Eventing'
'Microsoft.PowerShell.Security'
'Microsoft.WSMan.Management'
'System.Management.Automation'
)

$asmNames = $asmDirs | ForEach-Object {
if ($_ -eq 'Microsoft.Management.UI.Internal') {
'Microsoft.PowerShell.GraphicalHost'
} else {
$_
}
}

$testCases1 = @(
$asmDirs | ForEach-Object { @{ AssemblyDir = $_ } }
)
$testCases2 = @(
$langSet | ForEach-Object { @{ Language = $_ } }
)
}

It "Assembly folders with resources should match with records" {
try {
Push-Location $repoSrcDir
$assemblies = Get-ChildItem 'resources' -Recurse -Directory | ForEach-Object { $_.Parent.Name }

## Verifies that the assembly folders containing resource files match the expected records in $asmDirs.
$result = Compare-Object -ReferenceObject $asmDirs -DifferenceObject $assemblies
$result | Should -Be $null -Because "The assembly folders with resources do not match the expected records:`n$($result | Out-String)."

## Verifies that the default English resource files exist and match the expected count.
$defaultCultureResources = $assemblies | ForEach-Object { Get-ChildItem "$_/resources/*.resx" }
$defaultCultureResources | Should -HaveCount 150 -Because "Default English resource files count: $($defaultCultureResources.Count); Expected count: 150."
}
finally {
Pop-Location
}
}

It "Localized resource files for '<AssemblyDir>' should match the records" -TestCases $testCases1 {
param($AssemblyDir)

## Get the full path to the resources directory for the current assembly folder.
$resDir = Join-Path $repoSrcDir $AssemblyDir 'resources'
## Get all the localized resource directory names under the resources directory.
$locDirNames = @(Get-ChildItem $resDir -Directory | ForEach-Object Name | Where-Object { $_ -notin $excludeDirs })

## Verifies that the localized resource directories match the expected language set.
$results = Compare-Object -ReferenceObject $langSet -DifferenceObject $locDirNames
$results | Should -Be $null -Because "The localized resource directories for '$AssemblyDir' do not match the expected language set:`n$($results | Out-String)."

## Get the default English resource file names without extensions.
$default = @(Get-ChildItem "$resDir/*.resx" | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_.Name) })

foreach ($lang in $langSet) {
## Get the full path to the localized resource directory for the current language.
$langDir = Join-Path $resDir $lang
## Get all the localized resource file names without extensions for the current language.
$langResources = @(Get-ChildItem "$langDir/*.resx" | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_.Name) })

## The localized resource file should have the same base name as the default English resource file, with the language suffix added.
$expectedNames = @($default | ForEach-Object { "$_.$lang" })
## Verifies that the localized resource file names match the expected names.
$langResults = Compare-Object -ReferenceObject $expectedNames -DifferenceObject $langResources
$langResults | Should -Be $null -Because "The names of localized resource files for '$lang' in '$AssemblyDir' do not match the default English files:`n$($langResults | Out-String)."
}
}

It "Satellite assemblies should be produced for '<Language>'" -TestCases $testCases2 -Skip:(!$IsWindows) {
param($Language)

$satDir = Join-Path $PSHOME $Language
Test-Path $satDir | Should -BeTrue -Because "Satellite directory for language '$Language' should exist."

foreach ($asmName in $asmNames) {
$satAssemblyPath = Join-Path $satDir "$asmName.resources.dll"
Test-Path $satAssemblyPath | Should -BeTrue -Because "Satellite assembly '$asmName.resources.dll' for language '$Language' should exist."
}
}
}
Loading
Loading