diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp index 8f2ebaba8d..af35842afc 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp @@ -209,6 +209,11 @@ namespace AZ AZ::Outcome ReadJsonString(AZStd::string_view jsonText) { + if (jsonText.empty()) + { + return AZ::Failure(AZStd::string("Failed to parse JSON: input string is empty.")); + } + rapidjson::Document jsonDocument; jsonDocument.Parse(jsonText.data(), jsonText.size()); if (jsonDocument.HasParseError()) diff --git a/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.cpp b/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.cpp index 39dd482cb7..7bfdbb2f7e 100644 --- a/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.cpp +++ b/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.cpp @@ -36,28 +36,6 @@ namespace AzFramework { namespace Internal { - //! Save a JSON document to a stream. Otherwise returns a failure with error message. - AZ::Outcome WriteJsonToStream(const rapidjson::Document& document, AZ::IO::GenericStream& stream, WriteJsonSettings settings = WriteJsonSettings{}) - { - AZ::IO::RapidJSONStreamWriter jsonStreamWriter(&stream); - - rapidjson::PrettyWriter writer(jsonStreamWriter); - - if (settings.m_maxDecimalPlaces >= 0) - { - writer.SetMaxDecimalPlaces(settings.m_maxDecimalPlaces); - } - - if (document.Accept(writer)) - { - return AZ::Success(); - } - else - { - return AZ::Failure(AZStd::string{ "Json Writer failed" }); - } - } - static bool FindFilesInPath(const AZStd::string& folder, const AZStd::string& filter, bool recurseSubFolders, AZStd::list& fileList) { AZStd::string file_filter = folder; @@ -107,210 +85,8 @@ namespace AzFramework { return AZStd::string("(^|\\n\\s*)" + key + "([ \\t]*)=([ \\t]*)(.*)"); } - - /** - * Replaces a value in an ini-style content. - * - * \param[in] cfgContents The contents of the ini-style file - * \param[in] header The optional group title for the key - * \param[in] key The key of the value to replace - * \param[in] newValue The value to assign to the key - * - * \returns Void on success, error message on failure. - * - * If key has multiple values, it does not preserve other values. - * enabled_game_projects = oldProject1, oldProject2, oldProject3 - * becomes - * enabled_game_projects = newProject - * Cases to handle: - * 1. Key exists, value is identical -> do nothing - * This can occur if a user modifies a config file while the tooling is open. - * Example: - * 1) Load Project Configurator. - * 2) Modify your bootstrap.cfg to a different project. - * 3) Tell Project Configurator to set your project to the project you set in #2. - * 2. Key exists, value is missing -> stomps over key with new key value pair. - * 3. Key exists, value is different -> stomps over key with new key value pair. Ignores previous values. - * 4. Key does not exist, header is not required -> insert "key=value" at the end of file. - * 5. Key does not exist, required header does not exist -> insert "\nHeader\n" at end of file and continue to #6. - * 6. Key does not exist, required header does exist -> insert "key=value" at next line under the header. - * The header will always exist at this point, it was created in the previous check if it was missing. - */ - AZ::Outcome UpdateCfgContents(AZStd::string& cfgContents, const AZStd::string& header, const AZStd::string& key, const AZStd::string& value) - { - // Generate regex str and replacement str - AZStd::string lhsStr = key; - AZStd::string regexStr = BuildConfigKeyValueRegex(lhsStr); - AZStd::string gameFolderAssignment = "$1" + lhsStr + "$2=$03" + value; - - // Replace the current key with the new value - // AZStd's regex was not functional at the time this was authored, so convert to std from AZStd. - std::regex sysGameRegex(regexStr.c_str()); - std::smatch matchResults; - std::string settingsFileContentsStdStr = cfgContents.c_str(); - bool matchFound = std::regex_search(settingsFileContentsStdStr, matchResults, sysGameRegex); - - std::string result; - if (matchFound) - { - // Case 1, 2, and 3 - Key value pair exists, stomp over the key with a new value pair. - result = std::regex_replace(cfgContents.c_str(), sysGameRegex, gameFolderAssignment.c_str()); - } - else - { - // Cases 4 through 6 - the key does not exist. - result = cfgContents.c_str(); - std::size_t insertLocation = 0; - // Case 5 & 6 - key does not exist, header is required - if (!header.empty()) - { - insertLocation = result.find(header.c_str()); - // Case 6 - key does not exist, header does exist. - // Set the key insertion point to right after the header. - if (insertLocation != std::string::npos) - { - insertLocation += header.length(); - } - // Case 5 - key does not exist, required header does not exist. - // Insert the header at the top of the file, set the key insertion point after the header. - else - { - AZStd::string headerAndCr = AZStd::string::format("\n%s\n", header.c_str()); - result.insert(result.length(), headerAndCr.c_str()); - insertLocation = result.length() - 1; - } - } - // Case 4 - key does not exist, header is not required. - // Case 5 & 6 - the header has been added. - // Insert the key at the tracked insertion point - AZStd::string newConfigData = AZStd::string::format("\n%s=%s", key.c_str(), value.c_str()); - result.insert(insertLocation, newConfigData.c_str()); - } - cfgContents = result.c_str(); - return AZ::Success(); - } - - /** - * Updates a configuration (ini) style contents string representation with a list of replacement string rules - * - * \param[in] cfgContents The contents of the ini file to update - * \param[in] updateRules The update rules (list of update strings, see below) to apply - * - * The replace string rule format follows the following: - * ([header]/)[key]=[value] - * - * where: - * header (optional) : Optional group title for the key - * key : The key to lookup or create for the value - * value : The value to update or create - */ - AZ::Outcome UpdateCfgContents(AZStd::string& cfgContents, const AZStd::list& updateRules) - { - AZStd::string updateCfgContents = cfgContents; - for (const AZStd::string& updateRule : updateRules) - { - // Since we are parsing manually anyways, no need to do a regex validation - AZStd::string::size_type headerKeySep = updateRule.find_first_of('/'); - bool hasHeader = (headerKeySep != AZStd::string::npos); - AZStd::string::size_type keyValueSep = updateRule.find_first_of('=', !hasHeader ? 0 : headerKeySep + 1); - if (keyValueSep == AZStd::string::npos) - { - return AZ::Failure(AZStd::string::format("Invalid update config rule '%s'. Must be in the format ([header]/)[key]=[value]", updateRule.c_str())); - } - AZStd::string header = hasHeader ? updateRule.substr(0, headerKeySep) : AZStd::string(""); - AZStd::string key = hasHeader ? updateRule.substr(headerKeySep + 1, keyValueSep - (headerKeySep + 1)) : updateRule.substr(0, keyValueSep); - AZStd::string value = updateRule.substr(keyValueSep + 1); - - auto updateResult = UpdateCfgContents(updateCfgContents, header, key, value); - if (!updateResult.IsSuccess()) - { - return updateResult; - } - } - cfgContents = updateCfgContents; - return AZ::Success(); - } } // namespace Internal - AZ::Outcome WriteJsonToString(const rapidjson::Document& document, AZStd::string& jsonText, WriteJsonSettings settings) - { - AZ::IO::ByteContainerStream stream{ &jsonText }; - return Internal::WriteJsonToStream(document, stream, settings); - } - - AZ::Outcome ReadJsonFromString(AZStd::string_view jsonText) - { - if (jsonText.empty()) - { - return AZ::Failure(AZStd::string("Failed to parse JSON: input string is empty.")); - } - - rapidjson::Document jsonDocument; - jsonDocument.Parse(jsonText.data(), jsonText.size()); - if (jsonDocument.HasParseError()) - { - size_t lineNumber = 1; - - const size_t errorOffset = jsonDocument.GetErrorOffset(); - for (size_t searchOffset = jsonText.find('\n'); - searchOffset < errorOffset && searchOffset < AZStd::string::npos; - searchOffset = jsonText.find('\n', searchOffset + 1)) - { - lineNumber++; - } - - return AZ::Failure(AZStd::string::format("JSON parse error at line %zu: %s", lineNumber, rapidjson::GetParseError_En(jsonDocument.GetParseError()))); - } - else - { - return AZ::Success(AZStd::move(jsonDocument)); - } - } - - AZ::Outcome ReadJsonFile(const AZ::IO::Path& jsonFilePath, AZ::IO::FileIOBase* overrideFileIO /*= nullptr*/, size_t maxFileSize /*= AZ::Utils::DefaultMaxFileSize*/) - { - AZ::IO::FileIOBase* fileIo = overrideFileIO != nullptr ? overrideFileIO : AZ::IO::FileIOBase::GetInstance(); - if (fileIo == nullptr) - { - return AZ::Failure(AZStd::string("No FileIO instance present.")); - } - - // Read into memory first and then parse the JSON, rather than passing a file stream to rapidjson. - // This should avoid creating a large number of micro-reads from the file. - - auto readResult = AZ::Utils::ReadFile(jsonFilePath.String(), maxFileSize); - if (!readResult.IsSuccess()) - { - return AZ::Failure(readResult.GetError()); - } - - AZStd::string jsonContent = readResult.TakeValue(); - - auto result = ReadJsonFromString(jsonContent); - if (!result.IsSuccess()) - { - return AZ::Failure(AZStd::string::format("Failed to load '%s'. %s", jsonFilePath.c_str(), result.GetError().c_str())); - } - else - { - return result; - } - } - - AZ::Outcome WriteJsonFile(const rapidjson::Document& jsonDoc, const AZ::IO::Path& jsonFilePath, WriteJsonSettings settings) - { - // Write the JSON into memory first and then write the file, rather than passing a file stream to rapidjson. - // This should avoid creating a large number of micro-writes to the file. - AZStd::string fileContent; - auto outcome = WriteJsonToString(jsonDoc, fileContent, settings); - if (!outcome.IsSuccess()) - { - return outcome; - } - - return AZ::Utils::WriteFile(fileContent, jsonFilePath.String()); - } - AZ::Outcome, AZStd::string> FindFilesInPath(const AZStd::string& folder, const AZStd::string& filter, bool recurseSubFolders) { AZStd::list fileList; @@ -348,61 +124,6 @@ namespace AzFramework return AZ::Success(); } - AZ::Outcome ReplaceInCfgFile(const AZStd::string& filePath, const AZStd::list& updateRules) - { - if (!AZ::IO::SystemFile::Exists(filePath.c_str())) - { - return AZ::Failure(AZStd::string::format("Cfg file '%s' does not exist.", filePath.c_str())); - } - - // Load the settings file into a string - AZ::IO::SystemFile settingsFile; - if (!settingsFile.Open(filePath.c_str(), AZ::IO::SystemFile::SF_OPEN_READ_ONLY)) - { - return AZ::Failure(AZStd::string::format("Error reading cfg file '%s'.", filePath.c_str())); - } - - AZStd::string settingsFileContents(settingsFile.Length(), '\0'); - settingsFile.Read(settingsFileContents.size(), settingsFileContents.data()); - settingsFile.Close(); - - auto updateContentResult = Internal::UpdateCfgContents(settingsFileContents, updateRules); - if (!updateContentResult.IsSuccess()) - { - return updateContentResult; - } - - // Write the result. - if (!settingsFile.ReOpen(AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY | AZ::IO::SystemFile::SF_OPEN_TRUNCATE)) - { - return AZ::Failure(AZStd::string::format("Failed to open settings file %s.", filePath.c_str())); - } - auto bytesWritten = settingsFile.Write(settingsFileContents.c_str(), settingsFileContents.size()); - settingsFile.Close(); - - if (bytesWritten != settingsFileContents.size()) - { - return AZ::Failure(AZStd::string::format("Failed to write to config file %s.", filePath.c_str())); - } - - return AZ::Success(); - } - - AZ::Outcome ReplaceInCfgFile(const AZStd::string& filePath, const char* header, const AZStd::string& key, const AZStd::string& newValue) - { - if (key.length() <= 0) - { - return AZ::Failure(AZStd::string("'key' parameter for ReplaceInCfgFile must not be empty")); - } - - AZStd::string updateRule = (header != nullptr) ? AZStd::string::format("%s/%s=%s", header, key.c_str(), newValue.c_str()) : AZStd::string::format("%s=%s", key.c_str(), newValue.c_str()); - AZStd::list updateRules{ - updateRule - }; - auto replaceResult = ReplaceInCfgFile(filePath, updateRules); - return replaceResult; - } - AZ::Outcome GetValueForKeyInCfgFile(const AZStd::string& filePath, const char* key) { AZ::Outcome subCommandResult = GetCfgFileContents(filePath); diff --git a/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.h b/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.h index 43609986f7..1fcef4ccfa 100644 --- a/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.h +++ b/Code/Framework/AzFramework/AzFramework/FileFunc/FileFunc.h @@ -27,49 +27,6 @@ namespace AzFramework { namespace FileFunc { - struct WriteJsonSettings - { - int m_maxDecimalPlaces = -1; // -1 means use default - }; - - /* - * Read a string into a JSON document - * - * \param[in] jsonText The string of JSON to parse into a JSON document. - * \return Outcome ReadJsonFromString(AZStd::string_view jsonText); - - /* - * Read a text file into a JSON document - * - * \param[in] jsonFilePath The path to the JSON file path to open - * \param[in] overrideFileIO Optional file IO instance to use. If null, use the Singleton instead - * \param[in] maxFileSize The maximum size, in bytes, of the file to read. Defaults to 1 MB. - * \return Outcome(rapidjson::Document) Returns a failure with error message if the content is not valid JSON. - */ - AZ::Outcome ReadJsonFile(const AZ::IO::Path& jsonFilePath, AZ::IO::FileIOBase* overrideFileIO = nullptr, size_t maxFileSize = AZ::Utils::DefaultMaxFileSize); - - /** - * Write a JSON document to a string - * - * \param[in] jsonDoc The JSON document to write to a text file - * \param[out] jsonFilePath The string that the JSON text will be written to. - * \param[in] settings Settings to pass along to the JSON writer. - * \return StringOutcome Saves the JSON document to text. Otherwise returns a failure with error message. - */ - AZ::Outcome WriteJsonToString(const rapidjson::Document& document, AZStd::string& jsonText, WriteJsonSettings settings = WriteJsonSettings{}); - - /** - * Write a JSON document to a text file - * - * \param[in] jsonDoc The JSON document to write to a text file - * \param[in] jsonFilePath The path to the JSON file path to write to - * \param[in] settings Settings to pass along to the JSON writer. - * \return StringOutcome Saves the JSON document to a file. Otherwise returns a failure with error message. - */ - AZ::Outcome WriteJsonFile(const rapidjson::Document& jsonDoc, const AZ::IO::Path& jsonFilePath, WriteJsonSettings settings = WriteJsonSettings{}); - /** * Find all the files in a path based on an optional filter. Recurse if requested. * @@ -91,38 +48,6 @@ namespace AzFramework */ AZ::Outcome ReadTextFileByLine(const AZStd::string& filePath, AZStd::function perLineCallback); - /** - * Replaces a value in an ini-style file. - * - * \param[in] filePath The path to the config file to update - * \param[in] updateRules The update rules (list of update strings, see below) to apply - * - * The replace string rule format follows the following: - * ([header]/)[key]=[value] - * - * where: - * header (optional) : Optional group title for the key - * key : The key to lookup or create for the value - * value : The value to update or create - */ - AZ::Outcome ReplaceInCfgFile(const AZStd::string& filePath, const AZStd::list& updateRules); - - /** - * Replaces a value in an ini-style file. - * - * \param[in] filePath The path to the config file to update - * \param[in] updateRule The update rule (list of update strings, see below) to apply - * - * The replace string rule format follows the following: - * ([header]/)[key]=[value] - * - * where: - * header (optional) : Optional group title for the key - * key : The key to lookup or create for the value - * value : The value to update or create - */ - AZ::Outcome ReplaceInCfgFile(const AZStd::string& filePath, const char* header, const AZStd::string& key, const AZStd::string& newValue); - /** * Gets the value(s) for a key in an INI style config file. * diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp index 0a9c937832..85b89b93dc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp @@ -11,11 +11,12 @@ #include #include +#include #include #include +#include #include -#include #include #include #include @@ -134,7 +135,7 @@ namespace AzToolsFramework } // Read Template's prefab file from disk and parse Prefab DOM from file. - AZ::Outcome readPrefabFileResult = AzFramework::FileFunc::ReadJsonFromString(fileContent); + AZ::Outcome readPrefabFileResult = AZ::JsonSerializationUtils::ReadJsonString(fileContent); if (!readPrefabFileResult.IsSuccess()) { AZ_Error( @@ -346,7 +347,7 @@ namespace AzToolsFramework return false; } - auto outcome = AzFramework::FileFunc::WriteJsonFile(domAndFilepath->first, GetFullPath(domAndFilepath->second)); + auto outcome = AZ::JsonSerializationUtils::WriteJsonFile(domAndFilepath->first, GetFullPath(domAndFilepath->second).Native()); if (!outcome.IsSuccess()) { AZ_Error( @@ -387,7 +388,7 @@ namespace AzToolsFramework return false; } - auto outcome = AzFramework::FileFunc::WriteJsonFile(domAndFilepath->first, absolutePath); + auto outcome = AZ::JsonSerializationUtils::WriteJsonFile(domAndFilepath->first, absolutePath.Native()); if (!outcome.IsSuccess()) { AZ_Error( @@ -410,7 +411,7 @@ namespace AzToolsFramework return false; } - auto outcome = AzFramework::FileFunc::WriteJsonToString(domAndFilepath->first, output); + auto outcome = AZ::JsonSerializationUtils::WriteJsonString(domAndFilepath->first, output); if (!outcome.IsSuccess()) { AZ_Error( diff --git a/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp b/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp index 80b1576b33..c4299a6ff9 100644 --- a/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp @@ -26,20 +26,6 @@ #include #include -namespace AzFramework -{ - namespace FileFunc - { - namespace Internal - { - AZ::Outcome UpdateCfgContents(AZStd::string& cfgContents, const AZStd::list& updateRules); - AZ::Outcome UpdateCfgContents(AZStd::string& cfgContents, const AZStd::string& header, const AZStd::string& key, const AZStd::string& value); - AZ::Outcome WriteJsonToStream(const rapidjson::Document& document, AZ::IO::GenericStream& stream, - WriteJsonSettings settings = WriteJsonSettings{}); - } - } -} - namespace UnitTest { class FileFuncTest : public ScopedAllocatorSetupFixture @@ -62,110 +48,6 @@ namespace UnitTest AZ::IO::FileIOBase* m_prevFileIO; }; - TEST_F(FileFuncTest, UpdateCfgContents_InValidInput_Fail) - { - AZStd::string cfgContents = "[Foo]\n"; - AZStd::list updateRules; - - updateRules.push_back(AZStd::string("Foo/one*1")); - auto result = AzFramework::FileFunc::Internal::UpdateCfgContents(cfgContents, updateRules); - ASSERT_FALSE(result.IsSuccess()); - } - - TEST_F(FileFuncTest, UpdateCfgContents_ValidInput_Success) - { - AZStd::string cfgContents = - "[Foo]\n" - "one =2 \n" - "two= 3\n" - "three = 4\n" - "\n" - "[Bar]\n" - "four=3\n" - "five=3\n" - "six=3\n" - "eight=3\n"; - - AZStd::list updateRules; - - updateRules.push_back(AZStd::string("Foo/one=1")); - updateRules.push_back(AZStd::string("Foo/two=2")); - updateRules.push_back(AZStd::string("three=3")); - auto result = AzFramework::FileFunc::Internal::UpdateCfgContents(cfgContents, updateRules); - EXPECT_TRUE(result.IsSuccess()); - - AZStd::string compareCfgContents = - "[Foo]\n" - "one =1\n" - "two= 2\n" - "three = 3\n" - "\n" - "[Bar]\n" - "four=3\n" - "five=3\n" - "six=3\n" - "eight=3\n"; - - bool equals = cfgContents.compare(compareCfgContents) == 0; - ASSERT_TRUE(equals); - } - - TEST_F(FileFuncTest, UpdateCfgContents_ValidInputNewEntrySameHeader_Success) - { - AZStd::string cfgContents = - "[Foo]\n" - "one =2 \n" - "two= 3\n" - "three = 4\n"; - - AZStd::string header("[Foo]"); - AZStd::string key("four"); - AZStd::string value("4"); - auto result = AzFramework::FileFunc::Internal::UpdateCfgContents(cfgContents, header, key, value); - EXPECT_TRUE(result.IsSuccess()); - - AZStd::string compareCfgContents = - "[Foo]\n" - "four=4\n" - "one =2 \n" - "two= 3\n" - "three = 4\n"; - - bool equals = cfgContents.compare(compareCfgContents) == 0; - ASSERT_TRUE(equals); - } - - TEST_F(FileFuncTest, UpdateCfgContents_ValidInputNewEntryDifferentHeader_Success) - { - AZStd::string cfgContents = - ";Sample Data\n" - "[Foo]\n" - "one =2 \n" - "two= 3\n" - "three = 4\n"; - - AZStd::list updateRules; - - AZStd::string header("[Bar]"); - AZStd::string key("four"); - AZStd::string value("4"); - auto result = AzFramework::FileFunc::Internal::UpdateCfgContents(cfgContents, header, key, value); - EXPECT_TRUE(result.IsSuccess()); - - AZStd::string compareCfgContents = - ";Sample Data\n" - "[Foo]\n" - "one =2 \n" - "two= 3\n" - "three = 4\n" - "\n" - "[Bar]\n" - "four=4\n"; - - bool equals = cfgContents.compare(compareCfgContents) == 0; - ASSERT_TRUE(equals); - } - static bool CreateDummyFile(const QString& fullPathToFile, const QString& tempStr = {}) { QFileInfo fi(fullPathToFile); @@ -268,213 +150,4 @@ namespace UnitTest ASSERT_NE(findElement, result.GetValue().end()); } } - - class JsonFileFuncTest - : public FrameworkApplicationFixture - { - protected: - void SetUp() override - { - FrameworkApplicationFixture::SetUp(); - - AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get(); - auto projectPathKey = - AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey) + "/project_path"; - registry->Set(projectPathKey, "AutomatedTesting"); - AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - - m_serializeContext = AZStd::make_unique(); - m_jsonRegistrationContext = AZStd::make_unique(); - m_jsonSystemComponent = AZStd::make_unique(); - - m_serializationSettings.m_serializeContext = m_serializeContext.get(); - m_serializationSettings.m_registrationContext = m_jsonRegistrationContext.get(); - - m_deserializationSettings.m_serializeContext = m_serializeContext.get(); - m_deserializationSettings.m_registrationContext = m_jsonRegistrationContext.get(); - - m_jsonSystemComponent->Reflect(m_jsonRegistrationContext.get()); - } - - void TearDown() override - { - m_jsonRegistrationContext->EnableRemoveReflection(); - m_jsonSystemComponent->Reflect(m_jsonRegistrationContext.get()); - m_jsonRegistrationContext->DisableRemoveReflection(); - - m_jsonRegistrationContext.reset(); - m_serializeContext.reset(); - m_jsonSystemComponent.reset(); - - FrameworkApplicationFixture::TearDown(); - } - - AZStd::unique_ptr m_serializeContext; - AZStd::unique_ptr m_jsonRegistrationContext; - AZStd::unique_ptr m_jsonSystemComponent; - - AZ::JsonSerializerSettings m_serializationSettings; - AZ::JsonDeserializerSettings m_deserializationSettings; - }; - - TEST_F(JsonFileFuncTest, WriteJsonString_ValidJson_ExpectSuccess) - { - rapidjson::Document document; - document.SetObject(); - document.AddMember("a", 1, document.GetAllocator()); - document.AddMember("b", 2, document.GetAllocator()); - document.AddMember("c", 3, document.GetAllocator()); - - AZStd::string expectedJsonText = - R"({ - "a": 1, - "b": 2, - "c": 3 - })"; - expectedJsonText.erase(AZStd::remove_if(expectedJsonText.begin(), expectedJsonText.end(), ::isspace), expectedJsonText.end()); - - AZStd::string outString; - AZ::Outcome result = AzFramework::FileFunc::WriteJsonToString(document, outString); - EXPECT_TRUE(result.IsSuccess()); - - outString.erase(AZStd::remove_if(outString.begin(), outString.end(), ::isspace), outString.end()); - EXPECT_EQ(expectedJsonText, outString) << "expected:\n" << expectedJsonText.c_str() << "\nactual:\n" << outString.c_str(); - } - - TEST_F(JsonFileFuncTest, WriteJsonStream_ValidJson_ExpectSuccess) - { - rapidjson::Document document; - document.SetObject(); - document.AddMember("a", 1, document.GetAllocator()); - document.AddMember("b", 2, document.GetAllocator()); - document.AddMember("c", 3, document.GetAllocator()); - - AZStd::string expectedJsonText = - R"({ - "a": 1, - "b": 2, - "c": 3 - })"; - expectedJsonText.erase(AZStd::remove_if(expectedJsonText.begin(), expectedJsonText.end(), ::isspace), expectedJsonText.end()); - - AZStd::vector outBuffer; - AZ::IO::ByteContainerStream> outStream{ &outBuffer }; - AZ::Outcome result = AzFramework::FileFunc::Internal::WriteJsonToStream(document, outStream); - EXPECT_TRUE(result.IsSuccess()); - - outBuffer.push_back(0); - AZStd::string outString = outBuffer.data(); - outString.erase(AZStd::remove_if(outString.begin(), outString.end(), ::isspace), outString.end()); - EXPECT_EQ(expectedJsonText, outString) << "expected:\n" << expectedJsonText.c_str() << "\nactual:\n" << outString.c_str(); - } - - TEST_F(JsonFileFuncTest, WriteJsonFile_ValidJson_ExpectSuccess) - { - AZ::Test::ScopedAutoTempDirectory tempDir; - - rapidjson::Document document; - document.SetObject(); - document.AddMember("a", 1, document.GetAllocator()); - document.AddMember("b", 2, document.GetAllocator()); - document.AddMember("c", 3, document.GetAllocator()); - - AZStd::string expectedJsonText = - R"({ - "a": 1, - "b": 2, - "c": 3 - })"; - expectedJsonText.erase(AZStd::remove_if(expectedJsonText.begin(), expectedJsonText.end(), ::isspace), expectedJsonText.end()); - - AZStd::string pathStr; - AzFramework::StringFunc::Path::ConstructFull(tempDir.GetDirectory(), "test.json", pathStr, true); - - // Write the JSON to a file - AZ::IO::Path path(pathStr); - AZ::Outcome saveResult = AzFramework::FileFunc::WriteJsonFile(document, path); - EXPECT_TRUE(saveResult.IsSuccess()); - - // Verify that the contents of the file is what we expect - AZ::Outcome readResult = AZ::Utils::ReadFile(pathStr); - EXPECT_TRUE(readResult.IsSuccess()); - AZStd::string outString(readResult.TakeValue()); - outString.erase(AZStd::remove_if(outString.begin(), outString.end(), ::isspace), outString.end()); - EXPECT_EQ(outString, expectedJsonText); - - // Clean up - AZ::IO::FileIOBase::GetInstance()->Remove(path.c_str()); - } - - TEST_F(JsonFileFuncTest, ReadJsonString_ValidJson_ExpectSuccess) - { - const char* jsonText = - R"( - { - "a": 1, - "b": 2, - "c": 3 - })"; - - AZ::Outcome result = AzFramework::FileFunc::ReadJsonFromString(jsonText); - - EXPECT_TRUE(result.IsSuccess()); - EXPECT_TRUE(result.GetValue().IsObject()); - EXPECT_TRUE(result.GetValue().HasMember("a")); - EXPECT_TRUE(result.GetValue().HasMember("b")); - EXPECT_TRUE(result.GetValue().HasMember("c")); - EXPECT_EQ(result.GetValue()["a"].GetInt(), 1); - EXPECT_EQ(result.GetValue()["b"].GetInt(), 2); - EXPECT_EQ(result.GetValue()["c"].GetInt(), 3); - } - - TEST_F(JsonFileFuncTest, ReadJsonString_InvalidJson_ErrorReportsLineNumber) - { - const char* jsonText = - R"( - { - "a": "This line is missing a comma" - "b": 2, - "c": 3 - } - )"; - - AZ::Outcome result = AzFramework::FileFunc::ReadJsonFromString(jsonText); - - EXPECT_FALSE(result.IsSuccess()); - EXPECT_TRUE(result.GetError().find("JSON parse error at line 4:") == 0); - } - - TEST_F(JsonFileFuncTest, ReadJsonFile_ValidJson_ExpectSuccess) - { - AZ::Test::ScopedAutoTempDirectory tempDir; - - const char* inputJsonText = - R"({ - "a": 1, - "b": 2, - "c": 3 - })"; - - rapidjson::Document expectedDocument; - expectedDocument.SetObject(); - expectedDocument.AddMember("a", 1, expectedDocument.GetAllocator()); - expectedDocument.AddMember("b", 2, expectedDocument.GetAllocator()); - expectedDocument.AddMember("c", 3, expectedDocument.GetAllocator()); - - // Create test file - AZStd::string path; - AzFramework::StringFunc::Path::ConstructFull(tempDir.GetDirectory(), "test.json", path, true); - AZ::Outcome writeResult = AZ::Utils::WriteFile(inputJsonText, path); - EXPECT_TRUE(writeResult.IsSuccess()); - - - // Read the JSON from the test file - AZ::Outcome readResult = AzFramework::FileFunc::ReadJsonFile(path); - EXPECT_TRUE(readResult.IsSuccess()); - - EXPECT_EQ(expectedDocument, readResult.GetValue()); - - // Clean up - AZ::IO::FileIOBase::GetInstance()->Remove(path.c_str()); - } } // namespace UnitTest diff --git a/Code/Tools/SceneAPI/SceneCore/Components/SceneSystemComponent.h b/Code/Tools/SceneAPI/SceneCore/Components/SceneSystemComponent.h index a9ce974a59..296d791f9a 100644 --- a/Code/Tools/SceneAPI/SceneCore/Components/SceneSystemComponent.h +++ b/Code/Tools/SceneAPI/SceneCore/Components/SceneSystemComponent.h @@ -19,8 +19,7 @@ namespace AZ { // Scene system components are components that can be used to create system components // in situations where the full initialization and/or construction of regular - // system components don't apply such as in the Project Configurator's advanced - // settings and the ResourceCompilerScene. + // system components don't apply such as in the ResourceCompilerScene. class SCENE_CORE_CLASS SceneSystemComponent : public AZ::Component { diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp b/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp index 8bbe9e2ed3..d68b6c52d4 100644 --- a/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp @@ -21,10 +21,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -163,8 +163,7 @@ namespace AZ return false; } - AZ::IO::Path fileIoPath(absoluteFilePath); - auto saveToFileOutcome = AzFramework::FileFunc::WriteJsonFile(saveToJsonOutcome.GetValue(), fileIoPath); + auto saveToFileOutcome = AZ::JsonSerializationUtils::WriteJsonFile(saveToJsonOutcome.GetValue(), absoluteFilePath); if (!saveToFileOutcome.IsSuccess()) { AZ_Error(ErrorWindowName, false, "%s%s", errorMsg.c_str(), saveToFileOutcome.GetError().c_str()); @@ -309,7 +308,7 @@ namespace AZ else { // Attempt to read the stream as JSON - auto readJsonOutcome = AzFramework::FileFunc::ReadJsonFromString(fileContents); + auto readJsonOutcome = AZ::JsonSerializationUtils::ReadJsonString(fileContents); AZStd::string errorMsg; if (!readJsonOutcome.IsSuccess()) { diff --git a/Code/Tools/SceneAPI/SceneCore/DllMain.cpp b/Code/Tools/SceneAPI/SceneCore/DllMain.cpp index 27a5ee238f..408b516f84 100644 --- a/Code/Tools/SceneAPI/SceneCore/DllMain.cpp +++ b/Code/Tools/SceneAPI/SceneCore/DllMain.cpp @@ -137,7 +137,7 @@ namespace AZ // Check if this library hasn't already been reflected. This can happen as the ResourceCompilerScene needs // to explicitly load and reflect the SceneAPI libraries to discover the available extension, while - // Gems with system components need to do the same in the Project Configurator. + // Gems with system components need to do the same in the Project Manager. if (context && (context->IsRemovingReflection() || !context->FindClassData(AZ::SceneAPI::DataTypes::IGroup::TYPEINFO_Uuid()))) { AZ::SceneAPI::DataTypes::IManifestObject::Reflect(context); diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneManifestTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneManifestTests.cpp index 875e433bb7..1766395626 100644 --- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneManifestTests.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneManifestTests.cpp @@ -14,8 +14,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -325,7 +325,7 @@ namespace AZ ASSERT_TRUE(writeToJsonResult.IsSuccess()); AZStd::string jsonText; - auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText); + auto writeToStringResult = AZ::JsonSerializationUtils::WriteJsonString(writeToJsonResult.GetValue(), jsonText); ASSERT_TRUE(writeToStringResult.IsSuccess()); MockSceneManifest loaded; @@ -340,7 +340,7 @@ namespace AZ ASSERT_TRUE(writeToJsonResult.IsSuccess()); AZStd::string jsonText; - auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText); + auto writeToStringResult = AZ::JsonSerializationUtils::WriteJsonString(writeToJsonResult.GetValue(), jsonText); ASSERT_TRUE(writeToStringResult.IsSuccess()); MockSceneManifest loaded; @@ -371,7 +371,7 @@ namespace AZ ASSERT_TRUE(writeToJsonResult.IsSuccess()); AZStd::string jsonText; - auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText); + auto writeToStringResult = AZ::JsonSerializationUtils::WriteJsonString(writeToJsonResult.GetValue(), jsonText); ASSERT_TRUE(writeToStringResult.IsSuccess()); // Deserialize JSON diff --git a/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp b/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp index e32eff3471..7d0b5c72b1 100644 --- a/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp +++ b/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp @@ -49,7 +49,7 @@ namespace AZ { // Check if this library hasn't already been reflected. This can happen as the ResourceCompilerScene needs // to explicitly load and reflect the SceneAPI libraries to discover the available extension, while - // Gems with system components need to do the same in the Project Configurator. + // Gems with system components need to do the same in the Project Manager. if (!context->IsRemovingReflection() && context->FindClassData(SceneData::MeshGroup::TYPEINFO_Uuid())) { return; diff --git a/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp b/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp index 428788f626..e0d5cca484 100644 --- a/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp +++ b/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp @@ -20,12 +20,12 @@ #include #include #include +#include #include #include #include #include #include -#include namespace AZ { @@ -154,7 +154,7 @@ namespace AZ ASSERT_TRUE(writeToJsonResult.IsSuccess()); AZStd::string jsonText; - auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText); + auto writeToStringResult = AZ::JsonSerializationUtils::WriteJsonString(writeToJsonResult.GetValue(), jsonText); ASSERT_TRUE(writeToStringResult.IsSuccess()); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("$type": "MockRotationRule")")); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("rotation": [)")); @@ -191,7 +191,7 @@ namespace AZ ASSERT_TRUE(writeToJsonResult.IsSuccess()); AZStd::string jsonText; - auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText); + auto writeToStringResult = AZ::JsonSerializationUtils::WriteJsonString(writeToJsonResult.GetValue(), jsonText); ASSERT_TRUE(writeToStringResult.IsSuccess()); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("$type": "MockRotationRule")")); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("rotation": [)")); @@ -230,7 +230,7 @@ namespace AZ ASSERT_TRUE(writeToJsonResult.IsSuccess()); AZStd::string jsonText; - auto writeToStringResult = AzFramework::FileFunc::WriteJsonToString(writeToJsonResult.GetValue(), jsonText); + auto writeToStringResult = AZ::JsonSerializationUtils::WriteJsonString(writeToJsonResult.GetValue(), jsonText); ASSERT_TRUE(writeToStringResult.IsSuccess()); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("$type": "CoordinateSystemRule")")); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("useAdvancedData": true,)")); diff --git a/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp b/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp index 7b5196462c..c3d87bff86 100644 --- a/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp +++ b/Gems/AWSCore/Code/Source/ResourceMapping/AWSResourceMappingManager.cpp @@ -9,9 +9,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -211,8 +211,7 @@ namespace AWSCore } AzFramework::StringFunc::Path::Normalize(configJsonPath); - AZ::IO::Path configJsonFileIOPath(configJsonPath); - auto readJsonOutcome = AzFramework::FileFunc::ReadJsonFile(configJsonFileIOPath); + auto readJsonOutcome = AZ::JsonSerializationUtils::ReadJsonFile(configJsonPath); if (readJsonOutcome.IsSuccess()) { auto jsonDocument = readJsonOutcome.TakeValue(); diff --git a/Gems/AWSMetrics/Code/Source/IdentityProvider.cpp b/Gems/AWSMetrics/Code/Source/IdentityProvider.cpp index aa0f59976f..7e4ec05aba 100644 --- a/Gems/AWSMetrics/Code/Source/IdentityProvider.cpp +++ b/Gems/AWSMetrics/Code/Source/IdentityProvider.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace AWSMetrics { @@ -39,8 +39,7 @@ namespace AWSMetrics return ""; } - AZ::IO::Path configIoPath(resolvedPath); - auto readOutcome = AzFramework::FileFunc::ReadJsonFile(configIoPath, fileIO); + auto readOutcome = AZ::JsonSerializationUtils::ReadJsonFile(resolvedPath); if (!readOutcome.IsSuccess()) { AZ_Error("AWSMetrics", false, readOutcome.GetError().c_str()); diff --git a/Gems/AWSMetrics/Code/Source/MetricsEvent.cpp b/Gems/AWSMetrics/Code/Source/MetricsEvent.cpp index e23c97a5fe..737ef6abc5 100644 --- a/Gems/AWSMetrics/Code/Source/MetricsEvent.cpp +++ b/Gems/AWSMetrics/Code/Source/MetricsEvent.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -150,7 +150,7 @@ namespace AWSMetrics return false; } - auto result = AzFramework::FileFunc::ReadJsonFromString(stringStream.str().c_str()); + auto result = AZ::JsonSerializationUtils::ReadJsonString(stringStream.str().c_str()); if (!result.IsSuccess()) { return false; diff --git a/Gems/AWSMetrics/Code/Source/MetricsQueue.cpp b/Gems/AWSMetrics/Code/Source/MetricsQueue.cpp index 4cc037189a..ec90cf28ef 100644 --- a/Gems/AWSMetrics/Code/Source/MetricsQueue.cpp +++ b/Gems/AWSMetrics/Code/Source/MetricsQueue.cpp @@ -14,8 +14,8 @@ #include #include #include +#include #include -#include #include @@ -191,15 +191,7 @@ namespace AWSMetrics bool MetricsQueue::ReadFromJson(const AZStd::string& filePath) { - AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetDirectInstance(); - if (!fileIO) - { - AZ_Error("AWSMetrics", false, "Failed to get file IO instance"); - return false; - } - - AZ::IO::Path fileIoPath(filePath); - auto result = AzFramework::FileFunc::ReadJsonFile(fileIoPath, fileIO); + auto result = AZ::JsonSerializationUtils::ReadJsonFile(filePath); if (!result.IsSuccess() ||!ReadFromJsonDocument(result.GetValue())) { AZ_Error("AWSMetrics", false, "Failed to read metrics file %s", filePath.c_str()); diff --git a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MotionEventExport.cpp b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MotionEventExport.cpp index e1bde1ff79..d2a69bca67 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MotionEventExport.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Exporters/ExporterLib/Exporter/MotionEventExport.cpp @@ -11,8 +11,8 @@ #include #include #include +#include #include -#include #include "Exporter.h" #include #include @@ -55,10 +55,10 @@ namespace ExporterLib } AZStd::string serializedMotionEventTable; - auto writeToStringOutcome = AzFramework::FileFunc::WriteJsonToString(jsonDocument, serializedMotionEventTable); + auto writeToStringOutcome = AZ::JsonSerializationUtils::WriteJsonString(jsonDocument, serializedMotionEventTable); if (!writeToStringOutcome.IsSuccess()) { - AZ_Error("EMotionFX", false, "WriteJsonToString failed: %s", writeToStringOutcome.GetError().c_str()); + AZ_Error("EMotionFX", false, "WriteJsonString failed: %s", writeToStringOutcome.GetError().c_str()); return; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp index fad160407b..10f9c0dc60 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -1081,11 +1081,11 @@ namespace EMotionFX file->Read(&buffer[0], fileEventTable.m_size); AZStd::string_view bufferStringView(&buffer[0], buffer.size()); - auto readJsonOutcome = AzFramework::FileFunc::ReadJsonFromString(bufferStringView); + auto readJsonOutcome = AZ::JsonSerializationUtils::ReadJsonString(bufferStringView); AZStd::string errorMsg; if (!readJsonOutcome.IsSuccess()) { - AZ_Error("EMotionFX", false, "Loading motion event table failed due to ReadJsonFromString. %s", readJsonOutcome.TakeError().c_str()); + AZ_Error("EMotionFX", false, "Loading motion event table failed due to ReadJsonString. %s", readJsonOutcome.TakeError().c_str()); return false; } rapidjson::Document document = readJsonOutcome.TakeValue(); diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/Cloth/ClothJointInspectorPlugin.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/Cloth/ClothJointInspectorPlugin.cpp index 861100b073..e1a58f1f44 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/Cloth/ClothJointInspectorPlugin.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/Cloth/ClothJointInspectorPlugin.cpp @@ -71,7 +71,7 @@ namespace EMotionFX } else { - m_dock->setWidget(CreateErrorContentWidget("Cloth collider editor depends on the NVIDIA Cloth gem. Please enable it in the project configurator.")); + m_dock->setWidget(CreateErrorContentWidget("Cloth collider editor depends on the NVIDIA Cloth gem. Please enable it in the Project Manager.")); } return true; diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/HitDetection/HitDetectionJointInspectorPlugin.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/HitDetection/HitDetectionJointInspectorPlugin.cpp index c69fdd9393..b7cf3ea13d 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/HitDetection/HitDetectionJointInspectorPlugin.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/HitDetection/HitDetectionJointInspectorPlugin.cpp @@ -57,7 +57,7 @@ namespace EMotionFX } else { - m_dock->setWidget(CreateErrorContentWidget("Hit detection collider editor depends on the PhysX gem. Please enable it in the project configurator.")); + m_dock->setWidget(CreateErrorContentWidget("Hit detection collider editor depends on the PhysX gem. Please enable it in the Project Manager.")); } return true; diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp index 5324950c82..171100592d 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/Ragdoll/RagdollNodeInspectorPlugin.cpp @@ -86,7 +86,7 @@ namespace EMotionFX } else { - m_dock->setWidget(CreateErrorContentWidget("Ragdoll editor depends on the PhysX gem. Please enable it in the project configurator.")); + m_dock->setWidget(CreateErrorContentWidget("Ragdoll editor depends on the PhysX gem. Please enable it in the Project Manager.")); } return true; diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp index 1e35a084fa..ce9eb1cbae 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp @@ -389,7 +389,7 @@ namespace EMotionFX { QLabel* noColliders = new QLabel( "To adjust the properties of the Simulated Object Colliders, " - "enable the PhysX gem via the Project Configurator"); + "enable the PhysX gem via the Project Manager"); colliderWidgetLayout->addWidget(noColliders); } diff --git a/Gems/LmbrCentral/Code/Source/Builders/SliceBuilder/SliceBuilderWorker.cpp b/Gems/LmbrCentral/Code/Source/Builders/SliceBuilder/SliceBuilderWorker.cpp index 4fc350067d..14096f73d2 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/SliceBuilder/SliceBuilderWorker.cpp +++ b/Gems/LmbrCentral/Code/Source/Builders/SliceBuilder/SliceBuilderWorker.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -73,9 +73,7 @@ namespace SliceBuilder AzFramework::StringFunc::Path::Join(relativePath.c_str(), settingsAssetInfo.m_relativePath.c_str(), sliceBuilderSettingsPath, true, true); // Attempt to load the Slice Builder Settings file - AZ::IO::LocalFileIO localFileIO; - AZ::IO::Path sliceBuilderSettingsIoPath(sliceBuilderSettingsPath); - auto result = AzFramework::FileFunc::ReadJsonFile(sliceBuilderSettingsIoPath, &localFileIO); + auto result = AZ::JsonSerializationUtils::ReadJsonFile(sliceBuilderSettingsPath); if (result.IsSuccess()) { AZ::JsonSerializationResult::ResultCode serializaionResult = AZ::JsonSerialization::Load(m_settings, result.GetValue()); diff --git a/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.cpp b/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.cpp index bffb64e51b..a86d7b57e2 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.cpp @@ -132,7 +132,7 @@ namespace AZ::Prefab AZ::StringFunc::Path::ConstructFull(request.m_watchFolder.c_str(), request.m_sourceFile.c_str(), fullPath); // Load the JSON Dom - AZ::Outcome readPrefabFileResult = AzFramework::FileFunc::ReadJsonFile(AZ::IO::Path(fullPath)); + AZ::Outcome readPrefabFileResult = AZ::JsonSerializationUtils::ReadJsonFile(fullPath); if (!readPrefabFileResult.IsSuccess()) { AZ_Error( diff --git a/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.h b/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.h index 1458c8dd40..9ebdd690f5 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.h +++ b/Gems/Prefab/PrefabBuilder/PrefabBuilderComponent.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp index 95827d4457..7d3096a6da 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp @@ -9,6 +9,7 @@ #include "PrefabBuilderTests.h" #include #include +#include #include #include #include @@ -56,7 +57,7 @@ namespace UnitTest // Save to a string so we can load it as a PrefabDom and so that the nested instance becomes a Source file reference ASSERT_TRUE(prefabLoaderInterface->SaveTemplateToString(parentInstance->GetTemplateId(), serializedInstance)); - AZ::Outcome readPrefabFileResult = AzFramework::FileFunc::ReadJsonFromString(serializedInstance); + AZ::Outcome readPrefabFileResult = AZ::JsonSerializationUtils::ReadJsonString(serializedInstance); ASSERT_TRUE(readPrefabFileResult.IsSuccess()); diff --git a/Gems/SceneLoggingExample/Code/SceneLoggingExampleModule.cpp b/Gems/SceneLoggingExample/Code/SceneLoggingExampleModule.cpp index 92c6ba5a05..9a03d7c1ce 100644 --- a/Gems/SceneLoggingExample/Code/SceneLoggingExampleModule.cpp +++ b/Gems/SceneLoggingExample/Code/SceneLoggingExampleModule.cpp @@ -42,7 +42,7 @@ namespace SceneLoggingExample } // In this example, no system components are added. You can use system components - // to set global settings for this gem from the Project Configurator. + // to set global settings for this gem. // For functionality that should always be available to the SceneAPI, we recommend // that you use a BehaviorComponent instead. AZ::ComponentTypeList GetRequiredSystemComponents() const override diff --git a/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp b/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp index a648859b92..ea0c3520bf 100644 --- a/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp +++ b/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp @@ -34,7 +34,7 @@ namespace AZ ActivateSceneModule(SceneProcessing::s_sceneDataModule); ActivateSceneModule(SceneProcessing::s_sceneBuilderModule); - // Defaults in case there's no config setup in the Project Configurator. + // Defaults in case there's no config setup m_softNames.push_back(aznew NodeSoftNameSetting("^.*_[Ll][Oo][Dd]1(_optimized)?$", PatternMatcher::MatchApproach::Regex, "LODMesh1", true)); m_softNames.push_back(aznew NodeSoftNameSetting("^.*_[Ll][Oo][Dd]2(_optimized)?$", PatternMatcher::MatchApproach::Regex, "LODMesh2", true)); m_softNames.push_back(aznew NodeSoftNameSetting("^.*_[Ll][Oo][Dd]3(_optimized)?$", PatternMatcher::MatchApproach::Regex, "LODMesh3", true));