From 60db2601faac1009f5f84d6bb3fb74fa2524431f Mon Sep 17 00:00:00 2001 From: Fadi Hanna Date: Thu, 16 Mar 2017 16:10:28 -0700 Subject: [PATCH] CompilerServices APIs [tfs-changeset: 1651141] Commit migrated from https://github.com/dotnet/coreclr/commit/9d2a4a9f30ca6a6d0d538548f7972e2c0d8cfeb8 --- .../shared/System.Private.CoreLib.Shared.projitems | 11 +++++++++++ .../CompilerServices/CompilationRelaxations.cs | 16 ++++++++++++++++ .../CompilerGlobalScopeAttribute.cs | 16 ++++++++++++++++ .../CompilerServices/DefaultDependencyAttribute.cs | 18 ++++++++++++++++++ .../Runtime/CompilerServices/DependencyAttribute.cs | 20 ++++++++++++++++++++ .../CompilerServices/DiscardableAttribute.cs | 13 +++++++++++++ .../FixedAddressValueTypeAttribute.cs | 13 +++++++++++++ .../System/Runtime/CompilerServices/LoadHint.cs | 14 ++++++++++++++ .../Runtime/CompilerServices/MethodCodeType.cs | 17 +++++++++++++++++ .../Runtime/CompilerServices/MethodImplOptions.cs | 21 +++++++++++++++++++++ .../CompilerServices/StringFreezingAttribute.cs | 15 +++++++++++++++ .../CompilerServices/SuppressIldasmAttribute.cs | 13 +++++++++++++ 12 files changed, 187 insertions(+) create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilationRelaxations.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DefaultDependencyAttribute.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DiscardableAttribute.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/FixedAddressValueTypeAttribute.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/LoadHint.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodCodeType.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplOptions.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/StringFreezingAttribute.cs create mode 100644 src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/SuppressIldasmAttribute.cs diff --git a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index 87437f7..b56dc38 100644 --- a/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/coreclr/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -165,10 +165,21 @@ + + + + + + + + + + + diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilationRelaxations.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilationRelaxations.cs new file mode 100644 index 0000000..4da9502 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilationRelaxations.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.CompilerServices +{ + /// IMPORTANT: Keep this in sync with corhdr.h + [Flags] + [Serializable] + public enum CompilationRelaxations : int + { + NoStringInterning = 0x0008 // Start in 0x0008, we had other non public flags in this enum before, + // so we'll start here just in case somebody used them. This flag is only + // valid when set for Assemblies. + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.cs new file mode 100644 index 0000000..22fa694 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/CompilerGlobalScopeAttribute.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.CompilerServices +{ + // Attribute used to communicate to the VS7 debugger that a class should be treated as if it has global scope. + + [Serializable] + [AttributeUsage(AttributeTargets.Class)] + public class CompilerGlobalScopeAttribute : Attribute + { + public CompilerGlobalScopeAttribute() { } + } +} + diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DefaultDependencyAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DefaultDependencyAttribute.cs new file mode 100644 index 0000000..f5419d4 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DefaultDependencyAttribute.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.CompilerServices +{ + [Serializable] + [AttributeUsage(AttributeTargets.Assembly)] + public sealed class DefaultDependencyAttribute : Attribute + { + public DefaultDependencyAttribute(LoadHint loadHintArgument) + { + LoadHint = loadHintArgument; + } + + public LoadHint LoadHint { get; } + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs new file mode 100644 index 0000000..56f4242 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs @@ -0,0 +1,20 @@ +// 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 +{ + [Serializable] + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] + public sealed class DependencyAttribute : Attribute + { + public DependencyAttribute(String dependentAssemblyArgument, LoadHint loadHintArgument) + { + DependentAssembly = dependentAssemblyArgument; + LoadHint = loadHintArgument; + } + + public String DependentAssembly { get; } + public LoadHint LoadHint { get; } + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DiscardableAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DiscardableAttribute.cs new file mode 100644 index 0000000..c88b3a7 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/DiscardableAttribute.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 +{ + // Custom attribute to indicating a TypeDef is a discardable attribute. + + public class DiscardableAttribute : Attribute + { + public DiscardableAttribute() { } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/FixedAddressValueTypeAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/FixedAddressValueTypeAttribute.cs new file mode 100644 index 0000000..baf5824 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/FixedAddressValueTypeAttribute.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 +{ + [Serializable] + [AttributeUsage(AttributeTargets.Field)] + public sealed class FixedAddressValueTypeAttribute : Attribute + { + public FixedAddressValueTypeAttribute() { } + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/LoadHint.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/LoadHint.cs new file mode 100644 index 0000000..ae6d9b9 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/LoadHint.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.CompilerServices +{ + [Serializable] + public enum LoadHint + { + Default = 0x0000, // No preference specified + Always = 0x0001, // Dependency is always loaded + Sometimes = 0x0002, // Dependency is sometimes loaded + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodCodeType.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodCodeType.cs new file mode 100644 index 0000000..e82993a --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodCodeType.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. + +using System.Reflection; + +namespace System.Runtime.CompilerServices +{ + [Serializable] + public enum MethodCodeType + { + IL = MethodImplAttributes.IL, + Native = MethodImplAttributes.Native, + OPTIL = MethodImplAttributes.OPTIL, + Runtime = MethodImplAttributes.Runtime + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplOptions.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplOptions.cs new file mode 100644 index 0000000..2b5affc --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/MethodImplOptions.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 +{ + // This Enum matchs the miImpl flags defined in corhdr.h. It is used to specify + // certain method properties. + [Flags] + public enum MethodImplOptions + { + Unmanaged = 0x0004, + NoInlining = 0x0008, + ForwardRef = 0x0010, + Synchronized = 0x0020, + NoOptimization = 0x0040, + PreserveSig = 0x0080, + AggressiveInlining = 0x0100, + InternalCall = 0x1000 + } +} \ No newline at end of file diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/StringFreezingAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/StringFreezingAttribute.cs new file mode 100644 index 0000000..7772a1a --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/StringFreezingAttribute.cs @@ -0,0 +1,15 @@ +// 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 indicate that strings should be frozen. + + [Serializable] + [AttributeUsage(AttributeTargets.Assembly, Inherited = false)] + public sealed class StringFreezingAttribute : Attribute + { + public StringFreezingAttribute() { } + } +} diff --git a/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/SuppressIldasmAttribute.cs b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/SuppressIldasmAttribute.cs new file mode 100644 index 0000000..b4224b1 --- /dev/null +++ b/src/coreclr/src/mscorlib/shared/System/Runtime/CompilerServices/SuppressIldasmAttribute.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 +{ + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module)] + public sealed class SuppressIldasmAttribute : Attribute + { + public SuppressIldasmAttribute() { } + } +} + -- 2.7.4