From d568019c90148281446a94d92209788d3c6cda59 Mon Sep 17 00:00:00 2001
From: Joshua Larkin <70237359+j0shuams@users.noreply.github.com>
Date: Fri, 12 Nov 2021 10:59:17 -0800
Subject: [PATCH] Embedded CsWinRt Option (#1011)
---
docs/embedded.md | 103 ++++++++
...Microsoft.Windows.CsWinRT.Embedded.targets | 75 ++++++
nuget/Microsoft.Windows.CsWinRT.nuspec | 16 ++
nuget/Microsoft.Windows.CsWinRT.targets | 10 +-
.../C++ Components/Alpha/Alpha.cpp | 7 +
.../C++ Components/Alpha/Alpha.def | 3 +
.../TestEmbedded/C++ Components/Alpha/Alpha.h | 18 ++
.../C++ Components/Alpha/Alpha.idl | 13 +
.../C++ Components/Alpha/Alpha.vcxproj | 153 ++++++++++++
.../Alpha/Alpha.vcxproj.filters | 25 ++
.../C++ Components/Alpha/packages.config | 4 +
.../TestEmbedded/C++ Components/Alpha/pch.cpp | 1 +
.../TestEmbedded/C++ Components/Alpha/pch.h | 4 +
.../TestEmbedded/C++ Components/Beta/Beta.cpp | 7 +
.../TestEmbedded/C++ Components/Beta/Beta.def | 3 +
.../TestEmbedded/C++ Components/Beta/Beta.h | 18 ++
.../TestEmbedded/C++ Components/Beta/Beta.idl | 21 ++
.../C++ Components/Beta/Beta.vcxproj | 163 ++++++++++++
.../C++ Components/Beta/Beta.vcxproj.filters | 30 +++
.../C++ Components/Beta/QIAgent.cpp | 21 ++
.../C++ Components/Beta/QIAgent.h | 20 ++
.../C++ Components/Beta/packages.config | 4 +
.../TestEmbedded/C++ Components/Beta/pch.cpp | 1 +
.../TestEmbedded/C++ Components/Beta/pch.h | 6 +
.../C++ Components/Gamma/Gamma.cpp | 7 +
.../C++ Components/Gamma/Gamma.def | 3 +
.../TestEmbedded/C++ Components/Gamma/Gamma.h | 19 ++
.../C++ Components/Gamma/Gamma.idl | 13 +
.../C++ Components/Gamma/Gamma.vcxproj | 153 ++++++++++++
.../Gamma/Gamma.vcxproj.filters | 28 +++
.../C++ Components/Gamma/packages.config | 4 +
.../TestEmbedded/C++ Components/Gamma/pch.cpp | 1 +
.../TestEmbedded/C++ Components/Gamma/pch.h | 4 +
.../TestEmbedded/Directory.Build.props | 2 +
.../TestEmbedded/Directory.Build.targets | 2 +
.../Net5App.Bootstrap.csproj | 54 ++++
.../TestEmbedded/Net5App.Bootstrap/Program.cs | 113 +++++++++
.../TestEmbedded/Net5App/Net5App.csproj | 20 ++
src/Samples/TestEmbedded/Net5App/Program.cs | 26 ++
.../Net5App/Properties/launchSettings.json | 8 +
.../NetCore3App/NetCore3App.csproj | 14 ++
.../TestEmbedded/NetCore3App/Program.cs | 25 ++
.../Properties/launchSettings.json | 8 +
.../NetFrameworkApp/NetFrameworkApp.csproj | 51 ++++
.../TestEmbedded/NetFrameworkApp/Program.cs | 115 +++++++++
src/Samples/TestEmbedded/README.md | 16 ++
src/Samples/TestEmbedded/TestEmbedded.sln | 233 ++++++++++++++++++
.../TestEmbeddedLibrary.csproj | 52 ++++
.../TestEmbeddedLibrary/TestLib.cs | 93 +++++++
.../UnitTestEmbedded/TestClass.cs | 43 ++++
.../UnitTestEmbedded/UnitTestEmbedded.csproj | 36 +++
.../TestEmbedded/UseTestLib/Program.cs | 26 ++
.../UseTestLib/Properties/launchSettings.json | 8 +
.../TestEmbedded/UseTestLib/UseTestLib.csproj | 20 ++
src/Samples/TestEmbedded/clean.cmd | 34 +++
.../UnitTest/TestComponentCSharp_Tests.cs | 2 +-
.../Interop/IWeakReferenceSource.net5.cs | 7 +-
src/build.cmd | 24 +-
src/cswinrt.sln | 1 +
src/cswinrt/strings/WinRT.cs | 4 +-
60 files changed, 1988 insertions(+), 7 deletions(-)
create mode 100644 docs/embedded.md
create mode 100644 nuget/Microsoft.Windows.CsWinRT.Embedded.targets
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.def
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.h
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.idl
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj.filters
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/packages.config
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/pch.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Alpha/pch.h
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/Beta.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/Beta.def
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/Beta.h
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/Beta.idl
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj.filters
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.h
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/packages.config
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/pch.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Beta/pch.h
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.def
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.h
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.idl
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj.filters
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/packages.config
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/pch.cpp
create mode 100644 src/Samples/TestEmbedded/C++ Components/Gamma/pch.h
create mode 100644 src/Samples/TestEmbedded/Directory.Build.props
create mode 100644 src/Samples/TestEmbedded/Directory.Build.targets
create mode 100644 src/Samples/TestEmbedded/Net5App.Bootstrap/Net5App.Bootstrap.csproj
create mode 100644 src/Samples/TestEmbedded/Net5App.Bootstrap/Program.cs
create mode 100644 src/Samples/TestEmbedded/Net5App/Net5App.csproj
create mode 100644 src/Samples/TestEmbedded/Net5App/Program.cs
create mode 100644 src/Samples/TestEmbedded/Net5App/Properties/launchSettings.json
create mode 100644 src/Samples/TestEmbedded/NetCore3App/NetCore3App.csproj
create mode 100644 src/Samples/TestEmbedded/NetCore3App/Program.cs
create mode 100644 src/Samples/TestEmbedded/NetCore3App/Properties/launchSettings.json
create mode 100644 src/Samples/TestEmbedded/NetFrameworkApp/NetFrameworkApp.csproj
create mode 100644 src/Samples/TestEmbedded/NetFrameworkApp/Program.cs
create mode 100644 src/Samples/TestEmbedded/README.md
create mode 100644 src/Samples/TestEmbedded/TestEmbedded.sln
create mode 100644 src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj
create mode 100644 src/Samples/TestEmbedded/TestEmbeddedLibrary/TestLib.cs
create mode 100644 src/Samples/TestEmbedded/UnitTestEmbedded/TestClass.cs
create mode 100644 src/Samples/TestEmbedded/UnitTestEmbedded/UnitTestEmbedded.csproj
create mode 100644 src/Samples/TestEmbedded/UseTestLib/Program.cs
create mode 100644 src/Samples/TestEmbedded/UseTestLib/Properties/launchSettings.json
create mode 100644 src/Samples/TestEmbedded/UseTestLib/UseTestLib.csproj
create mode 100644 src/Samples/TestEmbedded/clean.cmd
diff --git a/docs/embedded.md b/docs/embedded.md
new file mode 100644
index 000000000..770abcf23
--- /dev/null
+++ b/docs/embedded.md
@@ -0,0 +1,103 @@
+# Embedded C#/WinRT Support
+
+## Overview
+
+**Note**: Embedded support is currently **in preview**.
+
+Embedded support is a C#/WinRT feature that allows you to compile the c# projection for the component, within the library/app itself.
+
+This is done by setting the build property `CsWinRTEmbedded` to `true` in the app or library's project file.
+
+Enabling embedded support compiles the sources for WinRT.Runtime with the project.
+For any types from the component which you want to embed in your project, they must be specified using `CsWinRTIncludes`.
+The specified types will be projected and embedded into the project's *.dll*.
+This means projects using embedded support no longer have a dependency on a projection for the component, `WinRT.Runtime.dll` or `Microsoft.Windows.SDK.NET.dll` in the case of the Windows SDK projection.
+
+For an example, you can look at the [sample](https://github.com/microsoft/CsWinRT/tree/master/src/Samples/TestEmbedded).
+
+Embedded support introduces new features to the C#/WinRT toolchain:
+ * Decreased component/app size: The developer only needs to include the minimum necessary parts of the Windows SDK required by their component or app, reducing the size of the output .dll significantly.
+ * Downlevel support: App developers on .NET 5+ can target Windows 7 (`net5.0-windows`) and light-up on Windows 10
+ (and Windows 11) when consuming an embedded .NET 5+ library.
+ * Removes the need for multi-targeting: Library authors can support all .NET Standard 2.0 app consumers, including .NET 5+, without the need for multi-targeting. App consumers are able to target any .NET Standard 2.0 compatible TFM (e.g. `netcoreapp3.1`, `net48`, and `net5.0-windows`).
+
+It is important to remember that embedded support constrains the scope of Windows Runtime types to your binary.
+
+## Scenarios
+
+This feature allows C# apps and libraries to target `net5.0` (and above), .NET Framework 4.6.1+, `netcoreapp3.1`, and `netstandard2.0` while also using the Windows SDK.
+Moreover, a library can target `netstandard2.0` and be able to run on NetFX, Net Core and Net 5.
+
+Note: the `netstandard2.0` generated projection is not optimized for .NET 5 and won't be as performant.
+
+## Usage
+
+Using embedded support allows you to target non-Windows specific TFMs and older versions of .NET.
+You will need to set a few properties:
+ * `CsWinRTEmbedded` - must be set to `true` to include the sources
+ * `CsWinRTIncludes` - Specify the types to be projected; error `CS0246` will highlight any missing namespaces
+ * `CsWinRTWindowsMetadata` - must be set to the Windows SDK release to use for Windows APIs
+ * `LangVersion` - must be set to `9` because the CsWinRT generated sources use C# 9
+
+Targeting `netstandard2.0` requires adding the following two package references:
+
+```xml
+
+
+```
+
+Here is an example project file for a library cross-targeting and embedding a C#/WinRT generated projection.
+
+```csproj
+
+
+
+ net6.0-windows;net5.0-windows;netstandard2.0
+ x64;x86
+
+
+
+ 9
+ true
+ 10.0.19041.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CppwinrtComponent;
+ Windows.Devices.Geolocation;
+ Windows.Foundation;
+
+
+
+
+```
+
+You will need to enable Windows Desktop Compatible for all your referenced C++/WinRT components -- either via the properties or in the `.vcxproj` file.
+
+If you try to use an embedded projection of a native (C++/WinRT) component, via ProjectReference, then you may encounter a runtime error `CLASS_NOT_REGISTERED`.
+You can fix this by unloading the native component project in Visual Studio, and adding the following:
+
+```vcxproj
+
+ true
+
+```
+
+Alternatively, you can right-click the C++ project in Visual Studio, select Properties > General > Project Defaults,
+ and set Windows Desktop Compatible to Yes for all configurations/platforms.
+
+If you find any other issues using embedded support, please [file an issue]()!
diff --git a/nuget/Microsoft.Windows.CsWinRT.Embedded.targets b/nuget/Microsoft.Windows.CsWinRT.Embedded.targets
new file mode 100644
index 000000000..38a975bfa
--- /dev/null
+++ b/nuget/Microsoft.Windows.CsWinRT.Embedded.targets
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+ $(DefineConstants);EMBED
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nuget/Microsoft.Windows.CsWinRT.nuspec b/nuget/Microsoft.Windows.CsWinRT.nuspec
index 660d3154c..67e291229 100644
--- a/nuget/Microsoft.Windows.CsWinRT.nuspec
+++ b/nuget/Microsoft.Windows.CsWinRT.nuspec
@@ -24,6 +24,7 @@
+
@@ -36,6 +37,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nuget/Microsoft.Windows.CsWinRT.targets b/nuget/Microsoft.Windows.CsWinRT.targets
index 0b52e4700..65b3bb291 100644
--- a/nuget/Microsoft.Windows.CsWinRT.targets
+++ b/nuget/Microsoft.Windows.CsWinRT.targets
@@ -18,6 +18,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
false
+
+
@@ -99,14 +101,18 @@ Copyright (C) Microsoft Corporation. All rights reserved.
-input $(CsWinRTInteropMetadata)
-include WinRT.Interop
+ -embedded
+ $(TargetFramework)
+ netstandard2.0
$(CsWinRTCommandVerbosity)
--target $(TargetFramework)
+-target $(CsWinRTExeTFM)
$(CsWinRTWindowsMetadataInput)
-input @(CsWinRTInputs->'"%(FullPath)"', ' ')
-output "$(CsWinRTGeneratedFilesDir.TrimEnd('\'))"
$(CsWinRTFilters)
$(CsWinRTIncludeWinRTInterop)
+$(CsWinRTEmbeddedParam)
@@ -131,7 +137,7 @@ $(CsWinRTIncludeWinRTInterop)
-
+
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.cpp b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.cpp
new file mode 100644
index 000000000..365fcd59f
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.cpp
@@ -0,0 +1,7 @@
+#include "pch.h"
+#include "Alpha.h"
+#include "Class.g.cpp"
+
+namespace winrt::Alpha::implementation
+{
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.def b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.def
new file mode 100644
index 000000000..24e7c1235
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.def
@@ -0,0 +1,3 @@
+EXPORTS
+DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
+DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.h b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.h
new file mode 100644
index 000000000..c1fe55067
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "Class.g.h"
+
+namespace winrt::Alpha::implementation
+{
+ struct Class : ClassT
+ {
+ Class() = default;
+ };
+}
+
+namespace winrt::Alpha::factory_implementation
+{
+ struct Class : ClassT
+ {
+ };
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.idl b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.idl
new file mode 100644
index 000000000..5f438a79d
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.idl
@@ -0,0 +1,13 @@
+namespace Alpha
+{
+ [default_interface]
+ runtimeclass Class
+ {
+ Class();
+ }
+
+ interface IAlpha
+ {
+ Int32 Five();
+ }
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj
new file mode 100644
index 000000000..5c54ea6bf
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj
@@ -0,0 +1,153 @@
+
+
+
+
+ true
+ true
+ true
+ true
+ {9d73f8c2-332b-4aa9-95e3-59c92e68efb4}
+ Alpha
+ Alpha
+ en-US
+ 14.0
+ true
+ Windows Store
+ 10.0
+ 10.0
+ 10.0.17134.0
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ ARM64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ ARM64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ DynamicLibrary
+ v143
+ v142
+ v141
+ v140
+ Unicode
+ false
+
+
+ true
+ true
+
+
+ false
+ true
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Use
+ pch.h
+ $(IntDir)pch.pch
+ Level4
+ %(AdditionalOptions) /bigobj
+
+ /DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)
+ _WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)
+ $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)
+
+
+ Console
+ false
+ Alpha.def
+
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ Alpha.idl
+
+
+
+
+ Create
+
+
+ Alpha.idl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj.filters b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj.filters
new file mode 100644
index 000000000..8fcbd9897
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/Alpha.vcxproj.filters
@@ -0,0 +1,25 @@
+
+
+
+
+ accd3aa8-1ba0-4223-9bbe-0c431709210b
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/packages.config b/src/Samples/TestEmbedded/C++ Components/Alpha/packages.config
new file mode 100644
index 000000000..fb20a4e61
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/pch.cpp b/src/Samples/TestEmbedded/C++ Components/Alpha/pch.cpp
new file mode 100644
index 000000000..bcb5590be
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/pch.cpp
@@ -0,0 +1 @@
+#include "pch.h"
diff --git a/src/Samples/TestEmbedded/C++ Components/Alpha/pch.h b/src/Samples/TestEmbedded/C++ Components/Alpha/pch.h
new file mode 100644
index 000000000..21199686d
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Alpha/pch.h
@@ -0,0 +1,4 @@
+#pragma once
+#include
+#include
+#include
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/Beta.cpp b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.cpp
new file mode 100644
index 000000000..7259525e2
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.cpp
@@ -0,0 +1,7 @@
+#include "pch.h"
+#include "Beta.h"
+#include "Class.g.cpp"
+
+namespace winrt::Beta::implementation
+{
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/Beta.def b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.def
new file mode 100644
index 000000000..24e7c1235
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.def
@@ -0,0 +1,3 @@
+EXPORTS
+DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
+DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/Beta.h b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.h
new file mode 100644
index 000000000..b9c9bc918
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "Class.g.h"
+
+namespace winrt::Beta::implementation
+{
+ struct Class : ClassT
+ {
+ Class() = default;
+ };
+}
+
+namespace winrt::Beta::factory_implementation
+{
+ struct Class : ClassT
+ {
+ };
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/Beta.idl b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.idl
new file mode 100644
index 000000000..3d10bbe21
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.idl
@@ -0,0 +1,21 @@
+namespace Beta
+{
+ [default_interface]
+ runtimeclass Class
+ {
+ Class();
+ }
+
+ runtimeclass QIAgent
+ {
+ QIAgent();
+ Boolean CheckForIGamma(Alpha.IAlpha alpha);
+ Alpha.IAlpha IdentityAlpha(Alpha.IAlpha alpha);
+ Int32 Run(Alpha.IAlpha alpha);
+ }
+
+ interface IBeta
+ {
+ Int32 CallFive(Alpha.IAlpha a);
+ }
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj
new file mode 100644
index 000000000..b6eadcfc1
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj
@@ -0,0 +1,163 @@
+
+
+
+
+ true
+ true
+ true
+ true
+ {e1c44b28-965c-45ab-bcb4-475b627e32a6}
+ Beta
+ Beta
+ en-US
+ 14.0
+ true
+ Windows Store
+ 10.0
+ 10.0
+ 10.0.17134.0
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ ARM64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ ARM64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ DynamicLibrary
+ v143
+ v142
+ v141
+ v140
+ Unicode
+ false
+
+
+ true
+ true
+
+
+ false
+ true
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Use
+ pch.h
+ $(IntDir)pch.pch
+ Level4
+ %(AdditionalOptions) /bigobj
+
+ /DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)
+ _WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)
+ $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)
+
+
+ Console
+ false
+ Beta.def
+
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ Beta.idl
+
+
+
+
+
+ Create
+
+
+ Beta.idl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {9d73f8c2-332b-4aa9-95e3-59c92e68efb4}
+
+
+ {ddb1a216-1527-4f49-8729-17a6519659c8}
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj.filters b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj.filters
new file mode 100644
index 000000000..6bbd0a011
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/Beta.vcxproj.filters
@@ -0,0 +1,30 @@
+
+
+
+
+ accd3aa8-1ba0-4223-9bbe-0c431709210b
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {926ab91d-31b4-48c3-b9a4-e681349f27f0}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.cpp b/src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.cpp
new file mode 100644
index 000000000..21f516911
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.cpp
@@ -0,0 +1,21 @@
+#include "pch.h"
+#include "QIAgent.h"
+#include "QIAgent.g.cpp"
+
+namespace winrt::Beta::implementation
+{
+ bool QIAgent::CheckForIGamma(winrt::Alpha::IAlpha const& alpha)
+ {
+ return alpha.try_as() ? true : false;
+ }
+
+ winrt::Alpha::IAlpha QIAgent::IdentityAlpha(winrt::Alpha::IAlpha const& alpha)
+ {
+ return alpha;
+ }
+
+ int32_t QIAgent::Run(winrt::Alpha::IAlpha const& alpha)
+ {
+ return alpha.Five();
+ }
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.h b/src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.h
new file mode 100644
index 000000000..b06f98b9d
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/QIAgent.h
@@ -0,0 +1,20 @@
+#pragma once
+#include "QIAgent.g.h"
+
+namespace winrt::Beta::implementation
+{
+ struct QIAgent : QIAgentT
+ {
+ QIAgent() = default;
+
+ bool CheckForIGamma(winrt::Alpha::IAlpha const& alpha);
+ winrt::Alpha::IAlpha IdentityAlpha(winrt::Alpha::IAlpha const& alpha);
+ int32_t Run(winrt::Alpha::IAlpha const& alpha);
+ };
+}
+namespace winrt::Beta::factory_implementation
+{
+ struct QIAgent : QIAgentT
+ {
+ };
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/packages.config b/src/Samples/TestEmbedded/C++ Components/Beta/packages.config
new file mode 100644
index 000000000..fb20a4e61
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/pch.cpp b/src/Samples/TestEmbedded/C++ Components/Beta/pch.cpp
new file mode 100644
index 000000000..bcb5590be
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/pch.cpp
@@ -0,0 +1 @@
+#include "pch.h"
diff --git a/src/Samples/TestEmbedded/C++ Components/Beta/pch.h b/src/Samples/TestEmbedded/C++ Components/Beta/pch.h
new file mode 100644
index 000000000..5e5e277bc
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Beta/pch.h
@@ -0,0 +1,6 @@
+#pragma once
+#include
+#include
+#include
+#include
+#include
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.cpp b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.cpp
new file mode 100644
index 000000000..e4dd061e5
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.cpp
@@ -0,0 +1,7 @@
+#include "pch.h"
+#include "Gamma.h"
+#include "Class.g.cpp"
+
+namespace winrt::Gamma::implementation
+{
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.def b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.def
new file mode 100644
index 000000000..24e7c1235
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.def
@@ -0,0 +1,3 @@
+EXPORTS
+DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
+DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.h b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.h
new file mode 100644
index 000000000..1ff56087b
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "Class.g.h"
+
+namespace winrt::Gamma::implementation
+{
+ struct Class : ClassT
+ {
+ Class() = default;
+
+ };
+}
+
+namespace winrt::Gamma::factory_implementation
+{
+ struct Class : ClassT
+ {
+ };
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.idl b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.idl
new file mode 100644
index 000000000..b7fb5bac5
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.idl
@@ -0,0 +1,13 @@
+namespace Gamma
+{
+ [default_interface]
+ runtimeclass Class
+ {
+ Class();
+ }
+
+ interface IGamma
+ {
+ Int32 Six();
+ }
+}
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj
new file mode 100644
index 000000000..5629eab1b
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj
@@ -0,0 +1,153 @@
+
+
+
+
+ true
+ true
+ true
+ true
+ {ddb1a216-1527-4f49-8729-17a6519659c8}
+ Gamma
+ Gamma
+ en-US
+ 14.0
+ true
+ Windows Store
+ 10.0
+ 10.0
+ 10.0.17134.0
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ ARM64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ ARM64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ DynamicLibrary
+ v143
+ v142
+ v141
+ v140
+ Unicode
+ false
+
+
+ true
+ true
+
+
+ false
+ true
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Use
+ pch.h
+ $(IntDir)pch.pch
+ Level4
+ %(AdditionalOptions) /bigobj
+
+ /DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)
+ _WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)
+ $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)
+
+
+ Console
+ false
+ Gamma.def
+
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ Gamma.idl
+
+
+
+
+ Create
+
+
+ Gamma.idl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj.filters b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj.filters
new file mode 100644
index 000000000..dbbb5df72
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/Gamma.vcxproj.filters
@@ -0,0 +1,28 @@
+
+
+
+
+ accd3aa8-1ba0-4223-9bbe-0c431709210b
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {926ab91d-31b4-48c3-b9a4-e681349f27f0}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/packages.config b/src/Samples/TestEmbedded/C++ Components/Gamma/packages.config
new file mode 100644
index 000000000..fb20a4e61
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/pch.cpp b/src/Samples/TestEmbedded/C++ Components/Gamma/pch.cpp
new file mode 100644
index 000000000..bcb5590be
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/pch.cpp
@@ -0,0 +1 @@
+#include "pch.h"
diff --git a/src/Samples/TestEmbedded/C++ Components/Gamma/pch.h b/src/Samples/TestEmbedded/C++ Components/Gamma/pch.h
new file mode 100644
index 000000000..21199686d
--- /dev/null
+++ b/src/Samples/TestEmbedded/C++ Components/Gamma/pch.h
@@ -0,0 +1,4 @@
+#pragma once
+#include
+#include
+#include
diff --git a/src/Samples/TestEmbedded/Directory.Build.props b/src/Samples/TestEmbedded/Directory.Build.props
new file mode 100644
index 000000000..9851da811
--- /dev/null
+++ b/src/Samples/TestEmbedded/Directory.Build.props
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/Directory.Build.targets b/src/Samples/TestEmbedded/Directory.Build.targets
new file mode 100644
index 000000000..9851da811
--- /dev/null
+++ b/src/Samples/TestEmbedded/Directory.Build.targets
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/Net5App.Bootstrap/Net5App.Bootstrap.csproj b/src/Samples/TestEmbedded/Net5App.Bootstrap/Net5App.Bootstrap.csproj
new file mode 100644
index 000000000..5ca8ddb9d
--- /dev/null
+++ b/src/Samples/TestEmbedded/Net5App.Bootstrap/Net5App.Bootstrap.csproj
@@ -0,0 +1,54 @@
+
+
+
+ Exe
+ net5.0-windows
+
+
+
+
+ 9
+ true
+ 10.0.19041.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Alpha;
+ Beta;
+ Gamma;
+ Windows.Devices.Geolocation;
+ Windows.Foundation.Metadata
+ Windows.Foundation.UniversalApiContract;
+ Windows.Foundation.IAsyncOperation;
+ Windows.Foundation.TypedEventHandler;
+ Windows.Foundation.FoundationContract;
+ Windows.Foundation.IAsyncInfo;
+ Windows.Foundation.IAsyncAction;
+ Windows.Foundation.AsyncStatus;
+ Windows.Foundation.AsyncActionCompletedHandler;
+ Windows.Foundation.AsyncActionProgressHandler;
+ Windows.Foundation.AsyncActionWithProgressCompletedHandler;
+ Windows.Foundation.AsyncOperationProgressHandler;
+ Windows.Foundation.AsyncOperationCompletedHandler;
+ Windows.Foundation.AsyncOperationWithProgressCompletedHandler;
+
+
+
+
+
diff --git a/src/Samples/TestEmbedded/Net5App.Bootstrap/Program.cs b/src/Samples/TestEmbedded/Net5App.Bootstrap/Program.cs
new file mode 100644
index 000000000..8faf71f1e
--- /dev/null
+++ b/src/Samples/TestEmbedded/Net5App.Bootstrap/Program.cs
@@ -0,0 +1,113 @@
+using System;
+using Alpha;
+using Beta;
+using Gamma;
+using Windows.Devices.Geolocation;
+
+namespace Net5App.Bootstrap
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+
+ TestLib testLib = new();
+ Console.WriteLine("Expect 10, Got " + testLib.Test1());
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test2());
+
+ (bool, bool) pair = testLib.Test3();
+ Console.WriteLine("Expect false, Got " + pair.Item1);
+ Console.WriteLine("Expect true, Got " + pair.Item2);
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test4());
+
+ testLib.Test5();
+ }
+ }
+
+ class MyAlpha : IAlpha
+ {
+ public int Five() { return 5; }
+ }
+
+ class MyBeta : IBeta
+ {
+ public int CallFive(Alpha.IAlpha a) { return a.Five(); }
+ }
+
+ class MyGreek : IAlpha, IGamma
+ {
+ public int Five() { return 5; }
+ public int Six() { return 6; }
+ }
+
+ public class TestLib
+ {
+ Geolocator g;
+ public TestLib()
+ {
+ WinRT.ComWrappersSupport.RegisterProjectionAssembly(typeof(TestLib).Assembly);
+ g = new();
+ }
+
+ public void SetDesiredAccuracy()
+ {
+ g.DesiredAccuracy = PositionAccuracy.Default;
+ }
+
+ public void ShowDesiredAccuracy()
+ {
+ Console.WriteLine("Desired accuracy = " + g.DesiredAccuracy);
+ }
+
+ internal int Test1_Helper(IAlpha alpha) { return alpha.Five(); }
+
+ public int Test1()
+ {
+ MyAlpha a = new();
+ MyGreek g = new();
+ return Test1_Helper(a) + Test1_Helper(g);
+ }
+
+ internal IBeta Test2_Helper(IBeta beta) { return beta; }
+
+ public int Test2()
+ {
+ MyGreek g = new();
+ MyBeta b = new();
+ return b.CallFive(g);
+ }
+
+ public (bool, bool) Test3()
+ {
+ IAlpha myAlpha = new MyAlpha();
+ MyGreek myGreek = new();
+ QIAgent qiAgent = new();
+ return (qiAgent.CheckForIGamma(myAlpha), qiAgent.CheckForIGamma(myGreek));
+ }
+
+ internal QIAgent GetQIAgent() { return new QIAgent(); }
+
+ public int Test4()
+ {
+ QIAgent qiAgent = GetQIAgent();
+ var x = qiAgent.IdentityAlpha(new MyAlpha());
+ return qiAgent.Run(x);
+ }
+
+ async System.Threading.Tasks.Task CallGeoAsyncApi()
+ {
+ Geolocator g = new();
+ g.DesiredAccuracy = PositionAccuracy.Default;
+ Console.WriteLine("Desired accuracy " + g.DesiredAccuracy);
+ Geoposition pos = await g.GetGeopositionAsync();
+ }
+
+ public void Test5()
+ {
+ CallGeoAsyncApi().Wait(1000);
+ }
+ }
+}
diff --git a/src/Samples/TestEmbedded/Net5App/Net5App.csproj b/src/Samples/TestEmbedded/Net5App/Net5App.csproj
new file mode 100644
index 000000000..28439e44d
--- /dev/null
+++ b/src/Samples/TestEmbedded/Net5App/Net5App.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ x64;x86
+ net5.0-windows
+ sdk
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Samples/TestEmbedded/Net5App/Program.cs b/src/Samples/TestEmbedded/Net5App/Program.cs
new file mode 100644
index 000000000..06048dc29
--- /dev/null
+++ b/src/Samples/TestEmbedded/Net5App/Program.cs
@@ -0,0 +1,26 @@
+using System;
+using TestEmbeddedLibrary;
+
+namespace UseTestLib
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+
+ TestEmbeddedLibrary.TestLib testLib = new();
+ Console.WriteLine("Expect 10, Got " + testLib.Test1());
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test2());
+
+ (bool, bool) pair = testLib.Test3();
+ Console.WriteLine("Expect false, Got " + pair.Item1);
+ Console.WriteLine("Expect true, Got " + pair.Item2);
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test4());
+
+ testLib.Test5();
+ }
+ }
+}
diff --git a/src/Samples/TestEmbedded/Net5App/Properties/launchSettings.json b/src/Samples/TestEmbedded/Net5App/Properties/launchSettings.json
new file mode 100644
index 000000000..09a2fcb65
--- /dev/null
+++ b/src/Samples/TestEmbedded/Net5App/Properties/launchSettings.json
@@ -0,0 +1,8 @@
+{
+ "profiles": {
+ "Net5App": {
+ "commandName": "Project",
+ "nativeDebugging": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/NetCore3App/NetCore3App.csproj b/src/Samples/TestEmbedded/NetCore3App/NetCore3App.csproj
new file mode 100644
index 000000000..a75f547ba
--- /dev/null
+++ b/src/Samples/TestEmbedded/NetCore3App/NetCore3App.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ netcoreapp3.1
+ x64;x86
+ 9
+
+
+
+
+
+
+
diff --git a/src/Samples/TestEmbedded/NetCore3App/Program.cs b/src/Samples/TestEmbedded/NetCore3App/Program.cs
new file mode 100644
index 000000000..287a3e024
--- /dev/null
+++ b/src/Samples/TestEmbedded/NetCore3App/Program.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace NetCore3App
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+
+ TestEmbeddedLibrary.TestLib testLib = new();
+ Console.WriteLine("Expect 10, Got " + testLib.Test1());
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test2());
+
+ (bool, bool) pair = testLib.Test3();
+ Console.WriteLine("Expect false, Got " + pair.Item1);
+ Console.WriteLine("Expect true, Got " + pair.Item2);
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test4());
+
+ testLib.Test5();
+ }
+ }
+}
diff --git a/src/Samples/TestEmbedded/NetCore3App/Properties/launchSettings.json b/src/Samples/TestEmbedded/NetCore3App/Properties/launchSettings.json
new file mode 100644
index 000000000..c9ae992ec
--- /dev/null
+++ b/src/Samples/TestEmbedded/NetCore3App/Properties/launchSettings.json
@@ -0,0 +1,8 @@
+{
+ "profiles": {
+ "NetCore3App": {
+ "commandName": "Project",
+ "nativeDebugging": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/NetFrameworkApp/NetFrameworkApp.csproj b/src/Samples/TestEmbedded/NetFrameworkApp/NetFrameworkApp.csproj
new file mode 100644
index 000000000..febb4c2c1
--- /dev/null
+++ b/src/Samples/TestEmbedded/NetFrameworkApp/NetFrameworkApp.csproj
@@ -0,0 +1,51 @@
+
+
+
+ Exe
+ net47
+
+
+
+ 9
+ true
+ 10.0.19041.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Alpha;
+ Beta;
+ Gamma;
+ Windows.Devices.Geolocation;
+ Windows.Foundation.Metadata;
+ Windows.Foundation.UniversalApiContract;
+ Windows.Foundation.IAsyncOperation;
+ Windows.Foundation.TypedEventHandler;
+ Windows.Foundation.FoundationContract;
+ Windows.Foundation.IAsyncInfo;
+ Windows.Foundation.IAsyncAction;
+ Windows.Foundation.AsyncStatus;
+ Windows.Foundation.AsyncActionCompletedHandler;
+ Windows.Foundation.AsyncActionProgressHandler;
+ Windows.Foundation.AsyncActionWithProgressCompletedHandler;
+ Windows.Foundation.AsyncOperationProgressHandler;
+ Windows.Foundation.AsyncOperationCompletedHandler;
+ Windows.Foundation.AsyncOperationWithProgressCompletedHandler;
+
+
+
+
+
diff --git a/src/Samples/TestEmbedded/NetFrameworkApp/Program.cs b/src/Samples/TestEmbedded/NetFrameworkApp/Program.cs
new file mode 100644
index 000000000..a787df462
--- /dev/null
+++ b/src/Samples/TestEmbedded/NetFrameworkApp/Program.cs
@@ -0,0 +1,115 @@
+using System;
+using Alpha;
+using Beta;
+using Gamma;
+using Windows.Devices.Geolocation;
+
+namespace NetFrameworkApp
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+
+ TestLib testLib = new();
+ Console.WriteLine("Expect 10, Got " + testLib.Test1());
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test2());
+
+ (bool, bool) pair = testLib.Test3();
+ Console.WriteLine("Expect false, Got " + pair.Item1);
+ Console.WriteLine("Expect true, Got " + pair.Item2);
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test4());
+
+ testLib.Test5();
+
+ }
+ }
+
+ class MyAlpha : IAlpha
+ {
+ public int Five() { return 5; }
+ }
+
+ class MyBeta : IBeta
+ {
+ public int CallFive(Alpha.IAlpha a) { return a.Five(); }
+ }
+
+ class MyGreek : IAlpha, IGamma
+ {
+ public int Five() { return 5; }
+ public int Six() { return 6; }
+ }
+
+ public class TestLib
+ {
+ Geolocator g;
+ public TestLib()
+ {
+ WinRT.ComWrappersSupport.RegisterProjectionAssembly(typeof(TestLib).Assembly);
+ g = new();
+ }
+
+ public void SetDesiredAccuracy()
+ {
+ g.DesiredAccuracy = PositionAccuracy.Default;
+ }
+
+ public void ShowDesiredAccuracy()
+ {
+ Console.WriteLine("Desired accuracy = " + g.DesiredAccuracy);
+ }
+
+ internal int Test1_Helper(IAlpha alpha) { return alpha.Five(); }
+
+ public int Test1()
+ {
+ MyAlpha a = new();
+ MyGreek g = new();
+ return Test1_Helper(a) + Test1_Helper(g);
+ }
+
+ internal IBeta Test2_Helper(IBeta beta) { return beta; }
+
+ public int Test2()
+ {
+ MyGreek g = new();
+ MyBeta b = new();
+ return b.CallFive(g);
+ }
+
+ public (bool, bool) Test3()
+ {
+ IAlpha myAlpha = new MyAlpha();
+ MyGreek myGreek = new();
+ QIAgent qiAgent = new();
+ return (qiAgent.CheckForIGamma(myAlpha), qiAgent.CheckForIGamma(myGreek));
+ }
+
+ internal QIAgent GetQIAgent() { return new QIAgent(); }
+
+ public int Test4()
+ {
+ QIAgent qiAgent = GetQIAgent();
+ var x = qiAgent.IdentityAlpha(new MyAlpha());
+ return qiAgent.Run(x);
+ }
+
+ async System.Threading.Tasks.Task CallGeoAsyncApi()
+ {
+ Geolocator g = new();
+ g.DesiredAccuracy = PositionAccuracy.Default;
+ Console.WriteLine("Desired accuracy " + g.DesiredAccuracy);
+ Geoposition pos = await g.GetGeopositionAsync();
+ }
+
+ public void Test5()
+ {
+ CallGeoAsyncApi().Wait(1000);
+ }
+ }
+
+}
diff --git a/src/Samples/TestEmbedded/README.md b/src/Samples/TestEmbedded/README.md
new file mode 100644
index 000000000..8449e1455
--- /dev/null
+++ b/src/Samples/TestEmbedded/README.md
@@ -0,0 +1,16 @@
+# Structure
+
+This sample is composed of C++/WinRT components, a C#/WinRT projection that uses embedded support
+(WinRT and Windows SDK), and apps of various flavors that use the embedded projection.
+
+Looking at the C#/WinRT projection, `TestEmbeddedLibrary`, we see it targets several different frameworks,
+demonstrating support for the latest Windows SDK on all platforms.
+
+```xml
+ net6.0-windows;net5.0-windows;netstandard2.0;net48
+```
+
+Of the apps, `Net5App` and `NetCore3App` use the same C#/WinRT projection to make use of Windows 10 APIs
+like `Windows.Devices.Geolocation` via the embedded WinRT support provided by C#/WinRT.
+
+The other two, `Net5App.Bootstrap` and `NetFrameworkApp` demonstrate how an app can generate and embed the projection itself.
diff --git a/src/Samples/TestEmbedded/TestEmbedded.sln b/src/Samples/TestEmbedded/TestEmbedded.sln
new file mode 100644
index 000000000..a15c88d63
--- /dev/null
+++ b/src/Samples/TestEmbedded/TestEmbedded.sln
@@ -0,0 +1,233 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31624.102
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestEmbeddedLibrary", "TestEmbeddedLibrary\TestEmbeddedLibrary.csproj", "{A732BAA0-7E07-462F-B11B-179210D50C1A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "C++ Components", "C++ Components", "{8E83DE92-80F7-4DD8-9B87-1AB3D6A75E3B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Alpha", "C++ Components\Alpha\Alpha.vcxproj", "{9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Gamma", "C++ Components\Gamma\Gamma.vcxproj", "{DDB1A216-1527-4F49-8729-17A6519659C8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Beta", "C++ Components\Beta\Beta.vcxproj", "{E1C44B28-965C-45AB-BCB4-475B627E32A6}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{74BB315F-0E6B-4BC7-BDC6-C0C992A92B79}"
+ ProjectSection(SolutionItems) = preProject
+ Directory.Build.props = Directory.Build.props
+ Directory.Build.targets = Directory.Build.targets
+ README.md = README.md
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net5App", "Net5App\Net5App.csproj", "{1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCore3App", "NetCore3App\NetCore3App.csproj", "{9B147973-329B-4331-8207-B6832696D01A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestEmbedded", "UnitTestEmbedded\UnitTestEmbedded.csproj", "{C7796A44-CD3E-4A04-9BED-42D2233C1182}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetFrameworkApp", "NetFrameworkApp\NetFrameworkApp.csproj", "{6A457D15-4080-4CCA-9980-D418C2EE2BDF}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net5App.Bootstrap", "Net5App.Bootstrap\Net5App.Bootstrap.csproj", "{D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|ARM64 = Debug|ARM64
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|ARM64 = Release|ARM64
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|ARM.Build.0 = Debug|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|x64.ActiveCfg = Debug|x64
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|x64.Build.0 = Debug|x64
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|x86.ActiveCfg = Debug|x86
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Debug|x86.Build.0 = Debug|x86
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|ARM.ActiveCfg = Release|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|ARM.Build.0 = Release|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|ARM64.Build.0 = Release|Any CPU
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|x64.ActiveCfg = Release|x64
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|x64.Build.0 = Release|x64
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|x86.ActiveCfg = Release|x86
+ {A732BAA0-7E07-462F-B11B-179210D50C1A}.Release|x86.Build.0 = Release|x86
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|ARM.Build.0 = Debug|ARM
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|x64.ActiveCfg = Debug|x64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|x64.Build.0 = Debug|x64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|x86.ActiveCfg = Debug|Win32
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Debug|x86.Build.0 = Debug|Win32
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|Any CPU.ActiveCfg = Release|Win32
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|ARM.ActiveCfg = Release|ARM
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|ARM.Build.0 = Release|ARM
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|ARM64.Build.0 = Release|ARM64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|x64.ActiveCfg = Release|x64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|x64.Build.0 = Release|x64
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|x86.ActiveCfg = Release|Win32
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4}.Release|x86.Build.0 = Release|Win32
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|ARM.ActiveCfg = Debug|ARM
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|ARM.Build.0 = Debug|ARM
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|ARM64.Build.0 = Debug|ARM64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|x64.ActiveCfg = Debug|x64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|x64.Build.0 = Debug|x64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|x86.ActiveCfg = Debug|Win32
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Debug|x86.Build.0 = Debug|Win32
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|Any CPU.ActiveCfg = Release|Win32
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|ARM.ActiveCfg = Release|ARM
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|ARM.Build.0 = Release|ARM
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|ARM64.ActiveCfg = Release|ARM64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|ARM64.Build.0 = Release|ARM64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|x64.ActiveCfg = Release|x64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|x64.Build.0 = Release|x64
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|x86.ActiveCfg = Release|Win32
+ {DDB1A216-1527-4F49-8729-17A6519659C8}.Release|x86.Build.0 = Release|Win32
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|ARM.ActiveCfg = Debug|ARM
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|ARM.Build.0 = Debug|ARM
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|ARM64.Build.0 = Debug|ARM64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|x64.ActiveCfg = Debug|x64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|x64.Build.0 = Debug|x64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|x86.ActiveCfg = Debug|Win32
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Debug|x86.Build.0 = Debug|Win32
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|Any CPU.ActiveCfg = Release|Win32
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|ARM.ActiveCfg = Release|ARM
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|ARM.Build.0 = Release|ARM
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|ARM64.ActiveCfg = Release|ARM64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|ARM64.Build.0 = Release|ARM64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|x64.ActiveCfg = Release|x64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|x64.Build.0 = Release|x64
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|x86.ActiveCfg = Release|Win32
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6}.Release|x86.Build.0 = Release|Win32
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|ARM.ActiveCfg = Debug|ARM
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|ARM.Build.0 = Debug|ARM
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|ARM64.Build.0 = Debug|ARM64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|x64.ActiveCfg = Debug|x64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|x64.Build.0 = Debug|x64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|x86.ActiveCfg = Debug|x86
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Debug|x86.Build.0 = Debug|x86
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|ARM.ActiveCfg = Release|ARM
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|ARM.Build.0 = Release|ARM
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|ARM64.ActiveCfg = Release|ARM64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|ARM64.Build.0 = Release|ARM64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|x64.ActiveCfg = Release|x64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|x64.Build.0 = Release|x64
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|x86.ActiveCfg = Release|x86
+ {1FD2F1DA-ACF3-408F-BD13-9D1BA24833E0}.Release|x86.Build.0 = Release|x86
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|ARM.ActiveCfg = Debug|ARM
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|ARM.Build.0 = Debug|ARM
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|ARM64.Build.0 = Debug|ARM64
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|x64.ActiveCfg = Debug|x64
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|x64.Build.0 = Debug|x64
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|x86.ActiveCfg = Debug|x86
+ {9B147973-329B-4331-8207-B6832696D01A}.Debug|x86.Build.0 = Debug|x86
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|ARM.ActiveCfg = Release|ARM
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|ARM.Build.0 = Release|ARM
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|ARM64.ActiveCfg = Release|AR64
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|ARM64.Build.0 = Release|AR64
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|x64.ActiveCfg = Release|x64
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|x64.Build.0 = Release|x64
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|x86.ActiveCfg = Release|x86
+ {9B147973-329B-4331-8207-B6832696D01A}.Release|x86.Build.0 = Release|x86
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|ARM.ActiveCfg = Debug|ARM
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|ARM.Build.0 = Debug|ARM
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|ARM64.Build.0 = Debug|ARM64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|x64.ActiveCfg = Debug|x64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|x64.Build.0 = Debug|x64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|x86.ActiveCfg = Debug|x86
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Debug|x86.Build.0 = Debug|x86
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|ARM.ActiveCfg = Release|ARM
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|ARM.Build.0 = Release|ARM
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|ARM64.ActiveCfg = Release|ARM64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|ARM64.Build.0 = Release|ARM64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|x64.ActiveCfg = Release|x64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|x64.Build.0 = Release|x64
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|x86.ActiveCfg = Release|x86
+ {C7796A44-CD3E-4A04-9BED-42D2233C1182}.Release|x86.Build.0 = Release|x86
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|ARM.Build.0 = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|x64.Build.0 = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Debug|x86.Build.0 = Debug|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|ARM.ActiveCfg = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|ARM.Build.0 = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|ARM64.Build.0 = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|x64.ActiveCfg = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|x64.Build.0 = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|x86.ActiveCfg = Release|Any CPU
+ {6A457D15-4080-4CCA-9980-D418C2EE2BDF}.Release|x86.Build.0 = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|ARM.Build.0 = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|x64.Build.0 = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Debug|x86.Build.0 = Debug|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|ARM.ActiveCfg = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|ARM.Build.0 = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|ARM64.Build.0 = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|x64.ActiveCfg = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|x64.Build.0 = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|x86.ActiveCfg = Release|Any CPU
+ {D2D4B83C-1E8B-44F0-BCC3-217B6D9141FB}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {9D73F8C2-332B-4AA9-95E3-59C92E68EFB4} = {8E83DE92-80F7-4DD8-9B87-1AB3D6A75E3B}
+ {DDB1A216-1527-4F49-8729-17A6519659C8} = {8E83DE92-80F7-4DD8-9B87-1AB3D6A75E3B}
+ {E1C44B28-965C-45AB-BCB4-475B627E32A6} = {8E83DE92-80F7-4DD8-9B87-1AB3D6A75E3B}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F19FA462-5CB6-4621-AEFD-0ADE3A3499B1}
+ EndGlobalSection
+EndGlobal
diff --git a/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj b/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj
new file mode 100644
index 000000000..d7cca46b2
--- /dev/null
+++ b/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestEmbeddedLibrary.csproj
@@ -0,0 +1,52 @@
+
+
+
+ net6.0-windows;net5.0-windows;netstandard2.0;net48
+ x64;x86
+
+
+
+ 9
+ true
+ 10.0.19041.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Alpha;
+ Beta;
+ Gamma;
+ Windows.Devices.Geolocation;
+ Windows.Foundation.Metadata;
+ Windows.Foundation.UniversalApiContract;
+ Windows.Foundation.IAsyncOperation;
+ Windows.Foundation.TypedEventHandler;
+ Windows.Foundation.UniversalApiContract;
+ Windows.Foundation.FoundationContract;
+ Windows.Foundation.IAsyncInfo;
+ Windows.Foundation.IAsyncAction;
+ Windows.Foundation.AsyncStatus;
+ Windows.Foundation.AsyncActionCompletedHandler;
+ Windows.Foundation.AsyncActionProgressHandler;
+ Windows.Foundation.AsyncActionWithProgressCompletedHandler;
+ Windows.Foundation.AsyncOperationProgressHandler;
+ Windows.Foundation.AsyncOperationCompletedHandler;
+ Windows.Foundation.AsyncOperationWithProgressCompletedHandler;
+
+
+
diff --git a/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestLib.cs b/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestLib.cs
new file mode 100644
index 000000000..270412b25
--- /dev/null
+++ b/src/Samples/TestEmbedded/TestEmbeddedLibrary/TestLib.cs
@@ -0,0 +1,93 @@
+using System;
+using Alpha;
+using Beta;
+using Gamma;
+using Windows.Devices.Geolocation;
+
+namespace TestEmbeddedLibrary
+{
+ class MyAlpha : IAlpha
+ {
+ public int Five() { return 5; }
+ }
+
+ class MyBeta : IBeta
+ {
+ public int CallFive(Alpha.IAlpha a) { return a.Five(); }
+ }
+
+ class MyGreek : IAlpha, IGamma
+ {
+ public int Five() { return 5; }
+ public int Six() { return 6; }
+ }
+
+ public class TestLib
+ {
+ Geolocator g;
+ public TestLib()
+ {
+ WinRT.ComWrappersSupport.RegisterProjectionAssembly(typeof(TestLib).Assembly);
+ g = new();
+ }
+
+ public void SetDesiredAccuracy()
+ {
+ g.DesiredAccuracy = PositionAccuracy.Default;
+ }
+
+ public void ShowDesiredAccuracy()
+ {
+ Console.WriteLine("Desired accuracy = " + g.DesiredAccuracy);
+ }
+
+ internal int Test1_Helper(IAlpha alpha) { return alpha.Five(); }
+
+ public int Test1()
+ {
+ MyAlpha a = new();
+ MyGreek g = new();
+ return Test1_Helper(a) + Test1_Helper(g);
+ }
+
+ internal IBeta Test2_Helper(IBeta beta) { return beta; }
+
+ public int Test2()
+ {
+ MyGreek g = new();
+ MyBeta b = new();
+ return b.CallFive(g);
+ }
+
+ public (bool, bool) Test3()
+ {
+ IAlpha myAlpha = new MyAlpha();
+ MyGreek myGreek = new();
+ QIAgent qiAgent = new();
+ return (qiAgent.CheckForIGamma(myAlpha), qiAgent.CheckForIGamma(myGreek));
+ }
+
+ internal QIAgent GetQIAgent() { return new QIAgent(); }
+
+ public int Test4()
+ {
+ QIAgent qiAgent = GetQIAgent();
+ var x = qiAgent.IdentityAlpha(new MyAlpha());
+ return qiAgent.Run(x);
+ }
+
+ async System.Threading.Tasks.Task CallGeoAsyncApi()
+ {
+ Geolocator g = new();
+ g.DesiredAccuracy = PositionAccuracy.Default;
+ Console.WriteLine("Desired accuracy " + g.DesiredAccuracy);
+ Geoposition pos = await g.GetGeopositionAsync();
+ }
+
+ public void Test5()
+ {
+ CallGeoAsyncApi().Wait(1000);
+ }
+ }
+
+}
diff --git a/src/Samples/TestEmbedded/UnitTestEmbedded/TestClass.cs b/src/Samples/TestEmbedded/UnitTestEmbedded/TestClass.cs
new file mode 100644
index 000000000..5c3ab0a48
--- /dev/null
+++ b/src/Samples/TestEmbedded/UnitTestEmbedded/TestClass.cs
@@ -0,0 +1,43 @@
+using System;
+using Xunit;
+
+namespace UnitTestEmbedded
+{
+ public class TestClass
+ {
+ TestEmbeddedLibrary.TestLib TestLib = new();
+
+ [Fact]
+ public void Test1()
+ {
+ Assert.Equal(10, TestLib.Test1());
+ }
+
+ [Fact]
+ public void Test2()
+ {
+ Assert.Equal(5, TestLib.Test2());
+ }
+
+ [Fact]
+ public void Test3()
+ {
+ (bool, bool) pair = TestLib.Test3();
+ Assert.True(!pair.Item1);
+ Assert.True(pair.Item2);
+ }
+
+ [Fact]
+ public void Test4()
+ {
+ Assert.Equal(5, TestLib.Test4());
+ }
+
+ [Fact]
+ public void Test5()
+ {
+ TestLib.Test5();
+ Assert.True(true);
+ }
+ }
+}
diff --git a/src/Samples/TestEmbedded/UnitTestEmbedded/UnitTestEmbedded.csproj b/src/Samples/TestEmbedded/UnitTestEmbedded/UnitTestEmbedded.csproj
new file mode 100644
index 000000000..1e134ea37
--- /dev/null
+++ b/src/Samples/TestEmbedded/UnitTestEmbedded/UnitTestEmbedded.csproj
@@ -0,0 +1,36 @@
+
+
+
+ netcoreapp2.0;net5.0;net6.0
+ x64;x86
+ false
+ 9
+ false
+
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/src/Samples/TestEmbedded/UseTestLib/Program.cs b/src/Samples/TestEmbedded/UseTestLib/Program.cs
new file mode 100644
index 000000000..06048dc29
--- /dev/null
+++ b/src/Samples/TestEmbedded/UseTestLib/Program.cs
@@ -0,0 +1,26 @@
+using System;
+using TestEmbeddedLibrary;
+
+namespace UseTestLib
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello World!");
+
+ TestEmbeddedLibrary.TestLib testLib = new();
+ Console.WriteLine("Expect 10, Got " + testLib.Test1());
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test2());
+
+ (bool, bool) pair = testLib.Test3();
+ Console.WriteLine("Expect false, Got " + pair.Item1);
+ Console.WriteLine("Expect true, Got " + pair.Item2);
+
+ Console.WriteLine("Expect 5, Got " + testLib.Test4());
+
+ testLib.Test5();
+ }
+ }
+}
diff --git a/src/Samples/TestEmbedded/UseTestLib/Properties/launchSettings.json b/src/Samples/TestEmbedded/UseTestLib/Properties/launchSettings.json
new file mode 100644
index 000000000..973b135b2
--- /dev/null
+++ b/src/Samples/TestEmbedded/UseTestLib/Properties/launchSettings.json
@@ -0,0 +1,8 @@
+{
+ "profiles": {
+ "UseTestLib": {
+ "commandName": "Project",
+ "nativeDebugging": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Samples/TestEmbedded/UseTestLib/UseTestLib.csproj b/src/Samples/TestEmbedded/UseTestLib/UseTestLib.csproj
new file mode 100644
index 000000000..481a6ab24
--- /dev/null
+++ b/src/Samples/TestEmbedded/UseTestLib/UseTestLib.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ net5.0
+
+
+
+ 10.0.19041.0
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Samples/TestEmbedded/clean.cmd b/src/Samples/TestEmbedded/clean.cmd
new file mode 100644
index 000000000..ee68aeb16
--- /dev/null
+++ b/src/Samples/TestEmbedded/clean.cmd
@@ -0,0 +1,34 @@
+@echo off
+
+set this_dir=%~dp0
+
+rd /q/s "%this_dir%\C++ Components\Alpha\Generated Files"
+rd /q/s "%this_dir%\C++ Components\Alpha\x64"
+rd /q/s "%this_dir%\C++ Components\Alpha\x86"
+
+rd /q/s "%this_dir%\C++ Components\Beta\Generated Files"
+rd /q/s "%this_dir%\C++ Components\Beta\x64"
+rd /q/s "%this_dir%\C++ Components\Beta\x86"
+
+rd /q/s "%this_dir%\C++ Components\Gamma\Generated Files"
+rd /q/s "%this_dir%\C++ Components\Gamma\x64"
+rd /q/s "%this_dir%\C++ Components\Gamma\x86"
+
+rd /q/s "%this_dir%\Net5App\bin"
+rd /q/s "%this_dir%\Net5App\obj"
+
+rd /q/s "%this_dir%\NetCore3App\bin"
+rd /q/s "%this_dir%\NetCore3App\obj"
+
+rd /q/s "%this_dir%\TestEmbeddedLibrary\bin"
+rd /q/s "%this_dir%\TestEmbeddedLibrary\obj"
+
+rd /q/s "%this_dir%\x64"
+rd /q/s "%this_dir%\x86"
+
+rd /q/s "%this_dir%\UnitTestEmbedded\bin"
+rd /q/s "%this_dir%\UnitTestEmbedded\obj"
+
+msbuild %this_dir%\TestEmbedded.sln /t:restore
+
+nuget restore TestEmbedded.sln
\ No newline at end of file
diff --git a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs
index 6fba76674..0fcfc71da 100644
--- a/src/Tests/UnitTest/TestComponentCSharp_Tests.cs
+++ b/src/Tests/UnitTest/TestComponentCSharp_Tests.cs
@@ -1458,7 +1458,7 @@ public void TestCCWMarshaler()
Assert.NotNull(marshalCCW2);
}
-#if !NETCOREAPP2_0
+#if NET
[Fact]
public void TestDelegateCCWMarshaler()
{
diff --git a/src/WinRT.Runtime/Interop/IWeakReferenceSource.net5.cs b/src/WinRT.Runtime/Interop/IWeakReferenceSource.net5.cs
index f331ab9e7..9158019d6 100644
--- a/src/WinRT.Runtime/Interop/IWeakReferenceSource.net5.cs
+++ b/src/WinRT.Runtime/Interop/IWeakReferenceSource.net5.cs
@@ -52,7 +52,12 @@ public IObjectReference Resolve(Guid riid)
namespace ABI.WinRT.Interop
{
- public static class IWeakReferenceSourceMethods
+#if EMBED
+ internal
+#else
+ public
+#endif
+ static class IWeakReferenceSourceMethods
{
public static unsafe global::WinRT.Interop.IWeakReference GetWeakReference(IObjectReference _obj)
{
diff --git a/src/build.cmd b/src/build.cmd
index 75c8e3a79..083ed7eb0 100644
--- a/src/build.cmd
+++ b/src/build.cmd
@@ -150,12 +150,22 @@ if ErrorLevel 1 (
)
if "%cswinrt_build_only%"=="true" goto :eof
+:buildembedded
+echo Building embedded sample for %cswinrt_platform% %cswinrt_configuration%
+call :exec %nuget_dir%\nuget.exe restore %nuget_params% %this_dir%Samples\TestEmbedded\TestEmbedded.sln
+call :exec %msbuild_path%msbuild.exe %this_dir%\Samples\TestEmbedded\TestEmbedded.sln /t:restore /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%
+call :exec %msbuild_path%msbuild.exe %this_dir%\Samples\TestEmbedded\TestEmbedded.sln /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration% /bl:embeddedsample.binlog
+if ErrorLevel 1 (
+ echo.
+ echo ERROR: Embedded build failed
+ exit /b !ErrorLevel!
+)
+
rem Tests are not yet enabled for ARM builds (not supported by Project Reunion)
if %cswinrt_platform%==arm goto :eof
if %cswinrt_platform%==arm64 goto :eof
:test
-:unittest
rem Build/Run xUnit tests, generating xml output report for Azure Devops reporting, via XunitXml.TestLogger NuGet
if %cswinrt_platform%==x86 (
set dotnet_exe="%DOTNET_ROOT(86)%\dotnet.exe"
@@ -170,6 +180,15 @@ if not exist %dotnet_exe% (
)
)
+:embeddedtests
+:: build the embedded sample and run the unittest
+call :exec %dotnet_exe% test --verbosity normal --no-build --logger xunit;LogFilePath=%~dp0embedunittest_%cswinrt_version_string%.xml %this_dir%Samples/TestEmbedded/UnitTestEmbedded/UnitTestEmbedded.csproj /nologo /m /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%
+if ErrorLevel 1 (
+ echo.
+ echo ERROR: Embedded unit test failed, skipping NuGet pack
+ exit /b !ErrorLevel!
+)
+
:objectlifetimetests
rem Running Object Lifetime Unit Tests
echo Running object lifetime tests for %cswinrt_platform% %cswinrt_configuration%
@@ -181,6 +200,7 @@ if ErrorLevel 1 (
exit /b !ErrorLevel!
)
+:unittest
rem WinUI NuGet package's Microsoft.WinUI.AppX.targets attempts to import a file that does not exist, even when
rem executing "dotnet test --no-build ...", which evidently still needs to parse and load the entire project.
rem Work around by using a dummy targets file and assigning it to the MsAppxPackageTargets property.
@@ -214,6 +234,7 @@ if ErrorLevel 1 (
)
:package
+rem We set the properties of the CsWinRT.nuspec here, and pass them as the -Properties option when we call `nuget pack`
set cswinrt_bin_dir=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\cswinrt\bin\
set cswinrt_exe=%cswinrt_bin_dir%cswinrt.exe
set interop_winmd=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\cswinrt\obj\merged\WinRT.Interop.winmd
@@ -223,6 +244,7 @@ set source_generator=%this_dir%Authoring\WinRT.SourceGenerator\bin\%cswinrt_conf
set winrt_host_%cswinrt_platform%=%this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\WinRT.Host\bin\WinRT.Host.dll
set winrt_shim=%this_dir%Authoring\WinRT.Host.Shim\bin\%cswinrt_configuration%\net5.0\WinRT.Host.Shim.dll
set guid_patch=%this_dir%Perf\IIDOptimizer\bin\%cswinrt_configuration%\net5.0\*.*
+rem Now call pack
echo Creating nuget package
call :exec %nuget_dir%\nuget pack %this_dir%..\nuget\Microsoft.Windows.CsWinRT.nuspec -Properties cswinrt_exe=%cswinrt_exe%;interop_winmd=%interop_winmd%;netstandard2_runtime=%netstandard2_runtime%;net5_runtime=%net5_runtime%;source_generator=%source_generator%;cswinrt_nuget_version=%cswinrt_version_string%;winrt_host_x86=%winrt_host_x86%;winrt_host_x64=%winrt_host_x64%;winrt_host_arm=%winrt_host_arm%;winrt_host_arm64=%winrt_host_arm64%;winrt_shim=%winrt_shim%;guid_patch=%guid_patch% -OutputDirectory %cswinrt_bin_dir% -NonInteractive -Verbosity Detailed -NoPackageAnalysis
goto :eof
diff --git a/src/cswinrt.sln b/src/cswinrt.sln
index 21c28bf37..4d2dea17a 100644
--- a/src/cswinrt.sln
+++ b/src/cswinrt.sln
@@ -59,6 +59,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Nuget", "Nuget", "{967889B0
..\nuget\LICENSE = ..\nuget\LICENSE
..\nuget\Microsoft.Windows.CsWinRT.Authoring.targets = ..\nuget\Microsoft.Windows.CsWinRT.Authoring.targets
..\nuget\Microsoft.Windows.CsWinRT.Authoring.Transitive.targets = ..\nuget\Microsoft.Windows.CsWinRT.Authoring.Transitive.targets
+ ..\nuget\Microsoft.Windows.CsWinRT.Embedded.targets = ..\nuget\Microsoft.Windows.CsWinRT.Embedded.targets
..\nuget\Microsoft.Windows.CsWinRT.IIDOptimizer.targets = ..\nuget\Microsoft.Windows.CsWinRT.IIDOptimizer.targets
..\nuget\Microsoft.Windows.CsWinRT.nuspec = ..\nuget\Microsoft.Windows.CsWinRT.nuspec
..\nuget\Microsoft.Windows.CsWinRT.props = ..\nuget\Microsoft.Windows.CsWinRT.props
diff --git a/src/cswinrt/strings/WinRT.cs b/src/cswinrt/strings/WinRT.cs
index 43b584a99..dd8c051c1 100644
--- a/src/cswinrt/strings/WinRT.cs
+++ b/src/cswinrt/strings/WinRT.cs
@@ -120,7 +120,7 @@ private static unsafe bool TryCreate(string fileName, out DllModule module)
// Explicitly look for module in the same directory as this one, and
// use altered search path to ensure any dependencies in the same directory are found.
var moduleHandle = Platform.LoadLibraryExW(System.IO.Path.Combine(_currentModuleDirectory, fileName), IntPtr.Zero, /* LOAD_WITH_ALTERED_SEARCH_PATH */ 8);
-#if !NETSTANDARD2_0 && !NETCOREAPP2_0
+#if NET
if (moduleHandle == IntPtr.Zero)
{
NativeLibrary.TryLoad(fileName, Assembly.GetExecutingAssembly(), null, out moduleHandle);
@@ -557,7 +557,7 @@ public static void Remove(IntPtr thisPtr, int index, System.WeakReference
{
if (caches.TryGetValue(thisPtr, out var cache))
{
-#if NETSTANDARD2_0
+#if !NET
// https://devblogs.microsoft.com/pfxteam/little-known-gems-atomic-conditional-removals-from-concurrentdictionary/
((ICollection>>)cache.states).Remove(
new KeyValuePair>(index, state));