Skip to content

Commit 7c324df

Browse files
authored
ApplicationData: Unpackaged support (#6277)
* ApplicationData.GetForUnpackaged() and supporting implementation * Integrated UnpackagedApplicationData into ApplicationData * Added tests. Removed debugging and dead code
1 parent 27a8089 commit 7c324df

27 files changed

Lines changed: 3080 additions & 56 deletions

dev/ApplicationData/ApplicationData.idl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ namespace Microsoft.Windows.Storage
8686
static ApplicationData GetForPackageFamily(String packageFamilyName);
8787

8888
/// Get an instance of ApplicationData for the specified unpackaged app for the current user.
89-
[feature(Feature_ApplicationData)]
89+
/// @note This method respects impersonation.
90+
/// @warning The returned instance of ApplicationData does not support LocalCache, PublisherCache or SharedLocal features.
9091
[contract(ApplicationDataContract, 2)]
9192
static ApplicationData GetForUnpackaged(String publisher, String product);
9293

@@ -95,6 +96,7 @@ namespace Microsoft.Windows.Storage
9596

9697
/// Return the path for the local cache data store not included in backup and restore operations.
9798
/// @note This is equivalent to Windows.Storage.ApplicationData.LocalCacheFolder().Path()
99+
/// @warning This method is not supported if the ApplicationData instance was acquired via GetForUnpackaged().
98100
/// @see https://learn.microsoft.com/uwp/api/windows.storage.applicationdata.localcachefolder
99101
String LocalCachePath { get; };
100102

@@ -111,6 +113,7 @@ namespace Microsoft.Windows.Storage
111113

112114
/// Return the path for the shared data store.
113115
/// @note This is equivalent to Windows.Storage.ApplicationData.SharedLocalFolder().Path()
116+
/// @warning This method is not supported if the ApplicationData instance was acquired via GetForUnpackaged().
114117
/// @see https://learn.microsoft.com/uwp/api/windows.storage.applicationdata.sharedlocalfolder
115118
String SharedLocalPath { get; };
116119

@@ -120,6 +123,7 @@ namespace Microsoft.Windows.Storage
120123
String TemporaryPath { get; };
121124

122125
/// Return a StorageFolder for the local cache data store not included in backup and restore operations.
126+
/// @warning This method is not supported if the ApplicationData instance was acquired via GetForUnpackaged().
123127
/// @see https://learn.microsoft.com/uwp/api/windows.storage.applicationdata.localcachefolder
124128
Windows.Storage.StorageFolder LocalCacheFolder { get; };
125129

@@ -134,6 +138,7 @@ namespace Microsoft.Windows.Storage
134138
Windows.Storage.StorageFolder MachineFolder { get; };
135139

136140
/// Return a StorageFolder for the shared data store.
141+
/// @warning This method is not supported if the ApplicationData instance was acquired via GetForUnpackaged().
137142
/// @see https://learn.microsoft.com/uwp/api/windows.storage.applicationdata.sharedlocalfolder
138143
Windows.Storage.StorageFolder SharedLocalFolder { get; };
139144

@@ -157,10 +162,12 @@ namespace Microsoft.Windows.Storage
157162

158163
/// Return the specified path of the shared data store for the publisher of the app.
159164
/// @note This is equivalent to Windows.Storage.ApplicationData.GetPublisherCacheFolder(folderName).Path()
165+
/// @warning This method is not supported if the ApplicationData instance was acquired via GetForUnpackaged().
160166
/// @see https://learn.microsoft.com/uwp/api/windows.storage.applicationdata.getpublishercachefolder
161167
String GetPublisherCachePath(String folderName);
162168

163169
/// Return the specified subfolder of the shared data store for the publisher of the app.
170+
/// @warning This method is not supported if the ApplicationData instance was acquired via GetForUnpackaged().
164171
/// @see https://learn.microsoft.com/uwp/api/windows.storage.applicationdata.getpublishercachefolder
165172
Windows.Storage.StorageFolder GetPublisherCacheFolder(String folderName);
166173
}

dev/ApplicationData/ApplicationData.vcxitems

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88
<ItemDefinitionGroup>
99
<ClCompile>
10-
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
10+
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory);$(RepoRoot)\dev\common</AdditionalIncludeDirectories>
1111
</ClCompile>
1212
</ItemDefinitionGroup>
1313
<ItemGroup>
@@ -16,12 +16,17 @@
1616
<ItemGroup>
1717
<ClCompile Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationData.cpp" />
1818
<ClCompile Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationDataContainer.cpp" />
19+
<ClCompile Include="$(MSBuildThisFileDirectory)UnpackagedApplicationData.cpp" />
20+
<ClCompile Include="$(MSBuildThisFileDirectory)UnpackagedApplicationDataContainer.cpp" />
1921
</ItemGroup>
2022
<ItemGroup>
2123
<ClInclude Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationData.h" />
2224
<ClInclude Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationDataContainer.h" />
2325
<ClInclude Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationDataTelemetry.h" />
2426
<ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
27+
<ClInclude Include="$(MSBuildThisFileDirectory)UnpackagedApplicationData.h" />
28+
<ClInclude Include="$(MSBuildThisFileDirectory)UnpackagedApplicationDataContainer.h" />
29+
<ClInclude Include="$(MSBuildThisFileDirectory)Validate.h" />
2530
</ItemGroup>
2631
<ItemGroup>
2732
<Midl Include="$(MSBuildThisFileDirectory)ApplicationData.idl" />

dev/ApplicationData/ApplicationData.vcxitems.filters

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
<ClCompile Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationDataContainer.cpp">
1818
<Filter>Source Files</Filter>
1919
</ClCompile>
20+
<ClCompile Include="$(MSBuildThisFileDirectory)UnpackagedApplicationData.cpp">
21+
<Filter>Source Files</Filter>
22+
</ClCompile>
23+
<ClCompile Include="$(MSBuildThisFileDirectory)UnpackagedApplicationDataContainer.cpp">
24+
<Filter>Source Files</Filter>
25+
</ClCompile>
2026
</ItemGroup>
2127
<ItemGroup>
2228
<ClInclude Include="$(MSBuildThisFileDirectory)M.W.S.ApplicationData.h">
@@ -31,6 +37,15 @@
3137
<ClInclude Include="$(MSBuildThisFileDirectory)pch.h">
3238
<Filter>Header Files</Filter>
3339
</ClInclude>
40+
<ClInclude Include="$(MSBuildThisFileDirectory)UnpackagedApplicationData.h">
41+
<Filter>Header Files</Filter>
42+
</ClInclude>
43+
<ClInclude Include="$(MSBuildThisFileDirectory)UnpackagedApplicationDataContainer.h">
44+
<Filter>Header Files</Filter>
45+
</ClInclude>
46+
<ClInclude Include="$(MSBuildThisFileDirectory)Validate.h">
47+
<Filter>Header Files</Filter>
48+
</ClInclude>
3449
</ItemGroup>
3550
<ItemGroup>
3651
<Midl Include="$(MSBuildThisFileDirectory)ApplicationData.idl" />

dev/ApplicationData/ApplicationDataTelemetry.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation and Contributors.
1+
// Copyright (c) Microsoft Corporation and Contributors.
22
// Licensed under the MIT license.
33

44
#pragma once
@@ -26,4 +26,16 @@ class ApplicationDataTelemetry : public wil::TraceLoggingProvider
2626
}
2727
CATCH_LOG()
2828
END_ACTIVITY_CLASS();
29+
BEGIN_COMPLIANT_MEASURES_ACTIVITY_CLASS(UnpackagedClearAsync, PDT_ProductAndServicePerformance);
30+
DEFINE_ACTIVITY_START(winrt::Microsoft::Windows::Storage::ApplicationDataLocality locality, winrt::hstring const& publisher, winrt::hstring const& product) noexcept try
31+
{
32+
TraceLoggingClassWriteStart(
33+
UnpackagedClearAsync,
34+
_GENERIC_PARTB_FIELDS_ENABLED,
35+
TraceLoggingInt32(static_cast<std::int32_t>(locality), "Locality"),
36+
TraceLoggingWideString(publisher.c_str(), "Publisher"),
37+
TraceLoggingWideString(product.c_str(), "Product"));
38+
}
39+
CATCH_LOG()
40+
END_ACTIVITY_CLASS();
2941
};

0 commit comments

Comments
 (0)