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

Rationalize behavior of TestItemsWithUnexpandableMetadata #6518

Open
KirillOsenkov opened this issue Jun 4, 2021 · 3 comments
Open

Rationalize behavior of TestItemsWithUnexpandableMetadata #6518

KirillOsenkov opened this issue Jun 4, 2021 · 3 comments

Comments

@KirillOsenkov
Copy link
Member

KirillOsenkov commented Jun 4, 2021

Reenable the test TestItemsWithUnexpandableMetadata

public void TestItemsWithUnexpandableMetadata()

Build this project:

<Project DefaultTargets="Build">

  <ItemDefinitionGroup>
    <F>
      <MetadataFileName>a\b\%(Filename).c</MetadataFileName>
    </F>
  </ItemDefinitionGroup>

  <ItemGroup>
    <F Include="-in &quot;x\y\z&quot;" />
  </ItemGroup>

 <Target Name="Build" />

</Project>

The diag console logger currently prints:

Initial Items:
F
    -in "x\y\z"
        MetadataFileName = Cannot expand metadata in expression "a\b\%(Filename).c". The item metadata "%(Filename)" ca
nnot be applied to the path "-in "x\y\z"". Illegal characters in path.

The logger in unit-test TestItemsWithUnexpandableMetadata currently prints:

Initial Items:
F
    -in "x\y\z"
        MetadataFileName = a\b\%(Filename).c

And I don't know why, nor do I know which behavior is better.

KirillOsenkov added a commit that referenced this issue Jun 4, 2021
Filed #6518 to clarify the expected behavior.
@KirillOsenkov KirillOsenkov self-assigned this Jun 4, 2021
@KirillOsenkov KirillOsenkov changed the title Rationalize behavior of unexpandable metadata Rationalize behavior of TestItemsWithUnexpandableMetadata Jun 4, 2021
@KirillOsenkov
Copy link
Member Author

KirillOsenkov commented Jun 4, 2021

On main branch, here's how it gets to an invalid file char exception:

Path.CheckInvalidPathChars Line 1394
Path.IsPathRooted Line 1190
FileUtilities.ItemSpecModifiers.IsRootDirectory Line 617
FileUtilities.ItemSpecModifiers.GetItemSpecModifier Line 426
BuiltInMetadata.GetMetadataValueEscaped Line 83
ProjectItemInstance.TaskItem.GetBuiltInMetadataEscaped Line 1843
ProjectItemInstance.TaskItem.BuiltInMetadataTable.GetEscapedValue Line 2178
ProjectItemInstance.TaskItem.BuiltInMetadataTable.GetEscapedValueIfPresent Line 2204
ProjectItemInstance.TaskItem.BuiltInMetadataTable.GetEscapedValue Line 2189
Expander`2.MetadataExpander.MetadataMatchEvaluator.ExpandSingleMetadata Line 1003
RegexReplacement.Replace
Regex.Replace
Regex.Replace
Expander`2.MetadataExpander.ExpandMetadataLeaveEscaped Line 870
Expander`2.ExpandIntoStringLeaveEscaped Line 414
ProjectItemInstance.TaskItem.GetMetadataEscaped Line 1336
ProjectItemInstance.TaskItem.GetMetadata Line 1305
BaseConsoleLogger.OutputItems Line 666
BaseConsoleLogger.WriteItems Line 604
SerialConsoleLogger.ProjectStartedHandler Line 273
EventSourceSink.RaiseProjectStartedEvent Line 548

@KirillOsenkov
Copy link
Member Author

Then the exception bubbles up to here:

catch (InvalidProjectFileException e)

@KirillOsenkov
Copy link
Member Author

KirillOsenkov commented Jun 4, 2021

On ProjectStartedEventArgs, the item in Items is of type ProjectItemInstance.TaskItem, which implements ITaskItem, so calling GetMetadata and catching the exception works here. This doesn't hold for Items on ProjectEvaluationFinished, which have ProjectItem instead of ProjectItemInstance.TaskItem.

KirillOsenkov added a commit that referenced this issue Jun 8, 2021
Filed #6518 to clarify the expected behavior.
KirillOsenkov added a commit that referenced this issue Jun 8, 2021
Issue #6518 is tracking.

More work is needed to understand the desired behavior of the system under test and then fix the test to test the desired behavior.
KirillOsenkov added a commit that referenced this issue Jun 15, 2021
Issue #6518 is tracking.

More work is needed to understand the desired behavior of the system under test and then fix the test to test the desired behavior.
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants