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

Commit fb95b29

Browse files
authored
Release/2.0.0 - Make coreclr exceptions serializable and add typeforwards (#14847)
* Make coreclr exceptions serializable and add typeforwards * Make ContractException public in impl assembly to support corert typeforwarding (#14589) * Make ContractException public in impl assembly to support corert typeforwarding * Make EventSourcException serializable in corert scenarios (#14716) * Use GenericEqualityComparer<string> instead of NonRandomizedStringEqualityComparer in serialization * Wrapped Exception header rename in VM, change from 'share four exception types' and fix merge errors * Update URLs to use for formatter job (#14785)
1 parent 4e3e4ea commit fb95b29

File tree

99 files changed

+414
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+414
-135
lines changed

src/mscorlib/shared/System/ApplicationException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace System
2222
// to create their own exceptions do so by extending this class.
2323
// ApplicationException extends but adds no new functionality to
2424
// RecoverableException.
25-
//
25+
[Serializable]
26+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2627
public class ApplicationException : Exception
2728
{
2829
// Creates a new ApplicationException with its message string set to
@@ -52,7 +53,6 @@ public ApplicationException(String message, Exception innerException)
5253

5354
protected ApplicationException(SerializationInfo info, StreamingContext context) : base(info, context)
5455
{
55-
throw new PlatformNotSupportedException();
5656
}
5757
}
5858
}

src/mscorlib/shared/System/ArgumentException.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ namespace System
1919
// The ArgumentException is thrown when an argument does not meet
2020
// the contract of the method. Ideally it should give a meaningful error
2121
// message describing what was wrong and which parameter is incorrect.
22-
//
22+
[Serializable]
23+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2324
public class ArgumentException : SystemException
2425
{
2526
private String _paramName;
@@ -64,12 +65,13 @@ public ArgumentException(String message, String paramName)
6465
protected ArgumentException(SerializationInfo info, StreamingContext context)
6566
: base(info, context)
6667
{
67-
throw new PlatformNotSupportedException();
68+
_paramName = info.GetString("ParamName");
6869
}
6970

7071
public override void GetObjectData(SerializationInfo info, StreamingContext context)
7172
{
7273
base.GetObjectData(info, context);
74+
info.AddValue("ParamName", _paramName, typeof(string));
7375
}
7476

7577
public override String Message

src/mscorlib/shared/System/ArgumentNullException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ namespace System
1717
{
1818
// The ArgumentException is thrown when an argument
1919
// is null when it shouldn't be.
20-
//
20+
[Serializable]
21+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2122
public class ArgumentNullException : ArgumentException
2223
{
2324
// Creates a new ArgumentNullException with its message
@@ -49,7 +50,6 @@ public ArgumentNullException(String paramName, String message)
4950

5051
protected ArgumentNullException(SerializationInfo info, StreamingContext context) : base(info, context)
5152
{
52-
throw new PlatformNotSupportedException();
5353
}
5454
}
5555
}

src/mscorlib/shared/System/ArgumentOutOfRangeException.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
namespace System
1818
{
1919
// The ArgumentOutOfRangeException is thrown when an argument
20-
// is outside the legal range for that argument.
20+
// is outside the legal range for that argument.
21+
[Serializable]
22+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2123
public class ArgumentOutOfRangeException : ArgumentException
2224
{
2325
private Object _actualValue;
@@ -61,12 +63,13 @@ public ArgumentOutOfRangeException(String paramName, Object actualValue, String
6163
protected ArgumentOutOfRangeException(SerializationInfo info, StreamingContext context)
6264
: base(info, context)
6365
{
64-
throw new PlatformNotSupportedException();
66+
_actualValue = info.GetValue("ActualValue", typeof(object));
6567
}
6668

6769
public override void GetObjectData(SerializationInfo info, StreamingContext context)
6870
{
6971
base.GetObjectData(info, context);
72+
info.AddValue("ActualValue", _actualValue, typeof(object));
7073
}
7174

7275
public override String Message

src/mscorlib/shared/System/ArithmeticException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ namespace System
1717
{
1818
// The ArithmeticException is thrown when overflow or underflow
1919
// occurs.
20-
//
20+
[Serializable]
21+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2122
public class ArithmeticException : SystemException
2223
{
2324
// Creates a new ArithmeticException with its message string set to
@@ -47,7 +48,6 @@ public ArithmeticException(String message, Exception innerException)
4748

4849
protected ArithmeticException(SerializationInfo info, StreamingContext context) : base(info, context)
4950
{
50-
throw new PlatformNotSupportedException();
5151
}
5252
}
5353
}

src/mscorlib/shared/System/ArrayTypeMismatchException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ namespace System
1717
{
1818
// The ArrayMismatchException is thrown when an attempt to store
1919
// an object of the wrong type within an array occurs.
20-
//
20+
[Serializable]
21+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2122
public class ArrayTypeMismatchException : SystemException
2223
{
2324
// Creates a new ArrayMismatchException with its message string set to
@@ -47,7 +48,6 @@ public ArrayTypeMismatchException(String message, Exception innerException)
4748

4849
protected ArrayTypeMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
4950
{
50-
throw new PlatformNotSupportedException();
5151
}
5252
}
5353
}

src/mscorlib/shared/System/BadImageFormatException.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
namespace System
1919
{
20+
[Serializable]
21+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
2022
public partial class BadImageFormatException : SystemException
2123
{
2224
private String _fileName; // The name of the corrupt PE file.
@@ -56,12 +58,15 @@ public BadImageFormatException(String message, String fileName, Exception inner)
5658
protected BadImageFormatException(SerializationInfo info, StreamingContext context)
5759
: base(info, context)
5860
{
59-
throw new PlatformNotSupportedException();
61+
_fileName = info.GetString("BadImageFormat_FileName");
62+
_fusionLog = info.GetString("BadImageFormat_FusionLog");
6063
}
6164

6265
public override void GetObjectData(SerializationInfo info, StreamingContext context)
6366
{
6467
base.GetObjectData(info, context);
68+
info.AddValue("BadImageFormat_FileName", _fileName, typeof(string));
69+
info.AddValue("BadImageFormat_FusionLog", _fusionLog, typeof(string));
6570
}
6671

6772
public override String Message

src/mscorlib/shared/System/Collections/Generic/KeyNotFoundException.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace System.Collections.Generic
99
{
10+
[Serializable]
11+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
1012
public class KeyNotFoundException : SystemException
1113
{
1214
public KeyNotFoundException()
@@ -29,7 +31,6 @@ public KeyNotFoundException(String message, Exception innerException)
2931

3032
protected KeyNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
3133
{
32-
throw new PlatformNotSupportedException();
3334
}
3435
}
3536
}

src/mscorlib/shared/System/DataMisalignedException.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace System
1515
{
16+
[Serializable]
17+
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
1618
public sealed class DataMisalignedException : SystemException
1719
{
1820
public DataMisalignedException()
@@ -32,5 +34,9 @@ public DataMisalignedException(String message, Exception innerException)
3234
{
3335
HResult = __HResults.COR_E_DATAMISALIGNED;
3436
}
37+
38+
internal DataMisalignedException(SerializationInfo info, StreamingContext context) : base(info, context)
39+
{
40+
}
3541
}
3642
}

src/mscorlib/shared/System/Diagnostics/Tracing/EventSourceException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace System.Diagnostics.Tracing
1818
/// <summary>
1919
/// Exception that is thrown when an error occurs during EventSource operation.
2020
/// </summary>
21-
#if !CORECLR && !ES_BUILD_PN && !ES_BUILD_PCL && !CORERT
21+
#if !ES_BUILD_PCL
2222
[Serializable]
23-
#endif // !CORECLR && !ES_BUILD_PN && !ES_BUILD_PCL && !CORERT
23+
#endif
2424
public class EventSourceException : Exception
2525
{
2626
/// <summary>

0 commit comments

Comments
 (0)