Repository: FlaxEngine/FlaxEngine
File: Source/Editor/Cooker/Steps/DeployDataStep.cpp (C++)

Code before:
                if (!failed)
                {
                    srcDotnet = parts[2].TrimTrailing();
                }
                if (failed || !FileSystem::DirectoryExists(srcDotnet))
                {
                    data.Error(TEXT("Failed to get .NET SDK location for the current host platform."));
                    return true;
                }
                FileSystem::NormalizePath(srcDotnet);
                LOG(Info, "Using .NET Runtime {} at {}", TEXT("Host"), srcDotnet);

                // Get major Version
                Array<String> pathParts;
                srcDotnet.Split('/', pathParts);
                String version;
                for (int i = 0; i < pathParts.Count(); i++)
                {
                    if (pathParts[i] == TEXT("runtimes"))
                    {
                        Array<String> versionParts;
                        pathParts[i - 1].Split('.', versionParts);
                        const String majorVersion = versionParts[0].TrimTrailing();
                        uint32 versionNum;
                        StringUtils::Parse(*majorVersion, majorVersion.Length(), &versionNum);
                        if (versionNum < GAME_BUILD_DOTNET_RUNTIME_MAX_VER || versionNum > GAME_BUILD_DOTNET_RUNTIME_MIN_VER) // Check for major part
                            version = majorVersion;
                    }
                }

                if (version.IsEmpty())
                {
                    data.Error(TEXT("Failed to find supported .NET version for the current host platform."));
                    return true;
                }

                // Deploy runtime files
                const Char* corlibPrivateName = TEXT("System.Private.CoreLib.dll");
                const bool srcDotnetFromEngine = srcDotnet.Contains(TEXT("Source/Platforms"));
                String packFolder = srcDotnet / TEXT("../../../");
                String dstDotnetLibs = dstDotnet, srcDotnetLibs = srcDotnet;
                StringUtils::PathRemoveRelativeParts(packFolder);
                if (usAOT)
                {
                    if (srcDotnetFromEngine)
                    {
                        // AOT runtime files inside Engine Platform folder
                        packFolder /= TEXT("Dotnet");
                        dstDotnetLibs /= String::Format(TEXT("lib/net{}.0"), version);
                        srcDotnetLibs = packFolder / String::Format(TEXT("lib/net{}.0"), version);
                    }

Review comment (suggestion):
You could use `Math::IsInRange(versionNum, GAME_BUILD_DOTNET_RUNTIME_MIN_VER, GAME_BUILD_DOTNET_RUNTIME_MAX_VER)` to check for range.

Code after:
                if (!failed)
                {
                    srcDotnet = parts[2].TrimTrailing();
                }
                if (failed || !FileSystem::DirectoryExists(srcDotnet))
                {
                    data.Error(TEXT("Failed to get .NET SDK location for the current host platform."));
                    return true;
                }
                FileSystem::NormalizePath(srcDotnet);
                LOG(Info, "Using .NET Runtime {} at {}", TEXT("Host"), srcDotnet);

                // Get major Version
                Array<String> pathParts;
                srcDotnet.Split('/', pathParts);
                String version;
                for (int i = 0; i < pathParts.Count(); i++)
                {
                    if (pathParts[i] == TEXT("runtimes"))
                    {
                        Array<String> versionParts;
                        pathParts[i - 1].Split('.', versionParts);
                        if (!versionParts.IsEmpty())
                        {
                            const String majorVersion = versionParts[0].TrimTrailing();
                            int32 versionNum;
                            StringUtils::Parse(*majorVersion, majorVersion.Length(), &versionNum);
                            if (Math::IsInRange(versionNum, GAME_BUILD_DOTNET_RUNTIME_MIN_VER, GAME_BUILD_DOTNET_RUNTIME_MAX_VER)) // Check for major part
                                version = majorVersion;
                        }
                    }
                }

                if (version.IsEmpty())
                {
                    data.Error(TEXT("Failed to find supported .NET version for the current host platform."));
                    return true;
                }

                // Deploy runtime files
                const Char* corlibPrivateName = TEXT("System.Private.CoreLib.dll");
                const bool srcDotnetFromEngine = srcDotnet.Contains(TEXT("Source/Platforms"));
                String packFolder = srcDotnet / TEXT("../../../");
                String dstDotnetLibs = dstDotnet, srcDotnetLibs = srcDotnet;
                StringUtils::PathRemoveRelativeParts(packFolder);
                if (usAOT)
                {
                    if (srcDotnetFromEngine)
                    {
                        // AOT runtime files inside Engine Platform folder
                        packFolder /= TEXT("Dotnet");