Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions CsWinRtTest/Coords/Coord.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace Coords
{
public sealed class Coord
{
public double X;
public double Y;

public Coord()
{
X = 0.0;
Y = 0.0;
}

public Coord(double x, double y)
{
X = x;
Y = y;
}

public double Distance(Coord dest)
{
double deltaX = (this.X - dest.X);
double deltaY = (this.Y - dest.Y);
return Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
}

public override string ToString()
{
return "(" + this.X + "," + this.Y + ")";
}
}

}
14 changes: 14 additions & 0 deletions CsWinRtTest/Coords/Coords.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<!-- C#/WinRT -->
<CsWinRTComponent>true</CsWinRTComponent>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.2.5" />
</ItemGroup>

</Project>
65 changes: 65 additions & 0 deletions CsWinRtTest/CsWinRtTest.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31025.218
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Coords", "Coords\Coords.csproj", "{0BD64186-9D97-47EC-A67D-893E95DBDB8A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedApp", "ManagedApp\ManagedApp.csproj", "{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NativeDesktopApp", "NativeDesktopApp\NativeDesktopApp.vcxproj", "{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Debug|x64.ActiveCfg = Debug|x64
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Debug|x64.Build.0 = Debug|x64
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Debug|x86.ActiveCfg = Debug|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Debug|x86.Build.0 = Debug|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Release|Any CPU.Build.0 = Release|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Release|x64.ActiveCfg = Release|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Release|x64.Build.0 = Release|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Release|x86.ActiveCfg = Release|Any CPU
{0BD64186-9D97-47EC-A67D-893E95DBDB8A}.Release|x86.Build.0 = Release|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Debug|x64.ActiveCfg = Debug|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Debug|x64.Build.0 = Debug|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Debug|x86.ActiveCfg = Debug|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Debug|x86.Build.0 = Debug|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Release|Any CPU.Build.0 = Release|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Release|x64.ActiveCfg = Release|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Release|x64.Build.0 = Release|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Release|x86.ActiveCfg = Release|Any CPU
{7E0DDF36-5ED9-4D95-8F0E-DF888D2B9EDE}.Release|x86.Build.0 = Release|Any CPU
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Debug|x64.ActiveCfg = Debug|x64
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Debug|x64.Build.0 = Debug|x64
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Debug|x86.ActiveCfg = Debug|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Debug|x86.Build.0 = Debug|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Debug|x86.Deploy.0 = Debug|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Release|Any CPU.ActiveCfg = Release|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Release|x64.ActiveCfg = Release|x64
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Release|x64.Build.0 = Release|x64
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Release|x86.ActiveCfg = Release|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Release|x86.Build.0 = Release|Win32
{73CCDBB3-4AC3-46C7-8171-E64939F1D89E}.Release|x86.Deploy.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {06F516EE-D095-492F-92E2-F5571B4EE1EB}
EndGlobalSection
EndGlobal
12 changes: 12 additions & 0 deletions CsWinRtTest/ManagedApp/ManagedApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
</PropertyGroup>

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

</Project>
16 changes: 16 additions & 0 deletions CsWinRtTest/ManagedApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Coords;
namespace ManagedApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Coord a = new Coord();
Coord b = new Coord(39.0, 80.0);
Console.WriteLine("Live from C# it is coords " + a.ToString() + " and " + b.ToString());
Console.WriteLine("The distance was " + a.Distance(b));
}
}
}
10 changes: 10 additions & 0 deletions CsWinRtTest/NativeDesktopApp/NativeDesktopApp.exe.manifest
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="Coords"/>
<file name="WinRT.Host.dll">
<activatableClass
name="Coords.Coord"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
</file>
</assembly>
Binary file added CsWinRtTest/NativeDesktopApp/NativeDesktopApp.rc
Binary file not shown.
131 changes: 131 additions & 0 deletions CsWinRtTest/NativeDesktopApp/NativeDesktopApp.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?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.210403.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210403.2\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>{73ccdbb3-4ac3-46c7-8171-e64939f1d89e}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NativeDesktopApp</RootNamespace>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.18362.0</WindowsTargetPlatformMinVersion>
</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>
</ItemGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>true</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>
<AdditionalOptions>%(AdditionalOptions) /permissive- /bigobj</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
<ClCompile Include="WinMain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ResourceCompile Include="NativeDesktopApp.rc" />
<Manifest Include="NativeDesktopApp.exe.manifest" />
<None Include="packages.config" />
<None Include="PropertySheet.props" />
<Text Include="readme.txt">
<DeploymentContent>false</DeploymentContent>
</Text>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Coords\Coords.csproj">
<Project>{0bd64186-9d97-47ec-a67d-893e95dbdb8a}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.210403.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210403.2\build\native\Microsoft.Windows.CppWinRT.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.210403.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.210403.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.210403.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.210403.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>
48 changes: 48 additions & 0 deletions CsWinRtTest/NativeDesktopApp/NativeDesktopApp.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WinMain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Text Include="readme.txt" />
</ItemGroup>
<ItemGroup>
<Manifest Include="NativeDesktopApp.exe.manifest" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="NativeDesktopApp.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions CsWinRtTest/NativeDesktopApp/NativeDesktopApp.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
Binary file not shown.
16 changes: 16 additions & 0 deletions CsWinRtTest/NativeDesktopApp/PropertySheet.props
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>
18 changes: 18 additions & 0 deletions CsWinRtTest/NativeDesktopApp/WinMain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "pch.h"

using namespace winrt;
using namespace Coords;
using namespace Windows::Foundation;

int __stdcall wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{
init_apartment(apartment_type::single_threaded);
Uri uri(L"http://aka.ms/cppwinrt");
::MessageBoxW(::GetDesktopWindow(), uri.AbsoluteUri().c_str(), L"C++/WinRT Desktop Application", MB_OK);
Coord a = Coord();
Coord b = Coord(39.0, 80.0);
::MessageBoxW(::GetDesktopWindow(), uri.AbsoluteUri().c_str(), L"C++/WinRT Desktop Application", MB_OK);
auto aStr = a.ToString();
auto bStr = b.ToString();
auto aToB = a.Distance(b);
}
4 changes: 4 additions & 0 deletions CsWinRtTest/NativeDesktopApp/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.210403.2" targetFramework="native" />
</packages>
1 change: 1 addition & 0 deletions CsWinRtTest/NativeDesktopApp/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "pch.h"
Loading