Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
23c016d
Add .net core project
almedina-ms Jul 8, 2019
1239d01
Remove generated images
almedina-ms Jul 8, 2019
948d360
Merge branch 'master' into user/almedina-ms/NETCore
Sep 5, 2019
dce07f8
Merge branch 'master' into user/almedina-ms/NETCore
almedina-ms Sep 24, 2019
c74d9a3
Add reference for handling fonts
almedina-ms Sep 24, 2019
407b246
Merge branch 'master' into user/almedina-ms/NETCore
Sep 25, 2019
e37bbf8
Add global.json
almedina-ms Sep 25, 2019
ffd0115
Merge branch 'user/almedina-ms/NETCore' of https://github.com/Microso…
almedina-ms Sep 25, 2019
e0e938a
Update global.json
almedina-ms Sep 25, 2019
3ca791f
Change globals location
almedina-ms Sep 25, 2019
d909fba
Go back in time to use a previous 3.0 version
almedina-ms Sep 25, 2019
36ccde4
Change global.json version
almedina-ms Sep 26, 2019
33d836e
Merge branch 'master' into user/almedina-ms/NETCore
almedina-ms Sep 26, 2019
cbeb3c9
Retry v 3.0.100
almedina-ms Sep 26, 2019
4f8e3fa
Go gack in version before contacting support
almedina-ms Sep 26, 2019
3d6007f
Change version to last for 16.2
almedina-ms Sep 26, 2019
76771fe
Fix version
almedina-ms Sep 26, 2019
0a27d94
Try to fix test file
almedina-ms Sep 26, 2019
456ee6a
Try to not add extra file
almedina-ms Sep 26, 2019
9d36a8e
Revert "Try to not add extra file"
almedina-ms Sep 26, 2019
352d961
Merge branch 'master' into user/almedina-ms/NETCore
almedina-ms Sep 26, 2019
b076776
Merge branch 'master' into user/almedina-ms/NETCore
almedina-ms Oct 11, 2019
78d44bb
Fix tabs
almedina-ms Oct 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 104 additions & 2 deletions source/dotnet/AdaptiveCards.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
# Visual Studio Version 16
VisualStudioVersion = 16.0.29025.244

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not ready to support VS2019 at this time :(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this page we should use .net core 3.0 with the latest preview of Visual Studio, I could try Visual Studio 17 to check if it works too there

https://dotnet.microsoft.com/download/dotnet-core/3.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But according to this one we must use 2019

Prerequisites for .NET Core 3.0 Preview 3

.NET Core 3.0 Preview 3 has the same prerequisites as other versions of .NET Core. However, if you want to use Visual Studio to create .NET Core 3.0 projects, you must use the Visual Studio 2019. Visual Studio 2019 can be installed side-by-side with other versions of Visual Studio without conflict.

https://docs.microsoft.com/en-us/dotnet/core/windows-prerequisites?tabs=netcore2x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paul Campbell (@paulcam206), almedina-ms what happened around this one? Are we ready to roll up to VS 2019? Let's try to close on this one!

MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{C443BF0A-C616-4E98-8994-C5BAE76AE556}"
EndProject
Expand Down Expand Up @@ -31,6 +31,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageRendererServer", "Samp
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "AdaptiveCards.Sample.WPFVisualizer.PackageProject", "Samples\WPFVisualizer.PackageProject\AdaptiveCards.Sample.WPFVisualizer.PackageProject.wapproj", "{71340F5E-2B3B-4F1D-B113-236BBB0D7632}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdaptiveCards.Rendering.Wpf.Core", "Library\AdaptiveCards.Rendering.Wpf.Core\AdaptiveCards.Rendering.Wpf.Core.csproj", "{34F849F9-E349-4237-B7CB-A63884DAB39D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdaptiveCards.Core.Sample.ImageRender", "Samples\AdaptiveCards.Core.Sample.ImageRender\AdaptiveCards.Core.Sample.ImageRender.csproj", "{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Expand Down Expand Up @@ -611,6 +615,102 @@ Global
{71340F5E-2B3B-4F1D-B113-236BBB0D7632}.Release|x86.ActiveCfg = Release|x86
{71340F5E-2B3B-4F1D-B113-236BBB0D7632}.Release|x86.Build.0 = Release|x86
{71340F5E-2B3B-4F1D-B113-236BBB0D7632}.Release|x86.Deploy.0 = Release|x86
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|ARM.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|iPhone.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|x64.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|x64.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|x86.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.AppStore|x86.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|ARM.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|iPhone.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|x64.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|x64.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|x86.ActiveCfg = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Debug|x86.Build.0 = Debug|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|Any CPU.Build.0 = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|ARM.ActiveCfg = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|ARM.Build.0 = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|iPhone.ActiveCfg = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|iPhone.Build.0 = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|x64.ActiveCfg = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|x64.Build.0 = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|x86.ActiveCfg = Release|Any CPU
{34F849F9-E349-4237-B7CB-A63884DAB39D}.Release|x86.Build.0 = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|ARM.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|iPhone.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|x64.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|x64.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|x86.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.AppStore|x86.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|ARM.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|iPhone.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|x64.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|x64.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|x86.ActiveCfg = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Debug|x86.Build.0 = Debug|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|Any CPU.Build.0 = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|ARM.ActiveCfg = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|ARM.Build.0 = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|iPhone.ActiveCfg = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|iPhone.Build.0 = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|x64.ActiveCfg = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|x64.Build.0 = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|x86.ActiveCfg = Release|Any CPU
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -627,6 +727,8 @@ Global
{BCFC1329-903B-4440-ABE1-160C22A3AE23} = {C443BF0A-C616-4E98-8994-C5BAE76AE556}
{03C99D2B-D6FC-4DBE-880C-5B1A4024DD67} = {C443BF0A-C616-4E98-8994-C5BAE76AE556}
{71340F5E-2B3B-4F1D-B113-236BBB0D7632} = {C443BF0A-C616-4E98-8994-C5BAE76AE556}
{34F849F9-E349-4237-B7CB-A63884DAB39D} = {C7727147-4AD9-4005-A8D0-EEEED82347D3}
{925EA86A-0B9F-4277-B05C-A3586DA3CA4D} = {C443BF0A-C616-4E98-8994-C5BAE76AE556}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {252F0196-794B-4F99-967E-81962ADF58DD}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>AdaptiveCards.Rendering.Wpf.Core</AssemblyName>
<RootNamespace>AdaptiveCards.Rendering.Wpf</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\AdaptiveCards\AdaptiveCards.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\AdaptiveCards.Rendering.Wpf\**\*.cs" Exclude="..\AdaptiveCards.Rendering.Wpf\obj\**" />
<None Include="..\AdaptiveCards.Rendering.Wpf\**\*.settings" />
<EmbeddedResource Include="..\AdaptiveCards.Rendering.Wpf\**\*.resx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.MarkedNet" Version="1.0.13" />
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
<Page Include="..\AdaptiveCards.Rendering.Wpf\Themes\generic.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

</Project>
16 changes: 8 additions & 8 deletions source/dotnet/RunAllTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ Write-Host Running HTML tests...
Set-Location .\Samples\AdaptiveCards.Sample.Html

Write-Host SupportsInteractivity = false...
dotnet run $v1scenariosPath -r -o $testResultsPath\HTML\StandardNonInteractive.html
dotnet run $v1scenariosPath -- -r -o $testResultsPath\HTML\StandardNonInteractive.html

Write-Host SupportsInteractivity = true...
dotnet run $v1scenariosPath -r -i -o $testResultsPath\HTML\Standard.html
dotnet run $v1scenariosPath -- -r -i -o $testResultsPath\HTML\Standard.html

Write-Host Windows notification config...
dotnet run $v1scenariosPath -r -o $testResultsPath\HTML\WindowsNotification.html --host-config $samplesPath\hostconfig\windows-notification.json
dotnet run $v1scenariosPath -- -r -o $testResultsPath\HTML\WindowsNotification.html --host-config $samplesPath\hostconfig\windows-notification.json

Write-Host Timeline config...
dotnet run $v1scenariosPath -r -o $testResultsPath\HTML\WindowsTimeline.html --host-config $samplesPath\hostconfig\windows-timeline.json
dotnet run $v1scenariosPath -- -r -o $testResultsPath\HTML\WindowsTimeline.html --host-config $samplesPath\hostconfig\windows-timeline.json

Write-Host Running WPF tests...
Set-Location ..\AdaptiveCards.Sample.ImageRender

Write-Host SupportsInteractivity = false...
dotnet run $v1scenariosPath -r -o $testResultsPath\WPF\StandardNonInteractive
dotnet run $v1scenariosPath -- -r -o $testResultsPath\WPF\StandardNonInteractive

Write-Host SupportsInteractivity = true...
dotnet run $v1scenariosPath -r -i -o $testResultsPath\WPF\Standard
dotnet run $v1scenariosPath -- -r -i -o $testResultsPath\WPF\Standard

Write-Host Windows notification config....
dotnet run $v1scenariosPath -r -o $testResultsPath\WPF\WindowsNotification --host-config $samplesPath\hostconfig\windows-notification.json
dotnet run $v1scenariosPath -- -r -o $testResultsPath\WPF\WindowsNotification --host-config $samplesPath\hostconfig\windows-notification.json

Write-Host Timeline config...
dotnet run $v1scenariosPath -r -o $testResultsPath\WPF\WindowsTimeline --host-config $samplesPath\hostconfig\windows-timeline.json
dotnet run $v1scenariosPath -- -r -o $testResultsPath\WPF\WindowsTimeline --host-config $samplesPath\hostconfig\windows-timeline.json

Pop-Location
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<StartupObject></StartupObject>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x86</PlatformTarget>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Library\AdaptiveCards.Rendering.Wpf.Core\AdaptiveCards.Rendering.Wpf.Core.csproj" />
</ItemGroup>

</Project>
138 changes: 138 additions & 0 deletions source/dotnet/Samples/AdaptiveCards.Core.Sample.ImageRender/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AdaptiveCards.Rendering;
using AdaptiveCards.Rendering.Wpf;
using Microsoft.Extensions.CommandLineUtils;

namespace AdaptiveCards.Core.Sample.ImageRender
{
class Program
{
static void Main(string[] args)
{
var app = new CommandLineApplication();

app.HelpOption("-h|--help");

var pathArg = app.Argument("path", "The path that contains JSON card payloads");
var optionRecurse = app.Option("-r|--recursive", "Recurse the directory for all JSON files", CommandOptionType.NoValue);
var optionOutput = app.Option("-o|--out", "The directory to output the image(s) to", CommandOptionType.SingleValue);
var optionSupportsInteracitivty = app.Option("-i|--supports-interactivity", "Include actions and inputs in the output", CommandOptionType.NoValue);
var hostConfigOption = app.Option("--host-config", "Specify a host config file", CommandOptionType.SingleValue);

app.OnExecute(() =>
{
var outPath = optionOutput.HasValue()
? optionOutput.Value()
: Environment.CurrentDirectory;

if (!Directory.Exists(outPath))
Directory.CreateDirectory(outPath);

// Get payload search path
var payloadPath = pathArg.Value ?? "..\\..\\..\\..\\samples\\v1.0\\Scenarios";
if (pathArg.Value == null)
{
Console.WriteLine($"No path argument specified, trying {payloadPath}...");
}

var files = new List<string>();

if (File.Exists(payloadPath))
{
files.Add(payloadPath);
}
else if (Directory.Exists(payloadPath))
{
var recurse = optionRecurse.HasValue()
? SearchOption.AllDirectories
: SearchOption.TopDirectoryOnly;

files = Directory.GetFiles(payloadPath, "*.json", recurse).ToList();
Console.WriteLine($"Found {files.Count} card payloads...");
}
else
{
Console.WriteLine($"{payloadPath} does not contain any JSON files. Nothing to do.");
return 1;
}

AdaptiveHostConfig hostConfig = new AdaptiveHostConfig()
{
SupportsInteractivity = optionSupportsInteracitivty.HasValue()
};


if (hostConfigOption.HasValue())
{
hostConfig = AdaptiveHostConfig.FromJson(File.ReadAllText(hostConfigOption.Value()));
}

AdaptiveCardRenderer renderer = new AdaptiveCardRenderer(hostConfig);

foreach (var file in files)
{
RenderCard(file, renderer, outPath).Wait();
}

Console.WriteLine($"All cards were written to {Path.GetFullPath(outPath)}");
return 0;
});

app.Execute(args);


// if output, launch the file
if (Debugger.IsAttached)
{
Console.ReadLine();
}
}

private static async Task RenderCard(string file, AdaptiveCardRenderer renderer, string outPath)
{
try
{
var watch = new Stopwatch();
watch.Start();

AdaptiveCardParseResult parseResult = AdaptiveCard.FromJson(File.ReadAllText(file, Encoding.UTF8));
AdaptiveCard card = parseResult.Card;

// Timeout after 30 seconds
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));

// Render the card to an image
RenderedAdaptiveCardImage renderedCard = await renderer.RenderCardToImageAsync(card, true, 400, cts.Token);

// Report any warnings
foreach (var warning in parseResult.Warnings.Union(renderedCard.Warnings))
{
Console.WriteLine($"[{Path.GetFileName(file)}] WARNING: {warning.Message}");
}

// Write to a png file with the same name as the json file
var outputFile = Path.Combine(outPath,
Path.ChangeExtension(Path.GetFileName(file), ".png"));

using (var fileStream = new FileStream(outputFile, FileMode.Create))
{
renderedCard.ImageStream.CopyTo(fileStream);
Console.WriteLine($"[{watch.ElapsedMilliseconds}ms T{Thread.CurrentThread.ManagedThreadId}]\t{Path.GetFileName(file)} => {Path.GetFileName(outputFile)}");
}
}
catch (Exception ex)
{
Console.Error.WriteLine($"[FAILED]\t{Path.GetFileName(file)} => {ex.Message}");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"AdaptiveCards.Core.Sample.ImageRender": {
"commandName": "Project",
"commandLineArgs": "..\\..\\..\\..\\..\\..\\..\\samples\\v1.0\\Scenarios -r -i -o ./out --host-config ..\\..\\..\\..\\..\\..\\..\\samples\\HostConfig\\windows-notification.json"
}
}
}
Loading