-
Notifications
You must be signed in to change notification settings - Fork 413
Add initial Protobuf support #3448
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ome file references
…directory if present, and online if necessary. Add new option -OnlineVSWhere to ignore the local VSInstaller copy and use the latest VSWhere from the net.
…are across dev machines
…ft/WindowsAppSDK into user/drustheaxe/protobuf
…erProtocol for ProtocolBuffers definitions for (Local)Manager<->RemoteManager communication.
…e under build/native
…eManager's dependencies
rhuang-msft
approved these changes
Feb 17, 2023
Contributor
rhuang-msft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Member
Author
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for Google's Protocol Buffers (aka protobuf)
Using protobuf requires 3 components:
Google provides a nuget containing a compiled protoc.exe but doesn't make headers or libs available via nuget. TL;DR we create a nuget for our use (Microsoft.WindowsAppSDK.Protobuf.3.21.12.nupkg). Details of what, why and how are in
tools\nuget\protobuf\README.md.TL;DR Developers working in WinAppSDK only need to know there's a nuget providing protobuf support. The messy details how to create that are only relevant to the developer creating the nuget (moi) or future devs if/when a new version is needed.
Added
KozaniProtocolcontaining Kozani's protobuf messages and related definitions. The purpose of KozaniManageProtocol project is to contain all of Kozani's protobuf definitions and compile them to produce the generated code for use by other projects.Updated
KozaniManagerto consume the protobuf code from KozaniProtocol and added wrappers showing how to use it.Updated
KozaniRemoteManagerto reference to consume the protobuf code from KozaniProtocol.General structure of our protobuf usage:
std::stringstd::stringorstd::ostream. NOTE: The serialized data's just bytes,stringis just a convenient container to pass the data around.std::stringis recommend when serializing a message to bytes.std::stringorstd::istreamis recommended when deserializing a message from bytes. Large messages may be more efficient viastd::istream; either works well enough for small messages so use whichever is more convenient.stringfields asstd::string. It does not do wide<->narrow conversions for you (unlike, say, SQLite) - that's the developer's responsibility. If you have a wide string (std::wstring,PCWSTR,HSTRING, etc) convert it to a UTF-8 string before assigning it to a protobuf field. Use functions in\dev\common\Microsoft.Utf8.hto convert wide->utf8 e.g.PCWSTR appUserModelId{ L"LolzCatzVidz" }; const std::string appUserModelIdUtf8{ ::Microsoft::Utf8::ToUtf8(appUserModelId) };\dev\common\Microsoft.Utf8.hto do this e.g.Everything compiles and links.
dev\Kozani\KozaniManager\main.cpphas an example serializing a protobuf message to bytes (as astd::string). Changing and extending that for all the rest of our functionality and likewise parsing bytes to protobuf messages in KozaniRemoteManager (or vice versa) is left as an exercise for the reader :-)