Fix uapaot binaryformatter tests (dotnet/corefx#35079)
authorViktor Hofer <viktor.hofer@microsoft.com>
Mon, 4 Feb 2019 23:52:11 +0000 (00:52 +0100)
committerDan Moseley <danmose@microsoft.com>
Mon, 4 Feb 2019 23:52:11 +0000 (15:52 -0800)
Commit migrated from https://github.com/dotnet/corefx/commit/61a8b5b02aa88772d2a73d643cfeb20bf3715458

src/libraries/System.Runtime.Serialization.Formatters/tests/BinaryFormatterTests.rd.xml
src/libraries/System.Runtime.Serialization.Formatters/tests/PlatformExtensions.cs

index 52f9ed3..61eb52e 100644 (file)
@@ -3,6 +3,7 @@
   <Library Name="System.Runtime.Serialization.Formatters.Tests">
     <!-- This test builds a big collection of objects to serialize in a way that's hard to track as well as reflecting for Equals methods-->
     <Assembly Name="Microsoft.CSharp" BinaryFormatter="All" Dynamic="Required Public" />
+    <Assembly Name="System.CodeDom" BinaryFormatter="All" Dynamic="Required Public" />
     <Assembly Name="System.Collections" BinaryFormatter="All" Dynamic="Required Public" />
     <Assembly Name="System.Collections.NonGeneric" BinaryFormatter="All" Dynamic="Required Public" />
     <Assembly Name="System.Collections.Specialized" BinaryFormatter="All" Dynamic="Required Public" />
index c087c21..19a11f1 100644 (file)
@@ -42,6 +42,7 @@ namespace System.Runtime.Serialization.Formatters.Tests
             }
 
             List<TypeSerializableValue> blobList = blobs.ToList();
+            int index;
 
             // .NET Framework
             if (PlatformDetection.IsFullFramework)
@@ -49,7 +50,7 @@ namespace System.Runtime.Serialization.Formatters.Tests
                 // Check if a specialized blob for >=netfx472 is present and return if found.
                 if (IsNetfx472PatchedOrNewer())
                 {
-                    int index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netfx472);
+                    index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netfx472);
 
                     if (index >= 0)
                         return index;
@@ -58,7 +59,7 @@ namespace System.Runtime.Serialization.Formatters.Tests
                 // Check if a specialized blob for >=netfx471 is present and return if found.
                 if (PlatformDetection.IsNetfx471OrNewer)
                 {
-                    int index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netfx471);
+                    index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netfx471);
 
                     if (index >= 0)
                         return index;
@@ -69,25 +70,19 @@ namespace System.Runtime.Serialization.Formatters.Tests
                 return blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netfx461);
             }
 
-            // .NET Core
-            if (PlatformDetection.IsNetCore)
-            {
-                // Check if a specialized blob for >=netcoreapp3.0 is present and return if found.
-                int index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netcoreapp30);
-                if (index >= 0)
-                    return index;
-
-                // Check if a specialized blob for netcoreapp2.1 is present and return if found.
-                index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netcoreapp21);
-                if (index >= 0)
-                    return index;
-
-                // If no newer blob for >=netcoreapp2.1 is present use existing one.
-                // If no netcoreapp blob is present then -1 will be returned.
-                return blobList.FindIndex((b => b.Platform == TargetFrameworkMoniker.netcoreapp20));
-            }
+            // Check if a specialized blob for >=netcoreapp3.0 is present and return if found.
+            index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netcoreapp30);
+            if (index >= 0)
+                return index;
+
+            // Check if a specialized blob for netcoreapp2.1 is present and return if found.
+            index = blobList.FindIndex(b => b.Platform == TargetFrameworkMoniker.netcoreapp21);
+            if (index >= 0)
+                return index;
 
-            return -1;
+            // If no newer blob for >=netcoreapp2.1 is present use existing one.
+            // If no netcoreapp blob is present then -1 will be returned.
+            return blobList.FindIndex((b => b.Platform == TargetFrameworkMoniker.netcoreapp20));
         }
     }
 }