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

Remove unused local variables and methods from System.Drawing.Common #39551

Merged

Conversation

MattKotsenas
Copy link
Member

Remove unused locals, and update a few unit tests that had no asserts.

Fixes a part of #30457

Remove unused locals, and update a few unit tests that has no asserts.
@ghost
Copy link

ghost commented Jul 17, 2020

Tagging subscribers to this area: @safern, @tannergooding
Notify danmosemsft if you want to be subscribed.

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Thanks!

@danmoseley
Copy link
Member

One failure in WASM

Assert.True() Failure\r\nExpected: True\r\nActual:   False


Stack trace
   at System.Drawing.Printing.Tests.PrinterSettingsTests.CanDuplex_ReturnsExpected() in /_/src/libraries/System.Drawing.Common/tests/Printing/PrinterSettingsTests.cs:line 53

@MattKotsenas
Copy link
Member Author

One failure in WASM

Assert.True() Failure\r\nExpected: True\r\nActual:   False


Stack trace
   at System.Drawing.Printing.Tests.PrinterSettingsTests.CanDuplex_ReturnsExpected() in /_/src/libraries/System.Drawing.Common/tests/Printing/PrinterSettingsTests.cs:line 53

Thanks for that! This was a case of a test that wasn't asserting anything, so my initial change was to default to true. From code inspection it looks like on "unix" systems CanDuplex is always false, so I've changed the assert to false.

If there are Windows tests that have / simulate a duplex printer, then I'll weaken the assert to just verify that the property doesn't throw and use a discard to avoid tripping the unused local check.

@danmoseley
Copy link
Member

I only know of [ConditionalFact(Helpers.AnyInstalledPrinters, Helpers.IsDrawingSupported)]. I don't think we have a way to also know whether it's a duplex printer without using the API itself. Probably all you can do is check it doesn't throw. Or conceivably call it twice and check you get the same result 😉

@safern
Copy link
Member

safern commented Jul 17, 2020

I was going to comment that actually but then thought it might just work and now I remember we intentionally don't assert on those properties, just make sure they "work" don't fail, since we can guarantee they will have the same behavior specially because the installed printers can be different in every computer we use to run tests and in every platform.

Since the tests run across different printer hardware they can't take a
dependency on the default printer settings. Revert adding asserts in
these cases so the tests still verify that the properties don't throw.
@MattKotsenas MattKotsenas force-pushed the refactor/30457-System.Drawing.Common branch from f61fda0 to 7b3cb5e Compare July 17, 2020 23:49
@MattKotsenas
Copy link
Member Author

I was going to comment that actually but then thought it might just work and now I remember we intentionally don't assert on those properties, just make sure they "work" don't fail, since we can guarantee they will have the same behavior specially because the installed printers can be different in every computer we use to run tests and in every platform.

This makes sense! I was a bit confused when I saw tests that looked like they weren't verifying anything -- the "assert that it doesn't throw" behavior makes sense now that you mention it.

I've undone my changes for all 4 tests in that area.

If you have any questions, please let me know. Thanks!

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Thanks again 😄

@ghost
Copy link

ghost commented Jul 18, 2020

Hello @danmosemsft!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@jkotas jkotas merged commit 1d12f2b into dotnet:master Jul 18, 2020
@MattKotsenas MattKotsenas deleted the refactor/30457-System.Drawing.Common branch July 18, 2020 05:48
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
…otnet#39551)

* Remove unused local variables and methods from System.Drawing.Common

Remove unused locals, and update a few unit tests that has no asserts.

* Revert adding asserts in tests

Since the tests run across different printer hardware they can't take a
dependency on the default printer settings. Revert adding asserts in
these cases so the tests still verify that the properties don't throw.
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants