forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose Assembly.GetEntryAssembly and TypeInfo.IsEquivalentTo()
Expose Assembly.GetEntryAssembly and TypeInfo.IsEquivalentTo() in System.Reflection. Fixes issues #4146 , #2101
- Loading branch information
Showing
7 changed files
with
60 additions
and
7 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
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
20 changes: 20 additions & 0 deletions
20
src/System.Reflection/tests/Assembly/Assembly_GetEntryAssembly.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,20 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Xunit; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace System.Reflection.Tests | ||
{ | ||
public class AssemblyGetEntryAssemblyTest | ||
{ | ||
[Fact] | ||
public void Test_GetEntryAssembly() | ||
{ | ||
Assert.NotNull(Assembly.GetEntryAssembly()); | ||
Assert.True(Assembly.GetEntryAssembly().ToString().StartsWith("xunit.console.netcore", StringComparison.OrdinalIgnoreCase)); | ||
} | ||
} | ||
} | ||
|
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
29 changes: 29 additions & 0 deletions
29
src/System.Reflection/tests/TypeInfo/TypeInfo_IsEquivalentTo.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,29 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Xunit; | ||
using System; | ||
using System.Reflection; | ||
using System.Collections.Generic; | ||
|
||
namespace System.Reflection.Tests | ||
{ | ||
public class IsEquivalentToReflectionTests | ||
{ | ||
[Fact] | ||
public void IsEquivalentTo() | ||
{ | ||
Assert.True(typeof(string).GetTypeInfo().IsEquivalentTo(typeof(string))); | ||
Assert.False(typeof(object).GetTypeInfo().IsEquivalentTo(typeof(string))); | ||
|
||
Object o = "stringAsObject"; | ||
string s = "stringAsString"; | ||
|
||
Assert.True(o.GetType().GetTypeInfo().IsEquivalentTo(s.GetType())); | ||
Assert.True(typeof(IsEquivalentToReflectionTests.MyClass1).GetTypeInfo().IsEquivalentTo(typeof(IsEquivalentToReflectionTests.MyClass1))); | ||
} | ||
|
||
public class MyClass1 { } | ||
} | ||
|
||
} |