Skip to content

Commit

Permalink
Add Thread.CurrentPrincipal, Thread.GetDomain, and Thread.GetDomainID…
Browse files Browse the repository at this point in the history
… for uapaot. (dotnet/corefx#17125)

* Remove from System.Threading.Thread "#if !NETNATIVE" lines that are no longer necessary.
* Add back System.Threading types for uapaot.
* Update baselines.


Commit migrated from dotnet/corefx@e0e59c0
  • Loading branch information
AntonLapounov authored and jkotas committed Mar 15, 2017
1 parent 37cf30a commit bf9d13b
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 168 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
Compat issues with assembly System.Runtime.Extensions:
TypesMustExist : Type 'System.AppDomain' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_AssemblyLoad(System.AssemblyLoadEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_AssemblyResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_FirstChanceException(System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs>)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_ProcessExit(System.EventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_ReflectionOnlyAssemblyResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_ResourceResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_TypeResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.add_UnhandledException(System.UnhandledExceptionEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.BaseDirectory.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.GetAssemblies()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.GetData(System.String)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.IsCompatibilitySwitchSet(System.String)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.RelativeSearchPath.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_AssemblyLoad(System.AssemblyLoadEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_AssemblyResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_FirstChanceException(System.EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs>)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_ProcessExit(System.EventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_ReflectionOnlyAssemblyResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_ResourceResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_TypeResolve(System.ResolveEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.remove_UnhandledException(System.UnhandledExceptionEventHandler)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.AppDomain.SetData(System.String, System.Object)' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.AssemblyLoadEventArgs' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.AssemblyLoadEventHandler' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Base64FormattingOptions' does not exist in the implementation but it does exist in the contract.
Expand Down Expand Up @@ -62,16 +82,11 @@ MembersMustExist : Member 'System.Math.Clamp(System.UInt64, System.UInt64, Syste
MembersMustExist : Member 'System.Math.DivRem(System.Int32, System.Int32, System.Int32)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Math.DivRem(System.Int64, System.Int64, System.Int64)' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.MathF' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Progress<T>' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.ResolveEventHandler' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.StringComparer.Compare(System.Object, System.Object)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.StringComparer.Create(System.Globalization.CultureInfo, System.Boolean)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.StringComparer.GetHashCode(System.Object)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.StringComparer.InvariantCulture.get()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.StringComparer.InvariantCultureIgnoreCase.get()' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.IO.BufferedStream' does not inherit from base type 'System.MarshalByRefObject' in the implementation but it does in the contract.
MembersMustExist : Member 'System.IO.EndOfStreamException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.IO.MemoryStream' does not inherit from base type 'System.MarshalByRefObject' in the implementation but it does in the contract.
MembersMustExist : Member 'System.IO.TextReader.Synchronized(System.IO.TextReader)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.IO.TextWriter.Synchronized(System.IO.TextWriter)' does not exist in the implementation but it does exist in the contract.
Total Issues: 75
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)'=='uapaot'">true</GenFacadesIgnoreMissingTypes>
<DefineConstants Condition="'$(TargetGroup)' == 'uapaot'">$(DefineConstants);uapaot</DefineConstants>
<!-- System.IO.Path conflicts between type in partial facade and in mscorlib -->
<NoWarn>0436</NoWarn>
<TargetsWindowsUap Condition="'$(TargetGroup)'=='uapaot'">true</TargetsWindowsUap>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
Expand All @@ -22,7 +22,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uapaot-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uapaot-Windows_NT-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System\AppDomain.cs" Condition="'$(TargetGroup)' != 'uapaot'" />
<Compile Include="System\AppDomain.cs" />
<Compile Include="System\Context.cs" />
<Compile Include="System\AppDomainUnloadedException.cs" />
<Compile Include="System\ApplicationId.cs" />
Expand Down Expand Up @@ -302,7 +302,7 @@
<Compile Include="System\StringNormalizationExtensions.cs" />
<Compile Include="System\Globalization\Extensions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">
<ItemGroup>
<ProjectReference Include="..\..\System.Private.Uri\src\System.Private.Uri.csproj" />
<ProjectReference Include="..\..\System.Diagnostics.Debug\src\System.Diagnostics.Debug.csproj" />
<ProjectReference Include="..\..\System.Security.Principal\src\System.Security.Principal.csproj">
Expand All @@ -314,8 +314,6 @@
<Reference Include="mscorlib" />
<Reference Include="Windows" />
<ReferenceFromRuntime Include="System.Private.Interop" />
<ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Private.Uri\src\System.Private.Uri.csproj" />
</ItemGroup>
<ItemGroup>
<ReferenceFromRuntime Include="System.Private.CoreLib" />
Expand Down
26 changes: 18 additions & 8 deletions src/libraries/System.Runtime.Extensions/src/System/AppDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
using System;
using System.Reflection;
using System.Runtime.ExceptionServices;
#if !uapaot
using System.Runtime.Loader;
#endif
using System.IO;

namespace System
Expand All @@ -27,6 +29,7 @@ private AppDomain() { }

public static AppDomain CurrentDomain => s_domain;

#if !uapaot
public string BaseDirectory => AppContext.BaseDirectory;

public string RelativeSearchPath => null;
Expand All @@ -36,6 +39,7 @@ public event UnhandledExceptionEventHandler UnhandledException
add { AppContext.UnhandledException += value; }
remove { AppContext.UnhandledException -= value; }
}
#endif

public string DynamicDirectory => null;

Expand All @@ -59,6 +63,7 @@ public string FriendlyName

public event EventHandler DomainUnload;

#if !uapaot
public event EventHandler<FirstChanceExceptionEventArgs> FirstChanceException
{
add { AppContext.FirstChanceException += value; }
Expand All @@ -70,6 +75,7 @@ public event EventHandler ProcessExit
add { AppContext.ProcessExit += value; }
remove { AppContext.ProcessExit -= value; }
}
#endif

public string ApplyPolicy(string assemblyName)
{
Expand Down Expand Up @@ -149,6 +155,7 @@ public int ExecuteAssemblyByName(string assemblyName) =>
public int ExecuteAssemblyByName(string assemblyName, params string[] args) =>
ExecuteAssembly(Assembly.Load(assemblyName), args);

#if !uapaot
public object GetData(string name) => AppContext.GetData(name);

public void SetData(string name, object data) => AppContext.SetData(name, data);
Expand All @@ -158,6 +165,7 @@ public int ExecuteAssemblyByName(string assemblyName, params string[] args) =>
bool result;
return AppContext.TryGetSwitch(value, out result) ? result : default(bool?);
}
#endif

public bool IsDefaultAppDomain() => true;

Expand Down Expand Up @@ -231,6 +239,7 @@ public void SetShadowCopyFiles() { }
[ObsoleteAttribute("AppDomain.SetShadowCopyPath has been deprecated. Please investigate the use of AppDomainSetup.ShadowCopyDirectories instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public void SetShadowCopyPath(string path) { }

#if !uapaot
public Assembly[] GetAssemblies() => AssemblyLoadContext.GetLoadedAssemblies();

public event AssemblyLoadEventHandler AssemblyLoad
Expand All @@ -239,6 +248,14 @@ public event AssemblyLoadEventHandler AssemblyLoad
remove { AssemblyLoadContext.AssemblyLoad -= value; }
}

public event ResolveEventHandler AssemblyResolve
{
add { AssemblyLoadContext.AssemblyResolve += value; }
remove { AssemblyLoadContext.AssemblyResolve -= value; }
}

public event ResolveEventHandler ReflectionOnlyAssemblyResolve;

public event ResolveEventHandler TypeResolve
{
add { AssemblyLoadContext.TypeResolve += value; }
Expand All @@ -250,6 +267,7 @@ public event ResolveEventHandler ResourceResolve
add { AssemblyLoadContext.ResourceResolve += value; }
remove { AssemblyLoadContext.ResourceResolve -= value; }
}
#endif

public void SetPrincipalPolicy(PrincipalPolicy policy) { }

Expand All @@ -270,13 +288,5 @@ public void SetThreadPrincipal(IPrincipal principal)
_defaultPrincipal = principal;
}
}

public event ResolveEventHandler AssemblyResolve
{
add { AssemblyLoadContext.AssemblyResolve += value; }
remove { AssemblyLoadContext.AssemblyResolve -= value; }
}

public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
Compat issues with assembly System.Threading.Tasks:
MembersMustExist : Member 'System.AggregateException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.OperationCanceledException' does not inherit from base type 'System.SystemException' in the implementation but it does in the contract.
MembersMustExist : Member 'System.OperationCanceledException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Threading.Tasks.Task' does not implement interface 'System.IDisposable' in the implementation but it does in the contract.
MembersMustExist : Member 'System.Threading.Tasks.Task.Dispose()' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Threading.Tasks.Task.Dispose(System.Boolean)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Threading.Tasks.Task<TResult>' does not implement interface 'System.IDisposable' in the implementation but it does in the contract.
CannotRemoveBaseTypeOrInterface : Type 'System.Threading.Tasks.TaskCanceledException' does not inherit from base type 'System.SystemException' in the implementation but it does in the contract.
MembersMustExist : Member 'System.Threading.Tasks.TaskCanceledException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Threading.Tasks.TaskSchedulerException..ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)' does not exist in the implementation but it does exist in the contract.
Total Issues: 10

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<!-- Type being defined conflicts with imported type from dependency assembly -->
<NoWarn>436</NoWarn>
<ProjectGuid>{06197EED-FF48-43F3-976D-463839D43E8C}</ProjectGuid>
<DefineConstants Condition="'$(TargetGroup)' == 'uapaot'">$(DefineConstants);uapaot</DefineConstants>
</PropertyGroup>
<!-- Help VS understand available configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
Expand All @@ -28,7 +27,7 @@
<Compile Include="System\Threading\ThreadAbortException.cs" />
<Compile Include="System\Threading\ThreadExceptionEventArgs.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">
<ItemGroup>
<ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj">
<Aliases>System_Runtime</Aliases>
</ProjectReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if !uapaot
extern alias System_Runtime_Extensions;
extern alias System_Security_Principal;
#endif

using System.Diagnostics;
using Internal.Runtime.Augments;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.ConstrainedExecution;
using Internal.Runtime.Augments;

namespace System.Threading
{
#if !uapaot
using AppDomain = System_Runtime_Extensions::System.AppDomain;
using IPrincipal = System_Security_Principal::System.Security.Principal.IPrincipal;
#endif

public sealed partial class Thread : CriticalFinalizerObject
{
Expand All @@ -27,9 +23,7 @@ public sealed partial class Thread : CriticalFinalizerObject

private readonly RuntimeThread _runtimeThread;
private Delegate _start;
#if !uapaot
private IPrincipal _principal;
#endif

private Thread(RuntimeThread runtimeThread)
{
Expand Down Expand Up @@ -162,7 +156,6 @@ public CultureInfo CurrentUICulture
}
}

#if !uapaot
public static IPrincipal CurrentPrincipal
{
get
Expand All @@ -174,7 +167,6 @@ public static IPrincipal CurrentPrincipal
CurrentThread._principal = value;
}
}
#endif

public ExecutionContext ExecutionContext => ExecutionContext.Capture();
public bool IsAlive => _runtimeThread.IsAlive;
Expand Down Expand Up @@ -285,10 +277,8 @@ public void SetCompressedStack(CompressedStack stack)
throw new InvalidOperationException(SR.Thread_GetSetCompressedStack_NotSupported);
}

#if !uapaot
public static AppDomain GetDomain() => AppDomain.CurrentDomain;
public static int GetDomainID() => GetDomain().Id;
#endif
public override int GetHashCode() => ManagedThreadId;
public void Interrupt() => _runtimeThread.Interrupt();
public void Join() => _runtimeThread.Join();
Expand Down
Loading

0 comments on commit bf9d13b

Please sign in to comment.