You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#8527
Context
Self referencing item metadata in an item definition within the target leads to possible unintended expansion (and cross-applying of pre-existing item instances).
This behavior is not a bug - it's the implication of the target batching feature - but might be confusing. So detection and warning is added here
Changes Made
A self reference (qualified or unqualified) of metadata within the item defeiniton (which is within a target) is detected and high importance message is issued.
Testing
Tests added for a warning case and for a non-warning case (self-referencing metadata outside of target context)
Doc
MicrosoftDocs/visualstudio-docs-pr#11034
Possible impact
It's unfortunately hard to obtain data on prevalence of this pattern due to limitations of available code searches (github search doesn't support '@' sign and no escaping option; SourceGraph, grep.app doesn't support regex lookaheads). So I cannot quantify (I'll try again later on).
But there are some sparse evidence of usage:
https://github.com/JeremyAnsel/JeremyAnsel.HLSL.Targets/blob/master/JeremyAnsel.HLSL.Targets/JeremyAnsel.HLSL.Targets/JeremyAnsel.HLSL.Targets.csproj#L49https://github.com/neuecc/MessagePack-CSharp/blob/master/src/MessagePack.MSBuild.Tasks/MessagePack.MSBuild.Tasks.csproj#L35https://github.com/dotnet/aspnetcore/blob/main/eng/AfterSigning.targets#L22
all of those seem to be doing something else then intended (the variable part of path is empty, so it gets just the base directory), but they do not break.
tl;dr;: unless we are able to better quantify, we might resort to demote the warning to a message Demoted to Message severity
0 commit comments