Skip to content

Conversation

adamsitnik
Copy link
Member

In #107553 a group of tests was failing because Bitmap is not supported on Mono.

System.Runtime.Serialization.Formatters.Tests.BinaryFormatterTests.ValidateAgainstBlobs [FAIL]
      System.TypeInitializationException : The type initializer for 'System.Drawing.DrawingCom' threw an exception.
      ---- System.PlatformNotSupportedException : Operation is not supported on this platform.
      Stack Trace:
           at System.Drawing.Bitmap..ctor(Stream stream, Boolean useIcm)
           at System.Drawing.Bitmap..ctor(Stream stream)

The code was already using a guard for that:

https://github.com/dotnet/runtime/blob/06a6ea78fbe99fd86f2f46df9b046cb4c4ea18a7/src/libraries/System.Runtime.Serialization.Formatters/tests/BinaryFormatterTestData.cs#L1346-L1349

I decided to update the logic behind PlatformDetection.IsDrawingSupported as I assumed it's simply not supported and could help in other places. But I need a confirmation from @matouskozak or someone else from the Mono team.

fixes #107553

@adamsitnik adamsitnik added test-enhancement Improvements of test source code binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it area-System.Formats.Nrbf labels Jan 8, 2025
@adamsitnik adamsitnik requested a review from matouskozak January 8, 2025 18:18
@adamsitnik
Copy link
Member Author

/azp run runtime-extra-platforms

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM

System.Drawing depends on ComWrappers that are not supported on Mono.

@adamsitnik adamsitnik merged commit 0e03405 into dotnet:main Jan 9, 2025
116 of 125 checks passed
@matouskozak
Copy link
Member

@adamsitnik could you backport this to .NET 9, to fix the failure on CI there?

@adamsitnik
Copy link
Member Author

could you backport this to .NET 9, to fix the failure on CI there?

@matouskozak sure! I'll do it today.

adamsitnik added a commit to adamsitnik/runtime that referenced this pull request Jan 16, 2025
* don't run Drawing-related tests that do things like creating Bitmaps on Mono, as it's not supported (it does not support ComWrappers)

* re-enable the tests
jkotas pushed a commit that referenced this pull request Jan 17, 2025
…removal (#111508)

* [NRBF] Reduce the most time-consuming test case to avoid timeouts for checked builds (#110550)

* don't run drawing tests on Mono (#111208)

* don't run Drawing-related tests that do things like creating Bitmaps on Mono, as it's not supported (it does not support ComWrappers)

* re-enable the tests
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Formats.Nrbf binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it test-enhancement Improvements of test source code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mono] Windows x64 Mono job BinaryFormatterTests exception
3 participants