-
Notifications
You must be signed in to change notification settings - Fork 4.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
BinaryFormatter tests are no longer skipped when ran against source-built runtime #107534
Comments
@ViktorHofer is offline, tagging @ericstj and @carlossanlop who should be able to help, as I am not sure why functional |
cc @bartonjs |
This is intentional because BinaryFormatter has no use in source-build. We only build the in-box implementation that throws PNSE. |
diff --git a/Directory.Build.props b/Directory.Build.props
index e887d066f5c..ab8adda9fb2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -473,6 +473,7 @@
<PropertyGroup Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true' or '$(IsTrimmingTestProject)' == 'true'">
<!-- we need to re-enable BinaryFormatter within test projects since some tests exercise these code paths to ensure compat -->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
+ <EnableUnsafeBinaryFormatterSerialization Condition="'$(DotNetBuildSourceOnly)' == 'true'">false</EnableUnsafeBinaryFormatterSerialization>
<!-- don't warn on usage of BinaryFormatter or legacy serialization infrastructure from test projects -->
<NoWarn>$(NoWarn);SYSLIB0011;SYSLIB0050;SYSLIB0051</NoWarn>
<!-- don't warn about unnecessary trim warning suppressions. can be removed with preview 6. --> Maybe this should fix it for source bulid? |
Or this: diff --git a/eng/testing/tests.props b/eng/testing/tests.props
index 2c555d1abaf..d81fc91ab85 100644
--- a/eng/testing/tests.props
+++ b/eng/testing/tests.props
@@ -9,6 +9,7 @@
<ILLinkDescriptorsPath>$(MSBuildThisFileDirectory)ILLinkDescriptors\</ILLinkDescriptorsPath>
<TestSingleFile Condition="'$(TestNativeAot)' == 'true'">true</TestSingleFile>
<TestSingleFile Condition="'$(TestReadyToRun)' == 'true'">true</TestSingleFile>
+ <DefineConstants Condition="'$(DotNetBuildSourceOnly)' == 'true'">$(DefineConstants);DOTNET_SOURCE_BUILD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
index d35885ae255..ca79cc1c92a 100644
--- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
+++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
@@ -728,6 +728,10 @@ private static bool GetSupportsSha3()
private static bool DetermineBinaryFormatterSupport()
{
+#if DOTNET_SOURCE_BUILD
+ return false; // binary formatter, by design, throws PNSE with source-build
+#endif
+
if (IsNetFramework)
{
return true; |
Thanks for the suggestions @am11!
This would be a good fix if it works. Let me give it a try.
Let's try to avoid going this way. |
Tagging subscribers to 'binaryformatter-migration': @adamsitnik, @bartonjs, @jeffhandley, @terrajobst |
Tagging subscribers to this area: @dotnet/area-system-runtime |
I think we need consistency with how the expectation for support is expressed. In the past it used to be binary: a platform supported it or it didn't. Now there are 3 states:
What you don't want to happen is accidentally losing test coverage because you fall into state 2 and treat it like 1. Can you state how you want these to be expressed, then adopt them consistently? I feel like applying different conditions in many places will lead you to a fragile solution. |
For For source-build configuration, we accept lower test coverage. If the OOB implementation isn't buildable, then the tests that depend on its behavior should be skipped. |
At least right now there are dozens of projects that still test the BinaryFormatter. I agree consolidating those to a single project might be a good idea. That way we don't accidentally depend on behavior that's only present in the compat package. |
When building runtime under the source-build configuration, no functional BinaryFormatter is being built.
Tests that require a functional binary formatter are skipped based on:
runtime/src/libraries/System.ObjectModel/tests/ReadOnlyDictionary/ReadOnlyDictionary_SerializationTests.cs
Line 19 in aa418fc
These tests are no longer being skipped on the
main
branch. This causes 1000s of test failures across different test projects.@adamsitnik I suspect this regressed in #106858 by removing the assembly version logic in
DetermineBinaryFormatterSupport
.cc @ViktorHofer @omajid
The text was updated successfully, but these errors were encountered: