diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32523972a..ffe1e2684 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,20 +57,20 @@ jobs: run: git config --global core.autocrlf input - name: Check out IronRuby - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: path: ironruby # The modern DLR is referenced as source projects from a sibling directory, # and prism supplies the parser itself. - name: Check out the DLR - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: repository: IronLanguages/dlr path: dlr - name: Check out prism - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: repository: ruby/prism path: prism @@ -86,7 +86,7 @@ jobs: # Both runtimes are installed on every matrix entry: the SDK builds either # target framework, but running the net8.0 output needs the .NET 8 runtime. - - uses: actions/setup-dotnet@v4 + - uses: actions/setup-dotnet@v6 with: dotnet-version: | 8.0.x @@ -97,7 +97,7 @@ jobs: ruby-version: '3.3' - name: Cache NuGet packages - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ~/.nuget/packages key: nuget-${{ matrix.os }}-${{ hashFiles('ironruby/**/*.csproj', 'ironruby/Directory.Build.props', 'dlr/**/*.csproj') }} @@ -109,7 +109,7 @@ jobs: - name: Cache the prism build id: prism-cache - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: prism/build key: prism-${{ matrix.os }}-${{ steps.prism.outputs.sha }} @@ -310,7 +310,7 @@ jobs: # The full transcript, for looking at a failure that is inside the baseline. - name: Keep the test output if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: ironruby-tests-${{ matrix.os }}-${{ matrix.tfm }} path: ironruby/Src/IronRuby.Tests/bin/Debug/${{ matrix.tfm }}/results.txt @@ -327,22 +327,22 @@ jobs: TFM: ${{ matrix.tfm }} IR_TFM: ${{ matrix.tfm }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: path: ironruby - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: repository: IronLanguages/dlr path: dlr - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: repository: ruby/prism path: prism - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: repository: ruby/spec path: ironruby/spec - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: repository: ruby/mspec path: ironruby/mspec @@ -355,7 +355,7 @@ jobs: git -C dlr apply "../$patch" done - - uses: actions/setup-dotnet@v4 + - uses: actions/setup-dotnet@v6 with: dotnet-version: | 8.0.x @@ -365,7 +365,7 @@ jobs: ruby-version: '3.3' - name: Cache NuGet packages - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ~/.nuget/packages key: nuget-ubuntu-latest-${{ hashFiles('ironruby/**/*.csproj', 'ironruby/Directory.Build.props', 'dlr/**/*.csproj') }} @@ -377,7 +377,7 @@ jobs: - name: Cache the prism build id: prism-cache - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: prism/build key: prism-ubuntu-latest-${{ steps.prism.outputs.sha }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b312ae74..80769fca2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,16 +48,16 @@ jobs: if: runner.os == 'Windows' run: git config --global core.autocrlf input - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: path: ironruby - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: repository: IronLanguages/dlr path: dlr - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 with: repository: ruby/prism ref: ${{ env.PRISM_REF }} @@ -72,7 +72,7 @@ jobs: # The DLR multi-targets up to net9.0, so the build needs the .NET 10 SDK; the # release itself targets net8.0. - - uses: actions/setup-dotnet@v4 + - uses: actions/setup-dotnet@v6 with: dotnet-version: | 8.0.x @@ -118,7 +118,7 @@ jobs: fi Util/package-release.sh "${{ matrix.rid }}" "$GITHUB_WORKSPACE/dist" - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 with: name: ironruby-${{ matrix.rid }} path: | @@ -134,7 +134,7 @@ jobs: permissions: contents: write steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v8 with: path: dist merge-multiple: true diff --git a/Src/IronRuby.Tests/DLR/ReflectionUtilsTests.cs b/Src/IronRuby.Tests/DLR/ReflectionUtilsTests.cs index d95d175ac..ba586a3c6 100644 --- a/Src/IronRuby.Tests/DLR/ReflectionUtilsTests.cs +++ b/Src/IronRuby.Tests/DLR/ReflectionUtilsTests.cs @@ -93,6 +93,7 @@ public virtual void PublicVirtualMethod2() { } // fields +#pragma warning disable 169, 649 // fields for GetMembers to find by reflection; nothing reads or writes them public static int A_PublicStaticField; private static int A_PrivateStaticField; protected static int A_ProtectedStaticField; @@ -102,6 +103,7 @@ public virtual void PublicVirtualMethod2() { } private int A_PrivateField; protected int A_ProtectedField; internal int A_InternalField; +#pragma warning restore 169, 649 public int PublicField; @@ -181,6 +183,7 @@ internal override void InternalVirtualMethod() { } // fields +#pragma warning disable 169, 649 // fields for GetMembers to find by reflection; nothing reads or writes them public static int B_PublicStaticField; private static int B_PrivateStaticField; protected static int B_ProtectedStaticField; @@ -190,6 +193,7 @@ internal override void InternalVirtualMethod() { } private int B_PrivateField; protected int B_ProtectedField; internal int B_InternalField; +#pragma warning restore 169, 649 public new int PublicField; diff --git a/Src/IronRuby.Tests/Helpers.cs b/Src/IronRuby.Tests/Helpers.cs index b525a1446..457328bd3 100644 --- a/Src/IronRuby.Tests/Helpers.cs +++ b/Src/IronRuby.Tests/Helpers.cs @@ -171,12 +171,6 @@ public static List GetRubyTokens(RubyContext context, ErrorSink log, str return tokens; } - private static int domainId = 0; - - private static AppDomain CreateDomain() { - return AppDomain.CreateDomain("RemoteScripts" + domainId++); - } - [Flags] enum OutputFlags { None = 0, @@ -290,13 +284,13 @@ private void RedirectOutput(TextWriter/*!*/ output, Action f) { f(); } else { MemoryStream stream = new MemoryStream(); - Runtime.IO.SetOutput(stream, StringUtils.DefaultEncoding); + Runtime.IO.SetOutput(stream, Encoding.Default); Runtime.IO.SetErrorOutput(Console.OpenStandardError(), Console.Error); try { f(); } finally { - output.Write(StringUtils.DefaultEncoding.GetString(stream.ToArray())); + output.Write(Encoding.Default.GetString(stream.ToArray())); Runtime.IO.RedirectToConsole(); } } diff --git a/Src/IronRuby.Tests/RubyTests.cs b/Src/IronRuby.Tests/RubyTests.cs index 26b440a16..f357edc06 100644 --- a/Src/IronRuby.Tests/RubyTests.cs +++ b/Src/IronRuby.Tests/RubyTests.cs @@ -106,8 +106,6 @@ public Tests(Driver/*!*/ driver) { Interpreter_JumpFromFinally1, Interpreter_JumpFromFinally2, Interpreter2, - Interpreter3, - Interpreter4, Interpreter5, Interpreter6, InterpreterNumeric1, diff --git a/Src/IronRuby.Tests/Runtime/InterpreterTests.cs b/Src/IronRuby.Tests/Runtime/InterpreterTests.cs index 1825d21f3..9a4c4dfc9 100644 --- a/Src/IronRuby.Tests/Runtime/InterpreterTests.cs +++ b/Src/IronRuby.Tests/Runtime/InterpreterTests.cs @@ -604,185 +604,6 @@ private void Interpreter2_Test(Func c Assert(comparer(fsc[1], fsi[1])); } - /// - /// ThreadAbortException handling. - /// - [Options(NoRuntime = true)] - public void Interpreter3() { - if (_driver.PartialTrust) return; - - // Thread.Abort throws PlatformNotSupportedException on .NET Core and .NET 5 and later - // (SYSLIB0006), so nothing can raise a ThreadAbortException there: Interpreter3_abort - // got that exception instead and the tracker never saw an abort. The scenario only - // exists on .NET Framework and Mono, which this project no longer targets. - if (!ThreadAbortSupported) return; - - var label = Ast.Label(typeof(void)); - foreach (var gotoLabel in new Expression[] { Ast.Goto(label), Ast.Empty() }) { - var var_tracker = Ast.Parameter(typeof(List)); - var var_abort1 = Ast.Parameter(typeof(ThreadAbortException)); - var var_e = Ast.Parameter(typeof(Exception)); - var var_abort2 = Ast.Parameter(typeof(ThreadAbortException)); - - var m_Interpreter3_abort = new Action(Interpreter3_abort).Method; - var m_Interpreter3_catchAbortThrowNSE = new Action, ThreadAbortException>(Interpreter3_catchAbortThrowNSE).Method; - var m_Interpreter3_catchE = new Action, Exception>(Interpreter3_catchE).Method; - var m_Interpreter3_unreachable = new Action>(Interpreter3_unreachable).Method; - var m_Interpreter3_catchAbort = new Action, ThreadAbortException>(Interpreter3_catchAbort).Method; - - var l = Ast.Lambda>>( - AstUtils.Try( - AstUtils.Try( - AstUtils.Try( - Ast.Call(null, m_Interpreter3_abort) - ).Catch(var_abort1, - Ast.Call(null, m_Interpreter3_catchAbortThrowNSE, var_tracker, var_abort1) - ) - ).Catch(var_e, - Ast.Call(null, m_Interpreter3_catchE, var_tracker, var_e), - gotoLabel - ), - Ast.Call(null, m_Interpreter3_unreachable, var_tracker), - Ast.Label(label, Ast.Call(null, m_Interpreter3_unreachable, var_tracker)) - ).Catch(var_abort2, - Ast.Call(null, m_Interpreter3_catchAbort, var_tracker, var_abort2) - ), - new[] { var_tracker } - ); - - var ctracker = new List(); - var itracker = new List(); - try { - l.Compile()(ctracker); - l.LightCompile()(itracker); - } catch (ThreadAbortException) { - Thread.ResetAbort(); - Assert(false); - return; - } - - foreach (var t in new[] { ctracker, itracker }) { - Assert(t.Count == 10); - Assert(t[0] as string == "1"); - Assert(t[1] is ThreadAbortException); - Assert(t[2] as string == "stateInfo"); - Assert(t[3] as string == "2"); - Assert(t[4] is NotSupportedException); - Assert((ThreadState)t[5] == ThreadState.AbortRequested); - Assert(t[6] as string == "3"); - Assert(t[7] is ThreadAbortException); - Assert(ReferenceEquals(t[8], t[2])); - Assert((ThreadState)t[9] == ThreadState.AbortRequested); - } - } - } - - private static bool ThreadAbortSupported { - get { - string runtime = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription; - return runtime.StartsWith(".NET Framework", StringComparison.Ordinal) - || runtime.StartsWith("Mono", StringComparison.Ordinal); - } - } - - public static void Interpreter3_abort() { - Thread.CurrentThread.Abort("stateInfo"); - } - - public static void Interpreter3_catchAbortThrowNSE(List tracker, ThreadAbortException e) { - tracker.Add("1"); - tracker.Add(e); - tracker.Add(e.ExceptionState); - throw new NotSupportedException(); - } - - public static void Interpreter3_catchE(List tracker, Exception e) { - tracker.Add("2"); - tracker.Add(e); - tracker.Add(Thread.CurrentThread.ThreadState); - } - - public static void Interpreter3_unreachable(List tracker) { - tracker.Add("UNREACHABLE"); - } - - public static void Interpreter3_catchAbort(List tracker, ThreadAbortException e) { - tracker.Add("3"); - tracker.Add(e); - tracker.Add(e.ExceptionState); - tracker.Add(Thread.CurrentThread.ThreadState); - Thread.ResetAbort(); - } - - public static void Interpreter4() { - // TODO: figure out if this is specified behavior of thread abort: - - //var var_tracker = Ast.Parameter(typeof(List)); - //var var_abort1 = Ast.Parameter(typeof(ThreadAbortException)); - //var var_abort2 = Ast.Parameter(typeof(ThreadAbortException)); - //var var_abort3 = Ast.Parameter(typeof(ThreadAbortException)); - //var var_abort4 = Ast.Parameter(typeof(ThreadAbortException)); - - //var m_Interpreter4_abort = new Action(Interpreter4_abort).Method; - //var m_Interpreter4_traceE = new Action, ThreadAbortException>(Interpreter4_traceE).Method; - //var m_Interpreter4_traceS = new Action, string>(Interpreter4_traceS).Method; - //var m_Interpreter4_reset = new Action, ThreadAbortException>(Interpreter4_reset).Method; - - //var l = Ast.Lambda>>( - // AstUtils.Try( - // AstUtils.Try( - // Ast.Call(null, m_Interpreter4_abort, Ast.Constant("r1")) - // ).Catch(var_abort1, - // Ast.Call(null, m_Interpreter4_traceE, var_tracker, var_abort1), - // AstUtils.Try( - // AstUtils.Try( - // Ast.Call(null, m_Interpreter4_abort, Ast.Constant("r2")) - // ).Catch(var_abort2, - // Ast.Call(null, m_Interpreter4_traceE, var_tracker, var_abort2) - // ), - // Ast.Call(null, m_Interpreter4_traceS, var_tracker, Ast.Constant("1")) - // ).Catch(var_abort3, - // Ast.Call(null, m_Interpreter4_traceE, var_tracker, var_abort3) - // ), - // Ast.Call(null, m_Interpreter4_traceS, var_tracker, Ast.Constant("2")) - // ), - // Ast.Call(null, m_Interpreter4_traceS, var_tracker, Ast.Constant("2")) - // ).Catch(var_abort4, - // Ast.Call(null, m_Interpreter4_reset, var_tracker, var_abort4) - // ), - // new[] { var_tracker } - //); - - //var ctracker = new List(); - //var itracker = new List(); - //try { - // l.Compile()(ctracker); - // //l.LightCompile()(itracker); - //} catch (ThreadAbortException) { - // Thread.ResetAbort(); - // Assert(false); - // return; - //} - } - - public static void Interpreter4_abort(string value) { - Thread.CurrentThread.Abort(value); - } - - public static void Interpreter4_traceE(List tracker, ThreadAbortException e) { - tracker.Add(e.ExceptionState); - } - - public static void Interpreter4_traceS(List tracker, string s) { - tracker.Add(s); - } - - public static void Interpreter4_reset(List tracker, ThreadAbortException e) { - tracker.Add(e.ExceptionState); - Thread.ResetAbort(); - tracker.Add(e.ExceptionState); - } - [Options(NoRuntime = true)] public void Interpreter5() { var strArray1 = new string[] { "foo" }; diff --git a/Src/Libraries/Builtins/EncodingConverter.cs b/Src/Libraries/Builtins/EncodingConverter.cs index 92746e122..6ab3dbf9a 100644 --- a/Src/Libraries/Builtins/EncodingConverter.cs +++ b/Src/Libraries/Builtins/EncodingConverter.cs @@ -329,7 +329,7 @@ internal MutableString/*!*/ Replacement { string chars = value.ToString(); try { return EncodeStageDestination.StrictEncoding.GetBytes(chars); - } catch (EncoderFallbackException e) { + } catch (EncoderFallbackException) { throw new UndefinedConversionError("replacement character setup failed"); } } diff --git a/Src/Libraries/Builtins/Errno.cs b/Src/Libraries/Builtins/Errno.cs index 9e44e061d..5bb72ece7 100644 --- a/Src/Libraries/Builtins/Errno.cs +++ b/Src/Libraries/Builtins/Errno.cs @@ -36,7 +36,7 @@ public static class Errno { return new UnauthorizedAccessException(message, inner); } - [RubyClass("EAGAIN"), Serializable] + [RubyClass("EAGAIN")] public class ResourceTemporarilyUnavailableError : ExternalException { private const string/*!*/ M = "Resource temporarily unavailable"; @@ -44,14 +44,9 @@ public ResourceTemporarilyUnavailableError() : this(null, null) { } public ResourceTemporarilyUnavailableError(string message) : this(message, null) { } public ResourceTemporarilyUnavailableError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ResourceTemporarilyUnavailableError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ResourceTemporarilyUnavailableError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("EINTR"), Serializable] + [RubyClass("EINTR")] public class InterruptedError : ExternalException { private const string/*!*/ M = "Interrupted function call"; @@ -59,14 +54,9 @@ public InterruptedError() : this(null, null) { } public InterruptedError(string message) : this(message, null) { } public InterruptedError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public InterruptedError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected InterruptedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("EDOM"), Serializable] + [RubyClass("EDOM")] public class DomainError : ExternalException { private const string/*!*/ M = "Domain error"; @@ -74,11 +64,6 @@ public DomainError() : this(null, null) { } public DomainError(string message) : this(message, null) { } public DomainError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public DomainError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected DomainError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } [RubyClass("EINVAL", Extends = typeof(InvalidError), Inherits = typeof(ExternalException))] @@ -122,7 +107,7 @@ public class UnauthorizedAccessExceptionOps { } } - [RubyClass("ECHILD"), Serializable] + [RubyClass("ECHILD")] public class ChildError : ExternalException { private const string/*!*/ M = "No child processes"; @@ -130,11 +115,6 @@ public ChildError() : this(null, null) { } public ChildError(string message) : this(message, null) { } public ChildError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ChildError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ChildError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } [RubyClass("EISDIR", Extends = typeof(DirectoryIsError), Inherits = typeof(ExternalException))] @@ -187,7 +167,7 @@ public class ExecFormatErrorOps { } } - [RubyClass("EPERM"), Serializable] + [RubyClass("EPERM")] public class OperationNotPermittedError : ExternalException { private const string/*!*/ M = "Operation not permitted"; @@ -195,14 +175,9 @@ public OperationNotPermittedError() : this(null, null) { } public OperationNotPermittedError(string message) : this(message, null) { } public OperationNotPermittedError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public OperationNotPermittedError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected OperationNotPermittedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ELOOP"), Serializable] + [RubyClass("ELOOP")] public class TooManySymbolicLinksError : ExternalException { private const string/*!*/ M = "Too many levels of symbolic links"; @@ -210,14 +185,9 @@ public TooManySymbolicLinksError() : this(null, null) { } public TooManySymbolicLinksError(string message) : this(message, null) { } public TooManySymbolicLinksError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public TooManySymbolicLinksError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected TooManySymbolicLinksError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ENOTEMPTY"), Serializable] + [RubyClass("ENOTEMPTY")] public class DirectoryNotEmptyError : ExternalException { private const string/*!*/ M = "Directory not empty"; @@ -225,14 +195,9 @@ public DirectoryNotEmptyError() : this(null, null) { } public DirectoryNotEmptyError(string message) : this(message, null) { } public DirectoryNotEmptyError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public DirectoryNotEmptyError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected DirectoryNotEmptyError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ENAMETOOLONG"), Serializable] + [RubyClass("ENAMETOOLONG")] public class NameTooLongError : ExternalException { private const string/*!*/ M = "File name too long"; @@ -240,14 +205,9 @@ public NameTooLongError() : this(null, null) { } public NameTooLongError(string message) : this(message, null) { } public NameTooLongError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public NameTooLongError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected NameTooLongError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("EPIPE"), Serializable] + [RubyClass("EPIPE")] public class PipeError : ExternalException { private const string/*!*/ M = "Broken pipe"; @@ -255,15 +215,10 @@ public PipeError() : this(null, null) { } public PipeError(string message) : this(message, null) { } public PipeError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public PipeError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected PipeError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("EXDEV"), Serializable] + [RubyClass("EXDEV")] public class ImproperLinkError : ExternalException { private const string/*!*/ M = "Improper link"; @@ -271,14 +226,9 @@ public ImproperLinkError() : this(null, null) { } public ImproperLinkError(string message) : this(message, null) { } public ImproperLinkError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ImproperLinkError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ImproperLinkError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ESPIPE"), Serializable] + [RubyClass("ESPIPE")] public class InvalidSeekError : ExternalException { private const string/*!*/ M = "Invalid seek"; @@ -286,18 +236,13 @@ public InvalidSeekError() : this(null, null) { } public InvalidSeekError(string message) : this(message, null) { } public InvalidSeekError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public InvalidSeekError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected InvalidSeekError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } #region Socket Errors // TODO: generate - [RubyClass("EWOULDBLOCK"), Serializable] + [RubyClass("EWOULDBLOCK")] public class WouldBlockError : ExternalException { private const string/*!*/ M = "A non-blocking socket operation could not be completed immediately."; public override int ErrorCode { get { return 10035; } } @@ -306,14 +251,9 @@ public WouldBlockError() : this(null, null) { } public WouldBlockError(string message) : this(message, null) { } public WouldBlockError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public WouldBlockError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected WouldBlockError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("EADDRINUSE"), Serializable] + [RubyClass("EADDRINUSE")] public class AddressInUseError : ExternalException { private const string/*!*/ M = "Only one usage of each socket address (protocol/network address/port) is normally permitted."; public override int ErrorCode { get { return 10048; } } @@ -322,14 +262,9 @@ public AddressInUseError() : this(null, null) { } public AddressInUseError(string message) : this(message, null) { } public AddressInUseError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public AddressInUseError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected AddressInUseError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ECONNABORTED"), Serializable] + [RubyClass("ECONNABORTED")] public class ConnectionAbortedError : ExternalException { private const string/*!*/ M = "An established connection was aborted by the software in your host machine."; public override int ErrorCode { get { return 10053; } } @@ -338,14 +273,9 @@ public ConnectionAbortedError() : this(null, null) { } public ConnectionAbortedError(string message) : this(message, null) { } public ConnectionAbortedError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ConnectionAbortedError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ConnectionAbortedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ECONNRESET"), Serializable] + [RubyClass("ECONNRESET")] public class ConnectionResetError : ExternalException { private const string/*!*/ M = "An existing connection was forcibly closed by the remote host."; public override int ErrorCode { get { return 10054; } } @@ -354,14 +284,9 @@ public ConnectionResetError() : this(null, null) { } public ConnectionResetError(string message) : this(message, null) { } public ConnectionResetError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ConnectionResetError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ConnectionResetError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ENOTCONN"), Serializable] + [RubyClass("ENOTCONN")] public class NotConnectedError : ExternalException { private const string/*!*/ M = "A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied."; public override int ErrorCode { get { return 10057; } } @@ -370,14 +295,9 @@ public NotConnectedError() : this(null, null) { } public NotConnectedError(string message) : this(message, null) { } public NotConnectedError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public NotConnectedError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected NotConnectedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("ECONNREFUSED"), Serializable] + [RubyClass("ECONNREFUSED")] public class ConnectionRefusedError : ExternalException { private const string/*!*/ M = "No connection could be made because the target machine actively refused it."; public override int ErrorCode { get { return 10061; } } @@ -386,14 +306,9 @@ public ConnectionRefusedError() : this(null, null) { } public ConnectionRefusedError(string message) : this(message, null) { } public ConnectionRefusedError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ConnectionRefusedError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ConnectionRefusedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [RubyClass("EHOSTDOWN"), Serializable] + [RubyClass("EHOSTDOWN")] public class HostDownError : ExternalException { private const string/*!*/ M = "A socket operation failed because the destination host was down."; public override int ErrorCode { get { return 10064; } } @@ -402,11 +317,6 @@ public HostDownError() : this(null, null) { } public HostDownError(string message) : this(message, null) { } public HostDownError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public HostDownError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected HostDownError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } #endregion diff --git a/Src/Libraries/Builtins/Exceptions.cs b/Src/Libraries/Builtins/Exceptions.cs index 8903b6f6c..a02cf2091 100644 --- a/Src/Libraries/Builtins/Exceptions.cs +++ b/Src/Libraries/Builtins/Exceptions.cs @@ -25,64 +25,46 @@ namespace IronRuby.Builtins { - [RubyException("NoMemoryError"), Serializable] + [RubyException("NoMemoryError")] public class NoMemoryError : Exception { public NoMemoryError() : this(null, null) { } public NoMemoryError(string message): this(message, null) { } public NoMemoryError(string message, Exception inner) : base(message ?? "NoMemoryError", inner) { } - - protected NoMemoryError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("EOFError"), Serializable] + [RubyException("EOFError")] public class EOFError : IOException { public EOFError() : this(null, null) { } public EOFError(string message): this(message, null) { } public EOFError(string message, Exception inner) : base(message ?? "EOFError", inner) { } - - protected EOFError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("FloatDomainError"), Serializable] + [RubyException("FloatDomainError")] public class FloatDomainError : ArgumentOutOfRangeException { public FloatDomainError() : this(null, null) { } public FloatDomainError(string message) : this(message, null) { } public FloatDomainError(string message, Exception inner) : base(message ?? "FloatDomainError", inner) { } - - protected FloatDomainError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("ThreadError"), Serializable] + [RubyException("ThreadError")] public class ThreadError : SystemException { public ThreadError() : this(null, null) { } public ThreadError(string message): this(message, null) { } public ThreadError(string message, Exception inner) : base(message ?? "ThreadError", inner) { } - - protected ThreadError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("StopIteration"), Serializable] + [RubyException("StopIteration")] public class StopIteration : IndexError { public StopIteration() : this(null, null) { } public StopIteration(string message): this(message, null) { } public StopIteration(string message, Exception inner) : base(message ?? "StopIteration", inner) { } - - protected StopIteration(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("ClosedQueueError"), Serializable] + [RubyException("ClosedQueueError")] public class ClosedQueueError : StopIteration { public ClosedQueueError() : this(null, null) { } public ClosedQueueError(string message): this(message, null) { } public ClosedQueueError(string message, Exception inner) : base(message ?? "ClosedQueueError", inner) { } - - protected ClosedQueueError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } [RubyException("SystemExit", Extends = typeof(SystemExit))] @@ -176,24 +158,18 @@ private static bool TryGetStatus(object value, out int status) { } } - [RubyException("SignalException"), Serializable] + [RubyException("SignalException")] public class SignalException : Exception { public SignalException() : this(null, null) { } public SignalException(string message): this(message, null) { } public SignalException(string message, Exception inner) : base(message ?? "SignalException", inner) { } - - protected SignalException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("Interrupt", Inherits = typeof(SignalException)), Serializable] + [RubyException("Interrupt", Inherits = typeof(SignalException))] public class Interrupt : Exception { public Interrupt() : this(null, null) { } public Interrupt(string message): this(message, null) { } public Interrupt(string message, Exception inner) : base(message ?? "Interrupt", inner) { } - - protected Interrupt(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } [RubyException("LocalJumpError", Extends = typeof(LocalJumpError))] diff --git a/Src/Libraries/Builtins/KernelOps.cs b/Src/Libraries/Builtins/KernelOps.cs index 99a53e412..247c38810 100644 --- a/Src/Libraries/Builtins/KernelOps.cs +++ b/Src/Libraries/Builtins/KernelOps.cs @@ -2653,21 +2653,15 @@ public static object ReadInputLine(CallSiteStorage 0) { throw RubyExceptions.CreateArgumentError("`{0}' is not a generic type definition", self.Name); } @@ -1859,7 +1859,7 @@ public static RubyModule ToClrRef(RubyModule/*!*/ self) { Type type = self.TypeTracker.Type; - if (!type.IsGenericTypeDefinition()) { + if (!type.IsGenericTypeDefinition) { if (genericArity > 0) { throw RubyExceptions.CreateArgumentError("`{0}' is not a generic type definition", self.Name); } diff --git a/Src/Libraries/Builtins/ProcOps.cs b/Src/Libraries/Builtins/ProcOps.cs index 30bcf3a9e..ab51b1e6d 100644 --- a/Src/Libraries/Builtins/ProcOps.cs +++ b/Src/Libraries/Builtins/ProcOps.cs @@ -24,7 +24,6 @@ using System.Globalization; using System.Collections.Generic; using System.Runtime.InteropServices; -using Microsoft.Scripting.Runtime; namespace IronRuby.Builtins { diff --git a/Src/Libraries/Builtins/RubyEncodingOps.cs b/Src/Libraries/Builtins/RubyEncodingOps.cs index 9c1feb881..bb79588e8 100644 --- a/Src/Libraries/Builtins/RubyEncodingOps.cs +++ b/Src/Libraries/Builtins/RubyEncodingOps.cs @@ -182,7 +182,9 @@ public static class ConverterNotFoundErrorOps { // TODO: lazy encoding load? [RubyConstant] +#pragma warning disable SYSLIB0001 // UTF-7 is obsolete in .NET, and still one of Ruby's encodings public static readonly RubyEncoding UTF_7 = RubyEncoding.GetRubyEncoding(Encoding.UTF7); +#pragma warning restore SYSLIB0001 // UTF-16 and UTF-32 without an endianness suffix are dummy encodings that carry a BOM. // They are distinct from UTF-16LE/BE and UTF-32LE/BE, which are not dummy. diff --git a/Src/Libraries/Builtins/RubyTimeOps.cs b/Src/Libraries/Builtins/RubyTimeOps.cs index 89c7d2970..bd5eb8e38 100644 --- a/Src/Libraries/Builtins/RubyTimeOps.cs +++ b/Src/Libraries/Builtins/RubyTimeOps.cs @@ -1071,7 +1071,7 @@ private static uint GetUint(byte[] data, int start) { return CopyExtraIVars(context, time, isUtc ? instant : WithLoadedZone(context, self, instant, hasOffset, offsetSeconds, zoneName)); - } catch (Exception e) when (!(e is RubyTime)) { + } catch (Exception) { throw RubyExceptions.CreateTypeError("marshaled time format differ"); } } diff --git a/Src/Libraries/Date/DateTime.cs b/Src/Libraries/Date/DateTime.cs index 0750b6efd..bd9fb5514 100644 --- a/Src/Libraries/Date/DateTime.cs +++ b/Src/Libraries/Date/DateTime.cs @@ -426,13 +426,13 @@ public static object GetOffset(BinaryOpStorage/*!*/ quo, RubyDate/*!*/ self) { #region formatting [RubyMethod("to_s")] - public static MutableString/*!*/ ToS(RubyDate/*!*/ self) { + public static new MutableString/*!*/ ToS(RubyDate/*!*/ self) { return MutableString.CreateAscii(DateFormatter.Format(self, "%Y-%m-%dT%H:%M:%S%:z")); } /// DateTime#strftime defaults to the full ISO form, not Date's "%F". [RubyMethod("strftime")] - public static MutableString/*!*/ Strftime(RubyDate/*!*/ self, + public static new MutableString/*!*/ Strftime(RubyDate/*!*/ self, [DefaultProtocol, DefaultParameterValue(null)]MutableString format) { if (format == null) { return ToS(self); diff --git a/Src/Libraries/Extensions/TypeGroupOps.cs b/Src/Libraries/Extensions/TypeGroupOps.cs index 30fbdbc6c..54b1972ab 100644 --- a/Src/Libraries/Extensions/TypeGroupOps.cs +++ b/Src/Libraries/Extensions/TypeGroupOps.cs @@ -124,7 +124,7 @@ public static object EachType(RubyContext/*!*/ context, BlockParam/*!*/ block, T [Emitted] public static RubyClass/*!*/ GetNonGenericClass(RubyContext/*!*/ context, TypeGroup/*!*/ typeGroup) { Type type = GetNonGenericType(typeGroup); - if (type.IsInterface()) { + if (type.IsInterface) { throw RubyExceptions.CreateTypeError("cannot instantiate an interface"); } return context.GetClass(type); @@ -169,7 +169,7 @@ public static object New(CallSiteStorage/native. --> + + diff --git a/Src/Libraries/MessagePack/MessagePack.cs b/Src/Libraries/MessagePack/MessagePack.cs index 53cece091..2aa6a013f 100644 --- a/Src/Libraries/MessagePack/MessagePack.cs +++ b/Src/Libraries/MessagePack/MessagePack.cs @@ -23,7 +23,6 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.Serialization; using IronRuby.Builtins; using IronRuby.Runtime; using IronRuby.Runtime.Calls; @@ -403,44 +402,39 @@ public static class MessagePackOps { #region errors - [RubyException("UnpackError"), Serializable] + [RubyException("UnpackError")] public class UnpackError : SystemException { public UnpackError() : this(null, null) { } public UnpackError(string message) : this(message, null) { } public UnpackError(string message, Exception inner) : base(message ?? "MessagePack::UnpackError", inner) { } - protected UnpackError(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("MalformedFormatError"), Serializable] + [RubyException("MalformedFormatError")] public class MalformedFormatError : UnpackError { public MalformedFormatError() : this(null, null) { } public MalformedFormatError(string message) : this(message, null) { } public MalformedFormatError(string message, Exception inner) : base(message ?? "MessagePack::MalformedFormatError", inner) { } - protected MalformedFormatError(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("StackError"), Serializable] + [RubyException("StackError")] public class StackError : UnpackError { public StackError() : this(null, null) { } public StackError(string message) : this(message, null) { } public StackError(string message, Exception inner) : base(message ?? "MessagePack::StackError", inner) { } - protected StackError(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("UnexpectedTypeError"), Serializable] + [RubyException("UnexpectedTypeError")] public class UnexpectedTypeError : UnpackError { public UnexpectedTypeError() : this(null, null) { } public UnexpectedTypeError(string message) : this(message, null) { } public UnexpectedTypeError(string message, Exception inner) : base(message ?? "MessagePack::UnexpectedTypeError", inner) { } - protected UnexpectedTypeError(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("UnknownExtTypeError"), Serializable] + [RubyException("UnknownExtTypeError")] public class UnknownExtTypeError : UnpackError { public UnknownExtTypeError() : this(null, null) { } public UnknownExtTypeError(string message) : this(message, null) { } public UnknownExtTypeError(string message, Exception inner) : base(message ?? "MessagePack::UnknownExtTypeError", inner) { } - protected UnknownExtTypeError(SerializationInfo info, StreamingContext context) : base(info, context) { } } #endregion diff --git a/Src/Libraries/Nio4r/Nio4r.cs b/Src/Libraries/Nio4r/Nio4r.cs index fdcbc6f2c..e0a7cd7e4 100644 --- a/Src/Libraries/Nio4r/Nio4r.cs +++ b/Src/Libraries/Nio4r/Nio4r.cs @@ -31,7 +31,6 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.Serialization; using System.Threading; using IronRuby.Builtins; using IronRuby.Runtime; @@ -784,7 +783,6 @@ internal void Resolve() { internal int _readiness; internal Selector _selector; internal object _value; - private bool _initialized; public Monitor(RubyClass/*!*/ rubyClass) : base(rubyClass) { } @@ -806,7 +804,6 @@ internal void Setup(RespondToStorage/*!*/ respondToStorage, _io = io; _interests = value; _selector = selector; - _initialized = true; } [RubyConstructor] @@ -950,21 +947,21 @@ public ByteBuffer(RubyClass/*!*/ rubyClass) : base(rubyClass) { return new ByteBuffer(ImmediateClass.NominalClass); } - [RubyException("OverflowError"), Serializable] + [RubyException("OverflowError")] public class OverflowError : System.IO.IOException { public OverflowError() : this(null, null) { } public OverflowError(string message) : this(message, null) { } public OverflowError(string message, Exception inner) : base(message ?? "OverflowError", inner) { } } - [RubyException("UnderflowError"), Serializable] + [RubyException("UnderflowError")] public class UnderflowError : System.IO.IOException { public UnderflowError() : this(null, null) { } public UnderflowError(string message) : this(message, null) { } public UnderflowError(string message, Exception inner) : base(message ?? "UnderflowError", inner) { } } - [RubyException("MarkUnsetError"), Serializable] + [RubyException("MarkUnsetError")] public class MarkUnsetError : System.IO.IOException { public MarkUnsetError() : this(null, null) { } public MarkUnsetError(string message) : this(message, null) { } diff --git a/Src/Libraries/Oj/Oj.cs b/Src/Libraries/Oj/Oj.cs index d98ede25c..e3f1c21f5 100644 --- a/Src/Libraries/Oj/Oj.cs +++ b/Src/Libraries/Oj/Oj.cs @@ -194,7 +194,6 @@ private OjState(RubyContext/*!*/ context) { internal bool EscapeHtml = true; internal bool XmlTime = true; internal object ActiveRecordBase; - internal object StringWriterClass; // mimic_JSON internal object JsonParserErrorOverride; diff --git a/Src/Libraries/Oj/OjRails.cs b/Src/Libraries/Oj/OjRails.cs index 9aaa50f11..8271eb2d2 100644 --- a/Src/Libraries/Oj/OjRails.cs +++ b/Src/Libraries/Oj/OjRails.cs @@ -153,8 +153,6 @@ internal static void Optimize(RubyContext/*!*/ context, object[]/*!*/ argv, Rail state.RailsArrayOpt = on; } else if (ReferenceEquals(arg, context.GetClass(typeof(double)))) { state.RailsFloatOpt = on; - } else if (ReferenceEquals(arg, state.StringWriterClass)) { - state.StringWriterOptimized = on; } else { ROpt ro = rot.Get(arg); if (ro == null && arg is RubyModule) { diff --git a/Src/Libraries/OpenSSL/OpenSSL.cs b/Src/Libraries/OpenSSL/OpenSSL.cs index dc848af41..55e9af5aa 100644 --- a/Src/Libraries/OpenSSL/OpenSSL.cs +++ b/Src/Libraries/OpenSSL/OpenSSL.cs @@ -61,17 +61,12 @@ public static class OpenSsl { public class Digest { // MRI's class for "this is not a digest OpenSSL knows"; code rescues it // by name, so it has to be this class and not its OpenSSLError parent. - [RubyException("DigestError"), Serializable] + [RubyException("DigestError")] public class DigestError : OpenSSLError { public DigestError() : this(null, null) { } public DigestError(string message) : this(message, null) { } public DigestError(string message, Exception inner) : base(message ?? "DigestError", inner) { } public DigestError(MutableString message) : base(message.ConvertToString()) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected DigestError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } private string/*!*/ _name = "SHA1"; @@ -421,7 +416,7 @@ public static class KDF { } } - [RubyException("KDFError"), Serializable] + [RubyException("KDFError")] public class KDFError : OpenSSLError { public KDFError() : this(null, null) { } public KDFError(string message) : this(message, null) { } @@ -468,8 +463,7 @@ public static class RandomModule { } byte[] data = new byte[length]; - var generator = new Crypto.RNGCryptoServiceProvider(); - generator.GetBytes(data); + Crypto.RandomNumberGenerator.Fill(data); return MutableString.CreateBinary(data); } @@ -489,8 +483,7 @@ public class BN { [RubyMethod("rand", RubyMethodAttributes.PublicSingleton)] public static BigInteger/*!*/ Rand(RubyClass/*!*/ self, [DefaultProtocol]int bits, [DefaultProtocol, Optional]int someFlag, [Optional]bool otherFlag) { // TODO: figure out someFlag and otherFlag byte[] data = new byte[bits >> 3]; - var generator = new Crypto.RNGCryptoServiceProvider(); - generator.GetBytes(data); + Crypto.RandomNumberGenerator.Fill(data); uint[] transformed = new uint[data.Length >> 2]; int j = 0; @@ -545,17 +538,12 @@ public class Name { // MRI's OpenSSL exceptions are plain StandardErrors: the message is exactly what was given, // not the " - " form of SystemCallError. - [RubyException("OpenSSLError"), Serializable] + [RubyException("OpenSSLError")] public class OpenSSLError : SystemException { public OpenSSLError() : this(null, null) { } public OpenSSLError(string message) : this(message, null) { } public OpenSSLError(string message, Exception inner) : base(message ?? "OpenSSLError", inner) { } public OpenSSLError(MutableString message) : base(message.ConvertToString()) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected OpenSSLError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } [RubyModule("SSL")] @@ -685,8 +673,10 @@ public static MutableString PeerCertificate(Transport/*!*/ self) { return null; } switch (self._ssl.SslProtocol) { +#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete, but a connection can still have negotiated one case SslProtocols.Tls: return MutableString.CreateAscii("TLSv1"); case SslProtocols.Tls11: return MutableString.CreateAscii("TLSv1.1"); +#pragma warning restore SYSLIB0039 case SslProtocols.Tls12: return MutableString.CreateAscii("TLSv1.2"); case SslProtocols.Tls13: return MutableString.CreateAscii("TLSv1.3"); default: return MutableString.CreateAscii(self._ssl.SslProtocol.ToString()); @@ -710,17 +700,12 @@ public static int Pending(Transport/*!*/ self) { } #endif - [RubyException("SSLError"), Serializable] + [RubyException("SSLError")] public class SSLError : OpenSSLError { public SSLError() : this(null, null) { } public SSLError(string message) : this(message, null) { } public SSLError(string message, Exception inner) : base(message ?? "SSLError", inner) { } public SSLError(MutableString message) : base(message.ConvertToString()) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected SSLError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } } } diff --git a/Src/Libraries/Puma/PumaHttp11.cs b/Src/Libraries/Puma/PumaHttp11.cs index ba5eb33d0..48c85c1d8 100644 --- a/Src/Libraries/Puma/PumaHttp11.cs +++ b/Src/Libraries/Puma/PumaHttp11.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; -using System.Runtime.Serialization; using System.Text; using IronRuby.Builtins; using IronRuby.Runtime; @@ -40,7 +39,7 @@ namespace IronRuby.StandardLibrary.Puma { [RubyModule("Puma")] public static class PumaModule { - [RubyException("HttpParserError"), Serializable] + [RubyException("HttpParserError")] public class HttpParserError : SystemException { public HttpParserError() : this(null, null) { } public HttpParserError(string message) : this(message, null) { } diff --git a/Src/Libraries/Sqlite3/Sqlite3.cs b/Src/Libraries/Sqlite3/Sqlite3.cs index 42c847737..7a411ffba 100644 --- a/Src/Libraries/Sqlite3/Sqlite3.cs +++ b/Src/Libraries/Sqlite3/Sqlite3.cs @@ -25,7 +25,6 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.InteropServices; -using System.Runtime.Serialization; using System.Text; using IronRuby.Builtins; using IronRuby.Runtime; @@ -137,220 +136,193 @@ internal static int ErrorOffset(sqlite3 db) { /// and read by attr_readers in Src/StdLib/ironruby/sqlite3/errors.rb, the way /// KeyError#key is done in the core (see StringFormatter.CreateKeyError). /// - [RubyException("Exception"), Serializable] + [RubyException("Exception")] public class SqliteException : SystemException { public SqliteException() : this(null, null) { } public SqliteException(string message) : this(message, null) { } public SqliteException(string message, Exception inner) : base(message ?? "SQLite3::Exception", inner) { } - protected SqliteException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("SQLException"), Serializable] + [RubyException("SQLException")] public class SQLException : SqliteException { public SQLException() : this(null, null) { } public SQLException(string message) : this(message, null) { } public SQLException(string message, Exception inner) : base(message ?? "SQLException", inner) { } - protected SQLException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("InternalException"), Serializable] + [RubyException("InternalException")] public class InternalException : SqliteException { public InternalException() : this(null, null) { } public InternalException(string message) : this(message, null) { } public InternalException(string message, Exception inner) : base(message ?? "InternalException", inner) { } - protected InternalException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("PermissionException"), Serializable] + [RubyException("PermissionException")] public class PermissionException : SqliteException { public PermissionException() : this(null, null) { } public PermissionException(string message) : this(message, null) { } public PermissionException(string message, Exception inner) : base(message ?? "PermissionException", inner) { } - protected PermissionException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("AbortException"), Serializable] + [RubyException("AbortException")] public class AbortException : SqliteException { public AbortException() : this(null, null) { } public AbortException(string message) : this(message, null) { } public AbortException(string message, Exception inner) : base(message ?? "AbortException", inner) { } - protected AbortException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("BusyException"), Serializable] + [RubyException("BusyException")] public class BusyException : SqliteException { public BusyException() : this(null, null) { } public BusyException(string message) : this(message, null) { } public BusyException(string message, Exception inner) : base(message ?? "BusyException", inner) { } - protected BusyException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("LockedException"), Serializable] + [RubyException("LockedException")] public class LockedException : SqliteException { public LockedException() : this(null, null) { } public LockedException(string message) : this(message, null) { } public LockedException(string message, Exception inner) : base(message ?? "LockedException", inner) { } - protected LockedException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("MemoryException"), Serializable] + [RubyException("MemoryException")] public class MemoryException : SqliteException { public MemoryException() : this(null, null) { } public MemoryException(string message) : this(message, null) { } public MemoryException(string message, Exception inner) : base(message ?? "MemoryException", inner) { } - protected MemoryException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("ReadOnlyException"), Serializable] + [RubyException("ReadOnlyException")] public class ReadOnlyException : SqliteException { public ReadOnlyException() : this(null, null) { } public ReadOnlyException(string message) : this(message, null) { } public ReadOnlyException(string message, Exception inner) : base(message ?? "ReadOnlyException", inner) { } - protected ReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("InterruptException"), Serializable] + [RubyException("InterruptException")] public class InterruptException : SqliteException { public InterruptException() : this(null, null) { } public InterruptException(string message) : this(message, null) { } public InterruptException(string message, Exception inner) : base(message ?? "InterruptException", inner) { } - protected InterruptException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("IOException"), Serializable] + [RubyException("IOException")] public class IOException : SqliteException { public IOException() : this(null, null) { } public IOException(string message) : this(message, null) { } public IOException(string message, Exception inner) : base(message ?? "IOException", inner) { } - protected IOException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("CorruptException"), Serializable] + [RubyException("CorruptException")] public class CorruptException : SqliteException { public CorruptException() : this(null, null) { } public CorruptException(string message) : this(message, null) { } public CorruptException(string message, Exception inner) : base(message ?? "CorruptException", inner) { } - protected CorruptException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("NotFoundException"), Serializable] + [RubyException("NotFoundException")] public class NotFoundException : SqliteException { public NotFoundException() : this(null, null) { } public NotFoundException(string message) : this(message, null) { } public NotFoundException(string message, Exception inner) : base(message ?? "NotFoundException", inner) { } - protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("FullException"), Serializable] + [RubyException("FullException")] public class FullException : SqliteException { public FullException() : this(null, null) { } public FullException(string message) : this(message, null) { } public FullException(string message, Exception inner) : base(message ?? "FullException", inner) { } - protected FullException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("CantOpenException"), Serializable] + [RubyException("CantOpenException")] public class CantOpenException : SqliteException { public CantOpenException() : this(null, null) { } public CantOpenException(string message) : this(message, null) { } public CantOpenException(string message, Exception inner) : base(message ?? "CantOpenException", inner) { } - protected CantOpenException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("ProtocolException"), Serializable] + [RubyException("ProtocolException")] public class ProtocolException : SqliteException { public ProtocolException() : this(null, null) { } public ProtocolException(string message) : this(message, null) { } public ProtocolException(string message, Exception inner) : base(message ?? "ProtocolException", inner) { } - protected ProtocolException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("EmptyException"), Serializable] + [RubyException("EmptyException")] public class EmptyException : SqliteException { public EmptyException() : this(null, null) { } public EmptyException(string message) : this(message, null) { } public EmptyException(string message, Exception inner) : base(message ?? "EmptyException", inner) { } - protected EmptyException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("SchemaChangedException"), Serializable] + [RubyException("SchemaChangedException")] public class SchemaChangedException : SqliteException { public SchemaChangedException() : this(null, null) { } public SchemaChangedException(string message) : this(message, null) { } public SchemaChangedException(string message, Exception inner) : base(message ?? "SchemaChangedException", inner) { } - protected SchemaChangedException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("TooBigException"), Serializable] + [RubyException("TooBigException")] public class TooBigException : SqliteException { public TooBigException() : this(null, null) { } public TooBigException(string message) : this(message, null) { } public TooBigException(string message, Exception inner) : base(message ?? "TooBigException", inner) { } - protected TooBigException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("ConstraintException"), Serializable] + [RubyException("ConstraintException")] public class ConstraintException : SqliteException { public ConstraintException() : this(null, null) { } public ConstraintException(string message) : this(message, null) { } public ConstraintException(string message, Exception inner) : base(message ?? "ConstraintException", inner) { } - protected ConstraintException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("MismatchException"), Serializable] + [RubyException("MismatchException")] public class MismatchException : SqliteException { public MismatchException() : this(null, null) { } public MismatchException(string message) : this(message, null) { } public MismatchException(string message, Exception inner) : base(message ?? "MismatchException", inner) { } - protected MismatchException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("MisuseException"), Serializable] + [RubyException("MisuseException")] public class MisuseException : SqliteException { public MisuseException() : this(null, null) { } public MisuseException(string message) : this(message, null) { } public MisuseException(string message, Exception inner) : base(message ?? "MisuseException", inner) { } - protected MisuseException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("UnsupportedException"), Serializable] + [RubyException("UnsupportedException")] public class UnsupportedException : SqliteException { public UnsupportedException() : this(null, null) { } public UnsupportedException(string message) : this(message, null) { } public UnsupportedException(string message, Exception inner) : base(message ?? "UnsupportedException", inner) { } - protected UnsupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("AuthorizationException"), Serializable] + [RubyException("AuthorizationException")] public class AuthorizationException : SqliteException { public AuthorizationException() : this(null, null) { } public AuthorizationException(string message) : this(message, null) { } public AuthorizationException(string message, Exception inner) : base(message ?? "AuthorizationException", inner) { } - protected AuthorizationException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("FormatException"), Serializable] + [RubyException("FormatException")] public class FormatException : SqliteException { public FormatException() : this(null, null) { } public FormatException(string message) : this(message, null) { } public FormatException(string message, Exception inner) : base(message ?? "FormatException", inner) { } - protected FormatException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("RangeException"), Serializable] + [RubyException("RangeException")] public class RangeException : SqliteException { public RangeException() : this(null, null) { } public RangeException(string message) : this(message, null) { } public RangeException(string message, Exception inner) : base(message ?? "RangeException", inner) { } - protected RangeException(SerializationInfo info, StreamingContext context) : base(info, context) { } } - [RubyException("NotADatabaseException"), Serializable] + [RubyException("NotADatabaseException")] public class NotADatabaseException : SqliteException { public NotADatabaseException() : this(null, null) { } public NotADatabaseException(string message) : this(message, null) { } public NotADatabaseException(string message, Exception inner) : base(message ?? "NotADatabaseException", inner) { } - protected NotADatabaseException(SerializationInfo info, StreamingContext context) : base(info, context) { } } /// diff --git a/Src/Libraries/StringScanner/StringScanner.cs b/Src/Libraries/StringScanner/StringScanner.cs index d2728fc41..5b8db7b72 100644 --- a/Src/Libraries/StringScanner/StringScanner.cs +++ b/Src/Libraries/StringScanner/StringScanner.cs @@ -35,15 +35,11 @@ namespace IronRuby.StandardLibrary.StringScanner { [RubyClass("StringScanner")] public sealed class StringScanner : RubyObject { - [RubyException("Error"), Serializable] + [RubyException("Error")] public class Error : SystemException { public Error() : this(null, null) { } public Error(string message) : this(message, null) { } public Error(string message, Exception inner) : base(message ?? "Error", inner) { } - -#if FEATURE_SERIALIZATION - protected Error(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } private MutableString/*!*/ _scanString; diff --git a/Src/Libraries/Zlib/zlib.cs b/Src/Libraries/Zlib/zlib.cs index f74b9a4c8..fb3f4ab9c 100644 --- a/Src/Libraries/Zlib/zlib.cs +++ b/Src/Libraries/Zlib/zlib.cs @@ -1243,94 +1243,67 @@ public static object DeflateString(ConversionStorage/*!*/ fixnumCast, Block #region Exceptions - [RubyException("Error"), Serializable] + [RubyException("Error")] public class Error : SystemException { public Error() : this(null, null) { } public Error(string message) : this(message, null) { } public Error(string message, Exception inner) : base(message ?? "Error", inner) { } - - protected Error(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("StreamEnd"), Serializable] + [RubyException("StreamEnd")] public class StreamEnd : Error { public StreamEnd() : this(null, null) { } public StreamEnd(string message) : this(message, null) { } public StreamEnd(string message, Exception inner) : base(message ?? "StreamEnd", inner) { } - - protected StreamEnd(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("NeedDict"), Serializable] + [RubyException("NeedDict")] public class NeedDict : Error { public NeedDict() : this(null, null) { } public NeedDict(string message) : this(message, null) { } public NeedDict(string message, Exception inner) : base(message ?? "NeedDict", inner) { } - - protected NeedDict(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("DataError"), Serializable] + [RubyException("DataError")] public class DataError : Error { public DataError() : this(null, null) { } public DataError(string message) : this(message, null) { } public DataError(string message, Exception inner) : base(message ?? "DataError", inner) { } - - protected DataError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("BufError"), Serializable] + [RubyException("BufError")] public class BufError : Error { public BufError() : this(null, null) { } public BufError(string message) : this(message, null) { } public BufError(string message, Exception inner) : base(message ?? "BufError", inner) { } - - protected BufError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("MemError"), Serializable] + [RubyException("MemError")] public class MemError : Error { public MemError() : this(null, null) { } public MemError(string message) : this(message, null) { } public MemError(string message, Exception inner) : base(message ?? "MemError", inner) { } - - protected MemError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("VersionError"), Serializable] + [RubyException("VersionError")] public class VersionError : Error { public VersionError() : this(null, null) { } public VersionError(string message) : this(message, null) { } public VersionError(string message, Exception inner) : base(message ?? "VersionError", inner) { } - - protected VersionError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("InProgressError"), Serializable] + [RubyException("InProgressError")] public class InProgressError : Error { public InProgressError() : this(null, null) { } public InProgressError(string message) : this(message, null) { } public InProgressError(string message, Exception inner) : base(message ?? "InProgressError", inner) { } - - protected InProgressError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } - [RubyException("StreamError"), Serializable] + [RubyException("StreamError")] public class StreamError : Error { public StreamError() : this(null, null) { } public StreamError(string message) : this(message, null) { } public StreamError(string message, Exception inner) : base(message ?? "StreamError", inner) { } - - protected StreamError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } } #endregion diff --git a/Src/Ruby/Builtins/Exceptions.cs b/Src/Ruby/Builtins/Exceptions.cs index 4c316ba61..c6b0e927a 100644 --- a/Src/Ruby/Builtins/Exceptions.cs +++ b/Src/Ruby/Builtins/Exceptions.cs @@ -20,9 +20,7 @@ namespace IronRuby.Builtins { - [Serializable] public class LocalJumpError : SystemException { - [NonSerialized] private readonly RuntimeFlowControl _skipFrame; /// @@ -32,10 +30,8 @@ internal RuntimeFlowControl SkipFrame { get { return _skipFrame; } } - [NonSerialized] private readonly string _reason; - [NonSerialized] private readonly object _exitValue; /// @@ -74,14 +70,8 @@ internal LocalJumpError(string/*!*/ message, RuntimeFlowControl/*!*/ skipFrame, public LocalJumpError() : this(null, (Exception)null) { } public LocalJumpError(string message) : this(message, (Exception)null) { } public LocalJumpError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected LocalJumpError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class SystemExit : Exception { private int _status; @@ -107,129 +97,68 @@ public SystemExit(int status) public SystemExit() : this(null, null) { } public SystemExit(string message) : this(message, null) { } public SystemExit(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected SystemExit(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class ScriptError : Exception { public ScriptError() : this(null, null) { } public ScriptError(string message) : this(message, null) { } public ScriptError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected ScriptError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class NotImplementedError : ScriptError { public NotImplementedError() : this(null, null) { } public NotImplementedError(string message) : this(message, null) { } public NotImplementedError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected NotImplementedError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class LoadError : ScriptError { public LoadError() : this(null, null) { } public LoadError(string message) : this(message, null) { } public LoadError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected LoadError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class SystemStackError : SystemException { public SystemStackError() : this(null, null) { } public SystemStackError(string message) : this(message, null) { } public SystemStackError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected SystemStackError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } /// /// Ruby's IndexError. Not System.IndexOutOfRangeException, which is sealed: KeyError and /// StopIteration (and Ruby classes) have to be able to subclass it. /// - [Serializable] public class IndexError : SystemException { public IndexError() : this(null, null) { } public IndexError(string message) : this(message, null) { } public IndexError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected IndexError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class RegexpError : SystemException { public RegexpError() : this(null, null) { } public RegexpError(string message) : this(message, null) { } public RegexpError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected RegexpError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class EncodingError : SystemException { public EncodingError() : this(null, null) { } public EncodingError(string message) : this(message, null) { } public EncodingError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected EncodingError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class EncodingCompatibilityError : EncodingError { public EncodingCompatibilityError() : this(null, null) { } public EncodingCompatibilityError(string message) : this(message, null) { } public EncodingCompatibilityError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected EncodingCompatibilityError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class UndefinedConversionError : EncodingError { public UndefinedConversionError() : this(null, null) { } public UndefinedConversionError(string message) : this(message, null) { } public UndefinedConversionError(string message, Exception inner) : base(message, inner) { } -#if FEATURE_SERIALIZATION - protected UndefinedConversionError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif - /// The encoding the failing conversion stage read from. May be null. - [NonSerialized] private RubyEncoding _sourceEncoding, _destinationEncoding; - [NonSerialized] private byte[] _errorCharBytes; public RubyEncoding SourceEncoding { get { return _sourceEncoding; } set { _sourceEncoding = value; } } @@ -239,26 +168,17 @@ protected UndefinedConversionError(System.Runtime.Serialization.SerializationInf public byte[] ErrorCharBytes { get { return _errorCharBytes; } set { _errorCharBytes = value; } } } - [Serializable] public class InvalidByteSequenceError : EncodingError { public InvalidByteSequenceError() : this(null, null) { } public InvalidByteSequenceError(string message) : this(message, null) { } public InvalidByteSequenceError(string message, Exception inner) : base(message, inner) { } -#if FEATURE_SERIALIZATION - protected InvalidByteSequenceError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif - - [NonSerialized] private RubyEncoding _sourceEncoding, _destinationEncoding; - [NonSerialized] private byte[] _errorBytes, _readAgainBytes; // Nullable: an error object that was not produced by a conversion has not been told // either way, and MRI's #incomplete_input? answers nil for it. - [NonSerialized] private bool? _incompleteInput; public RubyEncoding SourceEncoding { get { return _sourceEncoding; } set { _sourceEncoding = value; } } @@ -274,28 +194,16 @@ protected InvalidByteSequenceError(System.Runtime.Serialization.SerializationInf public bool? IncompleteInput { get { return _incompleteInput; } set { _incompleteInput = value; } } } - [Serializable] public class ConverterNotFoundError : EncodingError { public ConverterNotFoundError() : this(null, null) { } public ConverterNotFoundError(string message) : this(message, null) { } public ConverterNotFoundError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected ConverterNotFoundError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class RuntimeError : SystemException { public RuntimeError() : this(null, null) { } public RuntimeError(string message) : this(message, null) { } public RuntimeError(string message, Exception inner) : base(message, inner) { } - -#if FEATURE_SERIALIZATION - protected RuntimeError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } /// @@ -316,7 +224,6 @@ protected RuntimeError(System.Runtime.Serialization.SerializationInfo info, Syst /// KernelOps.Throw's counterpart in the core needs it; the registration is the usual /// one-liner in Src/Libraries/Builtins/Exceptions.cs. /// - [Serializable] public class UncaughtThrowError : ArgumentException { private readonly object _tag; private readonly object _value; @@ -339,7 +246,6 @@ public object Value { } } - [Serializable] public class FrozenError : RuntimeError { private object _receiver; private bool _hasReceiver; @@ -364,14 +270,8 @@ public FrozenError SetReceiver(object receiver) { _hasReceiver = true; return this; } - -#if FEATURE_SERIALIZATION - protected FrozenError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class SyntaxError : ScriptError { private readonly string _file; private readonly string _lineSourceCode; @@ -414,14 +314,8 @@ internal SyntaxError(string/*!*/ message, string file, int line, int column, str _lineSourceCode = lineSourceCode; _hasLineInfo = true; } - -#if FEATURE_SERIALIZATION - protected SyntaxError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class ExistError : ExternalException { private const string/*!*/ M = "File exists"; @@ -429,14 +323,8 @@ public ExistError() : this(null, null) { } public ExistError(string message) : this(message, null) { } public ExistError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ExistError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ExistError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class BadFileDescriptorError : ExternalException { private const string/*!*/ M = "Bad file descriptor"; @@ -444,11 +332,6 @@ public BadFileDescriptorError() : this(null, null) { } public BadFileDescriptorError(string message) : this(message, null) { } public BadFileDescriptorError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public BadFileDescriptorError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected BadFileDescriptorError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } /// @@ -456,7 +339,6 @@ protected BadFileDescriptorError(System.Runtime.Serialization.SerializationInfo /// directory throws UnauthorizedAccessException, which maps to EACCES -- so the /// runtime needs a type of its own to raise. Registered in Errno.cs. /// - [Serializable] public class DirectoryIsError : ExternalException { private const string/*!*/ M = "Is a directory"; @@ -464,14 +346,8 @@ public DirectoryIsError() : this(null, null) { } public DirectoryIsError(string message) : this(message, null) { } public DirectoryIsError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public DirectoryIsError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected DirectoryIsError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class ExecFormatError : ExternalException { private const string/*!*/ M = "Exec format error"; @@ -479,11 +355,6 @@ public ExecFormatError() : this(null, null) { } public ExecFormatError(string message) : this(message, null) { } public ExecFormatError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public ExecFormatError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected ExecFormatError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } /// @@ -491,7 +362,6 @@ protected ExecFormatError(System.Runtime.Serialization.SerializationInfo info, S /// /dev/tty, a FIFO opened for writing with no reader - as a bare IOException, which /// would otherwise surface as IOError. Registered in Errno.cs. /// - [Serializable] public class NoSuchDeviceOrAddressError : ExternalException { private const string/*!*/ M = "No such device or address"; @@ -499,14 +369,8 @@ public NoSuchDeviceOrAddressError() : this(null, null) { } public NoSuchDeviceOrAddressError(string message) : this(message, null) { } public NoSuchDeviceOrAddressError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public NoSuchDeviceOrAddressError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected NoSuchDeviceOrAddressError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } - [Serializable] public class InvalidError : ExternalException { private const string/*!*/ M = "Invalid argument"; @@ -514,11 +378,6 @@ public InvalidError() : this(null, null) { } public InvalidError(string message) : this(message, null) { } public InvalidError(string message, Exception inner) : base(RubyExceptions.MakeMessage(message, M), inner) { } public InvalidError(MutableString message) : base(RubyExceptions.MakeMessage(ref message, M)) { RubyExceptionData.InitializeException(this, message); } - -#if FEATURE_SERIALIZATION - protected InvalidError(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) - : base(info, context) { } -#endif } } diff --git a/Src/Ruby/Builtins/MutableString.cs b/Src/Ruby/Builtins/MutableString.cs index 8a0342f03..432c3467e 100644 --- a/Src/Ruby/Builtins/MutableString.cs +++ b/Src/Ruby/Builtins/MutableString.cs @@ -1862,7 +1862,7 @@ public int GetFirstChar() { public MutableString[]/*!*/ Split(char[]/*!*/ separators, int maxComponents, StringSplitOptions options) { // TODO: // TODO (encoding): - return MakeArray(StringUtils.Split(_content.ConvertToString(), separators, maxComponents, options), _encoding); + return MakeArray(_content.ConvertToString().Split(separators, maxComponents, options), _encoding); } #endregion diff --git a/Src/Ruby/Builtins/RubyClass.cs b/Src/Ruby/Builtins/RubyClass.cs index 228284c08..c5037b048 100644 --- a/Src/Ruby/Builtins/RubyClass.cs +++ b/Src/Ruby/Builtins/RubyClass.cs @@ -1276,7 +1276,7 @@ private bool IsVisible(MethodAttributes/*!*/ attributes, Type declaringType, boo case MethodAttributes.Family: case MethodAttributes.FamORAssem: - return declaringType != null && declaringType.IsVisible() && !declaringType.IsSealed(); + return declaringType != null && declaringType.IsVisible && !declaringType.IsSealed; } return true; @@ -1292,7 +1292,7 @@ private bool IsVisible(FieldInfo/*!*/ field) { } if (field.IsProtected()) { - return field.DeclaringType != null && field.DeclaringType.IsVisible() && !field.DeclaringType.IsSealed(); + return field.DeclaringType != null && field.DeclaringType.IsVisible && !field.DeclaringType.IsSealed; } return true; @@ -1542,7 +1542,7 @@ public void BuildObjectConstructionNoFlow(MetaObjectBuilder/*!*/ metaBuilder, Ca // TODO: handle protected constructors constructionOverloads = GetConstructors(type == typeof(object) ? typeof(RubyObject) : type).ToArray(); - if (type.IsValueType()) { + if (type.IsValueType) { if (constructionOverloads.Length == 0 || GetConstructor(type) == null) { constructionOverloads = ArrayUtils.Append(constructionOverloads, new ReflectionOverloadInfo(Methods.CreateDefaultInstance)); } @@ -1669,7 +1669,7 @@ private Expression GetAllocatorNewExpression(CallArguments/*!*/ args, Func /// Whether rules for calls to library methods report :c_call and :c_return. /// + [CLSCompliant(false)] // a volatile field is not CLS-compliant public static volatile bool CCallTracing; #endregion diff --git a/Src/Ruby/Compiler/Ast/AstFactory.cs b/Src/Ruby/Compiler/Ast/AstFactory.cs index b20356f06..399767cf9 100644 --- a/Src/Ruby/Compiler/Ast/AstFactory.cs +++ b/Src/Ruby/Compiler/Ast/AstFactory.cs @@ -109,7 +109,7 @@ public static class AstFactory { // We prefer to peek inside the delegate and call the target method directly. However, we need to // exclude DynamicMethods since Delegate.Method returns a dummy MethodInfo, and we cannot emit a call to it. - if (methodInfo.DeclaringType == null || !methodInfo.DeclaringType.IsPublic() || !methodInfo.IsPublic) { + if (methodInfo.DeclaringType == null || !methodInfo.DeclaringType.IsPublic || !methodInfo.IsPublic) { // do not inline: return Ast.Call(AstUtils.Constant(method), method.GetType().GetMethod("Invoke"), arguments); } diff --git a/Src/Ruby/Compiler/AstGenerator.cs b/Src/Ruby/Compiler/AstGenerator.cs index 402edea8e..dad45a0ad 100644 --- a/Src/Ruby/Compiler/AstGenerator.cs +++ b/Src/Ruby/Compiler/AstGenerator.cs @@ -1054,7 +1054,7 @@ internal static bool IsTransparentStatement(Expression/*!*/ statement) { } internal static bool CanAssign(Type/*!*/ to, Type/*!*/ from) { - return to.IsAssignableFrom(from) && (to.IsValueType() == from.IsValueType()); + return to.IsAssignableFrom(from) && (to.IsValueType == from.IsValueType); } internal MSA.Expression/*!*/ AddReturnTarget(MSA.Expression/*!*/ expression) { diff --git a/Src/Ruby/Compiler/Generation/ClsTypeEmitter.cs b/Src/Ruby/Compiler/Generation/ClsTypeEmitter.cs index 43f501c69..c52cf57ca 100644 --- a/Src/Ruby/Compiler/Generation/ClsTypeEmitter.cs +++ b/Src/Ruby/Compiler/Generation/ClsTypeEmitter.cs @@ -422,7 +422,7 @@ sealed class ReturnFixer { private readonly int _index; private ReturnFixer(LocalBuilder/*!*/ reference, ParameterInfo/*!*/ parameter, int index) { - Debug.Assert(reference.LocalType.IsGenericType() && reference.LocalType.GetGenericTypeDefinition() == typeof(StrongBox<>)); + Debug.Assert(reference.LocalType.IsGenericType && reference.LocalType.GetGenericTypeDefinition() == typeof(StrongBox<>)); Debug.Assert(parameter.ParameterType.IsByRef); _parameter = parameter; diff --git a/Src/Ruby/Compiler/Generation/InterfaceImplFeature.cs b/Src/Ruby/Compiler/Generation/InterfaceImplFeature.cs index 592ac5f7d..e31899692 100644 --- a/Src/Ruby/Compiler/Generation/InterfaceImplFeature.cs +++ b/Src/Ruby/Compiler/Generation/InterfaceImplFeature.cs @@ -49,7 +49,7 @@ internal InterfaceImplFeature(IList/*!*/ interfaceTypes) { private static void AddInterface(List/*!*/ types, Type/*!*/ type) { Assert.NotNull(type); - Assert.Equals(true, type.IsInterface() && !type.ContainsGenericParameters()); + Assert.Equals(true, type.IsInterface && !type.ContainsGenericParameters); for (int i = 0; i < types.Count; i++) { Type t = types[i]; diff --git a/Src/Ruby/Compiler/Generation/RubyTypeDispenser.cs b/Src/Ruby/Compiler/Generation/RubyTypeDispenser.cs index 369ac2fce..f6a56ca2e 100644 --- a/Src/Ruby/Compiler/Generation/RubyTypeDispenser.cs +++ b/Src/Ruby/Compiler/Generation/RubyTypeDispenser.cs @@ -101,7 +101,7 @@ private static bool TypeImplementsFeatures(Type/*!*/ type, IList - + - diff --git a/Src/Ruby/Runtime/Calls/MetaObjectBuilder.cs b/Src/Ruby/Runtime/Calls/MetaObjectBuilder.cs index 63f1b69d4..21fae0f2e 100644 --- a/Src/Ruby/Runtime/Calls/MetaObjectBuilder.cs +++ b/Src/Ruby/Runtime/Calls/MetaObjectBuilder.cs @@ -205,7 +205,7 @@ public void AddObjectTypeRestriction(object value, Expression/*!*/ expression) { public void AddTypeRestriction(Type/*!*/ type, Expression/*!*/ expression) { if (_treatRestrictionsAsConditions) { AddCondition(Ast.TypeEqual(expression, type)); - } else if (expression.Type != type || !type.IsSealed()) { + } else if (expression.Type != type || !type.IsSealed) { Add(BindingRestrictions.GetTypeRestriction(expression, type)); } } @@ -261,7 +261,7 @@ public void AddTargetTypeTest(object target, RubyClass/*!*/ targetClass, Express // Ruby objects (get the method directly to prevent interface dispatch): MethodInfo classGetter = type.GetMethod(Methods.IRubyObject_get_ImmediateClass.Name, BindingFlags.Public | BindingFlags.Instance); - if (type.IsVisible() && classGetter != null && classGetter.ReturnType == typeof(RubyClass)) { + if (type.IsVisible && classGetter != null && classGetter.ReturnType == typeof(RubyClass)) { AddCondition( // (#{type})target.ImmediateClass.Version.Method == #{immediateClass.Version.Method} Ast.Equal( diff --git a/Src/Ruby/Runtime/Calls/RubyMethodGroupBase.cs b/Src/Ruby/Runtime/Calls/RubyMethodGroupBase.cs index 6bbac2c9b..15d6308ec 100644 --- a/Src/Ruby/Runtime/Calls/RubyMethodGroupBase.cs +++ b/Src/Ruby/Runtime/Calls/RubyMethodGroupBase.cs @@ -335,7 +335,7 @@ internal static void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArg if (bindingTarget.Success) { // TODO: create a custom overload info: if (ReferenceEquals(bindingTarget.Overload.ReflectionInfo, Methods.CreateDefaultInstance)) { - Debug.Assert(args.TargetClass.TypeTracker.Type.IsValueType()); + Debug.Assert(args.TargetClass.TypeTracker.Type.IsValueType); metaBuilder.Result = Ast.New(args.TargetClass.TypeTracker.Type); } else if (args.Signature.IsVirtualCall && bindingTarget.Overload.IsVirtual) { // Virtual methods that have been detached from the CLR type and diff --git a/Src/Ruby/Runtime/Calls/RubyOverloadResolver.cs b/Src/Ruby/Runtime/Calls/RubyOverloadResolver.cs index 600908c76..15cf9e6df 100644 --- a/Src/Ruby/Runtime/Calls/RubyOverloadResolver.cs +++ b/Src/Ruby/Runtime/Calls/RubyOverloadResolver.cs @@ -486,7 +486,7 @@ public override Candidate SelectBestConversionFor(DynamicMetaObject/*!*/ arg, Pa if (typeOne == actualType) { if (typeTwo == actualType) { // prefer non-nullable reference type over nullable: - if (!actualType.IsValueType()) { + if (!actualType.IsValueType) { if (candidateOne.ProhibitNull) { return Candidate.One; } else if (candidateTwo.ProhibitNull) { @@ -513,11 +513,11 @@ public override Candidate SelectBestConversionFor(DynamicMetaObject/*!*/ arg, Pa } // prefer integer type over enum: - if (typeOne.IsEnum() && Enum.GetUnderlyingType(typeOne) == typeTwo) { + if (typeOne.IsEnum && Enum.GetUnderlyingType(typeOne) == typeTwo) { return Candidate.Two; } - if (typeTwo.IsEnum() && Enum.GetUnderlyingType(typeTwo) == typeOne) { + if (typeTwo.IsEnum && Enum.GetUnderlyingType(typeTwo) == typeOne) { return Candidate.One; } @@ -552,7 +552,7 @@ public override Candidate SelectBestConversionFor(DynamicMetaObject/*!*/ arg, Pa if (restrictedType != null) { if (restrictedType == typeof(DynamicNull)) { - if (!toType.IsValueType() || toType.IsGenericType() && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { + if (!toType.IsValueType || toType.IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { return AstUtils.Constant(null, toType); } else if (toType == typeof(bool)) { return AstUtils.Constant(false); @@ -817,7 +817,7 @@ private Expression MakeIncorrectArgumentCountError(BindingTarget target) { /// Array" into something no Ruby programmer would recognise. /// private string/*!*/ GetConversionTargetName(Type/*!*/ type) { - if (type.IsGenericType() && type.GetGenericTypeDefinition() == typeof(Union<,>)) { + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Union<,>)) { var g = type.GetGenericArguments(); return GetConversionTargetName(g[0]) + " or " + GetConversionTargetName(g[1]); } @@ -843,7 +843,7 @@ private Expression MakeCallFailureError(BindingTarget target) { return Methods.CreateArgumentsErrorForProc.OpCall(AstUtils.Constant(cr.GetArgumentTypeName(Binder))); } - Debug.Assert(typeof(BlockParam).IsSealed()); + Debug.Assert(typeof(BlockParam).IsSealed); if (cr.To == typeof(BlockParam)) { return Methods.CreateArgumentsErrorForMissingBlock.OpCall(); } diff --git a/Src/Ruby/Runtime/Conversions/Converter.cs b/Src/Ruby/Runtime/Conversions/Converter.cs index c4b687233..36589615b 100644 --- a/Src/Ruby/Runtime/Conversions/Converter.cs +++ b/Src/Ruby/Runtime/Conversions/Converter.cs @@ -75,11 +75,11 @@ internal static Convertibility CanConvertFrom(DynamicMetaObject fromArg, Type/*! return Convertibility.NotConvertible; } - if (toType.IsGenericType() && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { + if (toType.IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { return Convertibility.AlwaysConvertible; } - if (!toType.IsValueType()) { + if (!toType.IsValueType) { // null convertible to any reference type: return Convertibility.AlwaysConvertible; } else if (toType == typeof(bool)) { @@ -176,7 +176,7 @@ internal static Convertibility CanConvertFrom(DynamicMetaObject fromArg, Type/*! } // A COM object can potentially be converted to the given interface, but might also be not so use this only as the last resort: - if (TypeUtils.IsComObjectType(fromType) && toType.IsInterface()) { + if (TypeUtils.IsComObjectType(fromType) && toType.IsInterface) { return Convertibility.AlwaysConvertible; } @@ -244,7 +244,7 @@ internal static Expression ExplicitConvert(Expression/*!*/ expr, Type/*!*/ fromT if (toType == typeof(bool)) { Debug.Assert(fromType != typeof(bool)); - return fromType.IsValueType() ? AstUtils.Constant(true) : Ast.NotEqual(expr, AstUtils.Constant(null)); + return fromType.IsValueType ? AstUtils.Constant(true) : Ast.NotEqual(expr, AstUtils.Constant(null)); } // TODO: diff --git a/Src/Ruby/Runtime/Conversions/GenericConversionAction.cs b/Src/Ruby/Runtime/Conversions/GenericConversionAction.cs index 7bc25d96c..dd2fe4dc4 100644 --- a/Src/Ruby/Runtime/Conversions/GenericConversionAction.cs +++ b/Src/Ruby/Runtime/Conversions/GenericConversionAction.cs @@ -46,7 +46,7 @@ internal GenericConversionAction(RubyContext context, Type/*!*/ type) Assert.NotNull(type); // Type must be visible so that we can serialize it in MakeShared. - Debug.Assert(type.IsVisible()); + Debug.Assert(type.IsVisible); _type = type; } @@ -104,7 +104,7 @@ internal static bool BuildConversion(MetaObjectBuilder/*!*/ metaBuilder, Dynamic private static Expression TryImplicitConversion(DynamicMetaObject/*!*/ target, Type/*!*/ toType) { // TODO: include this into ImplicitConvert? if (target.Value == null) { - if (!toType.IsValueType() || toType.IsGenericType() && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { + if (!toType.IsValueType || toType.IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>)) { return AstUtils.Constant(null, toType); } else { return null; diff --git a/Src/Ruby/Runtime/Conversions/ProtocolConversionAction.cs b/Src/Ruby/Runtime/Conversions/ProtocolConversionAction.cs index 9bcc81afe..31e7fc278 100644 --- a/Src/Ruby/Runtime/Conversions/ProtocolConversionAction.cs +++ b/Src/Ruby/Runtime/Conversions/ProtocolConversionAction.cs @@ -87,7 +87,7 @@ private static Func TryGetDefaultCo // nullable int (see Array#fill, Sockets:ConvertToSocketFlag, Kernel#open(perm=nil), File.chown, IO#read) // TODO: do we want to use a default protocol for enums? - if (parameterType.IsEnum()) { + if (parameterType.IsEnum) { return null; } @@ -423,7 +423,7 @@ protected virtual void SetError(MetaObjectBuilder/*!*/ metaBuilder, CallArgument } private static Expression/*!*/ ConvertResult(Expression/*!*/ expression, Type/*!*/ resultType) { - if (resultType.IsGenericType() && resultType.GetGenericTypeDefinition() == typeof(Union<,>)) { + if (resultType.IsGenericType && resultType.GetGenericTypeDefinition() == typeof(Union<,>)) { var args = resultType.GetGenericArguments(); var ctor = resultType.GetConstructor(args); if (args[0].IsAssignableFrom(expression.Type)) { diff --git a/Src/Ruby/Runtime/InstanceDataWeakTable.cs b/Src/Ruby/Runtime/InstanceDataWeakTable.cs index 842de1258..329b3bda1 100644 --- a/Src/Ruby/Runtime/InstanceDataWeakTable.cs +++ b/Src/Ruby/Runtime/InstanceDataWeakTable.cs @@ -150,8 +150,7 @@ public void Add(TKey key, TValue value) { // _dict might be a new Dictionary after Cleanup(), // so use the field directly - // CF throws doesn't support long weak references (NotSuportedException is thrown) - _dict.Add(new WeakReference(key, !PlatformAdaptationLayer.IsCompactFramework), value); + _dict.Add(new WeakReference(key, trackResurrection: true), value); } } diff --git a/Src/Ruby/Runtime/Loader.cs b/Src/Ruby/Runtime/Loader.cs index 8a4a14515..491ccac30 100644 --- a/Src/Ruby/Runtime/Loader.cs +++ b/Src/Ruby/Runtime/Loader.cs @@ -16,6 +16,7 @@ using System; using System.Linq; using System.Collections; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -80,7 +81,7 @@ internal enum FileKind { private readonly Dictionary/*!*/ _unfinishedFiles; // lazy init - private SynchronizedDictionary _loadedScripts; + private ConcurrentDictionary _loadedScripts; #if FEATURE_FILESYSTEM // TODO: static @@ -127,7 +128,7 @@ public IDictionary/*!*/ LoadedScripts { get { if (_loadedScripts == null) { Interlocked.CompareExchange(ref _loadedScripts, - new SynchronizedDictionary(new Dictionary(DomainManager.Platform.PathComparer)), null + new ConcurrentDictionary(DomainManager.Platform.PathComparer), null ); } return _loadedScripts; diff --git a/Src/Ruby/Runtime/RubyContext.cs b/Src/Ruby/Runtime/RubyContext.cs index ae7282992..2a324d82c 100644 --- a/Src/Ruby/Runtime/RubyContext.cs +++ b/Src/Ruby/Runtime/RubyContext.cs @@ -217,8 +217,9 @@ public Random/*!*/ RandomNumberGenerator { private readonly RubyInputProvider/*!*/ _inputProvider; private Proc _traceListener; + // Set while the trace proc runs on this thread, so that what the proc does is not traced itself. [ThreadStatic] - private bool _traceListenerSuspended; + private static bool _traceListenerSuspended; private readonly Stopwatch _upTime; diff --git a/Src/Ruby/Runtime/RubyExceptionData.cs b/Src/Ruby/Runtime/RubyExceptionData.cs index b278ca14f..0564ddb7f 100644 --- a/Src/Ruby/Runtime/RubyExceptionData.cs +++ b/Src/Ruby/Runtime/RubyExceptionData.cs @@ -375,26 +375,10 @@ public void SetCause(Exception cause) { return newException; } -#if FEATURE_THREAD && FEATURE_EXCEPTION_STATE - public static void ActiveExceptionHandled(Exception visibleException) { - Debug.Assert(RubyUtils.GetVisibleException(visibleException) == visibleException); - - RubyExceptionData data = RubyExceptionData.GetInstance(visibleException); - if (data._exception != visibleException) { - // The exception was raised asynchronously with Thread.Abort. We can not just catch and ignore - // the ThreadAbortException as the CLR keeps trying to re-raise it unless ResetAbort is called. - // - // Note that ResetAbort can cause ThreadAbortException.ExceptionState to be cleared (though it may - // not be cleared under some circustances), and we use that to squirrel away the Ruby exception - // that the user is expecting. Hence, ResetAbort should only be called when - // ThreadAbortException.ExceptionState no longer needs to be accessed. - if ((Thread.CurrentThread.ThreadState & System.Threading.ThreadState.AbortRequested) != 0) { - Thread.ResetAbort(); - } - } - } -#else + // A handled exception used to leave a pending Thread.Abort behind when Thread#raise had delivered it + // that way, and Thread.ResetAbort cancelled it here. Thread#raise no longer aborts the target thread + // (see RubyUtils.RaiseAsyncException) and Thread.ResetAbort only throws on .NET Core, so there is + // nothing left to do. public static void ActiveExceptionHandled(Exception visibleException) {} -#endif } } diff --git a/Src/Ruby/Runtime/RubyExceptions.cs b/Src/Ruby/Runtime/RubyExceptions.cs index 3b42ce8b5..364429ad2 100644 --- a/Src/Ruby/Runtime/RubyExceptions.cs +++ b/Src/Ruby/Runtime/RubyExceptions.cs @@ -220,7 +220,7 @@ private static void AppendQuoted(StringBuilder/*!*/ result, MutableString/*!*/ s public static Exception/*!*/ CreateMissingDefaultConstructorError(RubyClass/*!*/ rubyClass, string/*!*/ initializerOwnerName) { Debug.Assert(rubyClass.IsRubyClass); - Type baseType = rubyClass.GetUnderlyingSystemType().GetBaseType(); + Type baseType = rubyClass.GetUnderlyingSystemType().BaseType; Debug.Assert(baseType != null); return CreateTypeError("can't allocate class `{1}' that derives from type `{0}' with no default constructor;" + diff --git a/Src/Ruby/Runtime/RubyOps.cs b/Src/Ruby/Runtime/RubyOps.cs index 1aef9f9c6..33e68e2dd 100644 --- a/Src/Ruby/Runtime/RubyOps.cs +++ b/Src/Ruby/Runtime/RubyOps.cs @@ -3923,7 +3923,6 @@ public static void SerializeObject(RubyInstanceData instanceData, RubyClass/*!*/ } else if (fieldCount <= 64) { return typeof(MutableTuple); } else { - Debug.Assert(!PlatformAdaptationLayer.IsCompactFramework); return MakeObjectTupleType128(); } } @@ -3957,7 +3956,6 @@ public static void SerializeObject(RubyInstanceData instanceData, RubyClass/*!*/ } else if (fieldCount <= 64) { return new MutableTuple(); } else { - Debug.Assert(!PlatformAdaptationLayer.IsCompactFramework); return CreateObjectTuple128(); } } diff --git a/Src/Ruby/Runtime/RubyStackTraceBuilder.cs b/Src/Ruby/Runtime/RubyStackTraceBuilder.cs index 9348fb0a0..fb67f6d44 100644 --- a/Src/Ruby/Runtime/RubyStackTraceBuilder.cs +++ b/Src/Ruby/Runtime/RubyStackTraceBuilder.cs @@ -332,7 +332,7 @@ private bool TryGetStackFrameInfo(StackFrame/*!*/ frame, out string/*!*/ methodN methodName = method.Name; fileName = (_hasFileAccessPermission) ? GetFileName(frame) : null; - var sourceLine = line = PlatformAdaptationLayer.IsCompactFramework ? 0 : frame.GetFileLineNumber(); + var sourceLine = line = frame.GetFileLineNumber(); if (TryParseRubyMethodName(ref methodName, ref fileName, ref line)) { if (sourceLine == 0) { diff --git a/Src/Ruby/Runtime/RubyUtils.cs b/Src/Ruby/Runtime/RubyUtils.cs index 2f7bc2edd..468a724d1 100644 --- a/Src/Ruby/Runtime/RubyUtils.cs +++ b/Src/Ruby/Runtime/RubyUtils.cs @@ -1481,12 +1481,14 @@ private static bool EvaluateBlock(BlockParam/*!*/ block, RubyModule/*!*/ module, string message = String.Format("Class {0} does not have a valid deserializing constructor", baseType.FullName); throw new NotSupportedException(message); } +#pragma warning disable SYSLIB0050 // Marshal.load hands the instance variables to the deserialization constructor; no formatter involved SerializationInfo info = new SerializationInfo(baseType, new FormatterConverter()); info.AddValue(SerializationInfoClassKey, theclass); foreach (var pair in attributes) { info.AddValue(pair.Key, pair.Value); } obj = ci.Invoke(new object[2] { info, new StreamingContext(StreamingContextStates.Other, theclass) }); +#pragma warning restore SYSLIB0050 } else { obj = CreateObject(theclass); foreach (var pair in attributes) {