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

Fix up relevant CA1416 warnings - Set 3 #26751

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

Conversation

Tamilarasan-Paranthaman
Copy link
Contributor

Description of Change

The CA1416 warnings were already resolved in PR #26593

In this PR, we have divided the file changes from the previous PR into smaller, more manageable groups and added test cases for the affected areas to ensure proper functionality.

Copy link
Contributor

Hey there @Tamilarasan-Paranthaman! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 20, 2024
@PureWeen PureWeen added this to the .NET 9 SR3 milestone Dec 20, 2024
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review December 20, 2024 15:14
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman requested a review from a team as a code owner December 20, 2024 15:14
@PureWeen PureWeen added the area-controls-image Image control label Dec 20, 2024
@vishnumenon2684 vishnumenon2684 added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 23, 2024
@Redth
Copy link
Member

Redth commented Dec 23, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR3, .NET 9 SR4 Jan 5, 2025
@PureWeen
Copy link
Member

PureWeen commented Jan 6, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@mattleibow
Copy link
Member

/rebase

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I have a review and I think we can just move to the new things. No need to have old code in here that we have to maintain just because we always had it.

And one small if block change needed.


// ctx will be null if the width/height of the view is zero
if (ctx is not null && !TryRender(window, out _))
if (!OperatingSystem.IsIOSVersionAtLeast(17))
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we reverse the polarity here :)

It makes it a bit easier to read if the first is the latest version and then the else gets older. If 17 else 16 else 15.

Copy link
Member

Choose a reason for hiding this comment

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

Also, why do we need this block for ios 17+? It seems to have been around since iOS 10? Can we just use that code? The UIGraphics style is obsolete in iOS 18, but we don't need to use that as the main flag here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattleibow, it seems that BeginImageContextWithOptions is not supported on iOS 17.0 and later.

image image

As @mattleibow suggested here, should we adopt the new approach for older versions as well, @PureWeen?

public Task<IScreenshotResult> CaptureAsync(UIWindow window)
{
	_ = window ?? throw new ArgumentNullException(nameof(window));

	using var renderer = new UIGraphicsImageRenderer(window.Bounds.Size);
	var resultImage = renderer.CreateImage((UIGraphicsImageRendererContext imageContext) =>
	{
		if (!TryRender(window, out _))
		{
			// TODO: test/handle this case
		}
	});
	var screenshotResult = new ScreenshotResult(resultImage);
	return Task.FromResult<IScreenshotResult>(screenshotResult);
}

var screenshotResult = new ScreenshotResult(resultImage);
return Task.FromResult<IScreenshotResult?>(screenshotResult);

Could you please share your thoughts on this, @PureWeen ?

UIGraphics.EndImageContext();

return image.ImageWithRenderingMode(UIImageRenderingMode.Automatic);
var renderer = new UIGraphicsImageRenderer(imagesize);
Copy link
Member

Choose a reason for hiding this comment

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

For example, here you switched directly to the new way without keeping the old way. I think this is better? Thoughts?

@mattleibow
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen requested a review from mattleibow January 29, 2025 17:12
@PureWeen PureWeen modified the milestones: .NET 9 SR4, .NET 9 SR5 Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-image Image control community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
Status: Ready To Review
Development

Successfully merging this pull request may close these issues.

5 participants