Skip to content

Commit 887db36

Browse files
authored
Merge branch 'feature/wsl-for-apps' into WslcVolumesManager
2 parents cfc4992 + 7baac47 commit 887db36

5 files changed

Lines changed: 97 additions & 45 deletions

File tree

localization/strings/en-US/Resources.resw

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,4 +2777,36 @@ On first run, creates the file with all settings commented out at their defaults
27772777
<value>Object not found: {}</value>
27782778
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
27792779
</data>
2780+
<data name="WSLCUserSettings_Warning_InvalidValue" xml:space="preserve">
2781+
<value>Warning: Invalid value for setting '{}' in {}:{}.</value>
2782+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2783+
</data>
2784+
<data name="WSLCUserSettings_Warning_InvalidType" xml:space="preserve">
2785+
<value>Warning: Invalid type for setting '{}' in {}:{}.</value>
2786+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2787+
</data>
2788+
<data name="WSLCUserSettings_Warning_NonStringKey" xml:space="preserve">
2789+
<value>Warning: Non-string key in section '{}' in {}:{}.</value>
2790+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2791+
</data>
2792+
<data name="WSLCUserSettings_Warning_UnknownSection" xml:space="preserve">
2793+
<value>Warning: Unknown setting section '{}' in {}:{}.</value>
2794+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2795+
</data>
2796+
<data name="WSLCUserSettings_Warning_UnknownKey" xml:space="preserve">
2797+
<value>Warning: Unknown setting '{}' in {}:{}.</value>
2798+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2799+
</data>
2800+
<data name="WSLCUserSettings_Warning_FailedToOpen" xml:space="preserve">
2801+
<value>Warning: Failed to open settings file at {}. Error: {}.</value>
2802+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2803+
</data>
2804+
<data name="WSLCUserSettings_Warning_ParseError" xml:space="preserve">
2805+
<value>Warning: Settings file at {} could not be parsed. Error: {}.</value>
2806+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2807+
</data>
2808+
<data name="WSLCUserSettings_Warning_InvalidStructure" xml:space="preserve">
2809+
<value>Warning: Settings file at {} is empty or has invalid structure. Expected a YAML mapping.</value>
2810+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2811+
</data>
27802812
</root>

packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<package id="Microsoft.WSL.bsdtar" version="0.0.2-2" />
1919
<package id="Microsoft.WSL.Dependencies.amd64fre" version="10.0.27820.1000-250318-1700.rs-base2-hyp" targetFramework="native" />
2020
<package id="Microsoft.WSL.Dependencies.arm64fre" version="10.0.27820.1000-250318-1700.rs-base2-hyp" targetFramework="native" />
21-
<package id="Microsoft.WSL.DeviceHost" version="1.2.10-0" />
21+
<package id="Microsoft.WSL.DeviceHost" version="1.2.14-0" />
2222
<package id="Microsoft.WSL.Kernel" version="6.6.114.1-1" targetFramework="native" />
2323
<package id="Microsoft.WSL.LinuxSdk" version="1.20.0" targetFramework="native" />
2424
<package id="Microsoft.WSL.TestData" version="0.4.0" />

src/windows/common/DeviceHostProxy.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ void DeviceHostProxy::RemoveDevice(const GUID& Type, const GUID& InstanceId)
7575
m_devices.erase(InstanceId);
7676
}
7777

78-
// TODO: Add this back after the the hotplug issue with the most recent wsldevicehost.dll is resolved.
79-
// See https://github.com/microsoft/openvmm/issues/3077 for more details.
80-
return;
81-
8278
// N.B. Removing the FlexIov device is best effort since not all versions of Windows support it.
8379
try
8480
{

src/windows/common/WSLCUserSettings.cpp

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace {
167167

168168
// Validates and stores a single setting from the YAML document.
169169
template <Setting S>
170-
void ValidateSetting(const YAML::Node& root, SettingsMap& map, std::vector<Warning>& warnings)
170+
void ValidateSetting(const YAML::Node& root, SettingsMap& map, const std::wstring& filePath, std::vector<Warning>& warnings)
171171
{
172172
constexpr auto path = details::SettingMapping<S>::YamlPath;
173173
auto node = NavigateYamlPath(root, path);
@@ -201,21 +201,23 @@ namespace {
201201
else
202202
{
203203
const auto widePath = MultiByteToWide(path);
204-
warnings.push_back({std::format(L"Warning: Invalid value for setting '{}'. Using default.", widePath), widePath});
204+
warnings.push_back(
205+
{wsl::shared::Localization::WSLCUserSettings_Warning_InvalidValue(widePath, filePath, node->Mark().line + 1), widePath});
205206
}
206207
}
207208
catch (...)
208209
{
209210
const auto widePath = MultiByteToWide(path);
210-
warnings.push_back({std::format(L"Warning: Invalid type for setting '{}'. Using default.", widePath), widePath});
211+
warnings.push_back(
212+
{wsl::shared::Localization::WSLCUserSettings_Warning_InvalidType(widePath, filePath, node->Mark().line + 1), widePath});
211213
}
212214
}
213215

214216
// Validates all settings via a fold over the Setting enum index sequence.
215217
template <size_t... S>
216-
void ValidateAll(const YAML::Node& root, SettingsMap& map, std::vector<Warning>& warnings, std::index_sequence<S...>)
218+
void ValidateAll(const YAML::Node& root, SettingsMap& map, const std::wstring& filePath, std::vector<Warning>& warnings, std::index_sequence<S...>)
217219
{
218-
(ValidateSetting<static_cast<Setting>(S)>(root, map, warnings), ...);
220+
(ValidateSetting<static_cast<Setting>(S)>(root, map, filePath, warnings), ...);
219221
}
220222

221223
// Collects the set of known dot-separated YAML paths from all SettingMapping specializations.
@@ -243,7 +245,12 @@ namespace {
243245
}
244246

245247
// Iteratively walks the YAML tree and warns about keys not in the known set.
246-
void WarnUnknownKeys(const YAML::Node& root, const std::set<std::string>& knownPaths, const std::set<std::string>& knownPrefixes, std::vector<Warning>& warnings)
248+
void WarnUnknownKeys(
249+
const YAML::Node& root,
250+
const std::set<std::string>& knownPaths,
251+
const std::set<std::string>& knownPrefixes,
252+
const std::wstring& filePath,
253+
std::vector<Warning>& warnings)
247254
{
248255
// Stack of (node, prefix) pairs to process.
249256
std::vector<std::pair<YAML::Node, std::string>> stack;
@@ -264,7 +271,8 @@ namespace {
264271
catch (...)
265272
{
266273
auto location = prefix.empty() ? std::wstring(L"root") : MultiByteToWide(prefix);
267-
warnings.push_back({std::format(L"Warning: Non-string key in section '{}'.", location), location});
274+
warnings.push_back(
275+
{wsl::shared::Localization::WSLCUserSettings_Warning_NonStringKey(location, filePath, it->first.Mark().line + 1), location});
268276
continue;
269277
}
270278

@@ -281,14 +289,18 @@ namespace {
281289
{
282290
// Unknown section — warn once, don't traverse.
283291
const auto widePath = MultiByteToWide(fullPath);
284-
warnings.push_back({std::format(L"Warning: Unknown setting section '{}'.", widePath), widePath});
292+
warnings.push_back(
293+
{wsl::shared::Localization::WSLCUserSettings_Warning_UnknownSection(
294+
widePath, filePath, it->first.Mark().line + 1),
295+
widePath});
285296
}
286297
}
287298
else if (!knownPaths.count(fullPath) && !knownPrefixes.count(fullPath))
288299
{
289300
// Unknown setting
290301
const auto widePath = MultiByteToWide(fullPath);
291-
warnings.push_back({std::format(L"Warning: Unknown setting '{}'.", widePath), widePath});
302+
warnings.push_back(
303+
{wsl::shared::Localization::WSLCUserSettings_Warning_UnknownKey(widePath, filePath, it->first.Mark().line + 1), widePath});
292304
}
293305
}
294306
}
@@ -306,8 +318,7 @@ namespace {
306318
// emit a warning so the user understands why settings were ignored.
307319
if (err != ENOENT)
308320
{
309-
warnings.push_back(
310-
{std::format(L"Warning: Failed to open '{}', errno: {}. Using default settings.", path.filename().wstring(), err), {}});
321+
warnings.push_back({wsl::shared::Localization::WSLCUserSettings_Warning_FailedToOpen(path.wstring(), err), {}});
311322
}
312323

313324
return std::nullopt;
@@ -320,7 +331,7 @@ namespace {
320331
catch (const std::exception& e)
321332
{
322333
warnings.push_back(
323-
{std::format(L"Warning: '{}' could not be parsed: {}.", path.filename().wstring(), MultiByteToWide(e.what())), {}});
334+
{wsl::shared::Localization::WSLCUserSettings_Warning_ParseError(path.wstring(), MultiByteToWide(e.what())), {}});
324335
return std::nullopt;
325336
}
326337
}
@@ -350,23 +361,21 @@ UserSettings::UserSettings(const std::filesystem::path& settingsDir)
350361
if (root.has_value())
351362
{
352363
m_type = UserSettingsType::Standard;
364+
const auto filePath = m_settingsPath.wstring();
353365

354366
if (root->IsMap())
355367
{
356368
constexpr auto settingCount = static_cast<size_t>(Setting::Max);
357-
ValidateAll(root.value(), m_settings, m_warnings, std::make_index_sequence<settingCount>());
369+
ValidateAll(root.value(), m_settings, filePath, m_warnings, std::make_index_sequence<settingCount>());
358370

359371
constexpr auto indexSeq = std::make_index_sequence<settingCount>();
360372
auto knownPaths = CollectKnownPaths(indexSeq);
361373
auto knownPrefixes = CollectKnownPrefixes(knownPaths);
362-
WarnUnknownKeys(root.value(), knownPaths, knownPrefixes, m_warnings);
374+
WarnUnknownKeys(root.value(), knownPaths, knownPrefixes, filePath, m_warnings);
363375
}
364376
else
365377
{
366-
m_warnings.push_back(
367-
{std::format(
368-
L"Warning: '{}' is empty or has invalid structure. Expected a YAML mapping.", m_settingsPath.filename().wstring()),
369-
{}});
378+
m_warnings.push_back({wsl::shared::Localization::WSLCUserSettings_Warning_InvalidStructure(filePath), {}});
370379
}
371380
}
372381

0 commit comments

Comments
 (0)