Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 8127614

Browse files
stephentoubdanmoseley
authored andcommitted
Fix serialization roundtrip line number test on desktop (#19473)
* Auto-format BinaryFormatterHelpers.cs Lots of tabs were used instead of spaces * Fix serialization roundtrip line number test on desktop
1 parent 581e5e4 commit 8127614

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/Common/tests/System/Runtime/Serialization/Formatters/BinaryFormatterHelpers.cs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010

1111
namespace System.Runtime.Serialization.Formatters.Tests
1212
{
13-
public static class BinaryFormatterHelpers
14-
{
15-
internal static T Clone<T>(T obj)
16-
{
13+
public static class BinaryFormatterHelpers
14+
{
15+
internal static T Clone<T>(T obj)
16+
{
1717
// https://github.com/dotnet/corefx/issues/18942 - Binary serialization still WIP on AOT platforms.
1818
if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Native"))
1919
return obj;
2020

21-
var f = new BinaryFormatter();
22-
using (var s = new MemoryStream())
23-
{
24-
f.Serialize(s, obj);
25-
s.Position = 0;
26-
return (T)f.Deserialize(s);
27-
}
28-
}
21+
var f = new BinaryFormatter();
22+
using (var s = new MemoryStream())
23+
{
24+
f.Serialize(s, obj);
25+
s.Position = 0;
26+
return (T)f.Deserialize(s);
27+
}
28+
}
2929

3030
internal static Lazy<T> Clone<T>(Lazy<T> lazy)
3131
{
@@ -40,36 +40,36 @@ internal static Lazy<T> Clone<T>(Lazy<T> lazy)
4040
}
4141

4242
public static void AssertRoundtrips<T>(T expected, params Func<T, object>[] additionalGetters)
43-
where T : Exception
44-
{
45-
for (int i = 0; i < 2; i++)
46-
{
47-
if (i > 0) // first time without stack trace, second time with
48-
{
49-
try { throw expected; }
50-
catch { }
51-
}
43+
where T : Exception
44+
{
45+
for (int i = 0; i < 2; i++)
46+
{
47+
if (i > 0) // first time without stack trace, second time with
48+
{
49+
try { throw expected; }
50+
catch { }
51+
}
5252

53-
// Serialize/deserialize the exception
54-
T actual = Clone(expected);
53+
// Serialize/deserialize the exception
54+
T actual = Clone(expected);
5555

56-
// Verify core state
57-
if (!PlatformDetection.IsFullFramework) // On full framework, line number is method body start
58-
{
59-
Assert.Equal(expected.StackTrace, actual.StackTrace);
60-
}
61-
Assert.Equal(expected.Data, actual.Data);
62-
Assert.Equal(expected.Message, actual.Message);
63-
Assert.Equal(expected.Source, actual.Source);
64-
Assert.Equal(expected.ToString(), actual.ToString());
65-
Assert.Equal(expected.HResult, actual.HResult);
56+
// Verify core state
57+
if (!PlatformDetection.IsFullFramework) // On full framework, line number may be method body start
58+
{
59+
Assert.Equal(expected.StackTrace, actual.StackTrace);
60+
Assert.Equal(expected.ToString(), actual.ToString()); // includes stack trace
61+
}
62+
Assert.Equal(expected.Data, actual.Data);
63+
Assert.Equal(expected.Message, actual.Message);
64+
Assert.Equal(expected.Source, actual.Source);
65+
Assert.Equal(expected.HResult, actual.HResult);
6666

67-
// Verify optional additional state
68-
foreach (Func<T, object> getter in additionalGetters)
69-
{
70-
Assert.Equal(getter(expected), getter(actual));
71-
}
72-
}
73-
}
74-
}
67+
// Verify optional additional state
68+
foreach (Func<T, object> getter in additionalGetters)
69+
{
70+
Assert.Equal(getter(expected), getter(actual));
71+
}
72+
}
73+
}
74+
}
7575
}

0 commit comments

Comments
 (0)