Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec updates for GenerationId and Bootstrap C# API #1284

Merged
merged 7 commits into from
Aug 28, 2021

Conversation

DrusTheAxe
Copy link
Member

@DrusTheAxe DrusTheAxe commented Aug 20, 2021

Update spec for the Bootstrap C# API and Dynamic Dependency GenerationId property. Spec update (changes in specs/dynamicdependencies)

  • specs/dynamicdependencies/DynamicDependencies.md
  • specs/dynamicdependencies/sample-b.1.md

Why Bootstrap C# API? The Bootstrapper provides a Flat-C API taking multiple optional parameters. The Bootstrap C# API is provided as a .NET assembly with the following features:

Function overloads to make optional parameters optional
Bootstrap APIs scoped to a standard namespace and class
Choice of error handling via throw exceptions or returned HRESULT
C# friendly syntax implementing the necessary P/Invoke definition to adds the Bootstrap Flat-C API..
NOTE: This is a revised form of MddBootstrap.cs in 0.8-preview1's samples incorporating improvements based on community feedback.

NOTE: This provides a natural C# form of the Bootstrap API, which has only been available as a Flat-C API. The Bootstrap API is not provided as a WinRT API due to the nature of the Bootstrap API's required use before accessing the Windows App SDK. Although possible for C# to use a WinRT API via RegFreeWinRT it requires additional developer effort (Fusion manifest isn't seamlessly integrated into the C# developer experience). This C# API complements the Flat-C format to provide a natural and frictionless C# developer experience, to a degree not as easily accomplished with a WinRT API at this time.

Why Generation Id? Generation Id is a unique value changed whenever a process' package graph is altered. This is used to quickly and efficiently detect if the package graph has changed since the last time one examined it. This is of import if package graph sensitive data is computed and cached e.g. when the package graph is used as a search order for resources that are cached or otherwise expensive to recompute. One can remember the generation id when retrieving the package graph to compute some data, then later, before using that data, get the current Generation Id to check if the package graph is the same and the data's safe to use, or the package graph has changed requiring query'ing the package graph, scrapping the previously computed (now stale) data and recomputing it.

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

std::cout << "Hello World!\n";

// Cleanup
MddBootstrapShutdown();
Copy link
Member

Choose a reason for hiding this comment

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

Consider showing adding a wil::unique_call here that handles calling this shutdown method, even on exceptions.

Copy link
Member Author

Choose a reason for hiding this comment

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

As discussed on the other PR, failure to call shutdown is a minor nit. Is automatic cleanup important? And if so, is that just a C++ thing or should we also provide it for C#?

Copy link
Member

Choose a reason for hiding this comment

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

It's good to show proper lifecycle behavior in a sample, even if someone chooses to not do it.

Maybe a wrapper type for C# that implements IDisposable as a sample, so you can say "var winappsdkref = Bootstrap.Initialize()" or something

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I was thinking of IDisposable. Will cook something up

Please check the related implementation PR #1274. Currently blocked by you. Feedback's been addressed. Would be helpful to get that and add this wrapper in a subsequent (smaller) PR than have it all await perfection.

@DrusTheAxe DrusTheAxe requested a review from jonwis August 26, 2021 06:29
std::cout << "Hello World!\n";

// Cleanup
MddBootstrapShutdown();
Copy link
Member

Choose a reason for hiding this comment

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

It's good to show proper lifecycle behavior in a sample, even if someone chooses to not do it.

Maybe a wrapper type for C# that implements IDisposable as a sample, so you can say "var winappsdkref = Bootstrap.Initialize()" or something

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe DrusTheAxe enabled auto-merge (squash) August 27, 2021 18:48
@DrusTheAxe
Copy link
Member Author

/azp run

@DrusTheAxe DrusTheAxe disabled auto-merge August 28, 2021 02:13
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe DrusTheAxe merged commit 143da0d into main Aug 28, 2021
@DrusTheAxe DrusTheAxe deleted the user/drustheaxe/spec-bootstrapcs-generationid branch August 28, 2021 06:51
ZenBird-zz pushed a commit that referenced this pull request Sep 4, 2021
* Spec updates for GenerationId and Bootstrap C# API

* Incorporated feedback

* Fixed typo (sheepish grin)

* Incorporated feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants