forked from dotnet/runtime
-
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.
Use reflection or a compile-time only shim assembly to reference unex…
…posed corelib types. Use reflection for the hosting tests as they'll be around indefinitely. Use the ref-assembly trick for ICastable testing since ICastable testing would require Ref-emit which makes the test significantly less readable and since ICastable will be going away within the .NET 7 timeframe. Supercedes dotnet#61754
- Loading branch information
1 parent
6ff57f1
commit 0cf62d2
Showing
15 changed files
with
135 additions
and
106 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 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
3 changes: 1 addition & 2 deletions
3
src/tests/Interop/COM/Activator/ActivatorBuiltInComDisabled.csproj
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
46 changes: 46 additions & 0 deletions
46
src/tests/Interop/COM/Activator/ComActivationContextShim.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,46 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
namespace Activator | ||
{ | ||
internal sealed class ComActivationContextShim | ||
{ | ||
private static readonly Type _comActivationContextType = typeof(object).Assembly.GetType("Internal.Runtime.InteropServices.ComActivationContext", throwOnError: true); | ||
private static readonly FieldInfo _classIdField = _comActivationContextType.GetField("ClassId"); | ||
private static readonly FieldInfo _interfaceIdField = _comActivationContextType.GetField("InterfaceId"); | ||
private static readonly FieldInfo _assemblyPathField = _comActivationContextType.GetField("AssemblyPath"); | ||
private static readonly FieldInfo _assemblyNameField = _comActivationContextType.GetField("AssemblyName"); | ||
private static readonly FieldInfo _typeNameField = _comActivationContextType.GetField("TypeName"); | ||
|
||
public object UnderlyingContext { get; } = System.Activator.CreateInstance(_comActivationContextType); | ||
|
||
public Guid ClassId | ||
{ | ||
get => (Guid)_classIdField.GetValue(UnderlyingContext); | ||
set => _classIdField.SetValue(UnderlyingContext, value); | ||
} | ||
public Guid InterfaceId | ||
{ | ||
get => (Guid)_interfaceIdField.GetValue(UnderlyingContext); | ||
set => _interfaceIdField.SetValue(UnderlyingContext, value); | ||
} | ||
public string AssemblyPath | ||
{ | ||
get => (string)_assemblyPathField.GetValue(UnderlyingContext); | ||
set => _assemblyPathField.SetValue(UnderlyingContext, value); | ||
} | ||
public string AssemblyName | ||
{ | ||
get => (string)_assemblyNameField.GetValue(UnderlyingContext); | ||
set => _assemblyNameField.SetValue(UnderlyingContext, value); | ||
} | ||
public string TypeName | ||
{ | ||
get => (string)_typeNameField.GetValue(UnderlyingContext); | ||
set => _typeNameField.SetValue(UnderlyingContext, 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
Oops, something went wrong.