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

Added support for LinkBase in Avalonia resources generator #16118

Closed
wants to merge 3 commits into from

Conversation

Abdesol
Copy link
Contributor

@Abdesol Abdesol commented Jun 25, 2024

What does the pull request do?

adds support for LinkBase in avalonia resources generator

What is the current behavior?

Avalonia asset loader is not resolving for LinkBase

What is the updated/expected behavior with this PR?

Using LinkBase to set resources path works

Fixed issues

Fixes #16056

@Abdesol Abdesol changed the title added support for linkbase in avalonia resources generator Added support for LinkBase in Avalonia resources generator Jun 25, 2024
@maxkatz6 maxkatz6 added area-xaml bug enhancement backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch and removed bug labels Jun 26, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0049412-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@kekekeks
Copy link
Member

Please, add a test (a resource outside of the test lib with LinkBase + some test that loads it from code should be sufficient).

- added InternalsVisibleTo of Avalonia.Build.Tasks in Avalonia.Build.Tasks.UnitTest
- added test for LinkBase support
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050004-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

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

The current implementation is wrong, see previous comments.

I don't think we should handle LinkBase in the task itself.
Let MSBuild expand the recursive globs from LinkBase into Link instead.

This is what the SDK is doing. We should probably copy this behavior.

Reference: https://github.com/dotnet/sdk/blob/74dafbfb0c0d311595da6fc61d24ca57e6d3f80d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.targets#L104-L107

var path = !string.IsNullOrEmpty(link)
? link
: relativePath;
: !string.IsNullOrEmpty(linkBase)
Copy link
Member

Choose a reason for hiding this comment

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

This treats LinkBase and Link the same, which isn't correct. Link is a file path whereas LinkBase is the path before the directory globs, i.e. a directory path.

public void Does_Support_LinkBase_In_Avalonia_Resources_Generator()
{
var path = "path/to/resources";
var expected = "/" + path;
Copy link
Member

Choose a reason for hiding this comment

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

The added test doesn't check the right thing: the expected path should be /path/to/resources/root.xml.

@maxkatz6
Copy link
Member

Closing due to inactivity

@maxkatz6 maxkatz6 closed this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AvaloniaResource inclusion results in erroneous embedding when resources are outside of project folder
5 participants