Skip to content

Conversation

@autoantwort
Copy link
Contributor

No description provided.

@firewave
Copy link
Collaborator

Thanks for your contribution.

Please avoid adding test-only code in the production code. See e04019c for an approach. If you inherit from ProjectConfiguration the added function could be moved into the test code and the additional constructor and moved implementation could me made protected.

Comment on lines 709 to 713
catch (const std::runtime_error& r)
{
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should report the exception as a debug or verbose message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the ErrorLogger infrastructure?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. reportErr() for a debug message or reportOut() for a verbose message. Not sure which would be more appropriate.

tokenlist.createAst();
for (const Token *tok = tokenlist.front(); tok; tok = tok->next()) {
if (tok->str() == "(" && tok->astOperand1() && tok->astOperand2()) {
// TODO: this is wrong - it is Contains() not Equals()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have filed a ticket for this since fixing it is a behavior change. Are you able to do that or should I file one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do that? :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do later. I want to have a reproducer first.

@firewave firewave marked this pull request as draft December 16, 2025 20:44
@autoantwort
Copy link
Contributor Author

Please avoid adding test-only code in the production code. See e04019c for an approach. If you inherit from ProjectConfiguration the added function could be moved into the test code and the additional constructor and moved implementation could me made protected.

Currently ProjectConfiguration and ConditionalGroup are an implementation detail and defined in the cpp file. I would have to move the classes to the header. Then they become an public interface only because of test-only code.
My thought was that exposing a single test-only function is better than exposing two complete implementation details classes.

@firewave
Copy link
Collaborator

Currently ProjectConfiguration and ConditionalGroup are an implementation detail and defined in the cpp file.

Sorry that I missed that.

I would have to move the classes to the header. Then they become an public interface only because of test-only code.
My thought was that exposing a single test-only function is better than exposing two complete implementation details classes.

Let's get the CI to pass first and the other stuff addressed and then I will have another look. It won't be merged before we made the 2.19 release anyways.

@autoantwort autoantwort force-pushed the fix-14334 branch 7 times, most recently from a327364 to e674fb6 Compare December 17, 2025 17:57
@autoantwort autoantwort requested a review from firewave December 30, 2025 22:37
@autoantwort autoantwort marked this pull request as ready for review December 30, 2025 22:37
@autoantwort autoantwort force-pushed the fix-14334 branch 3 times, most recently from 0818e64 to f0810d5 Compare December 31, 2025 02:27

static bool evalExpression(std::string expr /* should be a std::string_view */, const ProjectConfiguration& p)
{
const auto startsHere = [&](size_t& i, std::string string)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the feeling this could be simplified using string::compare

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will it change to

                if (expr.compare(i, string.length(), string) == 0)
                {
                    i += string.length();
                    return true;
                }
                return false;

}
return false;
};
const auto skipSpaces = [&](size_t& i)
Copy link
Owner

@danmar danmar Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i = expr.find_first_not_of(' ',i); can be used instead.

throw std::runtime_error("Expecting a start of a string!");
}
auto start = ++i;
while (i < expr.length() && expr[i] != '\'') ++i;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there be some escape sequences we should handle i.e. if expr is 'a\'b' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it seems that is not possible

if (startsHere(i, "$(Configuration."))
{
initialized = true;
if (startsHere(i, "Contains("))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to have spaces.. Contains ( ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never have seen this, but it seems to be possible.

{
return !evalExpression(expr.substr(i + 1), p);
}
if (startsHere(i, "And"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be true if expr contains AndXY.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm that is true. Otherwise this is then also an invalid msbuild project that does not build...

}
}

static bool evalExpression(std::string expr /* should be a std::string_view */, const ProjectConfiguration& p)

Check warning

Code scanning / Cppcheck Premium

Function parameter 'expr' should be passed by const reference. Warning

Function parameter 'expr' should be passed by const reference.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 2, 2026

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.

3 participants