Skip to content

Add Analyzer and CodeFixProvider for Initializing Bitmap with a "avares" scheme argument. #18150

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

Merged
merged 4 commits into from
Feb 16, 2025

Conversation

rabbitism
Copy link
Contributor

@rabbitism rabbitism commented Feb 8, 2025

What does the pull request do?

It is a common mistake (at least for beginners) to initialize a bitmap from Avalonia Asset directly like

var bitmap = new Bitmap("avares://Assembly/Directory/Name.jpg");

This PR introduce a code analyzer and a corresponding CodeFixProvider to help address this issue, and replace with correct usage: Use AssetLoader to open as a stream first.

Notice: All Diagnostic Id and descriptions can be updated according to team feadback.

What is the current behavior?

Nothing is reported.

What is the updated/expected behavior with this PR?

warning:
image
fix action:
image
after fix:
image

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot
Copy link

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

@MrJul
Copy link
Member

MrJul commented Feb 15, 2025

@rabbitism Can you please update your branch to re-trigger CI?

@avaloniaui-bot
Copy link

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

@maxkatz6 maxkatz6 added this pull request to the merge queue Feb 16, 2025
Merged via the queue into AvaloniaUI:master with commit afa124f Feb 16, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants