function removeHiddenStacksAndProperties()

in src/commands/createFunctionApp/stacks/getStackPicks.ts [141:177]


function removeHiddenStacksAndProperties(stacks: FunctionAppStack[]): void {
    const showHiddenStacks = getWorkspaceSetting<boolean>(hiddenStacksSetting);
    for (const stack of stacks) {
        for (const major of stack.majorVersions) {
            for (const minor of major.minorVersions) {
                // Temporary workaround because the platform team doesn't want .NET 5 to show in the portal yet, but they do want it in VS Code
                // https://github.com/microsoft/vscode-azurefunctions/issues/2552
                if (major.value === 'dotnet5') {
                    if (minor.stackSettings.linuxRuntimeSettings) {
                        minor.stackSettings.linuxRuntimeSettings.isHidden = false;
                    }
                    if (minor.stackSettings.windowsRuntimeSettings) {
                        minor.stackSettings.windowsRuntimeSettings.isHidden = false;
                    }
                }

                if (!showHiddenStacks) {
                    if (minor.stackSettings.linuxRuntimeSettings?.isHidden) {
                        delete minor.stackSettings.linuxRuntimeSettings;
                    }

                    if (minor.stackSettings.windowsRuntimeSettings?.isHidden) {
                        delete minor.stackSettings.windowsRuntimeSettings;
                    }
                }

                if (minor.stackSettings.windowsRuntimeSettings?.supportedFunctionsExtensionVersions.includes(FuncVersion.v3) &&
                    minor.stackSettings.windowsRuntimeSettings?.supportedFunctionsExtensionVersions.includes(FuncVersion.v4)) {
                    // Temporary workaround becausecurrently there are stacks that support both v3 and v4, but if netFrameworkVersion v6.0
                    // is set for ~3 app, it will break so delete the netFrameworkVersion and only set to v6.0 for ~4
                    // https://github.com/microsoft/vscode-azurefunctions/issues/2990
                    delete minor.stackSettings.windowsRuntimeSettings.siteConfigPropertiesDictionary.netFrameworkVersion;
                }
            }
        }
    }
}