Repository navigation
ApplicationData.GetForUnpackaged() API spec - #6946
Howard Kapustein (DrusTheAxe) wants to merge 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
| `ApplicationData.GetForUnpackaged(publisher, product)` e.g. they must be strings | ||
| with length >0. | ||
|
|
||
| `SetContextForUnpackaged()` fails if the context has already been set i.e. calling |
There was a problem hiding this comment.
The presence of a SetContextFor... implies a GetContextFor... so a caller can know if it's already been set.
There was a problem hiding this comment.
+1.
Scenario 1: I want to set the unpackaged identity if I am running unpackaged and the unpackaged identity hasn't already been set. (Say because I set things up so the main guy can set the identity if it wants, and if not, I'll fall back to a default one.) How do I know whether it is safe to call SetContextForUnpackaged()? Does GetForUnpackaged() return null?
Scenario 2: I want to know whether the unpackaged identity has been set so I know ahead of time whether it is safe to call GetForUnpackaged().
There was a problem hiding this comment.
Lol yeah, I'd mentioned that to Jesse but left it as a wait-and-see option. Seen enough :-)
And good examples Raymond
Adding GetContextForUnpackaged()
| } | ||
| return std::wstring{ reinterpret_cast<PCWSTR>(::LockResource(resourceValue)) }; | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Wait, you defined all these helpers but never defined the algorithm for GetForUnpackaged itself.
| #2 is needed by components used in processes where the component author doesn't know the calling | ||
| processes' context at build time, and isn't otherwise able to be handed the context at runtime. The | ||
| application sets the context fo the process and component authors use whatever has been defined for | ||
| the process' context. |
There was a problem hiding this comment.
What if I'm a component that wants to be usable in both packaged and unpackaged processes. How do I know whether to use AppplicationData.GetDefault().LocalPath or ApplicationData.GetForUnpackaged().LocalPath?
Right now, GetDefault() throws an exception if called from an unpackaged app.
Or are we going to modify GetDefault() so it forwards to GetForUnpackaged() if called from an unpackaged app?
There was a problem hiding this comment.
Taking this further: do we even need the new parameterless GetForUnpackaged()? Can we just use GetDefault()?
There was a problem hiding this comment.
Keith> GetDefault() works off the process' package identity. Adding 'context' support to that would complicate matters (regardless if we say context trumps identity or vice versa). I don't see that as a helpful step forward.
Raymond> The APIs are distinct worlds, so the decision tree is simple
if (IsPackagedProcess())
appdata = ApplicationData.GetDefault()
else
appdata = ApplicationData.GetForUnpackaged()
Or you could always try one and fallback to the other, but since WinRT throws exceptions when not-set (and there's no TryGet...) that could be more painful than desirable.
There was a problem hiding this comment.
IsPackagedProcess() isn't that trivial to define in C++ or especially C# in the most performant way, though. And to the end user, both unpackaged and packaged ApplicationData objects behave the same, so they don't have to check whether the process is packaged afterwards either.
So I would also +1 for making GetDefault() work for unpackaged apps
| `ApplicationData.GetForUnpackaged(publisher, product)` e.g. they must be strings | ||
| with length >0. | ||
|
|
||
| `SetContextForUnpackaged()` fails if the context has already been set i.e. calling |
There was a problem hiding this comment.
+1.
Scenario 1: I want to set the unpackaged identity if I am running unpackaged and the unpackaged identity hasn't already been set. (Say because I set things up so the main guy can set the identity if it wants, and if not, I'll fall back to a default one.) How do I know whether it is safe to call SetContextForUnpackaged()? Does GetForUnpackaged() return null?
Scenario 2: I want to know whether the unpackaged identity has been set so I know ahead of time whether it is safe to call GetForUnpackaged().
|
|
||
| #2 is needed by components used in processes where the component author doesn't know the calling | ||
| processes' context at build time, and isn't otherwise able to be handed the context at runtime. The | ||
| application sets the context fo the process and component authors use whatever has been defined for |
| `ApplicationData.GetForUnpackaged(publisher, product)` e.g. they must be strings | ||
| with length >0. | ||
|
|
||
| `SetContextForUnpackaged()` fails if the context has already been set i.e. calling |
There was a problem hiding this comment.
It might make things more convenient to the app author if SetContextForUnpackaged failed only if there is an attempt to set the context to something different to the previous call. Otherwise the app author is forced to keep track of whether they have already set it.
There was a problem hiding this comment.
+1
Good idea - Set to current value should succeed.
Goal was to not allow changing it once set. Set(x,y) Nx doesn't violate that so it should be allowed.
|
|
||
| ## 4.6. Component in Unpackaged app using LocalPath - Context defined at build-time | ||
|
|
||
| A component in an unpackaged app app creating a file in the app's LocalPath data store when the app |
There was a problem hiding this comment.
app app
nit: typo
API Spec for Feature Request: ApplicationData.GetForUnpackaged() overload that gives unpackaged apps a way to declare its default ApplicationData #6934
API spec for issue #6934