diff options
-rw-r--r-- | src/Common/src/TypeSystem/Interop/IL/Marshaller.cs | 94 | ||||
-rw-r--r-- | src/JitInterface/src/CorInfoImpl.cs | 7 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System.Private.CoreLib.csproj | 1 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Delegate.cs | 8 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/MulticastDelegate.cs | 8 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Reflection/Assembly.cs | 32 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs | 14 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs | 73 | ||||
-rw-r--r-- | src/System.Private.CoreLib/src/System/Security/Attributes.cs | 7 | ||||
-rw-r--r-- | src/packaging/netcoreapp/project.json | 38 | ||||
-rw-r--r-- | src/packaging/packages.targets | 48 | ||||
-rw-r--r-- | src/packaging/uap/project.json | 4 | ||||
-rw-r--r-- | tests/src/Simple/Generics/Generics.cs | 37 | ||||
-rw-r--r-- | tests/src/Simple/PInvoke/PInvoke.cs | 9 | ||||
-rw-r--r-- | tests/src/Simple/PInvoke/PInvokeNative.cpp | 9 |
15 files changed, 302 insertions, 87 deletions
diff --git a/src/Common/src/TypeSystem/Interop/IL/Marshaller.cs b/src/Common/src/TypeSystem/Interop/IL/Marshaller.cs index abfec6ab7..7b6f5cb7d 100644 --- a/src/Common/src/TypeSystem/Interop/IL/Marshaller.cs +++ b/src/Common/src/TypeSystem/Interop/IL/Marshaller.cs @@ -55,7 +55,10 @@ namespace Internal.TypeSystem.Interop /// <returns>The created Marshaller</returns> public static Marshaller CreateMarshaller(TypeDesc parameterType, PInvokeMethodData pInvokeMethodData, ParameterMetadata pInvokeParameterdata) { - MarshallerKind marshallerKind = GetMarshallerKind(parameterType, pInvokeParameterdata.MarshalAsDescriptor, pInvokeMethodData, pInvokeParameterdata.Return); + MarshallerKind marshallerKind = GetMarshallerKind(parameterType, + pInvokeParameterdata.MarshalAsDescriptor, + pInvokeMethodData, + pInvokeParameterdata); // Create the marshaller based on MarshallerKind Marshaller marshaller = Marshaller.CreateMarshallerInternal(marshallerKind); @@ -92,9 +95,9 @@ namespace Internal.TypeSystem.Interop throw new NotSupportedException(); } } - private static MarshallerKind GetMarshallerKind(TypeDesc type, MarshalAsDescriptor marshalAs, PInvokeMethodData PInvokeMethodData, bool isReturn) + private static MarshallerKind GetMarshallerKind(TypeDesc type, MarshalAsDescriptor marshalAs, PInvokeMethodData PInvokeMethodData, ParameterMetadata paramMetadata) { - if (isReturn) + if (paramMetadata.Return) { if (type.IsVoid) { @@ -184,6 +187,21 @@ namespace Internal.TypeSystem.Interop { return MarshallerKind.SafeHandle; } + + // Temporary fix for out SafeHandle scenario + // TODO: handle in,out,ref properly + if (paramMetadata.Out && !paramMetadata.In) + { + ByRefType byRefType = type as ByRefType; + if (byRefType != null) + { + if (PInvokeMethodData.IsSafeHandle(byRefType.ParameterType)) + { + return MarshallerKind.SafeHandle; + } + } + } + throw new NotSupportedException(); } #endregion @@ -366,28 +384,68 @@ namespace Internal.TypeSystem.Interop { protected override TypeDesc MarshalArgument(TypeDesc managedType, ILEmitter emitter, ILCodeStream marshallingCodeStream, ILCodeStream unmarshallingCodeStream) { + // we don't support [IN,OUT] together yet, either IN or OUT + Debug.Assert(!(PInvokeParameterMetadata.Out && PInvokeParameterMetadata.In)); + var safeHandleType = PInvokeMethodData.SafeHandleType; - var vAddRefed = emitter.NewLocal(PInvokeMethodData.Context.GetWellKnownType(WellKnownType.Boolean)); - var vSafeHandle = emitter.NewLocal(managedType); + if (PInvokeParameterMetadata.Out) + { + // 1) If this is an output parameter we need to preallocate a SafeHandle to wrap the new native handle value. We + // must allocate this before the native call to avoid a failure point when we already have a native resource + // allocated. We must allocate a new SafeHandle even if we have one on input since both input and output native + // handles need to be tracked and released by a SafeHandle. + // 2) Initialize a local IntPtr that will be passed to the native call. + // 3) After the native call, the new handle value is written into the output SafeHandle and that SafeHandle + // is propagated back to the caller. + + Debug.Assert(managedType is ByRefType); + var vOutArg = emitter.NewLocal(managedType); + marshallingCodeStream.EmitStLoc(vOutArg); + + TypeDesc resolvedType = ((ByRefType)managedType).ParameterType; + + var nativeType = PInvokeMethodData.Context.GetWellKnownType(WellKnownType.IntPtr).MakeByRefType(); + var vPinnedOutValue = emitter.NewLocal(nativeType, true); + var vSafeHandle = emitter.NewLocal(resolvedType); + marshallingCodeStream.Emit(ILOpcode.newobj, emitter.NewToken(resolvedType.GetDefaultConstructor())); + marshallingCodeStream.EmitStLoc(vSafeHandle); + marshallingCodeStream.EmitLdLoca(vPinnedOutValue); + + unmarshallingCodeStream.EmitLdLoc(vSafeHandle); + unmarshallingCodeStream.EmitLdLoc(vPinnedOutValue); + unmarshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( + PInvokeMethodData.SafeHandleType.GetKnownMethod("SetHandle", null))); - marshallingCodeStream.EmitStLoc(vSafeHandle); + unmarshallingCodeStream.EmitLdLoc(vOutArg); + unmarshallingCodeStream.EmitLdLoc(vSafeHandle); + unmarshallingCodeStream.Emit(ILOpcode.stind_i); - marshallingCodeStream.EmitLdLoc(vSafeHandle); - marshallingCodeStream.EmitLdLoca(vAddRefed); - marshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("DangerousAddRef", null))); + return nativeType; + } + else + { + var vAddRefed = emitter.NewLocal(PInvokeMethodData.Context.GetWellKnownType(WellKnownType.Boolean)); + var vSafeHandle = emitter.NewLocal(managedType); - marshallingCodeStream.EmitLdLoc(vSafeHandle); - marshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("DangerousGetHandle", null))); + marshallingCodeStream.EmitStLoc(vSafeHandle); - // TODO: This should be inside finally block and only executed it the handle was addrefed - unmarshallingCodeStream.EmitLdLoc(vSafeHandle); - unmarshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( - safeHandleType.GetKnownMethod("DangerousRelease", null))); + marshallingCodeStream.EmitLdLoc(vSafeHandle); + marshallingCodeStream.EmitLdLoca(vAddRefed); + marshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( + safeHandleType.GetKnownMethod("DangerousAddRef", null))); - return PInvokeMethodData.Context.GetWellKnownType(WellKnownType.IntPtr); + marshallingCodeStream.EmitLdLoc(vSafeHandle); + marshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( + safeHandleType.GetKnownMethod("DangerousGetHandle", null))); + + // TODO: This should be inside finally block and only executed it the handle was addrefed + unmarshallingCodeStream.EmitLdLoc(vSafeHandle); + unmarshallingCodeStream.Emit(ILOpcode.call, emitter.NewToken( + safeHandleType.GetKnownMethod("DangerousRelease", null))); + + return PInvokeMethodData.Context.GetWellKnownType(WellKnownType.IntPtr); + } } protected override TypeDesc MarshalReturn(TypeDesc managedType, ILEmitter emitter, ILCodeStream marshallingCodeStream, ILCodeStream returnValueMarshallingCodeStream ) diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs index 2064ed4de..89b8d6a7a 100644 --- a/src/JitInterface/src/CorInfoImpl.cs +++ b/src/JitInterface/src/CorInfoImpl.cs @@ -2659,7 +2659,11 @@ namespace Internal.JitInterface // to abort the inlining attempt if the inlinee does any generic lookups. bool inlining = contextMethod != MethodBeingCompiled; - if (targetMethod.IsSharedByGenericInstantiations && !inlining) + // If we resolved a constrained call, calling GetRuntimeDeterminedObjectForToken below would + // result in getting back the unresolved target. Don't capture runtime determined dependencies + // in that case and rely on the dependency analysis computing them based on seeing a call to the + // canonical method body. + if (targetMethod.IsSharedByGenericInstantiations && !inlining && !resolvedConstraint) { MethodDesc runtimeDeterminedMethod = (MethodDesc)GetRuntimeDeterminedObjectForToken(ref pResolvedToken); pResult.codePointerOrStubLookup.constLookup.addr = (void*)ObjectToHandle( @@ -2667,6 +2671,7 @@ namespace Internal.JitInterface } else { + Debug.Assert(!forceUseRuntimeLookup); pResult.codePointerOrStubLookup.constLookup.addr = (void*)ObjectToHandle( _compilation.NodeFactory.MethodEntrypoint(targetMethod)); } diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj index baf7c70b5..4998a45c6 100644 --- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -194,6 +194,7 @@ <Compile Include="System\Reflection\ReflectionContext.cs" /> <Compile Include="System\Reflection\ReflectionTypeLoadException.cs" /> <Compile Include="System\Reflection\ResourceLocation.cs" /> + <Compile Include="System\Reflection\StrongNameKeyPair.cs" /> <Compile Include="System\Reflection\TargetException.cs" /> <Compile Include="System\Reflection\TypeAttributes.cs" /> <Compile Include="System\Reflection\TypeFilter.cs" /> diff --git a/src/System.Private.CoreLib/src/System/Delegate.cs b/src/System.Private.CoreLib/src/System/Delegate.cs index 8263a8ac6..47b253e2c 100644 --- a/src/System.Private.CoreLib/src/System/Delegate.cs +++ b/src/System.Private.CoreLib/src/System/Delegate.cs @@ -5,6 +5,7 @@ using System.Text; using System.Runtime; using System.Reflection; +using System.Runtime.Serialization; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Diagnostics; @@ -19,7 +20,7 @@ namespace System // sequential layout directive so that Bartok matches it. [StructLayout(LayoutKind.Sequential)] [DebuggerDisplay("Target method(s) = {GetTargetMethodsDescriptionForDebugger()}")] - public abstract partial class Delegate : ICloneable + public abstract partial class Delegate : ICloneable, ISerializable { // This ctor exists solely to prevent C# from generating a protected .ctor that violates the surface area. I really want this to be a // "protected-and-internal" rather than "internal" but C# has no keyword for the former. @@ -707,6 +708,11 @@ namespace System return MemberwiseClone(); } + public virtual void GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new NotSupportedException(); + } + internal bool IsOpenStatic { get diff --git a/src/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/System.Private.CoreLib/src/System/MulticastDelegate.cs index 7caec691c..55b550239 100644 --- a/src/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -3,13 +3,14 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; +using System.Runtime.Serialization; using System.Runtime.CompilerServices; using Internal.Runtime.CompilerServices; namespace System { - public abstract class MulticastDelegate : Delegate + public abstract class MulticastDelegate : Delegate, ISerializable { // This ctor exists solely to prevent C# from generating a protected .ctor that violates the surface area. I really want this to be a // "protected-and-internal" rather than "internal" but C# has no keyword for the former. @@ -114,5 +115,10 @@ namespace System { return base.GetInvocationList(); } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new NotImplementedException(); + } } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs index 66f68e474..969324709 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Assembly.cs @@ -5,7 +5,9 @@ using System.IO; using System.Globalization; using System.Collections.Generic; +using System.Configuration.Assemblies; using System.Runtime.Serialization; +using System.Security; using Internal.Reflection.Augments; @@ -75,6 +77,8 @@ namespace System.Reflection public virtual Stream GetManifestResourceStream(string name) { throw NotImplemented.ByDesign; } public virtual Stream GetManifestResourceStream(Type type, string name) { throw NotImplemented.ByDesign; } + public bool IsFullyTrusted => true; + public virtual AssemblyName GetName() => GetName(copiedName: false); public virtual AssemblyName GetName(bool copiedName) { throw NotImplemented.ByDesign; } @@ -90,6 +94,8 @@ namespace System.Reflection public virtual object[] GetCustomAttributes(bool inherit) { throw NotImplemented.ByDesign; } public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) { throw NotImplemented.ByDesign; } + public virtual String EscapedCodeBase => AssemblyName.EscapeCodeBase(CodeBase); + public object CreateInstance(string typeName) => CreateInstance(typeName, false, BindingFlags.Public | BindingFlags.Instance, binder: null, args: null, culture: null, activationAttributes: null); public object CreateInstance(string typeName, bool ignoreCase) => CreateInstance(typeName, ignoreCase, BindingFlags.Public | BindingFlags.Instance, binder: null, args: null, culture: null, activationAttributes: null); public virtual object CreateInstance(string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes) @@ -129,6 +135,12 @@ namespace System.Reflection return displayName; } + /* + Returns true if the assembly was loaded from the global assembly cache. + */ + public virtual bool GlobalAssemblyCache { get { throw NotImplemented.ByDesign; } } + public virtual Int64 HostContext { get { throw NotImplemented.ByDesign; } } + public override bool Equals(object o) => base.Equals(o); public override int GetHashCode() => base.GetHashCode(); @@ -179,8 +191,28 @@ namespace System.Reflection return Load(name); } + public static Assembly LoadFile(String path) { throw new PlatformNotSupportedException(); } + public static Assembly LoadFrom(String assemblyFile) { throw new PlatformNotSupportedException(); } + public static Assembly LoadFrom(String assemblyFile, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm) { throw new PlatformNotSupportedException(); } + + [Obsolete("This method has been deprecated. Please use Assembly.Load() instead. http://go.microsoft.com/fwlink/?linkid=14202")] + public static Assembly LoadWithPartialName(String partialName) + { + if (partialName == null) + throw new ArgumentNullException(nameof(partialName)); + + return Load(partialName); + } + + public static Assembly UnsafeLoadFrom(string assemblyFile) => LoadFrom(assemblyFile); + + public Module LoadModule(String moduleName, byte[] rawModule) => LoadModule(moduleName, rawModule, null); + public virtual Module LoadModule(String moduleName, byte[] rawModule, byte[] rawSymbolStore) { throw NotImplemented.ByDesign; } + public static Assembly ReflectionOnlyLoad(byte[] rawAssembly) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } public static Assembly ReflectionOnlyLoad(string assemblyString) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } public static Assembly ReflectionOnlyLoadFrom(string assemblyFile) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ReflectionOnly); } + + public virtual SecurityRuleSet SecurityRuleSet => SecurityRuleSet.None; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs b/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs index 0eed90c2a..d4b8cebef 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs @@ -129,6 +129,18 @@ namespace System.Reflection public string CodeBase { get; set; } public AssemblyHashAlgorithm HashAlgorithm { get; set; } public AssemblyVersionCompatibility VersionCompatibility { get; set; } + public StrongNameKeyPair KeyPair { get; set; } + + public String EscapedCodeBase + { + get + { + if (CodeBase == null) + return null; + else + return EscapeCodeBase(CodeBase); + } + } public byte[] GetPublicKey() { @@ -172,6 +184,8 @@ namespace System.Reflection public static AssemblyName GetAssemblyName(String assemblyFile) { throw new NotImplementedException(); } public static bool ReferenceMatchesDefinition(AssemblyName reference, AssemblyName definition) { throw new NotImplementedException(); } + internal static String EscapeCodeBase(String codebase) { throw new PlatformNotSupportedException(); } + private AssemblyNameFlags _flags; private byte[] _publicKey; private byte[] _publicKeyToken; diff --git a/src/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs b/src/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs new file mode 100644 index 000000000..db3e92423 --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Reflection/StrongNameKeyPair.cs @@ -0,0 +1,73 @@ +// 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. + +/*============================================================ +** +** +** +** +** +** Purpose: Encapsulate access to a public/private key pair +** used to sign strong name assemblies. +** +** +===========================================================*/ + +using System; +using System.Runtime.Serialization; + +namespace System.Reflection +{ + [Serializable] + public class StrongNameKeyPair : IDeserializationCallback, ISerializable + { + private bool _keyPairExported; + private byte[] _keyPairArray; + private String _keyPairContainer; + private byte[] _publicKey; + + // Build key pair from byte array in memory. + public StrongNameKeyPair(byte[] keyPairArray) + { + if (keyPairArray == null) + throw new ArgumentNullException(nameof(keyPairArray)); + + _keyPairArray = new byte[keyPairArray.Length]; + Array.Copy(keyPairArray, _keyPairArray, keyPairArray.Length); + + _keyPairExported = true; + } + + protected StrongNameKeyPair(SerializationInfo info, StreamingContext context) + { + _keyPairExported = (bool)info.GetValue("_keyPairExported", typeof(bool)); + _keyPairArray = (byte[])info.GetValue("_keyPairArray", typeof(byte[])); + _keyPairContainer = (string)info.GetValue("_keyPairContainer", typeof(string)); + _publicKey = (byte[])info.GetValue("_publicKey", typeof(byte[])); + } + + public StrongNameKeyPair(String keyPairContainer) + { + throw new PlatformNotSupportedException(); + } + + public byte[] PublicKey + { + get + { + throw new PlatformNotSupportedException(); + } + } + + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + info.AddValue("_keyPairExported", _keyPairExported); + info.AddValue("_keyPairArray", _keyPairArray); + info.AddValue("_keyPairContainer", _keyPairContainer); + info.AddValue("_publicKey", _publicKey); + } + + void IDeserializationCallback.OnDeserialization(Object sender) { } + } +} diff --git a/src/System.Private.CoreLib/src/System/Security/Attributes.cs b/src/System.Private.CoreLib/src/System/Security/Attributes.cs index 538fbf15d..fcb292cd2 100644 --- a/src/System.Private.CoreLib/src/System/Security/Attributes.cs +++ b/src/System.Private.CoreLib/src/System/Security/Attributes.cs @@ -71,4 +71,11 @@ namespace System.Security { public SecurityTransparentAttribute() { } } + + public enum SecurityRuleSet : byte + { + None = 0, + Level1 = 1, // v2.0 transparency model + Level2 = 2, // v4.0 transparency model + } } diff --git a/src/packaging/netcoreapp/project.json b/src/packaging/netcoreapp/project.json index 6c036cd40..5d366a435 100644 --- a/src/packaging/netcoreapp/project.json +++ b/src/packaging/netcoreapp/project.json @@ -1,42 +1,12 @@ { "frameworks": { - "netcoreapp1.2": { + "netcoreapp2.0": { "dependencies": { - "System.Buffers": "4.4.0-beta-24913-02", - "System.Console": "4.4.0-beta-24913-02", - "System.Collections": "4.4.0-beta-24913-02", - "System.Collections.Concurrent": "4.4.0-beta-24913-02", - "System.Collections.NonGeneric": "4.4.0-beta-24913-02", - "System.Diagnostics.Debug": "4.4.0-beta-24913-02", - "System.Diagnostics.Tracing": "4.4.0-beta-24913-02", - "System.Diagnostics.Tools": "4.4.0-beta-24913-02", - "System.Globalization": "4.4.0-beta-24913-02", - "System.Globalization.Calendars": "4.4.0-beta-24913-02", - "System.IO": "4.4.0-beta-24913-02", - "System.IO.FileSystem": "4.4.0-beta-24913-02", - "System.IO.FileSystem.Primitives": "4.4.0-beta-24913-02", + "Microsoft.NETCore.App": "2.0.0-beta-001368-00", + + "System.Threading": "4.4.0-beta-24913-02", "System.Linq": "4.4.0-beta-24913-02", - "System.Reflection": "4.4.0-beta-24913-02", - "System.Reflection.Primitives": "4.4.0-beta-24913-02", - "System.Reflection.Extensions": "4.4.0-beta-24913-02", - "System.Reflection.TypeExtensions": "4.4.0-beta-24913-02", - "System.Resources.ResourceManager": "4.4.0-beta-24913-02", - "System.Runtime": "4.4.0-beta-24913-02", "System.Runtime.CompilerServices.Unsafe": "4.4.0-beta-24913-02", - "System.Runtime.Extensions": "4.4.0-beta-24913-02", - "System.Runtime.InteropServices": "4.4.0-beta-24913-02", - "System.Runtime.InteropServices.RuntimeInformation": "4.4.0-beta-24913-02", - "System.Runtime.Handles": "4.4.0-beta-24913-02", - "System.Runtime.Numerics": "4.4.0-beta-24913-02", - "System.Security.Principal": "4.4.0-beta-24913-02", - "System.Text.Encoding": "4.4.0-beta-24913-02", - "System.Text.Encoding.Extensions": "4.4.0-beta-24913-02", - "System.Threading": "4.4.0-beta-24913-02", - "System.Threading.Overlapped": "4.4.0-beta-24913-02", - "System.Threading.Tasks": "4.4.0-beta-24913-02", - "System.Threading.Thread": "4.4.0-beta-24913-02", - "System.Threading.Timer": "4.4.0-beta-24913-02", - "Microsoft.Win32.Primitives": "4.4.0-beta-24913-02", "runtime.native.System": "4.4.0-beta-24913-02" } diff --git a/src/packaging/packages.targets b/src/packaging/packages.targets index 7b848c057..f362e52cd 100644 --- a/src/packaging/packages.targets +++ b/src/packaging/packages.targets @@ -23,9 +23,10 @@ <StaticLibExt Condition="'$(OsEnvironment)'!='Windows_NT'">a</StaticLibExt> <CoreFxPackageVersion>4.4.0-beta-24913-02</CoreFxPackageVersion> + <NetCoreAppPackageVersion>2.0.0-beta-001368-00</NetCoreAppPackageVersion> <JitPackageVersion>1.2.0-beta-24911-02</JitPackageVersion> - + <ObjectWriterPackageVersion>1.0.13-prerelease-00001</ObjectWriterPackageVersion> <ObjectWriterNuPkgRid Condition="'$(OSGroup)'=='Linux'">ubuntu.14.04-x64</ObjectWriterNuPkgRid> <ObjectWriterNuPkgRid Condition="'$(ObjectWriterNuPkgRid)'==''">$(NuPkgRid)</ObjectWriterNuPkgRid> @@ -112,21 +113,35 @@ <!-- Repackage the CoreCLR framework --> <!-- TODO: Obtain this via nuget once the framework is properly packaged --> + <ILCompilerAnyFrameworkFiles Include="Microsoft.Win32.Primitives" /> + <ILCompilerAnyFrameworkFiles Include="mscorlib" /> + <ILCompilerAnyFrameworkFiles Include="System.Buffers" /> + <ILCompilerAnyFrameworkFiles Include="System.Collections.Concurrent" /> + <ILCompilerAnyFrameworkFiles Include="System.Collections.NonGeneric" /> + <ILCompilerAnyFrameworkFiles Include="System.Console" /> + <ILCompilerAnyFrameworkFiles Include="System.Diagnostics.Tools" /> <ILCompilerAnyFrameworkFiles Include="System.Globalization" /> <ILCompilerAnyFrameworkFiles Include="System.Globalization.Calendars" /> <ILCompilerAnyFrameworkFiles Include="System.IO" /> + <ILCompilerAnyFrameworkFiles Include="System.IO.FileSystem" /> + <ILCompilerAnyFrameworkFiles Include="System.IO.FileSystem.Primitives" /> <ILCompilerAnyFrameworkFiles Include="System.Reflection" /> + <ILCompilerAnyFrameworkFiles Include="System.Reflection.Extensions" /> + <ILCompilerAnyFrameworkFiles Include="System.Reflection.TypeExtensions" /> <ILCompilerAnyFrameworkFiles Include="System.Resources.ResourceManager" /> <ILCompilerAnyFrameworkFiles Include="System.Runtime.Handles" /> - <ILCompilerAnyFrameworkFiles Include="System.Diagnostics.Tools" /> + <ILCompilerAnyFrameworkFiles Include="System.Runtime.InteropServices.RuntimeInformation" /> + <ILCompilerAnyFrameworkFiles Include="System.Runtime.Numerics" /> + <ILCompilerAnyFrameworkFiles Include="System.Security.Principal" /> <ILCompilerAnyFrameworkFiles Include="System.Text.Encoding" /> <ILCompilerAnyFrameworkFiles Include="System.Text.Encoding.Extensions" /> + <ILCompilerAnyFrameworkFiles Include="System.Threading.Overlapped" /> + <ILCompilerAnyFrameworkFiles Include="System.Threading.Thread" /> <ILCompilerAnyFrameworkFiles Include="System.Threading.Timer" /> <ILCompilerSdkBinPlace Include="@(ILCompilerAnyFrameworkFiles)"> - <Text><![CDATA[ <file src="packages/runtime.any.%(Identity)/$(CoreFxPackageVersion)/lib/netstandard1.7/%(Identity).dll" target="runtimes/$(NuPkgRid)/native/framework/%(Identity).dll" /> ]]></Text> + <Text><![CDATA[ <file src="packages/runtime.$(NuPkgRid).Microsoft.NETCore.App/$(NetCoreAppPackageVersion)/runtimes/$(NuPkgRid)/lib/netcoreapp2.0/%(Identity).dll" target="runtimes/$(NuPkgRid)/native/framework/%(Identity).dll" /> ]]></Text> </ILCompilerSdkBinPlace> - <!-- Libraries with netcoreapp1.2corert configuration --> <ILCompilerFrameworkFiles Include="runtime.win7.System.Private.Uri/$(CoreFxPackageVersion)/runtimes/win-corert/lib/netcoreapp1.2/System.Private.Uri.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> <ILCompilerFrameworkFiles Include="runtime.unix.System.Private.Uri/$(CoreFxPackageVersion)/runtimes/unix-corert/lib/netcoreapp1.2/System.Private.Uri.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> @@ -148,32 +163,7 @@ <ILCompilerFrameworkFiles Include="System.Linq/$(CoreFxPackageVersion)/lib/netcore50/System.Linq.dll" /> - <ILCompilerFrameworkFiles Include="Microsoft.NETCore.Portable.Compatibility/1.0.2/runtimes/aot/lib/netcore50/mscorlib.dll" /> - - - <ILCompilerFrameworkFiles Include="runtime.win.System.Console/$(CoreFxPackageVersion)/runtimes/win/lib/netstandard1.7/System.Console.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="runtime.unix.System.Console/$(CoreFxPackageVersion)/runtimes/unix/lib/netstandard1.7/System.Console.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="runtime.win.Microsoft.Win32.Primitives/$(CoreFxPackageVersion)/runtimes/win/lib/netstandard1.7/Microsoft.Win32.Primitives.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="runtime.unix.Microsoft.Win32.Primitives/$(CoreFxPackageVersion)/runtimes/unix/lib/netstandard1.7/Microsoft.Win32.Primitives.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="runtime.win.System.IO.FileSystem/$(CoreFxPackageVersion)/runtimes/win/lib/netstandard1.7/System.IO.FileSystem.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="runtime.unix.System.IO.FileSystem/$(CoreFxPackageVersion)/runtimes/unix/lib/netstandard1.7/System.IO.FileSystem.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> - - <ILCompilerFrameworkFiles Include="System.Threading.Overlapped/$(CoreFxPackageVersion)/runtimes/win/lib/netstandard1.7/System.Threading.Overlapped.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="System.Threading.Overlapped/$(CoreFxPackageVersion)/runtimes/unix/lib/netstandard1.7/System.Threading.Overlapped.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="System.Threading.Thread/$(CoreFxPackageVersion)/runtimes/win/lib/netstandard1.7/System.Threading.Thread.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="System.Threading.Thread/$(CoreFxPackageVersion)/runtimes/unix/lib/netstandard1.7/System.Threading.Thread.dll" Condition="'$(OsEnvironment)'!='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="System.Runtime.InteropServices.RuntimeInformation/$(CoreFxPackageVersion)/runtimes/win/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - <ILCompilerFrameworkFiles Include="System.Runtime.InteropServices.RuntimeInformation/$(CoreFxPackageVersion)/runtimes/unix/lib/netstandard1.1/System.Runtime.InteropServices.RuntimeInformation.dll" Condition="'$(OsEnvironment)'=='Windows_NT'" /> - - <ILCompilerFrameworkFiles Include="System.Buffers/$(CoreFxPackageVersion)/lib/netcoreapp1.1/System.Buffers.dll" /> - <ILCompilerFrameworkFiles Include="System.Collections.Concurrent/$(CoreFxPackageVersion)/lib/netstandard1.7/System.Collections.Concurrent.dll" /> - <ILCompilerFrameworkFiles Include="System.Collections.NonGeneric/$(CoreFxPackageVersion)/lib/netstandard1.7/System.Collections.NonGeneric.dll" /> - <ILCompilerFrameworkFiles Include="System.IO.FileSystem.Primitives/$(CoreFxPackageVersion)/lib/netstandard1.7/System.IO.FileSystem.Primitives.dll" /> - <ILCompilerFrameworkFiles Include="System.Reflection.Extensions/$(CoreFxPackageVersion)/lib/netstandard1.7/System.Reflection.Extensions.dll" /> - <ILCompilerFrameworkFiles Include="System.Reflection.TypeExtensions/$(CoreFxPackageVersion)/lib/netstandard1.5/System.Reflection.TypeExtensions.dll" /> <ILCompilerFrameworkFiles Include="System.Runtime.CompilerServices.Unsafe/$(CoreFxPackageVersion)/lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll" /> - <ILCompilerFrameworkFiles Include="System.Runtime.Numerics/$(CoreFxPackageVersion)/lib/netstandard1.7/System.Runtime.Numerics.dll" /> - <ILCompilerFrameworkFiles Include="System.Security.Principal/$(CoreFxPackageVersion)/lib/netstandard1.7/System.Security.Principal.dll" /> <ILCompilerFrameworkFiles Include="runtime.$(NuPkgRid).runtime.native.System/$(CoreFxPackageVersion)/runtimes/$(NuPkgRid)/native/System.Native.a" Condition="'$(OsEnvironment)'!='Windows_NT'" /> diff --git a/src/packaging/uap/project.json b/src/packaging/uap/project.json index b8ea32560..b92a42b19 100644 --- a/src/packaging/uap/project.json +++ b/src/packaging/uap/project.json @@ -2,9 +2,7 @@ "frameworks": { "uap10.1": { "dependencies": { - "System.Diagnostics.Tracing": "4.4.0-beta-24913-02", - "System.Linq": "4.4.0-beta-24913-02", - "Microsoft.NETCore.Portable.Compatibility": "1.0.2" + "System.Diagnostics.Tracing": "4.4.0-beta-24913-02" } } }, diff --git a/tests/src/Simple/Generics/Generics.cs b/tests/src/Simple/Generics/Generics.cs index e4fc32932..603d5b792 100644 --- a/tests/src/Simple/Generics/Generics.cs +++ b/tests/src/Simple/Generics/Generics.cs @@ -18,6 +18,7 @@ class Program TestDelegateVirtualMethod.Run(); TestDelegateInterfaceMethod.Run(); TestThreadStaticFieldAccess.Run(); + TestConstrainedMethodCalls.Run(); TestNameManglingCollisionRegression.Run(); TestUnusedGVMsDoNotCrashCompiler.Run(); @@ -383,6 +384,42 @@ class Program } } + class TestConstrainedMethodCalls + { + interface IFoo<T> + { + void Frob(); + } + + struct Foo<T> : IFoo<T> + { + public int FrobbedValue; + + public void Frob() + { + FrobbedValue = 12345; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static void DoFrob<T, U>(ref T t) where T : IFoo<U> + { + // Perform a constrained interface call from shared code. + // This should have been resolved to a direct call at compile time. + t.Frob(); + } + + public static void Run() + { + var foo = new Foo<object>(); + DoFrob<Foo<object>, object>(ref foo); + + // If the FrobbedValue doesn't change when we frob, we must have done box+interface call. + if (foo.FrobbedValue != 12345) + throw new Exception(); + } + } + // // Regression test for issue https://github.com/dotnet/corert/issues/1964 // diff --git a/tests/src/Simple/PInvoke/PInvoke.cs b/tests/src/Simple/PInvoke/PInvoke.cs index 1e7a6fa99..ed7f53fb1 100644 --- a/tests/src/Simple/PInvoke/PInvoke.cs +++ b/tests/src/Simple/PInvoke/PInvoke.cs @@ -36,6 +36,9 @@ namespace PInvoke [DllImport("*", CallingConvention = CallingConvention.StdCall)] public static extern bool SafeHandleTest(SafeMemoryHandle sh1, Int64 sh1Value); + [DllImport("*", CallingConvention = CallingConvention.StdCall)] + public static extern int SafeHandleOutTest(out SafeMemoryHandle sh1); + [DllImport("*", CallingConvention = CallingConvention.StdCall, SetLastError = true)] public static extern bool LastErrorTest(); @@ -117,6 +120,12 @@ namespace PInvoke long val = hndIntPtr.ToInt64(); //return the 64-bit value associated with hnd ThrowIfNotEquals(true, SafeHandleTest(hnd, val), "SafeHandle marshalling failed."); + + Console.WriteLine("Testing marshalling out SafeHandle"); + SafeMemoryHandle hnd2; + val = SafeHandleOutTest(out hnd2); + int val2 = unchecked((int)hnd2.DangerousGetHandle().ToInt64()); + ThrowIfNotEquals(val, val2, "SafeHandle out marshalling failed"); } } diff --git a/tests/src/Simple/PInvoke/PInvokeNative.cpp b/tests/src/Simple/PInvoke/PInvokeNative.cpp index ca66eafb9..8c70cbb6e 100644 --- a/tests/src/Simple/PInvoke/PInvokeNative.cpp +++ b/tests/src/Simple/PInvoke/PInvokeNative.cpp @@ -116,3 +116,12 @@ DLL_EXPORT bool __stdcall SafeHandleTest(HANDLE sh, long shValue) { return (long)((size_t)(sh)) == shValue; } + +DLL_EXPORT long __stdcall SafeHandleOutTest(HANDLE **sh) +{ + if (sh == NULL) + return -1; + + *sh = (HANDLE *)malloc(100); + return (long)((size_t)(*sh)); +} |