Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp (C++)

Code before:

    try
    {
        _parse(OriginTag::User, {}, userJSON, userSettings);
    }
    catch (const JsonUtils::DeserializationError& e)
    {
        _rethrowSerializationExceptionWithLocationInfo(e, userJSON);
    }

    if (const auto sources = userSettings.globals->DisabledProfileSources())
    {
        _ignoredNamespaces.reserve(sources.Size());
        for (auto&& id : sources)
        {
            _ignoredNamespaces.emplace(std::move(id));
        }
    }

    // Apply DisabledProfileSources policy setting. Pick whatever policy is set first.
    // In most cases HKCU settings take precedence over HKLM settings, but the inverse is true for policies.
    for (const auto key : { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER })
    {
        wchar_t buffer[512]; // "640K ought to be enough for anyone"
        DWORD bufferSize = sizeof(buffer);
        if (RegGetValueW(key, LR"(Software\Policies\Microsoft\Windows\Terminal)", L"DisabledProfileSources", RRF_RT_REG_MULTI_SZ, nullptr, buffer, &bufferSize) == 0)
        {
            for (auto p = buffer; *p;)
            {
                const auto len = wcslen(p);
                _ignoredNamespaces.emplace(p, gsl::narrow_cast<uint32_t>(len));
                p += len + 1;
            }
            break;
        }
    }

    // See member description of _userProfileCount.
    _userProfileCount = userSettings.profiles.size();
}

// Generate dynamic profiles and add them to the list of "inbox" profiles
// (meaning profiles specified by the application rather by the user).
void SettingsLoader::GenerateProfiles()
{
    _executeGenerator(PowershellCoreProfileGenerator{});
    _executeGenerator(WslDistroGenerator{});
    _executeGenerator(AzureCloudShellGenerator{});
    _executeGenerator(VisualStudioGenerator{});
#if TIL_FEATURE_DYNAMICSSHPROFILES_ENABLED
    _executeGenerator(SshHostGenerator{});

Review comment (bug):
```suggestion
        if (RegGetValueW(key, LR"(Software\Policies\Microsoft\Windows\WindowsTerminal)", L"DisabledProfileSources", RRF_RT_REG_MULTI_SZ, nullptr, buffer, &bufferSize) == 0)
```

RDP policies using "Terminal" to. In a slightly different place but to avoid confusion you should change the registry key.


Code after:

    try
    {
        _parse(OriginTag::User, {}, userJSON, userSettings);
    }
    catch (const JsonUtils::DeserializationError& e)
    {
        _rethrowSerializationExceptionWithLocationInfo(e, userJSON);
    }

    if (const auto sources = userSettings.globals->DisabledProfileSources())
    {
        _ignoredNamespaces.reserve(sources.Size());
        for (auto&& id : sources)
        {
            _ignoredNamespaces.emplace(std::move(id));
        }
    }

    // Apply DisabledProfileSources policy setting. Pick whatever policy is set first.
    // In most cases HKCU settings take precedence over HKLM settings, but the inverse is true for policies.
    for (const auto key : { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER })
    {
        wchar_t buffer[512]; // "640K ought to be enough for anyone"
        DWORD bufferSize = sizeof(buffer);
        if (RegGetValueW(key, LR"(Software\Policies\Microsoft\Windows Terminal)", L"DisabledProfileSources", RRF_RT_REG_MULTI_SZ, nullptr, buffer, &bufferSize) == 0)
        {
            for (auto p = buffer; *p;)
            {
                const auto len = wcslen(p);
                _ignoredNamespaces.emplace(p, gsl::narrow_cast<uint32_t>(len));
                p += len + 1;
            }
            break;
        }
    }

    // See member description of _userProfileCount.
    _userProfileCount = userSettings.profiles.size();
}

// Generate dynamic profiles and add them to the list of "inbox" profiles
// (meaning profiles specified by the application rather by the user).
void SettingsLoader::GenerateProfiles()
{
    _executeGenerator(PowershellCoreProfileGenerator{});
    _executeGenerator(WslDistroGenerator{});
    _executeGenerator(AzureCloudShellGenerator{});
    _executeGenerator(VisualStudioGenerator{});
#if TIL_FEATURE_DYNAMICSSHPROFILES_ENABLED
    _executeGenerator(SshHostGenerator{});