diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 0eebe0bdb0a5..34780f7cd490 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -553,6 +553,8 @@ namespace { } } + // see https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-conditions + // properties are .NET String objects and you can call any of its members on them bool conditionIsTrue(const ProjectConfiguration &p) const { if (condition.empty()) return true; @@ -560,13 +562,14 @@ namespace { replaceAll(c, "$(Configuration)", p.configuration); replaceAll(c, "$(Platform)", p.platformStr); - // TODO: evaluate without using the Tokenizer + // TODO: improve evaluation const Settings s; - Tokenizer tokenizer(s, nullptr); + TokenList tokenlist(&s); std::istringstream istr(c); - tokenizer.tokenize(istr,"vcxproj.c"); - for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) { + tokenlist.createTokens(istr, Standards::Language::C); // TODO: check result + 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() if (tok->astOperand1()->expressionString() == "Configuration.Contains") return ('\'' + p.configuration + '\'') == tok->astOperand2()->str(); } diff --git a/test/testimportproject.cpp b/test/testimportproject.cpp index a21819c60ec4..7129f4f98776 100644 --- a/test/testimportproject.cpp +++ b/test/testimportproject.cpp @@ -389,6 +389,27 @@ class TestImportProject : public TestFixture { } // TODO: test fsParseCommand() + + // TODO: test vcxproj conditions + /* + + + + + Debug + x64 + + + + + CPPCHECKLIB_IMPORT + + + + + + + */ }; REGISTER_TEST(TestImportProject)