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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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]

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.

3 participants