This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11275 from rahku/appdomain
Add System.AppDomain apis
- Loading branch information
Showing
19 changed files
with
192 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\dir.props" /> | ||
<PropertyGroup> | ||
<AssemblyVersion>4.1.1.0</AssemblyVersion> | ||
<AssemblyVersion>4.2.0.0</AssemblyVersion> | ||
</PropertyGroup> | ||
</Project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// 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. | ||
// ------------------------------------------------------------------------------ | ||
// Changes to this file must follow the http://aka.ms/api-review process. | ||
// ------------------------------------------------------------------------------ | ||
|
||
|
||
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.AppContext))] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
MembersMustExist : Member 'System.AppContext.TargetFrameworkName.get()' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.GetData(System.String)' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.GetData(System.String)' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.add_UnhandledException(System.UnhandledExceptionEventHandler)' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.remove_UnhandledException(System.UnhandledExceptionEventHandler)' does not exist in the implementation but it does exist in the contract. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/System.AppContext/tests/AppContext.UnhandledException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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 Xunit; | ||
|
||
namespace System.Tests | ||
{ | ||
public partial class AppContextTests | ||
{ | ||
[Fact] | ||
public void UnhandledException_IsNull() | ||
{ | ||
Assert.IsNull(AppContext.UnhandledException); | ||
} | ||
|
||
[Fact] | ||
public void UnhandledException_Add_Remove() | ||
{ | ||
AppContext.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); | ||
Assert.IsNotNull(AppContext.UnhandledException); | ||
AppContext.UnhandledException -= new UnhandledExceptionEventHandler(MyHandler); | ||
Assert.IsNull(AppContext.UnhandledException); | ||
} | ||
|
||
[Fact] | ||
public void UnhandledException_NotCalled_When_Handled() | ||
{ | ||
AppContext.UnhandledException += new UnhandledExceptionEventHandler(NotExpectedToBeCalledHandler); | ||
try { | ||
throw new Exception(); | ||
} | ||
catch(Exception e) | ||
{ | ||
} | ||
AppContext.UnhandledException -= new UnhandledExceptionEventHandler(NotExpectedToBeCalledHandler); | ||
} | ||
|
||
static void NotExpectedToBeCalledHandler(object sender, UnhandledExceptionEventArgs args) | ||
{ | ||
Assert.Fail("UnhandledException handler not expected to be called"); | ||
} | ||
|
||
static void MyHandler(object sender, UnhandledExceptionEventArgs args) | ||
{ | ||
Exception e = (Exception) args.ExceptionObject; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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.Reflection; | ||
|
||
namespace System | ||
{ | ||
public partial class AppDomain | ||
{ | ||
private static AppDomain s_domain = new AppDomain(); | ||
private AppDomain() {} | ||
public static AppDomain CurrentDomain => s_domain; | ||
public string BaseDirectory => AppContext.BaseDirectory; | ||
public string RelativeSearchPath => null; | ||
public event UnhandledExceptionEventHandler UnhandledException | ||
{ | ||
add | ||
{ | ||
AppContext.UnhandledException += value; | ||
} | ||
|
||
remove | ||
{ | ||
AppContext.UnhandledException -= value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/System.Runtime.Extensions/tests/System/AppDomainTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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.Diagnostics; | ||
using System; | ||
using Xunit; | ||
using Xunit.NetCore.Extensions; | ||
|
||
namespace System.Tests | ||
{ | ||
public class AppDomainTests : RemoteExecutorTestBase | ||
{ | ||
[Fact] | ||
public void CurrentDomain_Not_Null() | ||
{ | ||
Assert.NotNull(AppDomain.CurrentDomain); | ||
} | ||
|
||
[Fact] | ||
public void CurrentDomain_Idempotent() | ||
{ | ||
Assert.Equal(AppDomain.CurrentDomain, AppDomain.CurrentDomain); | ||
} | ||
|
||
[Fact] | ||
public void BaseDirectory_Same_As_AppContext() | ||
{ | ||
Assert.Equal(AppDomain.CurrentDomain.BaseDirectory, AppContext.BaseDirectory); | ||
} | ||
|
||
[Fact] | ||
public void RelativeSearchPath_Is_Null() | ||
{ | ||
Assert.Null(AppDomain.CurrentDomain.RelativeSearchPath); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MembersMustExist : Member 'System.Type.IsSecurityCritical.get()' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.Type.IsSecuritySafeCritical.get()' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.Type.IsSecurityTransparent.get()' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.Reflection.Pointer..ctor()' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.TargetFrameworkName.get()' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.GetData(System.String)' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.add_UnhandledException(System.UnhandledExceptionEventHandler)' does not exist in the implementation but it does exist in the contract. | ||
MembersMustExist : Member 'System.AppContext.remove_UnhandledException(System.UnhandledExceptionEventHandler)' does not exist in the implementation but it does exist in the contract. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters