This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Runtime support for upcoming .NET Core WinRT Host #23402
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eef94cb
First pass at adding winrt host entry-point.
jkoritzinsky 7616f05
There's no way to specify HResult-swapping on a function called via h…
jkoritzinsky 0321896
Use the WindowsRuntimeMarshal class to create the activation factory …
jkoritzinsky 92a345d
Implement loading the dependent assemblies of a WinRT assembly into a…
jkoritzinsky 53336a0
PR Feedback.
jkoritzinsky 2ba2ab8
Fail to get the activation factory if the found type is not a managed…
jkoritzinsky d1e009b
Rearrange parameters based on PR feedback.
jkoritzinsky 87cc7b9
Remove unneeded include.
jkoritzinsky dbe5ded
Make ActivationFactoryLoader internal.
jkoritzinsky c1a0991
Merge branch 'master' of https://github.com/dotnet/coreclr into winrt…
jkoritzinsky 1789da5
Merge branch 'master' of https://github.com/dotnet/coreclr into winrt…
jkoritzinsky a484b3e
Fix null-ref in WinRT-dependent-assembly loading
jkoritzinsky 795ed3b
Remove extraneous "System."
jkoritzinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
...te.CoreLib/src/Internal/Runtime/InteropServices/WindowsRuntime/ActivationFactoryLoader.cs
This file contains hidden or 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,74 @@ | ||
| // 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.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.IO; | ||
| using System.Reflection; | ||
| using System.Runtime.InteropServices; | ||
| using System.Runtime.InteropServices.WindowsRuntime; | ||
| using System.Runtime.Loader; | ||
|
|
||
| namespace Internal.Runtime.InteropServices.WindowsRuntime | ||
| { | ||
| internal static class ActivationFactoryLoader | ||
| { | ||
| // Collection of all ALCs used for WinRT activation. | ||
| // Since each of the assemblies that act as the "key" here are WinRT assemblies | ||
| // we don't need to share this dictionary with the COM activation dictionary | ||
| // since there will be no overlap. | ||
| private static Dictionary<string, AssemblyLoadContext> s_AssemblyLoadContexts = new Dictionary<string, AssemblyLoadContext>(StringComparer.InvariantCultureIgnoreCase); | ||
|
|
||
| private static AssemblyLoadContext GetALC(string assemblyPath) | ||
| { | ||
| AssemblyLoadContext alc; | ||
|
|
||
| lock (s_AssemblyLoadContexts) | ||
| { | ||
| if (!s_AssemblyLoadContexts.TryGetValue(assemblyPath, out alc)) | ||
| { | ||
| alc = new IsolatedComponentLoadContext(assemblyPath); | ||
| s_AssemblyLoadContexts.Add(assemblyPath, alc); | ||
| } | ||
| } | ||
|
|
||
| return alc; | ||
| } | ||
|
|
||
| /// <summary>Get a WinRT activation factory for a given type name.</summary> | ||
| /// <param name="componentPath">The path to the WinRT component that the type is expected to be defined in.</param> | ||
| /// <param name="typeName">The name of the component type to activate</param> | ||
| /// <param name="activationFactory">The activation factory</param> | ||
| public unsafe static int GetActivationFactory( | ||
| char* componentPath, | ||
| [MarshalAs(UnmanagedType.HString)] string typeName, | ||
| [MarshalAs(UnmanagedType.Interface)] out IActivationFactory activationFactory) | ||
| { | ||
| activationFactory = null; | ||
| try | ||
| { | ||
| if (typeName is null) | ||
| { | ||
| throw new ArgumentNullException(nameof(typeName)); | ||
| } | ||
|
|
||
| AssemblyLoadContext context = GetALC(Marshal.PtrToStringUni((IntPtr)componentPath)); | ||
|
|
||
| Type winRTType = context.LoadTypeForWinRTTypeNameInContext(typeName); | ||
|
|
||
| if (winRTType is null || !winRTType.IsExportedToWindowsRuntime) | ||
| { | ||
| throw new TypeLoadException(typeName); | ||
| } | ||
| activationFactory = WindowsRuntimeMarshal.GetManagedActivationFactory(winRTType); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| return ex.HResult; | ||
| } | ||
| return 0; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.