summaryrefslogtreecommitdiff
path: root/src/mscorlib/shared/System/Runtime
diff options
context:
space:
mode:
authorDavid Wrighton <davidwr@microsoft.com>2017-09-13 14:50:39 -0700
committerDavid Wrighton <davidwr@microsoft.com>2017-09-13 14:50:39 -0700
commitd68f0916d0a2bf3787bc85261ef4a4f1f27f1f24 (patch)
tree6c21ac239ae268096f20d98a8db16a4b80394fd9 /src/mscorlib/shared/System/Runtime
parent96fa98525e0d64459148228cde5211c475b0c25c (diff)
parente866d072042f4ad9e0811aa36e338dac781c09a5 (diff)
downloadcoreclr-d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24.tar.gz
coreclr-d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24.tar.bz2
coreclr-d68f0916d0a2bf3787bc85261ef4a4f1f27f1f24.zip
Merge branch 'master' into update_from_master
Diffstat (limited to 'src/mscorlib/shared/System/Runtime')
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/AsyncMethodBuilderAttribute.cs21
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilder.cs111
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs71
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs12
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs19
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs39
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs13
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplAttribute.cs29
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/RuntimeWrappedException.cs33
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs37
-rw-r--r--src/mscorlib/shared/System/Runtime/ExceptionServices/HandleProcessCorruptedStateExceptionsAttribute.cs16
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/BestFitMappingAttribute.cs19
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/DefaultCharSetAttribute.cs17
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttribute.cs17
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/DllImportAttribute.cs26
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/DllImportSearchPath.cs18
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/ExternalException.cs6
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/FieldOffsetAttribute.cs17
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/InAttribute.cs14
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/MarshalAsAttribute.cs39
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/OptionalAttribute.cs14
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/OutAttribute.cs14
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/PreserveSigAttribute.cs14
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/StructLayoutAttribute.cs26
-rw-r--r--src/mscorlib/shared/System/Runtime/InteropServices/UnmanagedFunctionPointerAttribute.cs10
-rw-r--r--src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs6
26 files changed, 647 insertions, 11 deletions
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/AsyncMethodBuilderAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/AsyncMethodBuilderAttribute.cs
new file mode 100644
index 0000000000..688a3a01ba
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/AsyncMethodBuilderAttribute.cs
@@ -0,0 +1,21 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>
+ /// Indicates the type of the async method builder that should be used by a language compiler to
+ /// build the attributed type when used as the return type of an async method.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Enum, Inherited = false, AllowMultiple = false)]
+ public sealed class AsyncMethodBuilderAttribute : Attribute
+ {
+ /// <summary>Initializes the <see cref="AsyncMethodBuilderAttribute"/>.</summary>
+ /// <param name="builderType">The <see cref="Type"/> of the associated builder.</param>
+ public AsyncMethodBuilderAttribute(Type builderType) => BuilderType = builderType;
+
+ /// <summary>Gets the <see cref="Type"/> of the associated builder.</summary>
+ public Type BuilderType { get; }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilder.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilder.cs
new file mode 100644
index 0000000000..813d9e5cd7
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilder.cs
@@ -0,0 +1,111 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Threading.Tasks;
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>Represents a builder for asynchronous methods that returns a <see cref="ValueTask{TResult}"/>.</summary>
+ /// <typeparam name="TResult">The type of the result.</typeparam>
+ [StructLayout(LayoutKind.Auto)]
+ public struct AsyncValueTaskMethodBuilder<TResult>
+ {
+ /// <summary>The <see cref="AsyncTaskMethodBuilder{TResult}"/> to which most operations are delegated.</summary>
+ private AsyncTaskMethodBuilder<TResult> _methodBuilder; // mutable struct; do not make it readonly
+ /// <summary>The result for this builder, if it's completed before any awaits occur.</summary>
+ private TResult _result;
+ /// <summary>true if <see cref="_result"/> contains the synchronous result for the async method; otherwise, false.</summary>
+ private bool _haveResult;
+ /// <summary>true if the builder should be used for setting/getting the result; otherwise, false.</summary>
+ private bool _useBuilder;
+
+ /// <summary>Creates an instance of the <see cref="AsyncValueTaskMethodBuilder{TResult}"/> struct.</summary>
+ /// <returns>The initialized instance.</returns>
+ public static AsyncValueTaskMethodBuilder<TResult> Create() =>
+#if CORECLR
+ // _methodBuilder should be initialized to AsyncTaskMethodBuilder<TResult>.Create(), but on coreclr
+ // that Create() is a nop, so we can just return the default here.
+ default(AsyncValueTaskMethodBuilder<TResult>);
+#else
+ // corert's AsyncTaskMethodBuilder<TResult>.Create() currently does additional debugger-related
+ // work, so we need to delegate to it.
+ new AsyncValueTaskMethodBuilder<TResult>() { _methodBuilder = AsyncTaskMethodBuilder<TResult>.Create() };
+#endif
+
+ /// <summary>Begins running the builder with the associated state machine.</summary>
+ /// <typeparam name="TStateMachine">The type of the state machine.</typeparam>
+ /// <param name="stateMachine">The state machine instance, passed by reference.</param>
+ public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine =>
+ _methodBuilder.Start(ref stateMachine); // will provide the right ExecutionContext semantics
+
+ /// <summary>Associates the builder with the specified state machine.</summary>
+ /// <param name="stateMachine">The state machine instance to associate with the builder.</param>
+ public void SetStateMachine(IAsyncStateMachine stateMachine) => _methodBuilder.SetStateMachine(stateMachine);
+
+ /// <summary>Marks the task as successfully completed.</summary>
+ /// <param name="result">The result to use to complete the task.</param>
+ public void SetResult(TResult result)
+ {
+ if (_useBuilder)
+ {
+ _methodBuilder.SetResult(result);
+ }
+ else
+ {
+ _result = result;
+ _haveResult = true;
+ }
+ }
+
+ /// <summary>Marks the task as failed and binds the specified exception to the task.</summary>
+ /// <param name="exception">The exception to bind to the task.</param>
+ public void SetException(Exception exception) => _methodBuilder.SetException(exception);
+
+ /// <summary>Gets the task for this builder.</summary>
+ public ValueTask<TResult> Task
+ {
+ get
+ {
+ if (_haveResult)
+ {
+ return new ValueTask<TResult>(_result);
+ }
+ else
+ {
+ _useBuilder = true;
+ return new ValueTask<TResult>(_methodBuilder.Task);
+ }
+ }
+ }
+
+ /// <summary>Schedules the state machine to proceed to the next action when the specified awaiter completes.</summary>
+ /// <typeparam name="TAwaiter">The type of the awaiter.</typeparam>
+ /// <typeparam name="TStateMachine">The type of the state machine.</typeparam>
+ /// <param name="awaiter">the awaiter</param>
+ /// <param name="stateMachine">The state machine.</param>
+ public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
+ where TAwaiter : INotifyCompletion
+ where TStateMachine : IAsyncStateMachine
+ {
+ _useBuilder = true;
+ _methodBuilder.AwaitOnCompleted(ref awaiter, ref stateMachine);
+ }
+
+ /// <summary>Schedules the state machine to proceed to the next action when the specified awaiter completes.</summary>
+ /// <typeparam name="TAwaiter">The type of the awaiter.</typeparam>
+ /// <typeparam name="TStateMachine">The type of the state machine.</typeparam>
+ /// <param name="awaiter">the awaiter</param>
+ /// <param name="stateMachine">The state machine.</param>
+ [SecuritySafeCritical]
+ public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
+ where TAwaiter : ICriticalNotifyCompletion
+ where TStateMachine : IAsyncStateMachine
+ {
+ _useBuilder = true;
+ _methodBuilder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs
new file mode 100644
index 0000000000..4ec931c4af
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs
@@ -0,0 +1,71 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>Provides an awaitable type that enables configured awaits on a <see cref="ValueTask{TResult}"/>.</summary>
+ /// <typeparam name="TResult">The type of the result produced.</typeparam>
+ [StructLayout(LayoutKind.Auto)]
+ public struct ConfiguredValueTaskAwaitable<TResult>
+ {
+ /// <summary>The wrapped <see cref="ValueTask{TResult}"/>.</summary>
+ private readonly ValueTask<TResult> _value;
+ /// <summary>true to attempt to marshal the continuation back to the original context captured; otherwise, false.</summary>
+ private readonly bool _continueOnCapturedContext;
+
+ /// <summary>Initializes the awaitable.</summary>
+ /// <param name="value">The wrapped <see cref="ValueTask{TResult}"/>.</param>
+ /// <param name="continueOnCapturedContext">
+ /// true to attempt to marshal the continuation back to the original synchronization context captured; otherwise, false.
+ /// </param>
+ internal ConfiguredValueTaskAwaitable(ValueTask<TResult> value, bool continueOnCapturedContext)
+ {
+ _value = value;
+ _continueOnCapturedContext = continueOnCapturedContext;
+ }
+
+ /// <summary>Returns an awaiter for this <see cref="ConfiguredValueTaskAwaitable{TResult}"/> instance.</summary>
+ public ConfiguredValueTaskAwaiter GetAwaiter() =>
+ new ConfiguredValueTaskAwaiter(_value, _continueOnCapturedContext);
+
+ /// <summary>Provides an awaiter for a <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
+ [StructLayout(LayoutKind.Auto)]
+ public struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion
+ {
+ /// <summary>The value being awaited.</summary>
+ private ValueTask<TResult> _value; // Methods are called on this; avoid making it readonly so as to avoid unnecessary copies
+ /// <summary>The value to pass to ConfigureAwait.</summary>
+ private readonly bool _continueOnCapturedContext;
+
+ /// <summary>Initializes the awaiter.</summary>
+ /// <param name="value">The value to be awaited.</param>
+ /// <param name="continueOnCapturedContext">The value to pass to ConfigureAwait.</param>
+ internal ConfiguredValueTaskAwaiter(ValueTask<TResult> value, bool continueOnCapturedContext)
+ {
+ _value = value;
+ _continueOnCapturedContext = continueOnCapturedContext;
+ }
+
+ /// <summary>Gets whether the <see cref="ConfiguredValueTaskAwaitable{TResult}"/> has completed.</summary>
+ public bool IsCompleted => _value.IsCompleted;
+
+ /// <summary>Gets the result of the ValueTask.</summary>
+ public TResult GetResult() =>
+ _value._task == null ?
+ _value._result :
+ _value._task.GetAwaiter().GetResult();
+
+ /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
+ public void OnCompleted(Action continuation) =>
+ _value.AsTask().ConfigureAwait(_continueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
+
+ /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
+ public void UnsafeOnCompleted(Action continuation) =>
+ _value.AsTask().ConfigureAwait(_continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs
new file mode 100644
index 0000000000..f75693eb40
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs
@@ -0,0 +1,12 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
+ public abstract class CustomConstantAttribute : Attribute
+ {
+ public abstract Object Value { get; }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
new file mode 100644
index 0000000000..813e6803bf
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
+ public sealed class DateTimeConstantAttribute : CustomConstantAttribute
+ {
+ private DateTime _date;
+
+ public DateTimeConstantAttribute(long ticks)
+ {
+ _date = new DateTime(ticks);
+ }
+
+ public override Object Value => _date;
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
new file mode 100644
index 0000000000..19db84eb43
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Note: If you add a new ctor overloads you need to update ParameterInfo.RawDefaultValue
+
+namespace System.Runtime.CompilerServices
+{
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
+ public sealed class DecimalConstantAttribute : Attribute
+ {
+ private Decimal _dec;
+
+ [CLSCompliant(false)]
+ public DecimalConstantAttribute(
+ byte scale,
+ byte sign,
+ uint hi,
+ uint mid,
+ uint low
+ )
+ {
+ _dec = new Decimal((int)low, (int)mid, (int)hi, (sign != 0), scale);
+ }
+
+ public DecimalConstantAttribute(
+ byte scale,
+ byte sign,
+ int hi,
+ int mid,
+ int low
+ )
+ {
+ _dec = new Decimal(low, mid, hi, (sign != 0), scale);
+ }
+
+ public Decimal Value => _dec;
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs
new file mode 100644
index 0000000000..dd01bacc49
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs
@@ -0,0 +1,13 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ // Calls to methods or references to fields marked with this attribute may be replaced at
+ // some call sites with jit intrinsic expansions.
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)]
+ internal sealed class IntrinsicAttribute : Attribute
+ {
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplAttribute.cs
new file mode 100644
index 0000000000..8e8f93c268
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplAttribute.cs
@@ -0,0 +1,29 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ // Custom attribute to specify additional method properties.
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)]
+ sealed public class MethodImplAttribute : Attribute
+ {
+ public MethodCodeType MethodCodeType;
+
+ public MethodImplAttribute(MethodImplOptions methodImplOptions)
+ {
+ Value = methodImplOptions;
+ }
+
+ public MethodImplAttribute(short value)
+ {
+ Value = (MethodImplOptions)value;
+ }
+
+ public MethodImplAttribute()
+ {
+ }
+
+ public MethodImplOptions Value { get; }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/RuntimeWrappedException.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/RuntimeWrappedException.cs
new file mode 100644
index 0000000000..e4af9be678
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/RuntimeWrappedException.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>
+ /// Exception used to wrap all non-CLS compliant exceptions.
+ /// </summary>
+ public sealed class RuntimeWrappedException : Exception
+ {
+ private Object _wrappedException; // EE expects this name
+
+ // Not an api but has to be public as System.Linq.Expression invokes this through Reflection when an expression
+ // throws an object that doesn't derive from Exception.
+ public RuntimeWrappedException(Object thrownObject)
+ : base(SR.RuntimeWrappedException)
+ {
+ HResult = HResults.COR_E_RUNTIMEWRAPPED;
+ _wrappedException = thrownObject;
+ }
+
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData(info, context);
+ }
+
+ public Object WrappedException => _wrappedException;
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs
new file mode 100644
index 0000000000..c419482521
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs
@@ -0,0 +1,37 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+
+namespace System.Runtime.CompilerServices
+{
+ /// <summary>Provides an awaiter for a <see cref="ValueTask{TResult}"/>.</summary>
+ public struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion
+ {
+ /// <summary>The value being awaited.</summary>
+ private ValueTask<TResult> _value; // Methods are called on this; avoid making it readonly so as to avoid unnecessary copies
+
+ /// <summary>Initializes the awaiter.</summary>
+ /// <param name="value">The value to be awaited.</param>
+ internal ValueTaskAwaiter(ValueTask<TResult> value) => _value = value;
+
+ /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> has completed.</summary>
+ public bool IsCompleted => _value.IsCompleted;
+
+ /// <summary>Gets the result of the ValueTask.</summary>
+ public TResult GetResult() =>
+ _value._task == null ?
+ _value._result :
+ _value._task.GetAwaiter().GetResult();
+
+ /// <summary>Schedules the continuation action for this ValueTask.</summary>
+ public void OnCompleted(Action continuation) =>
+ _value.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().OnCompleted(continuation);
+
+ /// <summary>Schedules the continuation action for this ValueTask.</summary>
+ public void UnsafeOnCompleted(Action continuation) =>
+ _value.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().UnsafeOnCompleted(continuation);
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/ExceptionServices/HandleProcessCorruptedStateExceptionsAttribute.cs b/src/mscorlib/shared/System/Runtime/ExceptionServices/HandleProcessCorruptedStateExceptionsAttribute.cs
new file mode 100644
index 0000000000..cc1bc81e5a
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/ExceptionServices/HandleProcessCorruptedStateExceptionsAttribute.cs
@@ -0,0 +1,16 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.ExceptionServices
+{
+ // This attribute can be applied to methods to indicate that ProcessCorruptedState
+ // Exceptions should be delivered to them.
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
+ public sealed class HandleProcessCorruptedStateExceptionsAttribute : Attribute
+ {
+ public HandleProcessCorruptedStateExceptionsAttribute()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/BestFitMappingAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/BestFitMappingAttribute.cs
new file mode 100644
index 0000000000..4ebee1538c
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/BestFitMappingAttribute.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
+ public sealed class BestFitMappingAttribute : Attribute
+ {
+ public BestFitMappingAttribute(bool BestFitMapping)
+ {
+ this.BestFitMapping = BestFitMapping;
+ }
+
+ public bool BestFitMapping { get; }
+
+ public bool ThrowOnUnmappableChar;
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/DefaultCharSetAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/DefaultCharSetAttribute.cs
new file mode 100644
index 0000000000..7a486f7017
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/DefaultCharSetAttribute.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Module, Inherited = false)]
+ public sealed class DefaultCharSetAttribute : Attribute
+ {
+ public DefaultCharSetAttribute(CharSet charSet)
+ {
+ CharSet = charSet;
+ }
+
+ public CharSet CharSet { get; }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttribute.cs
new file mode 100644
index 0000000000..1ff27fbbd5
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/DefaultDllImportSearchPathsAttribute.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)]
+ public sealed class DefaultDllImportSearchPathsAttribute : Attribute
+ {
+ public DefaultDllImportSearchPathsAttribute(DllImportSearchPath paths)
+ {
+ Paths = paths;
+ }
+
+ public DllImportSearchPath Paths { get; }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/DllImportAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/DllImportAttribute.cs
new file mode 100644
index 0000000000..97f870d49c
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/DllImportAttribute.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+ public sealed class DllImportAttribute : Attribute
+ {
+ public DllImportAttribute(string dllName)
+ {
+ Value = dllName;
+ }
+
+ public string Value { get; }
+
+ public string EntryPoint;
+ public CharSet CharSet;
+ public bool SetLastError;
+ public bool ExactSpelling;
+ public CallingConvention CallingConvention;
+ public bool BestFitMapping;
+ public bool PreserveSig;
+ public bool ThrowOnUnmappableChar;
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/DllImportSearchPath.cs b/src/mscorlib/shared/System/Runtime/InteropServices/DllImportSearchPath.cs
new file mode 100644
index 0000000000..8dbdb40be9
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/DllImportSearchPath.cs
@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [Flags]
+ public enum DllImportSearchPath
+ {
+ UseDllDirectoryForDependencies = 0x100,
+ ApplicationDirectory = 0x200,
+ UserDirectories = 0x400,
+ System32 = 0x800,
+ SafeDirectories = 0x1000,
+ AssemblyDirectory = 0x2,
+ LegacyBehavior = 0x0
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/ExternalException.cs b/src/mscorlib/shared/System/Runtime/InteropServices/ExternalException.cs
index 81b9a46928..0861d19362 100644
--- a/src/mscorlib/shared/System/Runtime/InteropServices/ExternalException.cs
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/ExternalException.cs
@@ -26,19 +26,19 @@ namespace System.Runtime.InteropServices
public ExternalException()
: base(SR.Arg_ExternalException)
{
- HResult = __HResults.E_FAIL;
+ HResult = HResults.E_FAIL;
}
public ExternalException(string message)
: base(message)
{
- HResult = __HResults.E_FAIL;
+ HResult = HResults.E_FAIL;
}
public ExternalException(string message, Exception inner)
: base(message, inner)
{
- HResult = __HResults.E_FAIL;
+ HResult = HResults.E_FAIL;
}
public ExternalException(string message, int errorCode)
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/FieldOffsetAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/FieldOffsetAttribute.cs
new file mode 100644
index 0000000000..27e1097749
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/FieldOffsetAttribute.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Field, Inherited = false)]
+ public sealed class FieldOffsetAttribute : Attribute
+ {
+ public FieldOffsetAttribute(int offset)
+ {
+ Value = offset;
+ }
+
+ public int Value { get; }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/InAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/InAttribute.cs
new file mode 100644
index 0000000000..39f5a958bc
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/InAttribute.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
+ public sealed class InAttribute : Attribute
+ {
+ public InAttribute()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/MarshalAsAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/MarshalAsAttribute.cs
new file mode 100644
index 0000000000..4a64050ed1
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/MarshalAsAttribute.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.ReturnValue, Inherited = false)]
+ public sealed class MarshalAsAttribute : Attribute
+ {
+ public MarshalAsAttribute(UnmanagedType unmanagedType)
+ {
+ Value = unmanagedType;
+ }
+ public MarshalAsAttribute(short unmanagedType)
+ {
+ Value = (UnmanagedType)unmanagedType;
+ }
+
+ public UnmanagedType Value { get; }
+
+ // Fields used with SubType = SafeArray.
+ public VarEnum SafeArraySubType;
+ public Type SafeArrayUserDefinedSubType;
+
+ // Field used with iid_is attribute (interface pointers).
+ public int IidParameterIndex;
+
+ // Fields used with SubType = ByValArray and LPArray.
+ // Array size = parameter(PI) * PM + C
+ public UnmanagedType ArraySubType;
+ public short SizeParamIndex; // param index PI
+ public int SizeConst; // constant C
+
+ // Fields used with SubType = CustomMarshaler
+ public string MarshalType; // Name of marshaler class
+ public Type MarshalTypeRef; // Type of marshaler class
+ public string MarshalCookie; // cookie to pass to marshaler
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/OptionalAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/OptionalAttribute.cs
new file mode 100644
index 0000000000..5ac75d7b3e
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/OptionalAttribute.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
+ public sealed class OptionalAttribute : Attribute
+ {
+ public OptionalAttribute()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/OutAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/OutAttribute.cs
new file mode 100644
index 0000000000..338ceac91e
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/OutAttribute.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
+ public sealed class OutAttribute : Attribute
+ {
+ public OutAttribute()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/PreserveSigAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/PreserveSigAttribute.cs
new file mode 100644
index 0000000000..464e1abcbe
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/PreserveSigAttribute.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+ public sealed class PreserveSigAttribute : Attribute
+ {
+ public PreserveSigAttribute()
+ {
+ }
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/StructLayoutAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/StructLayoutAttribute.cs
new file mode 100644
index 0000000000..c4cce9956e
--- /dev/null
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/StructLayoutAttribute.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
+ public sealed class StructLayoutAttribute : Attribute
+ {
+ public StructLayoutAttribute(LayoutKind layoutKind)
+ {
+ Value = layoutKind;
+ }
+
+ public StructLayoutAttribute(short layoutKind)
+ {
+ Value = (LayoutKind)layoutKind;
+ }
+
+ public LayoutKind Value { get; }
+
+ public int Pack;
+ public int Size;
+ public CharSet CharSet;
+ }
+}
diff --git a/src/mscorlib/shared/System/Runtime/InteropServices/UnmanagedFunctionPointerAttribute.cs b/src/mscorlib/shared/System/Runtime/InteropServices/UnmanagedFunctionPointerAttribute.cs
index 2d69c95afe..c4f96903ee 100644
--- a/src/mscorlib/shared/System/Runtime/InteropServices/UnmanagedFunctionPointerAttribute.cs
+++ b/src/mscorlib/shared/System/Runtime/InteropServices/UnmanagedFunctionPointerAttribute.cs
@@ -7,11 +7,6 @@ namespace System.Runtime.InteropServices
[AttributeUsage(AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
public sealed class UnmanagedFunctionPointerAttribute : Attribute
{
- public bool BestFitMapping;
- public bool SetLastError;
- public bool ThrowOnUnmappableChar;
- public CharSet CharSet;
-
public UnmanagedFunctionPointerAttribute()
{
CallingConvention = CallingConvention.Winapi;
@@ -23,5 +18,10 @@ namespace System.Runtime.InteropServices
}
public CallingConvention CallingConvention { get; }
+
+ public bool BestFitMapping;
+ public bool SetLastError;
+ public bool ThrowOnUnmappableChar;
+ public CharSet CharSet;
}
}
diff --git a/src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs b/src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs
index bfe3313659..3e0af092c0 100644
--- a/src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs
+++ b/src/mscorlib/shared/System/Runtime/Serialization/SerializationException.cs
@@ -15,19 +15,19 @@ namespace System.Runtime.Serialization
public SerializationException()
: base(s_nullMessage)
{
- HResult = __HResults.COR_E_SERIALIZATION;
+ HResult = HResults.COR_E_SERIALIZATION;
}
public SerializationException(String message)
: base(message)
{
- HResult = __HResults.COR_E_SERIALIZATION;
+ HResult = HResults.COR_E_SERIALIZATION;
}
public SerializationException(String message, Exception innerException)
: base(message, innerException)
{
- HResult = __HResults.COR_E_SERIALIZATION;
+ HResult = HResults.COR_E_SERIALIZATION;
}
protected SerializationException(SerializationInfo info, StreamingContext context)