-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AdaptiveCards Template WinRT Component (#8805)
* added a new project file * added test app and c# winrt component * mostly working? * fix impl * updated nuget path * added c# runtime component * updated * updated * updated * updated * updated * updated * updated * updated * update * removed winrt prject from AC and added C++ console sample app and the AC project to visualizer * removed nuget config changes --------- Co-authored-by: Paul Campbell <paulcam@microsoft.com>
- Loading branch information
1 parent
b1972c6
commit fcebb6d
Showing
14 changed files
with
532 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
source/dotnet/Library/AdaptiveCards.Templating.CSharp.WinRT/AdaptiveCards.Template.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework> | ||
<Platforms>x86;x64;arm64</Platforms> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<CsWinRTComponent>true</CsWinRTComponent> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AdaptiveCards.Templating" Version="1.5.0" /> | ||
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
34 changes: 34 additions & 0 deletions
34
source/dotnet/Library/AdaptiveCards.Templating.CSharp.WinRT/AdaptiveCardsTemplate.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,34 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
// AdaptiveCards template windows runtime component library | ||
namespace AdaptiveCards.Template | ||
{ | ||
/// <summary> | ||
/// AdaptiveCards template windows runtime component library | ||
/// </summary> | ||
public sealed class AdaptiveCardTemplate | ||
{ | ||
/// <summary> | ||
/// Given a JSON template, create a AdaptiveCardTemplate object that can be used to expand the template | ||
/// </summary> | ||
/// <param name="jsonTemplate">JSON serialized AdaptiveCard Template</param> | ||
public AdaptiveCardTemplate(String jsonTemplate) | ||
{ | ||
adaptiveCardTemplate = new AdaptiveCards.Templating.AdaptiveCardTemplate(jsonTemplate); | ||
} | ||
|
||
/// <summary> | ||
/// Expands the template with the given data | ||
/// </summary> | ||
/// <param name="rootData">JSON serialized data for AdaptiveCard template</param> | ||
/// <returns></returns> | ||
public string Expand(String rootData) | ||
{ | ||
return adaptiveCardTemplate.Expand(rootData); | ||
} | ||
|
||
private AdaptiveCards.Templating.AdaptiveCardTemplate adaptiveCardTemplate; | ||
|
||
} | ||
} |
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
149 changes: 149 additions & 0 deletions
149
source/dotnet/Library/CppConsoleApp/CppConsoleApp.vcxproj
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,149 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" /> | ||
<PropertyGroup Label="Globals"> | ||
<CppWinRTOptimized>true</CppWinRTOptimized> | ||
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge> | ||
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata> | ||
<MinimalCoreWin>true</MinimalCoreWin> | ||
<VCProjectVersion>15.0</VCProjectVersion> | ||
<ProjectGuid>{ed459eec-7211-403e-8c08-78a43a05a7be}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>CppConsoleApp</RootNamespace> | ||
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.22621.0</WindowsTargetPlatformVersion> | ||
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion> | ||
<ProjectName>TemplateCppConsoleTestApp</ProjectName> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|arm64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>arm64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|arm64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>arm64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset> | ||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset> | ||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets"> | ||
<Import Project="PropertySheet.props" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> | ||
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile> | ||
<PreprocessorDefinitions>_CONSOLE;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<WarningLevel>Level4</WarningLevel> | ||
<TreatWarningAsError>true</TreatWarningAsError> | ||
<ControlFlowGuard>Guard</ControlFlowGuard> | ||
<AdditionalOptions>%(AdditionalOptions) /permissive- /bigobj</AdditionalOptions> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'"> | ||
<ClCompile> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<DebugInformationFormat Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ProgramDatabase</DebugInformationFormat> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
<AdditionalOptions>/profile /DEBUGTYPE:FIXUP %(AdditionalOptions)</AdditionalOptions> | ||
<AdditionalLibraryDirectories>$(VC_LibraryPath_VC_OneCore_CurrentPlatform_spectre);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'"> | ||
<ClCompile> | ||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<DebugInformationFormat Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ProgramDatabase</DebugInformationFormat> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'"> | ||
<ClCompile> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClInclude Include="pch.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="main.cpp" /> | ||
<ClCompile Include="pch.cpp"> | ||
<PrecompiledHeader>Create</PrecompiledHeader> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<None Include="PropertySheet.props" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Manifest Include="TemplateCppConsoleTestApp.exe.manifest"> | ||
<DeploymentContent>true</DeploymentContent> | ||
</Manifest> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" /> | ||
<Import Project="..\..\packages\AdaptiveCards.Template.1.0.0\build\AdaptiveCards.Template.targets" Condition="Exists('..\..\packages\AdaptiveCards.Template.1.0.0\build\AdaptiveCards.Template.targets')" /> | ||
</ImportGroup> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>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}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.props'))" /> | ||
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.240111.5\build\native\Microsoft.Windows.CppWinRT.targets'))" /> | ||
<Error Condition="!Exists('..\..\packages\AdaptiveCards.Template.1.0.0\build\AdaptiveCards.Template.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\AdaptiveCards.Template.1.0.0\build\AdaptiveCards.Template.targets'))" /> | ||
</Target> | ||
</Project> |
37 changes: 37 additions & 0 deletions
37
source/dotnet/Library/CppConsoleApp/CppConsoleApp.vcxproj.filters
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,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="pch.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="pch.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="main.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="PropertySheet.props" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Manifest Include="TemplateCppConsoleTestApp.exe.manifest" /> | ||
</ItemGroup> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ImportGroup Label="PropertySheets" /> | ||
<PropertyGroup Label="UserMacros" /> | ||
<!-- | ||
To customize common C++/WinRT project properties: | ||
* right-click the project node | ||
* expand the Common Properties item | ||
* select the C++/WinRT property page | ||
For more advanced scenarios, and complete documentation, please see: | ||
https://github.com/Microsoft/cppwinrt/tree/master/nuget | ||
--> | ||
<PropertyGroup /> | ||
<ItemDefinitionGroup /> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
source/dotnet/Library/CppConsoleApp/TemplateCppConsoleTestApp.exe.manifest
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<assemblyIdentity version="1.0.0.0" name="TemplateCppConsoleTestApp"/> | ||
<file name="WinRT.Host.dll"> | ||
<activatableClass | ||
name="AdaptiveCards.Template.AdaptiveCardTemplate" | ||
threadingModel="both" | ||
xmlns="urn:schemas-microsoft-com:winrt.v1" /> | ||
</file> | ||
</assembly> |
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,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "pch.h" | ||
|
||
using namespace winrt; | ||
using namespace Windows::Foundation; | ||
|
||
// Sample Test App for AdaptiveCards.Template project which is a C#/WinRT component | ||
int main() | ||
{ | ||
init_apartment(); | ||
|
||
hstring input{ | ||
L"{\"type\": \"AdaptiveCard\",\"body\": [{\"type\": \"TextBlock\",\"text\": \"Hello, ${hi}!\"}]}"}; | ||
|
||
AdaptiveCards::Template::AdaptiveCardTemplate adaptiveCardTemplate{ input }; | ||
|
||
hstring data{ L"{\"hi\": \"world\"}" }; | ||
auto result = adaptiveCardTemplate.Expand(data); | ||
|
||
std::cout << "Expanded: " << to_string(result) << std::endl; | ||
|
||
return 0; | ||
}; |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="AdaptiveCards.Template" version="1.0.0" targetFramework="native" /> | ||
<package id="Microsoft.Windows.CppWinRT" version="2.0.240111.5" targetFramework="native" /> | ||
</packages> |
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,3 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
#include "pch.h" |
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 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
|
||
#include <iostream> | ||
|
||
#include <winrt/Windows.Foundation.h> | ||
#include <winrt/Windows.Foundation.Collections.h> | ||
#include <winrt/AdaptiveCards.Template.h> |