Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-01-18 02:02:29 +0300
committerGitHub <noreply@github.com>2017-01-18 02:02:29 +0300
commit2b801186a2a037fdcd9ba88d3375be8e4d9ce2fc (patch)
tree4a62d958f24a43d3be65fe6306c25d0c497b15d8
parenta915dbaa67c5c164227c2e94b19aae88098c7b34 (diff)
parent785a34fc3c1523baf2717e2e8ce5c059395ba07a (diff)
Merge pull request #2523 from dotnet-bot/from-tfs
Merge changes from TFS
-rw-r--r--src/System.Private.CoreLib/src/System.Private.CoreLib.csproj1
-rw-r--r--src/System.Private.CoreLib/src/System/ByReference.cs41
-rw-r--r--src/System.Private.CoreLib/src/System/Runtime/CompilerServices/InternalCompilerAttributes.cs17
3 files changed, 42 insertions, 17 deletions
diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
index 15ea8ef11..baf7c70b5 100644
--- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
+++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
@@ -222,6 +222,7 @@
<Compile Include="System\BadImageFormatException.cs" />
<Compile Include="System\Boolean.cs" />
<Compile Include="System\Buffer.cs" />
+ <Compile Include="System\ByReference.cs" />
<Compile Include="System\Byte.cs" />
<Compile Include="System\Char.cs" />
<Compile Include="System\CharEnumerator.cs" />
diff --git a/src/System.Private.CoreLib/src/System/ByReference.cs b/src/System.Private.CoreLib/src/System/ByReference.cs
new file mode 100644
index 000000000..d0129c2ee
--- /dev/null
+++ b/src/System.Private.CoreLib/src/System/ByReference.cs
@@ -0,0 +1,41 @@
+// 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.CompilerServices;
+
+namespace System
+{
+ // ByReference<T> is meant to be used to represent "ref T" fields. It is working
+ // around lack of first class support for byref fields in C# and IL. The JIT and
+ // type loader have special handling for it that turns it into a thin wrapper around ref T.
+ [StackOnly]
+ internal struct ByReference<T>
+ {
+ // CS0169: The private field '{blah}' is never used
+#pragma warning disable 169
+ private IntPtr _value;
+#pragma warning restore
+
+ [Intrinsic]
+ public ByReference(ref T value)
+ {
+ // Implemented as a JIT intrinsic - This default implementation is for
+ // completeness and to provide a concrete error if called via reflection
+ // or if intrinsic is missed.
+ throw new System.PlatformNotSupportedException();
+ }
+
+ public ref T Value
+ {
+ [Intrinsic]
+ get
+ {
+ // Implemented as a JIT intrinsic - This default implementation is for
+ // completeness and to provide a concrete error if called via reflection
+ // or if the intrinsic is missed.
+ throw new System.PlatformNotSupportedException();
+ }
+ }
+ }
+}
diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/InternalCompilerAttributes.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/InternalCompilerAttributes.cs
index 298b4e466..3ad095e91 100644
--- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/InternalCompilerAttributes.cs
+++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/InternalCompilerAttributes.cs
@@ -21,21 +21,4 @@ namespace System.Runtime.CompilerServices
[AttributeUsage(AttributeTargets.Struct)]
public sealed class StackOnlyAttribute : Attribute { }
-
-#if false // Unused right now. It is likely going to be useful for Span<T> implementation.
- // This is a dummy class to be replaced by the compiler with a ref T
- // It has to be a dummy class to avoid complicated type substitution
- // and other complications in the compiler.
- public sealed class ByReference<T>
- {
- //
- // Managed pointer creation
- //
- [Intrinsic]
- public static extern ByReference<T> FromRef(ref T source);
-
- [Intrinsic]
- public static extern ref T ToRef(ByReference<T> source);
- }
-#endif
}