Skip to content

Don't warn about recursive includes merged from c_cpp_properties.json - #14620

Open
owevertonguedes wants to merge 1 commit into
microsoft:mainfrom
owevertonguedes:fix/14125-recursive-include-warning-merge
Open

Don't warn about recursive includes merged from c_cpp_properties.json#14620
owevertonguedes wants to merge 1 commit into
microsoft:mainfrom
owevertonguedes:fix/14125-recursive-include-warning-merge

Conversation

@owevertonguedes

Copy link
Copy Markdown
Contributor

Fixes #14125

Problem

sendCustomConfigurations warned whenever any includePath entry ended in **:

if (item.configuration.includePath.some(path => path.endsWith('**'))) {
    console.warn("custom include paths should not use recursive includes ('**')");
}

Its only caller is provideCustomConfigurationAsync, and when mergeConfigurations is enabled that caller has already appended the includePath entries from the user's c_cpp_properties.json to every configuration returned by the provider. A trailing ** is a supported way to recurse there, so the warning fired for paths the configuration provider never supplied.

Change

Move the check ahead of that append, so it only ever sees the provider's own include paths. The warning for a provider that really does use ** is unchanged, with or without mergeConfigurations.

The check now runs before isSourceFileConfigurationItem validates each item, so it is guarded by configs instanceof Array and util.isArrayOfString(...) to keep the same tolerance for malformed third-party data. It also sits after deepCopy, so when merging it reads the same normalized copy the existing merge loop reads.

Testing

I drove provideCustomConfigurationAsync against the compiled extension with a stub provider and compared every case to main:

** comes from mergeConfigurations before after
c_cpp_properties.json only on warns no warning
the provider on warns warns
c_cpp_properties.json only off no warning no warning
the provider off warns warns

I also checked malformed provider input that the pre-patch code tolerated, so the earlier validation is not skipped: an includePath that is not an array, an array-like object instead of an array, and a falsy first element all behave exactly as they did before.

One difference worth flagging: an item that carries a recursive include and fails validation for an unrelated reason now produces the recursive-include warning in addition to the existing "discarding invalid SourceFileConfigurationItem" one, because the check no longer sits behind that validation. Both are console.warn diagnostics for provider authors and neither item is sent either way, but I can restrict the check to fully valid items if you would rather keep that exact.

tsc --build, eslint src test ui .scripts, the unit suite (193 passing) and git diff --check are all clean. I could not run the SimpleCppProject integration suite, which is where a regression test for this would belong, because it needs the native binaries and I have no way to run it here, so I did not add a test I could not execute.

The check for include paths ending in '**' ran in sendCustomConfigurations,
after mergeConfigurations had already appended the includePath entries from
the user's c_cpp_properties.json to each configuration from the provider. A
trailing '**' is a supported way to recurse there, so the warning fired for
paths the provider never supplied.

Move the check ahead of that append so it only sees the provider's own
include paths.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an incorrect provider diagnostic that was triggered when mergeConfigurations appended includePath entries from c_cpp_properties.json (where a trailing ** is valid) into configurations supplied by a custom configuration provider.

Changes:

  • Moves the “recursive include” (**) warning so it runs before merging c_cpp_properties.json include paths into provider configs.
  • Removes the same warning from sendCustomConfigurations, ensuring only provider-supplied include paths are evaluated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

console.warn("custom include paths should not use recursive includes ('**')") occurs with mergeConfigurations

2 participants