-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
base: main
Are you sure you want to change the base?
Fix up relevant CA1416 warnings - Set 3 #26751
Conversation
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. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/rebase |
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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); |
There was a problem hiding this comment.
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?
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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.