Add Analyzer and CodeFixProvider for Initializing Bitmap with a "avares" scheme argument. #18150
+170
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
It is a common mistake (at least for beginners) to initialize a bitmap from Avalonia Asset directly like
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](https://private-user-images.githubusercontent.com/14807942/411173225-ba979822-3726-4727-9f0c-f5017eb46e50.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODE0NjYsIm5iZiI6MTczOTA4MTE2NiwicGF0aCI6Ii8xNDgwNzk0Mi80MTExNzMyMjUtYmE5Nzk4MjItMzcyNi00NzI3LTlmMGMtZjUwMTdlYjQ2ZTUwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA2MDYwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRmZDNlNDY2MWY1MDg3MjkyNGRjNTM2YWQ2ZDEzNGZhOGQyNWU0MmQyMDY1OTNiNmZiM2UzYjg1MDgyMjdhYjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.5gCmBFFvIDyaQTt1R9ck2XQ2evzAwj55vvRYpXc0AA8)
![image](https://private-user-images.githubusercontent.com/14807942/411173906-e811370b-37ff-4abe-8847-54f4b07cefe7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODE0NjYsIm5iZiI6MTczOTA4MTE2NiwicGF0aCI6Ii8xNDgwNzk0Mi80MTExNzM5MDYtZTgxMTM3MGItMzdmZi00YWJlLTg4NDctNTRmNGIwN2NlZmU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA2MDYwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVkNjBjZjUxYTYyMzc4YmY0YjQ4OGRhNGFmYTllMzVhNDI1MjI5ZDBmYjQ4MzU5NDFlOGNjMjg2OTZkMWU0MjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.yw_pdeOSaeoSbaBPmLE3Bdel_fERA9xI2YMtPjJAGTQ)
![image](https://private-user-images.githubusercontent.com/14807942/411173978-69b11c0a-260b-4231-9651-feae8c3b65df.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODE0NjYsIm5iZiI6MTczOTA4MTE2NiwicGF0aCI6Ii8xNDgwNzk0Mi80MTExNzM5NzgtNjliMTFjMGEtMjYwYi00MjMxLTk2NTEtZmVhZThjM2I2NWRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDA2MDYwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJhYmI5OWU4NjAxN2UwNTIyZGQ2NDRlNWM0ZGY4YTYzZjkyOWM1YmM4ZTk3NDc1YTJlOTVkYjYwNGExMzVhZWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.qb_zqxqUrgWT8WwLeukXopHvc51Xd9F_r5nBmpftsBA)
fix action:
after fix:
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues