uno icon indicating copy to clipboard operation
uno copied to clipboard

fix: Fixed bug with Additional Files metadata override.

Open HavenDV opened this issue 3 years ago • 14 comments

GitHub Issue (If applicable): closes #8176

PR Type

What kind of change does this PR introduce?

Bugfix

What is the current behavior?

At the moment the Uno package does not take into account that the user may have other generators that have metadata in AdditionalFiles

What is the new behavior?

_InjectAdditionalFiles Target will correctly take into account the presence of AdditionalFiles by comparing them by full path. This will simply add new metadata to existing files that are also Page/ApplicationDefinition/PRIResource/TSBindingAssemblySource without losing the existing metadata.

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

HavenDV avatar Apr 17 '22 21:04 HavenDV

gitpod-io[bot] avatar Apr 17 '22 21:04 gitpod-io[bot]

It's not entirely clear to me what caused the tests to crash after the last change. Everything works correctly in VS 2022 preview 4.0, but the CI environment may have a different msbuild that doesn't support this (or a nested %()). Should I undo the change?

HavenDV avatar Apr 29 '22 08:04 HavenDV

This caused by:

The expression """.Contains()" cannot be evaluated. Method 'System.String.Contains' not found.

Most likely because _Pages or others can be null. Either check for empty in the expression, or make it non-empty before getting to the ItemGroup creation,

jeromelaban avatar Apr 29 '22 12:04 jeromelaban

This caused by:

The expression """.Contains()" cannot be evaluated. Method 'System.String.Contains' not found.

Most likely because _Pages or others can be null. Either check for empty in the expression, or make it non-empty before getting to the ItemGroup creation,

In addition to this message, there is also such a message here, so I do not think that this is the reason

src\SourceGenerators\Uno.UI.SourceGenerators\Content\Uno.UI.SourceGenerators.props(365,47): Error MSB4184: The expression ""C:\a\1\s\src\Uno.UI.FluentTheme.v2\themeresources_v2.xaml".Contains()" cannot be evaluated. Method 'System.String.Contains' not found.

HavenDV avatar Apr 29 '22 13:04 HavenDV

In addition to this message, there is also such a message here, so I do not think that this is the reason

src\SourceGenerators\Uno.UI.SourceGenerators\Content\Uno.UI.SourceGenerators.props(365,47): Error MSB4184: The expression ""C:\a\1\s\src\Uno.UI.FluentTheme.v2\themeresources_v2.xaml".Contains()" cannot be evaluated. Method 'System.String.Contains' not found.

It's likely because the parameter is null or empty, and there's no signature that matches Contains without parameters.

jeromelaban avatar Apr 29 '22 13:04 jeromelaban

I have updated the code according to the latest changes in the master branch. I also added the necessary checks.

HavenDV avatar Jun 27 '22 14:06 HavenDV

There are errors in the build that I don't understand. Perhaps they are caused by the fact that the full path is always used to avoid collisions.

HavenDV avatar Jun 29 '22 04:06 HavenDV

@HavenDV I'm seeing for example:

System.InvalidOperationException: Cannot locate resource from 'ms-resource:///Files/App/Linked/Test_Dictionary_Linked.xaml'

During When_Implicit_Style_And_Programmatic_Explicit_Style. You should be able to reproduce it locally when you select net461 as target and using the UnitTests-only.slnf

MartinZikmund avatar Jul 13 '22 08:07 MartinZikmund

I checked, the error is caused by the fact that data with an absolute path was added to the dictionary instead of a relative one, as it was before. I will try to find an alternative solution instead of changing the current tests.

HavenDV avatar Jul 15 '22 14:07 HavenDV

I made some edits to make the final output match the current one. Here is a project where you can experiment and evaluate the changes. https://github.com/HavenDV/Uno.Issues/tree/main/uno_removes_additional_files_metadata Ultimately, the problem was not that Uno was removing metadata, but that Uno was adding duplicate values with other metadata, causing other generators that could work with these files to only get the element with Uno's metadata (the second an element with the same FullPath and other metadata was lost) There was also a problem with finding resources after testing on a real project, but this has also been fixed.

HavenDV avatar Jul 22 '22 05:07 HavenDV