Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix reflect-cpp compilation when msgpack is enabled #6205

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

mirageAlchemy
Copy link
Contributor

  • Before adding new features and new modules, please go to issues to submit the relevant feature description first.
  • Write good commit messages and use the same coding conventions as the rest of the project.
  • Please commit code to dev branch and we will merge into master branch in feature
  • Ensure your edited codes with four spaces instead of TAB.

  • 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
  • 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
  • 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
  • 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。

@mirageAlchemy
Copy link
Contributor Author

i would actually like to include some trivial tests for msgpack behaviour, maybe like this:

        
        assert(package:check_cxxsnippets({test = [[
            #include <rfl/msgpack.hpp>
            #include <rfl.hpp>
            struct Person {
                std::string first_name;
                std::string last_name;
                int age;
            };
            const auto homer = Person{.first_name = "Homer",
                                      .last_name = "Simpson",
                                      .age = 45};
            void test() {
                const std::vector<char> msgpack_data = rfl::msgpack::write(homer);
                auto homer2 = rfl::msgpack::read<Person>(msgpack_data).value();
            }   
        ]]}, {configs = {languages = "c++20", msgpack = true}}))

But I am not quite sure it is advocated?

@mirageAlchemy mirageAlchemy marked this pull request as ready for review January 21, 2025 12:46
@waruqi
Copy link
Member

waruqi commented Jan 22, 2025

i would actually like to include some trivial tests for msgpack behaviour, maybe like this:

        
        assert(package:check_cxxsnippets({test = [[
            #include <rfl/msgpack.hpp>
            #include <rfl.hpp>
            struct Person {
                std::string first_name;
                std::string last_name;
                int age;
            };
            const auto homer = Person{.first_name = "Homer",
                                      .last_name = "Simpson",
                                      .age = 45};
            void test() {
                const std::vector<char> msgpack_data = rfl::msgpack::write(homer);
                auto homer2 = rfl::msgpack::read<Person>(msgpack_data).value();
            }   
        ]]}, {configs = {languages = "c++20", msgpack = true}}))

But I am not quite sure it is advocated?

How is it different from the current test? As long as the test code is kept as short as possible, it is allowed to add some other tests as appropriate.

@mirageAlchemy
Copy link
Contributor Author

Current test only covers a subset of all configuration cases, that is only json support is enabled. The test I provided above has msgpack configured, so ensures any possible upgrade does not break msgpack support. I was hesitant to add it because I am not sure if I should add the test only when the user demands msgpack explicitly in config, or should I include it by default so it is checked by CI.

@waruqi
Copy link
Member

waruqi commented Jan 22, 2025

Current test only covers a subset of all configuration cases, that is only json support is enabled. The test I provided above has msgpack configured, so ensures any possible upgrade does not break msgpack support. I was hesitant to add it because I am not sure if I should add the test only when the user demands msgpack explicitly in config, or should I include it by default so it is checked by CI.

we can test it when msgpack is enabled.

if package:config("msgpack") then
    -- test it
end

@mirageAlchemy mirageAlchemy force-pushed the update-msgpack-support branch from 0cd774e to 2525595 Compare January 22, 2025 06:00
@mirageAlchemy
Copy link
Contributor Author

I have added a test only when msgpack is specified by the user

@waruqi waruqi merged commit fc3bc1f into xmake-io:dev Jan 22, 2025
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants