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

Code Quality: Improved SetAs actions #16480

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

0x5bfa
Copy link
Member

@0x5bfa 0x5bfa commented Nov 18, 2024

Resolved / Related Issues

  • Annotated that the service methods may throw COMException
  • Throw COMException when failed in all the com methods
  • Release the PIDLs properly
  • Use stackalloc

Steps used to test these changes

  1. Set as wallpaper
  2. Set as slideshow
  3. Set as app background

@0x5bfa 0x5bfa changed the title Init Code Quality: Improved SetAs actions Nov 18, 2024
@yaira2 yaira2 added the changes requested Changes are needed for this pull request label Nov 18, 2024

public override Task ExecuteAsync(object? parameter = null)
{
if (context.SelectedItem is not null)
Copy link
Member

Choose a reason for hiding this comment

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

@hishitetsu can you confirm if this is okay to remove? I'm pretty sure it's needed to prevent a crash.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this code is necessary because the item may be deselected between the time it is checked in IsExecutable and the time the action is actually executed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not use IsExecutable prop instead?

Copy link
Member

Choose a reason for hiding this comment

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

Certainly, but I noticed we should do the following instead of simply checking to prevent NullReferenceException completely.

if (ContentPageContext.SelectedItem is ListedItem selectedItem)
	AppearanceSettingsService.AppThemeBackgroundImageSource = selectedItem.ItemPath;

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes are needed for this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants