Skip to content

Commit

Permalink
AddProject - Standardized project templates to develop WinAppSDK (mic…
Browse files Browse the repository at this point in the history
…rosoft#3296)

* Initial KozaniAppGraph project

* Added WinRT IDL support

* Woohoo! Success!

* Refactoring vcxproj

* Moar refactoring

* Yet Moar Refactoring

* Even Moar Refactoring

* Added missing C++/WinRT package dependency

* Added 1st template -- Dev C++ DLL WinRT

* New AddProject command to add a new project to the repository based on one of the available project templates. Supports -List; -Add coming RSN

* -Add support

* -Add now works!

* Enabled StrictMode

* Configuration Manager fixed incorrect configurations

* Fixed AddProject.ps1 not to replace cmdlets with local functions (no wonder Get-Content was returning a string instead of the file's content...). Streamlined the template .vcxproj contents. Fixed vcxproj references to dependencies to use the standard macros

* Added Get-UpdatedContent to update <ProjectGuid> in *.vcxproj with an actual value

* Fixed up Name substitution for some content. Added more templates

* Added metadata per template

* Yet more templates (dev COM OOPServer + TAEF test dll + test MSIX package) + some minor fixes

* Fixed up LIBID/CLSID for COM OOP server templates

* Fixed string replacement logic. Other tweaks

* Regenerated projects with latest AddProject and templates. Added Test projects

* Removed Kozani Projection project (premature)

* Fixed test projects (misnamed)

* Rename template file winmain.cpp to main.cpp. Regenerated Kozani projects

* More fixes. Foo/FooInterface/FooProxyStub is quirk complicated

* Updated AdditionalIncludeDirectories. Added dependencies across Kozani projects

* Fixed ProxyStub to publish *_h.h from correct location

* Added MakeMSIX build dependencies

* Fixed test names. Added build dependencies for Tests.

* Template fixes for naming

* Added Activity+TraceLogging support to dev.cpp.exe.com-oopserver. Fixed up *TraceLogging.h details. Updated templates

* Added Activity+TraceLogging support to dev.cpp.com-oopserver. Fixed up some references to Activity+TraceLogging

* Fixed up some references

* Merged with latest in develop; fixed up breakages

* Fixed up tracelogging goo. Meta macro code generation is fun! Sorta :P

* Added TraceLogging override headers

* Fix a linker issue. Improve the C++/WinRT templating starting point. Add dev.cpp.dll.winrt-client template

* Removed bad reference to nonexistent natvis

* Yet more fixups

* Expanded template love. Fixed ARM64 MIDL generated files requiring WIN32 #define

* Added missing files I forgot to include in previous commit

* Fixed typo in AddProject.ps1. Corrected dev.cpp.dll.winrt-client description
  • Loading branch information
DrusTheAxe authored Jan 16, 2023
1 parent 1bd56a4 commit c2f70fb
Show file tree
Hide file tree
Showing 357 changed files with 13,087 additions and 8 deletions.
580 changes: 574 additions & 6 deletions WindowsAppRuntime.sln

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions dev/Common/Microsoft.TraceLogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#ifndef __MICROSOFT_TRACELOGGING_H
#define __MICROSOFT_TRACELOGGING_H

#define Microsoft_TraceLogging_Std_String(_s_, _name_) \
TraceLoggingCountedString(_s_.c_str(), static_cast<ULONG>(_s_.size()), _name_)

#define Microsoft_TraceLogging_Std_WString(_s_, _name_) \
TraceLoggingCountedWideString(_s_.c_str(), static_cast<ULONG>(_s_.size()), _name_)

#define Microsoft_TraceLogging_Std_StringView(_sv_, _name_) \
TraceLoggingCountedString(_sv_.empty() ? "" : _sv_.data(), static_cast<ULONG>(_sv_.size()), _name_)

#define Microsoft_TraceLogging_Std_WStringView(_sv_, _name_) \
TraceLoggingCountedWideString(_sv_.empty() ? "" : _sv_.data(), static_cast<ULONG>(_sv_.size()), _name_)

#endif // __MICROSOFT_TRACELOGGING_H
6 changes: 6 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "KozaniAppGraph.h"
6 changes: 6 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; Copyright (c) Microsoft Corporation. All rights reserved.
; Licensed under the MIT License. See LICENSE in the project root for license information.

EXPORTS
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
24 changes: 24 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#if !defined(KOZANIAPPGRAPH_H)
#define KOZANIAPPGRAPH_H

#include <appmodel.h>

#if defined(__cplusplus)
#define KOZANIAPPGRAPH_NOEXCEPT noexcept
#else
#define KOZANIAPPGRAPH_NOEXCEPT
#endif // defined(__cplusplus)

//TODO Flat-C API

// C++ friendly APIs
#if defined(__cplusplus)

//TODO C++ API

#endif // defined(__cplusplus)

#endif // KOZANIAPPGRAPH_H
17 changes: 17 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

namespace Microsoft.Kozani.AppGraph
{
[contractversion(1)]
apicontract AppGraphContract{};

[contract(AppGraphContract, 1)]
runtimeclass AppGraphManager
{
/// Get an AppGraph manager for the caller's context.
static AppGraphManager Open();

void TODO_ReplaceMeWithRealContent();
};
}
6 changes: 6 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include <winresrc.h>
#define VERSIONINFO_FILENAME "KozaniAppGraph.dll"
#include "eng\common\VersionInfo\AssemblyInfo.ver"
221 changes: 221 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.vcxproj

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraph.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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;c++;cppm;ixx;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;h++;hm;inl;inc;ipp;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="framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KozaniAppGraph.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KozaniAppGraphTraceLogging.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KozaniAppGraphActivity.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="M.K.AG.AppGraphManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KozaniAppGraph.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KozaniAppGraphActivity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KozaniAppGraphTraceLogging.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="M.K.AG.AppGraphManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="$(MSBuildThisFileDirectory)KozaniAppGraph.idl" />
</ItemGroup>
<ItemGroup>
<None Include="KozaniAppGraph.def">
<Filter>Source Files</Filter>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="KozaniAppGraph.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraphActivity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "pch.h"

#include "KozaniAppGraphActivity.h"
10 changes: 10 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraphActivity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "KozaniAppGraphTraceLogging.h"

namespace Microsoft::Kozani::KozaniAppGraph::Activity
{
}
6 changes: 6 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraphTracelogging.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "pch.h"
42 changes: 42 additions & 0 deletions dev/Kozani/KozaniAppGraph/KozaniAppGraphTracelogging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "pch.h"

#include "Microsoft.TraceLogging.h"

bool __stdcall wilResultLoggingThreadCallback(const wil::FailureInfo& failure) noexcept;

GUID& GetLifetimeActivityId() noexcept;

class Microsoft_Kozani_AppGraph_TraceLogger final : public wil::TraceLoggingProvider
{
IMPLEMENT_TRACELOGGING_CLASS(
Microsoft_Kozani_AppGraph_TraceLogger,
"Microsoft.Kozani.AppGraph",
// 6b731824-91e7-47ae-ae99-e9dd6c6379dc
(0x6b731824, 0x91e7, 0x47ae, 0xae, 0x99, 0xe9, 0xdd, 0x6c, 0x63, 0x79, 0xdc));

public:
};

#define _MICROSOFT_KOZANI_APPGRAPH_WRITE_FAILURE_INFO \
TraceLoggingValue(static_cast<uint32_t>(failure.type), "Type"),\
TraceLoggingValue(failure.hr, "HResult"),\
TraceLoggingValue(failure.pszFile, "File"),\
TraceLoggingValue(failure.uLineNumber,"Line"),\
TraceLoggingValue(failure.pszModule, "Module"),\
TraceLoggingValue(failure.pszMessage,"Message")

// In the future, if the project includes multiple modules and threads, we could log that data as well from FailureInfo
// In the future and on need basis, we could log call stack as well
#define KozaniAppGraph_WriteEventWithActivity(_eventname_,_activityId_,...) \
TraceLoggingWriteActivity(\
Microsoft_Kozani_AppGraph_TraceLogger::Provider(),\
_eventname_,\
_activityId_,\
nullptr,\
_MICROSOFT_KOZANI_APPGRAPH_WRITE_FAILURE_INFO,\
__VA_ARGS__)
20 changes: 20 additions & 0 deletions dev/Kozani/KozaniAppGraph/M.K.AG.AppGraphManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#include "pch.h"

#include "M.K.AG.AppGraphManager.h"

#include "Microsoft.Kozani.AppGraph.AppGraphManager.g.cpp"

namespace winrt::Microsoft::Kozani::AppGraph::implementation
{
winrt::Microsoft::Kozani::AppGraph::AppGraphManager AppGraphManager::Open()
{
throw hresult_not_implemented();
}
void AppGraphManager::TODO_ReplaceMeWithRealContent()
{
throw hresult_not_implemented();
}
}
23 changes: 23 additions & 0 deletions dev/Kozani/KozaniAppGraph/M.K.AG.AppGraphManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#pragma once

#include "Microsoft.Kozani.AppGraph.AppGraphManager.g.h"

namespace winrt::Microsoft::Kozani::AppGraph::implementation
{
struct AppGraphManager : AppGraphManagerT<AppGraphManager>
{
AppGraphManager() = default;

static winrt::Microsoft::Kozani::AppGraph::AppGraphManager Open();
void TODO_ReplaceMeWithRealContent();
};
}
namespace winrt::Microsoft::Kozani::AppGraph::factory_implementation
{
struct AppGraphManager : AppGraphManagerT<AppGraphManager, implementation::AppGraphManager>
{
};
}
27 changes: 27 additions & 0 deletions dev/Kozani/KozaniAppGraph/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

// Including this file once per binary will automatically opt WIL error handling macros into calling RoOriginateError when they
// begin logging a new error. This greatly improves the debuggability of errors that propagate before a failfast.
#include <wil/result_originate.h>

BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hmodule);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}

// Give WIL a crack at DLLMain processing
// See DLLMain() in wil/result_macros.h for why
wil::DLLMain(hmodule, reason, reserved);

return TRUE;
}
30 changes: 30 additions & 0 deletions dev/Kozani/KozaniAppGraph/framework.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include <unknwn.h>
#include <appmodel.h>
#include <shobjidl.h>

#include <thread>
#include <mutex>

#include <wil/cppwinrt.h>
#include <wil/token_helpers.h>
#include <wil/win32_helpers.h>
#include <wil/result.h>
#include <wil/com.h>
#include <wil/resource.h>

#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>

#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.ApplicationModel.AppExtensions.h>
#include <winrt/Windows.Management.Deployment.h>

#include <appmodel.identity.h>
#include <security.integritylevel.h>

#include "kozaniappgraph.h"
8 changes: 8 additions & 0 deletions dev/Kozani/KozaniAppGraph/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Build.Tasks.Git" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="1.1.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.220929.3" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220914.1" targetFramework="native" />
</packages>
4 changes: 4 additions & 0 deletions dev/Kozani/KozaniAppGraph/pch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
20 changes: 20 additions & 0 deletions dev/Kozani/KozaniAppGraph/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.

#ifndef PCH_H
#define PCH_H

#include <WindowsAppRuntimeInsights.h>

// add headers that you want to pre-compile here
#include "framework.h"
#include "KozaniAppGraphActivity.h"
#include "KozaniAppGraphTraceLogging.h"

#endif //PCH_H
6 changes: 6 additions & 0 deletions dev/Kozani/KozaniHostRuntime/KozaniHostRuntime.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "KozaniHostRuntime.h"
4 changes: 4 additions & 0 deletions dev/Kozani/KozaniHostRuntime/KozaniHostRuntime.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
; Copyright (c) Microsoft Corporation. All rights reserved.
; Licensed under the MIT License. See LICENSE in the project root for license information.

EXPORTS
Loading

0 comments on commit c2f70fb

Please sign in to comment.